Skip to content

Commit b20d8e3

Browse files
committed
fix: windows hah
1 parent dd9dc60 commit b20d8e3

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"scripts": {
1010
"test": "npm run lint && npm run test:integration && npm run coverage",
1111
"test:nolint": "npm run test:integration && npm run coverage",
12-
"test:unit": "AWS_ACCESS_KEY_ID=\"blah\" AWS_SECRET_ACCESS_KEY=\"blah\" node --test --test-reporter=spec 'test/unit/**/*-test.js'",
12+
"test:unit": "node test/run-with-env.js --test --test-reporter=spec 'test/unit/**/*-test.js'",
1313
"test:slow": "node --test --test-reporter=spec 'test/slow/**/*-test.js'",
14-
"test:integration": "AWS_ACCESS_KEY_ID=\"blah\" AWS_SECRET_ACCESS_KEY=\"blah\" node test/integration/static/index-test.js && AWS_ACCESS_KEY_ID=\"blah\" AWS_SECRET_ACCESS_KEY=\"blah\" node test/integration/static/publish/index-test.js && AWS_ACCESS_KEY_ID=\"blah\" AWS_SECRET_ACCESS_KEY=\"blah\" node --test --test-reporter=spec 'test/integration/macros-n-plugins-test.js'",
15-
"coverage": "mkdir -p coverage && AWS_ACCESS_KEY_ID=\"blah\" AWS_SECRET_ACCESS_KEY=\"blah\" node --test --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/lcov.info 'test/unit/**/*-test.js'",
14+
"test:integration": "node test/integration/static/index-test.js && node test/integration/static/publish/index-test.js && node test/run-with-env.js --test --test-reporter=spec 'test/integration/macros-n-plugins-test.js'",
15+
"coverage": "mkdir -p coverage && node test/run-with-env.js --test --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/lcov.info 'test/unit/**/*-test.js'",
1616
"lint": "eslint . --fix",
1717
"rc": "npm version prerelease --preid RC"
1818
},

test/integration/static/index-test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/usr/bin/env node
22
// Custom test runner to avoid Node.js test runner serialization issues
3+
4+
// Set environment variables for AWS (required for tests)
5+
process.env.AWS_ACCESS_KEY_ID = 'blah'
6+
process.env.AWS_SECRET_ACCESS_KEY = 'blah'
7+
38
const { join } = require('path')
49
const { mkdtempSync, mkdirSync, writeFileSync, rmSync } = require('fs')
510
const { tmpdir } = require('os')

test/integration/static/publish/index-test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/usr/bin/env node
22
// Custom test runner to avoid Node.js test runner serialization issues
3+
4+
// Set environment variables for AWS (required for tests)
5+
process.env.AWS_ACCESS_KEY_ID = 'blah'
6+
process.env.AWS_SECRET_ACCESS_KEY = 'blah'
7+
38
const awsLite = require('@aws-lite/client')
49
const { join, dirname } = require('path')
510
const { mkdtempSync, mkdirSync, writeFileSync, rmSync } = require('fs')

test/run-with-env.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env node
2+
// Cross-platform script to run tests with environment variables
3+
process.env.AWS_ACCESS_KEY_ID = 'blah'
4+
process.env.AWS_SECRET_ACCESS_KEY = 'blah'
5+
6+
const { spawn } = require('child_process')
7+
const args = process.argv.slice(2)
8+
9+
// On Windows, we need to use shell to expand globs
10+
const isWindows = process.platform === 'win32'
11+
12+
const child = spawn('node', args, {
13+
stdio: 'inherit',
14+
shell: isWindows,
15+
})
16+
17+
child.on('exit', (code) => {
18+
process.exit(code || 0)
19+
})

0 commit comments

Comments
 (0)