Skip to content

Commit fb0c536

Browse files
committed
Fix serialize-error tests on Windows with GitHub Actions
GitHub Actions runs the tests from a different drive than where the temp files are located. Create a temporary directory on the same drive to ensure an otherwise failing tests passes.
1 parent 53d7fe1 commit fb0c536

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
.nyc_output
33
coverage
44
bench/.results
5+
test/.tmpdir

test/serialize-error.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ require('../lib/worker/options').set({});
44

55
const fs = require('fs');
66
const path = require('path');
7+
const makeDir = require('make-dir');
78
const sourceMapFixtures = require('source-map-fixtures');
89
const sourceMapSupport = require('source-map-support');
910
const tempWrite = require('temp-write');
@@ -18,6 +19,16 @@ const serialize = error => serializeError('Test', true, error);
1819
// Needed to test stack traces from source map fixtures.
1920
sourceMapSupport.install({environment: 'node'});
2021

22+
const makeTempDir = () => {
23+
if (process.platform !== 'win32') {
24+
return uniqueTempDir({create: true});
25+
}
26+
27+
const dir = path.join(__dirname, '.tmpdir', `serialize-error.${process.pid}`);
28+
makeDir.sync(dir);
29+
return dir;
30+
};
31+
2132
test('serialize standard props', t => {
2233
const error = new Error('Hello');
2334
const serializedError = serialize(error);
@@ -67,7 +78,7 @@ test('source file is an absolute path, after source map correction, even if alre
6778
const fixture = sourceMapFixtures.mapFile('throws');
6879
const map = JSON.parse(fs.readFileSync(fixture.file + '.map'));
6980

70-
const tmp = uniqueTempDir({create: true});
81+
const tmp = makeTempDir();
7182
const sourceRoot = path.join(tmp, 'src');
7283
const expectedSourceFile = path.join(sourceRoot, map.file);
7384

0 commit comments

Comments
 (0)