Skip to content

Commit

Permalink
fix e2e test CI with windows; node(unit-test:8, e2e-test:16)
Browse files Browse the repository at this point in the history
  • Loading branch information
fritx committed Oct 21, 2022
1 parent ece6188 commit 1d752bb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ jobs:
node-version:
# trying to pick up the lowest versions within the supported options
# https://github.com/actions/node-versions/blob/main/versions-manifest.json
- 6
# - 8 # skip
# - 10 # skip
# - 12 # skip
# - 14 # skip
# - 16 # skip
- 16
# - 18 # skip
os:
# trying to pick up the lowest versions within the supported options
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners
# - windows-2019
- windows-2019
- ubuntu-20.04
- macos-11

Expand All @@ -46,19 +45,20 @@ jobs:
run: |
npm install --production
npm link
- name: Test default
run: |
echo "[1,2,3,4,5]" | jayin "x.slice(1,4)" > tmp
node -e "assert.equal(fs.readFileSync('tmp','utf8'), '[2,3,4]')"
node -e "assert.equal(fs.readFileSync('tmp','utf8').trim(), '[2,3,4]')"
- name: Test -t
run: |
echo "[1,2,3,4,5]" | jayin -t "JSON.stringify(JSON.parse(x.trim()).slice(1,4))" > tmp
node -e "assert.equal(fs.readFileSync('tmp','utf8'), '[2,3,4]')"
echo "[1,2,3,4,5]" | jayin -t "JSON.stringify(JSON.parse(x).slice(1,4))" > tmp
node -e "assert.equal(fs.readFileSync('tmp','utf8').trim(), '[2,3,4]')"
- name: Test -ti
run: |
echo "[1,2,3,4,5]" | jayin -ti "JSON.parse(x.trim()).slice(1,4)" > tmp
node -e "assert.equal(fs.readFileSync('tmp','utf8'), '[2,3,4]')"
echo "[1,2,3,4,5]" | jayin -ti "JSON.parse(x).slice(1,5)" > tmp
node -e "assert.equal(fs.readFileSync('tmp','utf8').trim(), '[2,3,4,5]')"
- name: Test -to
run: |
echo "[1,2,3,4,5]" | jayin -to "JSON.stringify(x.slice(1,4))" > tmp
node -e "assert.equal(fs.readFileSync('tmp','utf8'), '[2,3,4]')"
node -e "assert.equal(fs.readFileSync('tmp','utf8').trim(), '[2,3,4]')"
8 changes: 4 additions & 4 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ jobs:
strategy:
matrix:
node-version:
# currently devDependencies require node>=6 (>=8 with Windows)
# - 8 # skip
# currently devDependencies require node>=8.9
- 8
# - 10 # skip
# - 12 # skip
# - 14 # skip
# - 16 # skip
- 18
# - 18 # skip
os:
- windows-latest
- ubuntu-latest
# - windows-latest
- macos-latest

runs-on: ${{ matrix.os }}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"jayin": "index.js"
},
"scripts": {
"test": "nyc mocha"
"test": "nyc mocha --timeout 5000"
},
"devDependencies": {
"bufferhelper": "^0.2.1",
"mocha": "^2.4.5",
"nyc": "^11.6.0",
"nyc": "^15.1.0",
"which": "^2.0.2"
},
"dependencies": {
Expand Down
6 changes: 4 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ const assert = require('assert')
const cp = require('child_process')
const fs = require('fs')

console.log('process.platform', process.platform)
let nodeCmd = 'node'
if (process.platform === 'win32') {
nodeCmd = require('which').sync('node')
}
console.log('nodeCmd', nodeCmd)

// todo: more test cases

Expand Down Expand Up @@ -109,12 +111,12 @@ describe('jayin', () => {
// const env = { count: 0 }
// execSync('count=0')
const helper = new BufferHelper()
const js = cp.spawn(nodeCmd, ['./index.js', '-e', '-c', 'echo "${i}: ${x}" >> tmp'])
const js = cp.spawn(nodeCmd, ['./index.js', '-e', '-c', "(echo ${i}: ${x}) >> tmp"])
js.stdout.once('end', () => {
// assert.equal(execSync('echo $count').toString(), '15')
// assert.equal(env.count, '15')
assert.equal(helper.toString(), '["a","b","c"]') // in chain
assert.equal(cp.execSync('cat tmp').toString(), '0: a\n1: b\n2: c\n')
assert.equal(cp.execSync('cat tmp').toString().replace(/\r\n/g, '\n'), '0: a\n1: b\n2: c\n')
done()
})
js.stdout.on('data', (chunk) => {
Expand Down

0 comments on commit 1d752bb

Please sign in to comment.