From 6db1f963fff9ebf1c63b1ef802329fa318a27c2c Mon Sep 17 00:00:00 2001 From: Radon Rosborough Date: Mon, 27 May 2024 15:19:00 -0700 Subject: [PATCH] Add (failing) node_modules test --- .shellcheckrc | 1 + test/formatters/apheleia-ft.el | 10 ++++++- .../test-uses-node-modules/.apheleia-ft.bash | 1 + .../test-uses-node-modules/.gitignore | 1 + .../prettier/test-uses-node-modules/in.js | 6 ++++ .../prettier/test-uses-node-modules/out.js | 8 +++++ .../test-uses-node-modules/package-lock.json | 30 +++++++++++++++++++ .../test-uses-node-modules/package.json | 12 ++++++++ test/shared/run-func.bash | 2 +- 9 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 .shellcheckrc create mode 100644 test/formatters/samplecode/prettier/test-uses-node-modules/.apheleia-ft.bash create mode 100644 test/formatters/samplecode/prettier/test-uses-node-modules/.gitignore create mode 100644 test/formatters/samplecode/prettier/test-uses-node-modules/in.js create mode 100644 test/formatters/samplecode/prettier/test-uses-node-modules/out.js create mode 100644 test/formatters/samplecode/prettier/test-uses-node-modules/package-lock.json create mode 100644 test/formatters/samplecode/prettier/test-uses-node-modules/package.json diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 0000000..7434b8b --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1 @@ +disable=SC2148 \ No newline at end of file diff --git a/test/formatters/apheleia-ft.el b/test/formatters/apheleia-ft.el index d99bf82..99500b1 100755 --- a/test/formatters/apheleia-ft.el +++ b/test/formatters/apheleia-ft.el @@ -209,7 +209,15 @@ directory." apheleia-ft--temp-dir "^\\(in\\|out\\)\\.")) (unless (string= fname new-file) - (delete-file fname)))))) + (delete-file fname))) + (let ((init-script (expand-file-name ".apheleia-ft.bash" + apheleia-ft--temp-dir))) + (when (file-exists-p init-script) + (let ((default-directory (file-name-directory init-script))) + (unless (zerop + (call-process + "bash" nil nil nil init-script)) + (error "init script failed: %S" init-script)))))))) (defun apheleia-ft--path-join (component &rest components) "Join COMPONENT and COMPONENTS together, left to right. diff --git a/test/formatters/samplecode/prettier/test-uses-node-modules/.apheleia-ft.bash b/test/formatters/samplecode/prettier/test-uses-node-modules/.apheleia-ft.bash new file mode 100644 index 0000000..5fdd18f --- /dev/null +++ b/test/formatters/samplecode/prettier/test-uses-node-modules/.apheleia-ft.bash @@ -0,0 +1 @@ +npm install diff --git a/test/formatters/samplecode/prettier/test-uses-node-modules/.gitignore b/test/formatters/samplecode/prettier/test-uses-node-modules/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/test/formatters/samplecode/prettier/test-uses-node-modules/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/test/formatters/samplecode/prettier/test-uses-node-modules/in.js b/test/formatters/samplecode/prettier/test-uses-node-modules/in.js new file mode 100644 index 0000000..1b5b832 --- /dev/null +++ b/test/formatters/samplecode/prettier/test-uses-node-modules/in.js @@ -0,0 +1,6 @@ +// Behavior differs between 2.x and 3.x +// https://prettier.io/blog/2023/07/05/3.0.0.html +call( + @dec + class {}, +); diff --git a/test/formatters/samplecode/prettier/test-uses-node-modules/out.js b/test/formatters/samplecode/prettier/test-uses-node-modules/out.js new file mode 100644 index 0000000..0be04cf --- /dev/null +++ b/test/formatters/samplecode/prettier/test-uses-node-modules/out.js @@ -0,0 +1,8 @@ +// Behavior differs between 2.x and 3.x +// https://prettier.io/blog/2023/07/05/3.0.0.html +call( + ( + @dec + class {} + ) +); diff --git a/test/formatters/samplecode/prettier/test-uses-node-modules/package-lock.json b/test/formatters/samplecode/prettier/test-uses-node-modules/package-lock.json new file mode 100644 index 0000000..dacc29d --- /dev/null +++ b/test/formatters/samplecode/prettier/test-uses-node-modules/package-lock.json @@ -0,0 +1,30 @@ +{ + "name": "apheleia-ft-prettier-test-uses-node-modules", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "apheleia-ft-prettier-test-uses-node-modules", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "prettier": "^2.8.8" + } + }, + "node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + } + } +} diff --git a/test/formatters/samplecode/prettier/test-uses-node-modules/package.json b/test/formatters/samplecode/prettier/test-uses-node-modules/package.json new file mode 100644 index 0000000..601a9d0 --- /dev/null +++ b/test/formatters/samplecode/prettier/test-uses-node-modules/package.json @@ -0,0 +1,12 @@ +{ + "name": "apheleia-ft-prettier-test-uses-node-modules", + "version": "1.0.0", + "description": "Prettier should be used from node_modules", + "main": "index.js", + "author": "Radian LLC ", + "license": "MIT", + "private": true, + "dependencies": { + "prettier": "^2.8.8" + } +} diff --git a/test/shared/run-func.bash b/test/shared/run-func.bash index db6c689..8742c95 100755 --- a/test/shared/run-func.bash +++ b/test/shared/run-func.bash @@ -14,4 +14,4 @@ exec emacs --batch -L . "$@" \ --eval "(setq debug-on-error t)" \ --eval "(setq backtrace-line-length 0)" \ -f "${func}" \ - 2>&1 | sed -uE 's/^(.{640}).+$/\1...[truncated]/' + 2>&1 | sed -uE 's/^(.{320}).+$/\1...[truncated]/'