Skip to content

Commit

Permalink
test: check values on pipe reject propagations (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub authored Nov 22, 2024
1 parent e666e11 commit 15bb135
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/core.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,12 +483,14 @@ describe('core', () => {
await p1
} catch (e) {
assert.equal(e.exitCode, 1)
assert.equal(e.stdout, '')
}

try {
await p2
} catch (e) {
assert.equal(e.exitCode, 1)
assert.equal(e.stdout, '')
}

const p3 = await $({ nothrow: true })`echo hello && exit 1`.pipe($`cat`)
Expand All @@ -500,14 +502,17 @@ describe('core', () => {
await p4
} catch (e) {
assert.equal(e.exitCode, 1)
assert.equal(e.stdout, '')
}

const p5 = $`echo foo && exit 1`
const [r1, r2] = await Promise.allSettled([
p5.pipe($({ nothrow: true })`cat`),
p5.pipe($`cat`),
])
assert.equal(r1.value.stdout, 'foo\n')
assert.equal(r1.value.exitCode, 0)
assert.equal(r2.reason.stdout, 'foo\n')
assert.equal(r2.reason.exitCode, 1)
})
})
Expand Down

0 comments on commit 15bb135

Please sign in to comment.