Skip to content

armgit / Pake

Public Imported from GitHub
0

Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.

fix(test): drop hashbangs that broke the review gate tests on windows

youxi7981c6853672e3f
diff --git a/scripts/check-incidents.mjs b/scripts/check-incidents.mjs
index 5b0fb2dd..b385212f 100644
--- a/scripts/check-incidents.mjs
+++ b/scripts/check-incidents.mjs
@@ -1,4 +1,3 @@
-#!/usr/bin/env node
// Every row of docs/incidents.md names real commits, a known layer and a
// catcher the code defines.
//
diff --git a/scripts/risk-tier.mjs b/scripts/risk-tier.mjs
index 5cc72f03..174893ff 100644
--- a/scripts/risk-tier.mjs
+++ b/scripts/risk-tier.mjs
@@ -1,4 +1,3 @@
-#!/usr/bin/env node
// Name the verification a change needs from the paths it touches, not from
// who wrote it.
//
diff --git a/tests/unit/check-incidents.test.ts b/tests/unit/check-incidents.test.ts
index 1ff3bd4a..3c27608d 100644
--- a/tests/unit/check-incidents.test.ts
+++ b/tests/unit/check-incidents.test.ts
@@ -140,3 +140,32 @@ describe('incident ledger', () => {
);
});
});
+
+describe('scripts imported by tests', () => {
+ // Windows checks out CRLF, and Vitest fails to parse an imported module whose
+ // first line is a hashbang ending in \r ("Invalid or unexpected token").
+ it('do not start with a hashbang', () => {
+ const testsDir = path.join(process.cwd(), 'tests');
+ const imported = new Set<string>();
+ const walk = (dir: string) => {
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
+ const full = path.join(dir, entry.name);
+ if (entry.isDirectory()) walk(full);
+ else if (/\.test\.[cm]?[jt]s$/.test(entry.name)) {
+ const text = fs.readFileSync(full, 'utf8');
+ for (const m of text.matchAll(
+ /from '((?:\.\.\/)+scripts\/[^']+\.mjs)'/g,
+ )) {
+ imported.add(path.resolve(dir, m[1]));
+ }
+ }
+ }
+ };
+ walk(testsDir);
+ expect(imported.size).toBeGreaterThan(0);
+ const withHashbang = [...imported].filter((file) =>
+ fs.readFileSync(file, 'utf8').startsWith('#!'),
+ );
+ expect(withHashbang).toEqual([]);
+ });
+});