From 2963bed4c0b0336b6dc214e3c1e5bb6846115e2c Mon Sep 17 00:00:00 2001 From: Alec Larson <1925840+aleclarson@users.noreply.github.com> Date: Mon, 26 Aug 2024 11:30:29 -0400 Subject: [PATCH] test: ensure prefixing handles line segments --- test/index.js | 23 +++++++++++++++++++++++ test/snapshots/index.js.md | 20 ++++++++++++++++++++ test/snapshots/index.js.snap | Bin 0 -> 314 bytes 3 files changed, 43 insertions(+) create mode 100644 test/snapshots/index.js.md create mode 100644 test/snapshots/index.js.snap diff --git a/test/index.js b/test/index.js index d0a5880..408ca0f 100644 --- a/test/index.js +++ b/test/index.js @@ -42,3 +42,26 @@ test('run multiple tasks', async t => { t.is(resolved[1].subprocess.stdout, 'bar') t.true(durations[1].duration >= 1000) }) + +test('prefixing handles line segments', t => { + const { execSync } = require('child_process') + + let program = ` + process.stdout.write('hello ', () => { + process.stdout.write('world\\n', () => { + process.stdout.write('nice to meet you') + }) + }) + ` + + program = program.replace(/\\/g, '\\\\') + program = `node -e "${program}"` + program = program.replace(/"/g, '\\"') + + const stdout = execSync(`./bin/index.js "${program}" --names "foo"`, { + encoding: 'utf-8', + stdio: 'pipe' + }) + + t.snapshot(stdout) +}) diff --git a/test/snapshots/index.js.md b/test/snapshots/index.js.md new file mode 100644 index 0000000..2fd2f45 --- /dev/null +++ b/test/snapshots/index.js.md @@ -0,0 +1,20 @@ +# Snapshot report for `test/index.js` + +The actual snapshot is saved in `index.js.snap`. + +Generated by [AVA](https://avajs.dev). + +## prefixing handles line segments + +> Snapshot 1 + + `foo started pid=79072␊ + foo hello foo world␊ + foo nice to meet youfoo cmd='node -e "␊ + process.stdout.write('hello ', () => {␊ + process.stdout.write('world\\n', () => {␊ + process.stdout.write('nice to meet you')␊ + })␊ + })␊ + "' exitCode=0 signalCode=null duration=0s␊ + ` diff --git a/test/snapshots/index.js.snap b/test/snapshots/index.js.snap new file mode 100644 index 0000000000000000000000000000000000000000..ffb7ed9e4d92fdc131c969bedd4bd86781bd4869 GIT binary patch literal 314 zcmV-A0mc47RzVc#(l*7wPWa%-u0bd#lyMFl|(jnVl!OVZgNc4 zXf46}$LF`(z*!OV;QL!aYMjV6oVgU_)T(kub&j6C&b^Ay-rUfH4Xt+k-rpu~{RQyyRT M4fi)qkFfy&09ewN@Bjb+ literal 0 HcmV?d00001