Skip to content

Commit

Permalink
Fix code duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 5, 2024
1 parent 48f21bc commit 1a80ede
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/helpers/args.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Works on TEST_VERSION but not on OLD_TEST_VERSION
export const printModernNodeArgs = ['node', '-p', '".".at(0)']
7 changes: 4 additions & 3 deletions src/parallel.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import test from 'ava'
import { each } from 'test-each'

import { printModernNodeArgs } from './helpers/args.test.js'
import { runCli, runSerial, runParallel } from './helpers/run.test.js'
import { TEST_VERSION, OLD_TEST_VERSION } from './helpers/versions.test.js'

test('Forward exit code and output on late failure | runParallel', async (t) => {
const { exitCode, stdout, stderr } = await runCli(
`${TEST_VERSION},${OLD_TEST_VERSION}`,
['node', '-p', '".".at(0)'],
printModernNodeArgs,
['--parallel', '--continue'],
)

Expand All @@ -27,7 +28,7 @@ Node ${OLD_TEST_VERSION} failed with exit code 1`),
test('No --continue | runParallel', async (t) => {
const { exitCode, stdout, stderr } = await runCli(
`${OLD_TEST_VERSION},${TEST_VERSION}`,
['node', '-p', '".".at(0)'],
printModernNodeArgs,
['--parallel'],
)

Expand All @@ -44,7 +45,7 @@ Node ${OLD_TEST_VERSION} failed with exit code 1`,
test('--continue | runParallel', async (t) => {
const { exitCode, stdout, stderr } = await runCli(
`${OLD_TEST_VERSION},${TEST_VERSION}`,
['node', '-p', '".".at(0)'],
printModernNodeArgs,
['--parallel', '--continue'],
)

Expand Down
5 changes: 3 additions & 2 deletions src/serial.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import test from 'ava'

import { printModernNodeArgs } from './helpers/args.test.js'
import { runCli } from './helpers/run.test.js'
import { TEST_VERSION, OLD_TEST_VERSION } from './helpers/versions.test.js'

test(`Forward exit code and output on late failure | runSerial`, async (t) => {
const { exitCode, stdout, stderr } = await runCli(
`${TEST_VERSION},${OLD_TEST_VERSION}`,
['node', '-p', '".".at(0)'],
printModernNodeArgs,
)

t.is(exitCode, 1)
Expand All @@ -26,7 +27,7 @@ test(`Forward exit code and output on late failure | runSerial`, async (t) => {
test(`--continue | runSerial`, async (t) => {
const { exitCode, stdout, stderr } = await runCli(
`${OLD_TEST_VERSION},${TEST_VERSION}`,
['node', '-p', '".".at(0)'],
printModernNodeArgs,
['--continue'],
)

Expand Down

0 comments on commit 1a80ede

Please sign in to comment.