build: run tests using actual build (#23)
* build: run tests using actual build * build: build script that includes hashbang prepending * ci: missing /bin/zsh
This commit is contained in:
parent
540ce0bbbb
commit
ec2e46e04d
9 changed files with 54 additions and 12 deletions
8
.github/workflows/nodejs.yml
vendored
8
.github/workflows/nodejs.yml
vendored
|
@ -44,11 +44,13 @@ jobs:
|
|||
key: ${{ runner.os }}-build-${{env.cache-name}}-${{ hashFiles('**/yarn.lock') }}-node-${{ matrix.node-version }}
|
||||
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
|
||||
run: corepack enable && yarn
|
||||
|
||||
integration:
|
||||
runs-on: ubuntu-latest
|
||||
needs: dependencies
|
||||
name: Integration tests
|
||||
|
||||
env:
|
||||
SHELL: /usr/bin/bash
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [16, 18]
|
||||
|
@ -95,6 +97,8 @@ jobs:
|
|||
matrix:
|
||||
node-version: [16, 18]
|
||||
|
||||
env:
|
||||
SHELL: /usr/bin/bash
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
|
@ -115,6 +119,8 @@ jobs:
|
|||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: dependencies
|
||||
env:
|
||||
SHELL: /usr/bin/bash
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [16, 18]
|
||||
|
|
|
@ -16,9 +16,10 @@
|
|||
"prebuild": "rm -rf dist",
|
||||
"lint": "rome format src tests && rome check src tests",
|
||||
"lint:fix": "rome format src tests --write && rome check src tests --apply",
|
||||
"test": "ts-node ./src/cli.ts ./tests",
|
||||
"test:integration": "/usr/bin/bash ./script/integration-tests",
|
||||
"build": "tsc --project ."
|
||||
"test": "$SHELL ./script/test-suite",
|
||||
"test:integration": "$SHELL ./script/integration-tests",
|
||||
"build:ts": "tsc --project .",
|
||||
"build": "$SHELL ./script/build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.15.10",
|
||||
|
|
18
script/build
Normal file
18
script/build
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
yarn build:ts
|
||||
|
||||
# Certain files need hashbangs as they are executables.
|
||||
|
||||
NODE_HASHBANG="#!/usr/bin/env node"
|
||||
|
||||
addHashbang() {
|
||||
echo $1
|
||||
echo $NODE_HASHBANG > $1_prefixed
|
||||
cat $1 >> $1_prefixed
|
||||
mv $1_prefixed $1
|
||||
}
|
||||
|
||||
addHashbang dist/cli.js
|
||||
addHashbang dist/collector.js
|
||||
addHashbang dist/worker.js
|
23
script/test-suite
Normal file
23
script/test-suite
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
#
|
||||
# Tests are executed using a built version of the runner.
|
||||
#
|
||||
# This will first build the package, install it in a temporary
|
||||
# environment and run the test suite with it.
|
||||
#
|
||||
|
||||
yarn pack --out integration-build.tgz
|
||||
|
||||
mkdir .tests
|
||||
|
||||
echo "{}" > .tests/package.json
|
||||
touch .tests/yarn.lock
|
||||
|
||||
(
|
||||
cd .tests
|
||||
yarn add ../integration-build.tgz ts-node
|
||||
yarn womm ../tests --ts --workers=2
|
||||
)
|
||||
|
||||
rm -rf .tests
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
import helpText from './help'
|
||||
import parseArgs from './argumentParser'
|
||||
import { getContext, redText, assertTsNodeInstall } from './utils'
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env ts-node
|
||||
|
||||
import { type Context } from './types'
|
||||
import { getContext, spawnProcess } from './utils'
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#!/usr/bin/env ts-node
|
||||
|
||||
import path from 'path'
|
||||
|
||||
import { getContext, spawnProcess } from './utils'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import assert from 'assert'
|
||||
import { describe, test, expect } from '../src'
|
||||
import { describe, test, expect } from 'works-on-my-machine'
|
||||
|
||||
describe('Equality', () => {
|
||||
test.each([1, 'expectations', true])('Equality (value=%s)', (value: unknown) => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import assert from 'assert'
|
||||
|
||||
import { it, test, expect, describe } from '../src'
|
||||
import { it, test, expect, describe } from 'works-on-my-machine'
|
||||
|
||||
describe.each([it, test])('Runs tests', (fn: unknown) => {
|
||||
const testFn = fn as typeof test
|
||||
|
|
Reference in a new issue