Skip to content

Commit

Permalink
fix capturing stdout and stderr when running tests (#454)
Browse files Browse the repository at this point in the history
* fix capturing stdout and stderr when running tests

* use node 18.x for tests

* use node 18.x in tests ci
  • Loading branch information
aeschli authored Feb 21, 2024
1 parent 1ab42f6 commit b16dd88
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand Down
6 changes: 3 additions & 3 deletions build/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ extends:
testPlatforms:
- name: Linux
nodeVersions:
- 16.x
- 18.x
- name: MacOS
nodeVersions:
- 16.x
- 18.x
- name: Windows
nodeVersions:
- 16.x
- 18.x

testSteps:
- script: npm i
Expand Down
11 changes: 9 additions & 2 deletions test/test-integration.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,19 @@ describe('integration tests', function () {

async function doSpawn(execName, allArguments, options) {
return new Promise((resolve, reject) => {
const child = cp.execFile(execName, allArguments, { stdio: 'inherit', ...options });
const child = cp.execFile(execName, allArguments, { stdio: 'pipe', ...options });
let stdout = [], stderr = [];
child.stdout.on('data', (data) => {
stdout.push(data.toString());
});
child.stderr.on('data', (data) => {
stderr.push(data.toString());
});
child.on('error', (err) => {
reject(err);
});
child.on('exit', (exitCode) => {
resolve({ exitCode });
resolve({ exitCode, stdout: stdout.join(''), stderr: stderr.join('')});
});
});
}
Expand Down

0 comments on commit b16dd88

Please sign in to comment.