Skip to content

Commit

Permalink
Maintenance (#1956)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
cspotcode authored Feb 13, 2023
1 parent a376570 commit ba741fa
Show file tree
Hide file tree
Showing 35 changed files with 1,044 additions and 1,585 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ jobs:
typescriptFlag: next
# Node nightly
- flavor: 5
node: 19-nightly
nodeFlag: 19_nightly
node: 20-nightly
nodeFlag: 20_nightly
typescript: latest
typescriptFlag: latest
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ npm-debug.log
/website/static/api
/tsconfig.tsbuildinfo
/temp
/tmp
/yarn-error.log
/.yarn/install-state.gz
/tests/.yarn/install-state.gz
Expand Down
3 changes: 2 additions & 1 deletion ava.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module.exports = {
// This avoids passing it to spawned processes under test, which would negatively affect
// their behavior.
FORCE_COLOR: '3',
NODE_PATH: ''
NODE_PATH: '',
CONCURRENT_TESTS: '4'
},
require: ['./src/test/remove-env-var-force-color.js'],
nodeArguments: ['--loader', './src/test/test-loader.mjs', '--no-warnings'],
Expand Down
6 changes: 6 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ regenerate:
install:
yarn

yarn *ARGS:
yarn "$@"

node *ARGS:
node "$@"

# EVERYTHING BELOW THIS LINE IS AUTO-GENERATED FROM PACKAGE.JSON
# DO NOT MODIFY BY HAND

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@
},
"homepage": "https://typestrong.org/ts-node",
"devDependencies": {
"@TypeStrong/fs-fixture-builder": "github:TypeStrong/fs-fixture-builder#8abd1494280116ff5318dde2c50ad01e1663790c",
"@cspotcode/ava-lib": "github:cspotcode/ava-lib#edcc1885d192d08d5af83490af9341468402ec41",
"@cspotcode/expect-stream": "github:cspotcode/node-expect-stream#4e425ff1eef240003af8716291e80fbaf3e3ae8f",
"@microsoft/api-extractor": "^7.19.4",
"@swc/core": ">=1.3.32",
"@swc/wasm": ">=1.3.32",
Expand All @@ -119,12 +122,10 @@
"@types/react": "^16.14.19",
"@types/rimraf": "^3.0.0",
"@types/semver": "^7.1.0",
"@yarnpkg/fslib": "^2.4.0",
"ava": "^5.1.1",
"axios": "^0.21.1",
"dprint": "^0.25.0",
"expect": "27.0.2",
"get-stream": "^6.0.0",
"lodash": "^4.17.15",
"nyc": "^15.0.1",
"outdent": "^0.8.0",
Expand All @@ -135,7 +136,7 @@
"throat": "^6.0.1",
"typedoc": "^0.22.10",
"typescript": "4.7.4",
"typescript-json-schema": "^0.53.0"
"typescript-json-schema": "^0.54.0"
},
"peerDependencies": {
"@swc/core": ">=1.2.50",
Expand Down
27 changes: 27 additions & 0 deletions scripts/node-nightly.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

# Hacky script to grab node nightly and plonk it into node_modules/.bin, for
# locally testing against nightly builds.

set -euo pipefail
shopt -s inherit_errexit
__dirname="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$__dirname/.."

set -x

mkdir -p tmp

version=$(curl https://nodejs.org/download/nightly/index.json | jq -r '.[0].version')
[ -e "tmp/$version.tar.xz" ] || \
curl -o "tmp/$version.tar.xz" "https://nodejs.org/download/nightly/$version/node-$version-linux-x64.tar.xz"

[ -e "tmp/$version.tar" ] || \
unxz "tmp/$version.tar.xz"

{
cd tmp
tar -xvf "$version.tar"
}

ln -s "../../tmp/node-$version-linux-x64/bin/node" ./node_modules/.bin/node
2 changes: 1 addition & 1 deletion src/test/ci-node-and-ts-versions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { context, expect } from './testlib';

const test = context(ctxTsNode);
test.suite('Confirm node and typescript versions on CI', (test) => {
test.runIf(!!process.env.CI);
test.if(!!process.env.CI);
test('node version is correct', async (t) => {
const expectedVersion = process.env.TEST_MATRIX_NODE_VERSION!;
const actualVersion = process.versions.node;
Expand Down
34 changes: 16 additions & 18 deletions src/test/diagnostics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,22 @@ import { once } from 'lodash';
const test = context(ctxTsNode);

test.suite('TSError diagnostics', ({ context }) => {
const test = context(
once(async (t) => {
// Locking to es2020, because:
// 1) es2022 -- default in @tsconfig/bases for node18 -- changes this diagnostic
// to be a composite "No overload matches this call."
// 2) TS 4.2 doesn't support es2021 or higher
const service = t.context.tsNodeUnderTest.create({
compilerOptions: { target: 'es5', lib: ['es2020'] },
skipProject: true,
});
try {
service.compile('new Error(123)', 'test.ts');
} catch (err) {
return { err: err as TSError };
}
return { err: undefined };
})
);
const test = context(async (t) => {
// Locking to es2020, because:
// 1) es2022 -- default in @tsconfig/bases for node18 -- changes this diagnostic
// to be a composite "No overload matches this call."
// 2) TS 4.2 doesn't support es2021 or higher
const service = t.context.tsNodeUnderTest.create({
compilerOptions: { target: 'es5', lib: ['es2020'] },
skipProject: true,
});
try {
service.compile('new Error(123)', 'test.ts');
} catch (err) {
return { err: err as TSError };
}
return { err: undefined };
});

const diagnosticCode = 2345;
const diagnosticMessage =
Expand Down
Loading

0 comments on commit ba741fa

Please sign in to comment.