Skip to content

Commit ba741fa

Browse files
authored
Maintenance (#1956)
* Get rid of tons of unnecessary destructuring in tests * control in-process concurrency w/env var formatting in testlib split `context` into `context` and `contextEach`; stop sprinkling `once` around `beforeAll` -> `before` `runIf` -> `if` `runSerially` -> `serial`, makes `serial` overloaded * extract testlib to git dep * extract getStream/expectStream to git dep * Replace bundled fs-fixture-builder with git dep * fix lockfile * try to make yarn happy grrr * test against node 20 nightly, since 19 seems not to be building every night * bump git deps * lockfile * try to fix install on node nightly * organize test helpers into multiple files, remove @yarnpkg/fslib dep, extract ctxTmpDir to its own context builder * fix bug in tests supposed to run *outside* of the git clone directory * fix transitive dep crash * fix fs-fixture-builder bug
1 parent a376570 commit ba741fa

35 files changed

+1044
-1585
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ jobs:
8989
typescriptFlag: next
9090
# Node nightly
9191
- flavor: 5
92-
node: 19-nightly
93-
nodeFlag: 19_nightly
92+
node: 20-nightly
93+
nodeFlag: 20_nightly
9494
typescript: latest
9595
typescriptFlag: latest
9696
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ npm-debug.log
1313
/website/static/api
1414
/tsconfig.tsbuildinfo
1515
/temp
16+
/tmp
1617
/yarn-error.log
1718
/.yarn/install-state.gz
1819
/tests/.yarn/install-state.gz

ava.config.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ module.exports = {
1212
// This avoids passing it to spawned processes under test, which would negatively affect
1313
// their behavior.
1414
FORCE_COLOR: '3',
15-
NODE_PATH: ''
15+
NODE_PATH: '',
16+
CONCURRENT_TESTS: '4'
1617
},
1718
require: ['./src/test/remove-env-var-force-color.js'],
1819
nodeArguments: ['--loader', './src/test/test-loader.mjs', '--no-warnings'],

justfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ regenerate:
2121
install:
2222
yarn
2323

24+
yarn *ARGS:
25+
yarn "$@"
26+
27+
node *ARGS:
28+
node "$@"
29+
2430
# EVERYTHING BELOW THIS LINE IS AUTO-GENERATED FROM PACKAGE.JSON
2531
# DO NOT MODIFY BY HAND
2632

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@
108108
},
109109
"homepage": "https://typestrong.org/ts-node",
110110
"devDependencies": {
111+
"@TypeStrong/fs-fixture-builder": "github:TypeStrong/fs-fixture-builder#8abd1494280116ff5318dde2c50ad01e1663790c",
112+
"@cspotcode/ava-lib": "github:cspotcode/ava-lib#edcc1885d192d08d5af83490af9341468402ec41",
113+
"@cspotcode/expect-stream": "github:cspotcode/node-expect-stream#4e425ff1eef240003af8716291e80fbaf3e3ae8f",
111114
"@microsoft/api-extractor": "^7.19.4",
112115
"@swc/core": ">=1.3.32",
113116
"@swc/wasm": ">=1.3.32",
@@ -119,12 +122,10 @@
119122
"@types/react": "^16.14.19",
120123
"@types/rimraf": "^3.0.0",
121124
"@types/semver": "^7.1.0",
122-
"@yarnpkg/fslib": "^2.4.0",
123125
"ava": "^5.1.1",
124126
"axios": "^0.21.1",
125127
"dprint": "^0.25.0",
126128
"expect": "27.0.2",
127-
"get-stream": "^6.0.0",
128129
"lodash": "^4.17.15",
129130
"nyc": "^15.0.1",
130131
"outdent": "^0.8.0",
@@ -135,7 +136,7 @@
135136
"throat": "^6.0.1",
136137
"typedoc": "^0.22.10",
137138
"typescript": "4.7.4",
138-
"typescript-json-schema": "^0.53.0"
139+
"typescript-json-schema": "^0.54.0"
139140
},
140141
"peerDependencies": {
141142
"@swc/core": ">=1.2.50",

scripts/node-nightly.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
# Hacky script to grab node nightly and plonk it into node_modules/.bin, for
4+
# locally testing against nightly builds.
5+
6+
set -euo pipefail
7+
shopt -s inherit_errexit
8+
__dirname="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9+
cd "$__dirname/.."
10+
11+
set -x
12+
13+
mkdir -p tmp
14+
15+
version=$(curl https://nodejs.org/download/nightly/index.json | jq -r '.[0].version')
16+
[ -e "tmp/$version.tar.xz" ] || \
17+
curl -o "tmp/$version.tar.xz" "https://nodejs.org/download/nightly/$version/node-$version-linux-x64.tar.xz"
18+
19+
[ -e "tmp/$version.tar" ] || \
20+
unxz "tmp/$version.tar.xz"
21+
22+
{
23+
cd tmp
24+
tar -xvf "$version.tar"
25+
}
26+
27+
ln -s "../../tmp/node-$version-linux-x64/bin/node" ./node_modules/.bin/node

src/test/ci-node-and-ts-versions.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { context, expect } from './testlib';
88

99
const test = context(ctxTsNode);
1010
test.suite('Confirm node and typescript versions on CI', (test) => {
11-
test.runIf(!!process.env.CI);
11+
test.if(!!process.env.CI);
1212
test('node version is correct', async (t) => {
1313
const expectedVersion = process.env.TEST_MATRIX_NODE_VERSION!;
1414
const actualVersion = process.versions.node;

src/test/diagnostics.spec.ts

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,22 @@ import { once } from 'lodash';
66
const test = context(ctxTsNode);
77

88
test.suite('TSError diagnostics', ({ context }) => {
9-
const test = context(
10-
once(async (t) => {
11-
// Locking to es2020, because:
12-
// 1) es2022 -- default in @tsconfig/bases for node18 -- changes this diagnostic
13-
// to be a composite "No overload matches this call."
14-
// 2) TS 4.2 doesn't support es2021 or higher
15-
const service = t.context.tsNodeUnderTest.create({
16-
compilerOptions: { target: 'es5', lib: ['es2020'] },
17-
skipProject: true,
18-
});
19-
try {
20-
service.compile('new Error(123)', 'test.ts');
21-
} catch (err) {
22-
return { err: err as TSError };
23-
}
24-
return { err: undefined };
25-
})
26-
);
9+
const test = context(async (t) => {
10+
// Locking to es2020, because:
11+
// 1) es2022 -- default in @tsconfig/bases for node18 -- changes this diagnostic
12+
// to be a composite "No overload matches this call."
13+
// 2) TS 4.2 doesn't support es2021 or higher
14+
const service = t.context.tsNodeUnderTest.create({
15+
compilerOptions: { target: 'es5', lib: ['es2020'] },
16+
skipProject: true,
17+
});
18+
try {
19+
service.compile('new Error(123)', 'test.ts');
20+
} catch (err) {
21+
return { err: err as TSError };
22+
}
23+
return { err: undefined };
24+
});
2725

2826
const diagnosticCode = 2345;
2927
const diagnosticMessage =

0 commit comments

Comments
 (0)