Skip to content

Commit 05835ca

Browse files
committed
added tests for Windows
1 parent cf3f285 commit 05835ca

2 files changed

Lines changed: 33 additions & 11 deletions

File tree

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
node-version: [20.x, 22.x]
15-
os: [ubuntu-latest, macos-latest]
15+
os: [ubuntu-latest, macos-latest, windows-latest]
1616

1717
runs-on: ${{ matrix.os }}
1818
steps:

test/spec-runner.js

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const {
1212
isAbsolutePosixPath,
1313
isAbsoluteWindowsPath,
1414
} = require("../lib/util");
15+
const { IS_WINDOWS } = require("../lib/constants");
1516
const { version } = require("../package.json");
1617

1718
const config = {
@@ -120,12 +121,24 @@ script.cgi`);
120121
httpVersion: "1.1",
121122
uniqueId: randomUUID(),
122123
};
123-
const extraInfo = {
124-
filePath: "files/script.cgi",
125-
fullFilePath: "/home/username/cgi-bin/files/script.cgi",
126-
env: { ANOTHER_VAR: "another value" },
127-
trustProxy: false,
128-
};
124+
let extraInfo;
125+
126+
if (IS_WINDOWS) {
127+
extraInfo = {
128+
filePath: "files/script.cgi",
129+
fullFilePath: "C:\\Users\\username\\cgi-bin\\files\\script.cgi",
130+
env: { ANOTHER_VAR: "another value" },
131+
trustProxy: false,
132+
};
133+
} else {
134+
extraInfo = {
135+
filePath: "files/script.cgi",
136+
fullFilePath: "/home/username/cgi-bin/files/script.cgi",
137+
env: { ANOTHER_VAR: "another value" },
138+
trustProxy: false,
139+
};
140+
}
141+
129142
let env = createEnvObject(req, extraInfo);
130143

131144
assert.strictEqual(env.HTTP_CONTENT_TYPE, "application/json");
@@ -149,10 +162,19 @@ script.cgi`);
149162
env.SERVER_SOFTWARE,
150163
`Node.js/${process.version} (cgi-core/v${version})`
151164
);
152-
assert.strictEqual(
153-
env.SCRIPT_FILENAME,
154-
"/home/username/cgi-bin/files/script.cgi"
155-
);
165+
166+
if (IS_WINDOWS) {
167+
assert.strictEqual(
168+
env.SCRIPT_FILENAME,
169+
"C:\\Users\\username\\cgi-bin\\files\\script.cgi"
170+
);
171+
} else {
172+
assert.strictEqual(
173+
env.SCRIPT_FILENAME,
174+
"/home/username/cgi-bin/files/script.cgi"
175+
);
176+
}
177+
156178
assert.strictEqual(env.HTTP_HOST, "www.example.org:3002");
157179
assert.strictEqual(env.REMOTE_ADDR, "100.100.100.100");
158180
assert.strictEqual(env.SERVER_PORT, "3001");

0 commit comments

Comments
 (0)