Skip to content

Commit

Permalink
Make CLI tests run on Windows. I would rather tets the .cmd wrappers,…
Browse files Browse the repository at this point in the history
… but that can wait.

Make tests run on Windows
  • Loading branch information
DESKTOP-5IPRP36\joe-m committed Jul 28, 2021
1 parent a88d969 commit e710618
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion packages/cbor-cli/test/exec.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const test = require('ava')
const { spawn } = require('child_process')
const path = require('path')
const process = require('process')
const pkg = require('../package.json')
const { Buffer } = require('buffer') // not the mangled version

Expand All @@ -19,7 +20,12 @@ function exec(bin, opts = {}) {
...process.env,
...opts.env
}
const c = spawn(bin, opts.args, {
const args = opts.args || []
if (process.platform === 'win32') {
args.unshift(bin)
bin = process.argv[0]
}
const c = spawn(bin, args, {
stdio: 'pipe',
env
})
Expand Down
4 changes: 2 additions & 2 deletions packages/cbor/test/test-vectors.ava.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use command \`git submodule update --init\` to load test-vectors`)
}

// HACK: don't lose data when JSON parsing
vecStr = vecStr.replace(/"decoded":\s*(-?\d+(\.\d+)?(e[+-]\d+)?)\n/g,
vecStr = vecStr.replace(/"decoded":\s*(-?\d+(\.\d+)?(e[+-]\d+)?)\r?\n/g,
`"decoded": {
"___TYPE___": "number",
"___VALUE___": "$1"
Expand Down Expand Up @@ -108,7 +108,7 @@ test('vectors', t => {
}

if (v.hasOwnProperty('decoded')) {
t.deepEqual(decoded, v.decoded)
t.deepEqual(decoded, v.decoded, v.hex)

if (v.roundtrip) {
// TODO: Don't know how to make these round-trip. See:
Expand Down

0 comments on commit e710618

Please sign in to comment.