Skip to content

Commit

Permalink
test: refactor test workflow and handle platform-specific input in te…
Browse files Browse the repository at this point in the history
…st script
  • Loading branch information
leoliu0605 committed Mar 14, 2024
1 parent de8eaa1 commit ae65de3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ jobs:
run: |
npm install -g pnpm
pnpm install
- name: Run tests
if: ${{ matrix.os != 'windows-latest' }}
- name: Run tests (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
npm run test
shell: bash
- name: Run tests (macOS)
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'macos-14' }}
run: |
npm run test
shell: zsh {0}
- name: Run tests (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
Expand Down
6 changes: 5 additions & 1 deletion test/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ const child = spawn('node', [path.join(__dirname, '../src/index.mjs')], {
env: { ...process.env, NODE_ENV: 'test' },
});

child.stdin.write('aa\n'); // Press 'a' twice to deselect all.
if (os.platform() === 'linux') {
child.stdin.write('a\n');
} else {
child.stdin.write('aa\n'); // Press 'a' twice to deselect all.
}

child.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
Expand Down

0 comments on commit ae65de3

Please sign in to comment.