From 45e184e1a8926957dd7d8536fbcd5262d43e8781 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Tue, 6 Aug 2024 02:21:35 +0800 Subject: [PATCH 01/45] Add tests for pear stage # Conflicts: # test/05-commands.test.js --- test/05-commands.test.js | 1704 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 1704 insertions(+) create mode 100644 test/05-commands.test.js diff --git a/test/05-commands.test.js b/test/05-commands.test.js new file mode 100644 index 000000000..ec7619a46 --- /dev/null +++ b/test/05-commands.test.js @@ -0,0 +1,1704 @@ +const test = require('brittle') +const path = require('bare-path') +const Helper = require('./helper') +const fs = require('bare-fs') + +const harness = path.join(Helper.root, 'test', 'fixtures', 'harness') +const minimal = path.join(Helper.root, 'test', 'fixtures', 'minimal') + +class Rig { + setup = async ({ comment }) => { + this.helper = new Helper() + comment('connecting local sidecar') + await this.helper.ready() + await this.helper.shutdown() + this.helper = new Helper() + await this.helper.ready() + comment('local sidecar connected') + } + + cleanup = async ({ comment }) => { + comment('shutting down local sidecar') + setTimeout(async () => { + await this.helper.shutdown() + comment('local sidecar shut down') + }, 5000) + } +} + +const rig = new Rig() + +test('commands setup', rig.setup) + +test('pear stage --json ', async function ({ plan, alike, is }) { + plan(2) + + const testId = Math.floor(Math.random() * 100000) + const argv = ['stage', '--json', 'test-' + testId, minimal] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + for await (const line of running.lineout) { + const result = JSON.parse(line) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + if (result.tag === 'final') break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage ', async function ({ plan, is }) { + plan(2) + + const testId = Math.floor(Math.random() * 100000) + const argv = ['stage', 'test-' + testId, minimal] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + for await (const line of running.lineout) { + if (line === 'Staging complete!') completedStaging = true + if (line.endsWith('Success')) break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(completedStaging, true, 'should complete staging') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage ', async function ({ plan, is }) { + plan(2) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argv = ['stage', 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + for await (const line of running.lineout) { + if (line === 'Staging complete!') completedStaging = true + if (line.endsWith('Success')) break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(completedStaging, true, 'should complete staging') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage (package.json pear.config.stage.entrypoints )', async function ({ plan, teardown, is }) { + plan(2) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argv = ['stage', 'test-' + testId, relativePath] + + const originalPackageJson = fs.readFileSync(path.join(minimal, 'package.json'), 'utf8') + const packageJson = JSON.parse(originalPackageJson) + packageJson.pear.stage = { entrypoints: ['index.js'] } + fs.writeFileSync(path.join(minimal, 'run.js'), 'console.log("run")') + fs.writeFileSync(path.join(minimal, 'package.json'), JSON.stringify(packageJson, null, 2)) + teardown(() => { + fs.writeFileSync(path.join(minimal, 'package.json'), originalPackageJson) + fs.unlinkSync(path.join(minimal, 'run.js')) + }) + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + for await (const line of running.lineout) { + if (line === 'Staging complete!') completedStaging = true + if (line.endsWith('Success')) break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(completedStaging, true, 'should complete staging') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage (package.json pear.stage.ignore )', async function ({ plan, teardown, is }) { + plan(3) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argv = ['stage', 'test-' + testId, relativePath] + + const originalPackageJson = fs.readFileSync(path.join(harness, 'package.json'), 'utf8') + const packageJson = JSON.parse(originalPackageJson) + packageJson.pear.stage = { ignore: ['/ignoreinner.txt'] } + fs.writeFileSync(path.join(minimal, 'ignoreinner.txt'), 'this file should be ignored') + fs.writeFileSync(path.join(minimal, 'package.json'), JSON.stringify(packageJson, null, 2)) + teardown(() => { + fs.writeFileSync(path.join(minimal, 'package.json'), originalPackageJson) + fs.unlinkSync(path.join(minimal, 'ignoreinner.txt')) + }) + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + let addedIgnored = false + for await (const line of running.lineout) { + if (line === 'Staging complete!') completedStaging = true + if (line.includes('/ignoreinner.txt')) addedIgnored = true + if (line.endsWith('Success')) break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(addedIgnored, false, 'should not add ignoreinner.txt') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --json ', async function ({ plan, alike, is }) { + plan(2) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argv = ['stage', '--json', 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + for await (const line of running.lineout) { + const result = JSON.parse(line) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + if (result.tag === 'final') break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --dry-run ', async function ({ plan, is }) { + plan(2) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argv = ['stage', '--dry-run', 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + for await (const line of running.lineout) { + if (line === 'Staging dry run complete!') completedStaging = true + if (line.endsWith('Success')) break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(completedStaging, true, 'should complete staging') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --dry-run --json ', async function ({ plan, alike, is }) { + plan(3) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argv = ['stage', '--dry-run', '--json', 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + let completeTag + for await (const line of running.lineout) { + const result = JSON.parse(line) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'complete') completeTag = result + if (result.tag === 'final') break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(completeTag?.data?.dryRun, true) + alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --bare ', async function ({ plan, is }) { + plan(3) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argv = ['stage', '--bare', 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + let skippedWarmup = false + for await (const line of running.lineout) { + if (line === 'Staging complete!') completedStaging = true + if (line.endsWith('Skipping warmup (bare)')) skippedWarmup = true + if (line.endsWith('Success')) break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(skippedWarmup, true, 'should skip warmup') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --bare --json ', async function ({ plan, alike, is }) { + plan(3) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argv = ['stage', '--bare', '--json', 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + let skipTag + for await (const line of running.lineout) { + const result = JSON.parse(line) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'skipping') skipTag = result + if (result.tag === 'final') break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(skipTag?.data?.reason, 'bare', 'should skip warmup') + alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --ignore ', async function ({ plan, teardown, is }) { + plan(4) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + + const argv = ['stage', '--ignore', 'ignored.txt', 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + let addedIgnored = false + let addedIndex = false + for await (const line of running.lineout) { + if (line === 'Staging complete!') completedStaging = true + if (line.includes('/ignored.txt')) addedIgnored = true + if (line.includes('/index.js')) addedIndex = true + if (line.endsWith('Success')) break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(addedIgnored, false, 'should not add ignored.txt') + is(addedIndex, true, 'should add index.js') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --ignore --json ', async function ({ plan, alike, teardown, is }) { + plan(4) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + + const argv = ['stage', '--ignore', 'ignored.txt', '--json', 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + const files = [] + for await (const line of running.lineout) { + const result = JSON.parse(line) + if (result.tag === 'byte-diff') files.push(result.data.message) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'final') break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') + is(files.includes('/index.js'), true, 'should add index.js') + alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --truncate ', async function ({ plan, is }) { + plan(4) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + for await (const line of stager1.lineout) { + if (line.endsWith('Success')) break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--truncate', '0', 'test-' + testId, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + let readdedFile = false + for await (const line of stager2.lineout) { + if (line === 'Staging complete!') completedStaging = true + if (line.includes('/index.js')) readdedFile = true + if (line.endsWith('Success')) break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(readdedFile, true, 'should readd index.js') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --truncate --json ', async function ({ plan, alike, is }) { + plan(4) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + for await (const line of stager1.lineout) { + if (line.endsWith('Success')) break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--truncate', '0', '--json', 'test-' + testId, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + const files = [] + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (result.tag === 'byte-diff') files.push(result.data.message) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'final') break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(files.includes('/index.js'), true, 'should readd index.js') + alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --name ', async function ({ plan, is }) { + plan(3) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argv = ['stage', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + let stagedName + const stagingRegex = /Staging (.*) into test-\d+/ + for await (const line of running.lineout) { + if (line === 'Staging complete!') completedStaging = true + + const stagingMatch = line.match(stagingRegex) + if (stagingMatch) stagedName = stagingMatch[1] + + if (line.endsWith('Success')) break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(stagedName, 'test-name-' + testId, 'should use --name flag') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --name --json ', async function ({ plan, alike, is }) { + plan(3) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argv = ['stage', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + let stagedName + for await (const line of running.lineout) { + const result = JSON.parse(line) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'staging') stagedName = result.data.name + if (result.tag === 'final') break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(stagedName, 'test-name-' + testId, 'should use --name flag') + alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --ignore --name ', async function ({ plan, teardown, is }) { + plan(5) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + + const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + let addedIgnored = false + let addedIndex = false + let stagedName + const stagingRegex = /Staging (.*) into test-\d+/ + for await (const line of running.lineout) { + if (line === 'Staging complete!') completedStaging = true + if (line.includes('/index.js')) addedIndex = true + if (line.includes('/ignored.txt')) addedIgnored = true + + const stagingMatch = line.match(stagingRegex) + if (stagingMatch) stagedName = stagingMatch[1] + + if (line.endsWith('Success')) break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(addedIgnored, false, 'should not add ignored.txt') + is(addedIndex, true, 'should add index.js') + is(stagedName, 'test-name-' + testId, 'should use --name flag') + + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --ignore --name --json ', async function ({ plan, alike, teardown, is }) { + plan(5) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + + const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + const files = [] + let stagedName + for await (const line of running.lineout) { + const result = JSON.parse(line) + if (result.tag === 'byte-diff') files.push(result.data.message) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'staging') stagedName = result.data.name + if (result.tag === 'final') break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') + is(files.includes('/index.js'), true, 'should add index.js') + is(stagedName, 'test-name-' + testId, 'should use --name flag') + alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --dry-run --bare --ignore --truncate --name ', async function ({ plan, teardown, is }) { + plan(7) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + for await (const line of stager1.lineout) { + if (line.endsWith('Success')) break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-${testId}`, 'test-' + testId, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const stagingRegex = /Staging (.*) into test-\d+/ + let completedStaging = false + let readdedFile = false + let addedIndex = false + let addedIgnored = false + let stagedName + for await (const line of stager2.lineout) { + if (line === 'Staging dry run complete!') completedStaging = true + if (line.includes('/package.json')) readdedFile = true + if (line.includes('/index.js')) addedIndex = true + if (line.includes('/ignored.txt')) addedIgnored = true + + const stagingMatch = line.match(stagingRegex) + if (stagingMatch) stagedName = stagingMatch[1] + + if (line.endsWith('Success')) break + } + + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(readdedFile, true, 'should readd package.json after truncate') + is(addedIgnored, false, 'should not add ignored.txt') + is(addedIndex, true, 'should add index.js') + is(stagedName, 'test-' + testId, 'should use --name flag') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --dry-run --bare --ignore --truncate --name --json ', async function ({ plan, alike, teardown, is }) { + plan(7) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + for await (const line of stager1.lineout) { + if (line.endsWith('Success')) break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-${testId}`, '--json', 'test-' + testId, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + const files = [] + let stagedName + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (result.tag === 'byte-diff') files.push(result.data.message) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'staging') stagedName = result.data.name + if (result.tag === 'final') break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(files.includes('/package.json'), true, 'should readd package.json after truncate') + is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') + is(files.includes('/index.js'), true, 'should add index.js') + is(stagedName, 'test-' + testId, 'should use --name flag') + alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage pear:// ', async function ({ plan, is }) { + plan(3) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + for await (const line of stager2.lineout) { + if (line === 'Staging complete!') completedStaging = true + if (line.endsWith('Success')) break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(completedStaging, true, 'should complete staging') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --json pear:// ', async function ({ plan, alike, is }) { + plan(3) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--json', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'final') break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --dry-run pear:// ', async function ({ plan, is }) { + plan(3) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--dry-run', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + for await (const line of stager2.lineout) { + if (line === 'Staging dry run complete!') completedStaging = true + if (line.endsWith('Success')) break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(completedStaging, true, 'should complete staging') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --dry-run --json pear:// ', async function ({ plan, alike, is }) { + plan(4) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--dry-run', '--json', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + let completeTag + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'complete') completeTag = result + if (result.tag === 'final') break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + alike(tags, ['staging', 'dry', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') + is(completeTag?.data?.dryRun, true, 'should be dry run') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --bare pear:// ', async function ({ plan, is }) { + plan(4) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--bare', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + let skippedWarmup = false + for await (const line of stager2.lineout) { + if (line === 'Staging complete!') completedStaging = true + if (line.endsWith('Skipping warmup (bare)')) skippedWarmup = true + if (line.endsWith('Success')) break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(skippedWarmup, true, 'should skip warmup') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --bare --json pear:// ', async function ({ plan, alike, is }) { + plan(4) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--bare', '--json', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + let skipTag + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'skipping') skipTag = result + if (result.tag === 'final') break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(skipTag?.data?.reason, 'bare', 'should skip warmup') + alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --ignore pear:// ', async function ({ plan, teardown, is }) { + plan(4) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + const argv = ['stage', '--ignore', 'ignored.txt', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + let addedIgnored = false + for await (const line of stager2.lineout) { + if (line === 'Staging complete!') completedStaging = true + if (line.includes('/ignored.txt')) addedIgnored = true + if (line.endsWith('Success')) break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(addedIgnored, false, 'should not add ignored.txt') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --ignore --json pear:// ', async function ({ plan, teardown, is }) { + plan(3) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + const argv = ['stage', '--ignore', 'ignored.txt', '--json', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + const files = [] + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (result.tag === 'byte-diff') files.push(result.data.message) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'final') break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --truncate pear:// ', async function ({ plan, is }) { + plan(4) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--truncate', '0', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + let readdedFile = false + for await (const line of stager2.lineout) { + if (line === 'Staging complete!') completedStaging = true + if (line.includes('/package.json')) readdedFile = true + if (line.endsWith('Success')) break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(readdedFile, true, 'should readd package.json after truncate') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --truncate --json pear:// ', async function ({ plan, alike, is }) { + plan(4) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--truncate', '0', '--json', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + const files = [] + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (result.tag === 'byte-diff') files.push(result.data.message) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'final') break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(files.includes('/package.json'), true, 'should readd package.json after truncate') + alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --name pear:// ', async function ({ plan, is }) { + plan(4) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--name', `test-${testId}`, link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + const stagingRegex = /Staging (.*) into test-\d+/ + let stagedName + for await (const line of stager2.lineout) { + if (line === 'Staging complete!') completedStaging = true + + const stagingMatch = line.match(stagingRegex) + if (stagingMatch) stagedName = stagingMatch[1] + + if (line.endsWith('Success')) break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(stagedName, 'test-' + testId, 'should use --name flag') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --name --json pear:// ', async function ({ plan, alike, is }) { + plan(4) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--name', `test-${testId}`, '--json', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + let stagedName + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'staging') stagedName = result.data.name + if (result.tag === 'final') break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(stagedName, 'test-' + testId, 'should use --name flag') + alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --ignore --name pear:// ', async function ({ plan, teardown, is }) { + plan(5) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-${testId}`, link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + let addedIgnored = false + const stagingRegex = /Staging (.*) into test-\d+/ + let stagedName + for await (const line of stager2.lineout) { + if (line === 'Staging complete!') completedStaging = true + + const stagingMatch = line.match(stagingRegex) + if (stagingMatch) stagedName = stagingMatch[1] + + if (line.includes('/ignored.txt')) addedIgnored = true + if (line.endsWith('Success')) break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(addedIgnored, false, 'should not add ignored.txt') + is(stagedName, 'test-' + testId, 'should use --name flag') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --ignore --name --json pear:// ', async function ({ plan, alike, teardown, is }) { + plan(5) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-${testId}`, '--json', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + const files = [] + let stagedName + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (result.tag === 'byte-diff') files.push(result.data.message) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'staging') stagedName = result.data.name + if (result.tag === 'final') break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') + is(stagedName, 'test-' + testId, 'should use --name flag') + alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --dry-run --bare --ignore --truncate --name pear:// ', async function ({ plan, is }) { + plan(7) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-${testId}`, link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const stagingRegex = /Staging (.*) into test-\d+/ + let completedStaging = false + let readdedFile = false + let addedIndex = false + let addedIgnored = false + let stagedName + for await (const line of stager2.lineout) { + if (line === 'Staging dry run complete!') completedStaging = true + if (line.includes('/package.json')) readdedFile = true + if (line.includes('/index.js')) addedIndex = true + if (line.includes('/ignored.txt')) addedIgnored = true + + const stagingMatch = line.match(stagingRegex) + if (stagingMatch) stagedName = stagingMatch[1] + + if (line.endsWith('Success')) break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(readdedFile, true, 'should readd package.json after truncate') + is(addedIgnored, false, 'should not add ignored.txt') + is(addedIndex, true, 'should add index.js') + is(stagedName, 'test-' + testId, 'should use --name flag') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --dry-run --bare --ignore --truncate --name --json pear:// ', async function ({ plan, alike, is }) { + plan(7) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-${testId}`, '--json', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + const files = [] + let stagedName + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (result.tag === 'byte-diff') files.push(result.data.message) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'staging') stagedName = result.data.name + if (result.tag === 'final') break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.close() + + is(files.includes('/package.json'), true, 'should readd package.json after truncate') + is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') + is(files.includes('/index.js'), true, 'should add index.js') + is(stagedName, 'test-' + testId, 'should use --name flag') + alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test.todo('pear seed ') +test.todo('pear seed ') +test.todo('pear seed --json ') +test.todo('pear seed --seeders ') +test.todo('pear seed --seeders --json ') +test.todo('pear seed --name ') +test.todo('pear seed --name --json ') +test.todo('pear seed pear://') +test.todo('pear seed --json pear://') +test.todo('pear seed --seeders pear://') +test.todo('pear seed --seeders --json pear://') +test.todo('pear seed --name pear://') +test.todo('pear seed --name --json pear://') + +test.todo('pear run ') +test.todo('pear run ') +test.todo('pear run --tmp-store') +test.todo('pear run --store ') +test.todo('pear run --store ') +test.todo('pear run --unsafe-clear-app-storage') +test.todo('pear run --unsafe-clear-preferences') +test.todo('pear run file:///') +test.todo('pear run pear://') +test.todo('pear run pear:///') +test.todo('pear run pear:// --store ') +test.todo('pear run pear:// --tmp-store') +test.todo('pear run pear:// --unsafe-clear-app-storage') +test.todo('pear run pear:// --unsafe-clear-preferences') + +test.todo('pear run (package.json pear.config.previewFor )') +test.todo('pear run (package.json pear.config.links )') +test.todo('pear run (package.json pear.config.links )') +test.todo('pear run (package.json pear.config.type )') +test.todo('pear run --updates-diff') +test.todo('pear run --no-updates') +test.todo('pear run --link ') +// test.skip('pear run --updates-diff --no-updates') // TODO: after task Paparam flag relationships +// test.skip('pear run --tmp-store --store ') // TODO: after task Paparam flag relationships +test.todo('pear run pear:// --updates-diff') +test.todo('pear run pear:// --no-updates') +test.todo('pear run pear:// --link ') +test.todo('pear run pear:// --checkout ') +test.todo('pear run pear:// --checkout release') +test.todo('pear run pear:// --checkout staged') +test.todo('pear run pear:// --checkout --unsafe-clear-app-storage --unsafe-clear-preferences') + +test.todo('pear release ') +test.todo('pear release ') +test.todo('pear release --json ') +test.todo('pear release pear://') +test.todo('pear release --json pear://') +test.todo('pear release --checkout pear://') +test.todo('pear release --checkout --json pear://') +test.todo('pear release --checkout staged pear://') +test.todo('pear release --checkout staged --json pear://') +test.todo('pear release --checkout release pear://') +test.todo('pear release --checkout release --json pear://') + +test.todo('pear info') +test.todo('pear info --json') +test.todo('pear info ') +test.todo('pear info --json ') +test.todo('pear info --changelog ') +test.todo('pear info --changelog --json ') +test.todo('pear info --changelog --metadata ') +test.todo('pear info --changelog --metadata --json ') +test.todo('pear info --changelog --key ') +test.todo('pear info --changelog --key --json ') +test.todo('pear info --changelog --metadata --key ') +test.todo('pear info --changelog --metadata --key --json ') +test.todo('pear info --full-changelog ') +test.todo('pear info --full-changelog --metadata ') +test.todo('pear info --full-changelog --metadata --json ') +test.todo('pear info --full-changelog --metadata --key ') +test.todo('pear info --full-changelog --metadata --key --json ') +// test.skip('pear info --full-changelog --changelog') // TODO: after task Paparam flag relationships +test.todo('pear info --metadata ') +test.todo('pear info --metadata --key ') +test.todo('pear info --metadata --key --json ') +test.todo('pear info --key ') +test.todo('pear info --key --json ') +test.todo('pear info pear://') +test.todo('pear info --json pear://') +test.todo('pear info --changelog pear://') +test.todo('pear info --changelog --json pear://') +test.todo('pear info --changelog --metadata pear://') +test.todo('pear info --changelog --metadata --json pear://') +test.todo('pear info --changelog --key pear://') +test.todo('pear info --changelog --key --json pear://') +test.todo('pear info --changelog --metadata --key pear://') +test.todo('pear info --changelog --metadata --key --json pear://') +test.todo('pear info --full-changelog pear://') +test.todo('pear info --full-changelog --metadata pear://') +test.todo('pear info --full-changelog --metadata --json pear://') +test.todo('pear info --full-changelog --metadata --key pear://') +test.todo('pear info --full-changelog --metadata --key --json pear://') +test.todo('pear info --metadata pear://') +test.todo('pear info --metadata --key pear://') +test.todo('pear info --metadata --key --json pear://') +test.todo('pear info --key pear://') +test.todo('pear info --key --json pear://') + +test.todo('pear info --no-changelog ') +test.todo('pear info --no-changelog --json ') +test.todo('pear info --no-metadata ') +test.todo('pear info --no-metadata --json ') +test.todo('pear info --no-key ') +test.todo('pear info --no-key --json ') +test.todo('pear info --no-changelog --no-metadata ') +test.todo('pear info --no-changelog --no-metadata --json ') +test.todo('pear info --no-changelog --no-key ') +test.todo('pear info --no-changelog --no-key --json ') +test.todo('pear info --no-key --no-metadata ') +test.todo('pear info --no-key --no-metadata --json ') +test.todo('pear info --no-changelog --no-metadata --no-key ') +test.todo('pear info --no-changelog --no-metadata --no-key --json ') +test.todo('pear info --no-changelog pear://') +test.todo('pear info --no-changelog --json pear://') +test.todo('pear info --no-metadata pear://') +test.todo('pear info --no-metadata --json pear://') +test.todo('pear info --no-key pear://') +test.todo('pear info --no-key --json pear://') +test.todo('pear info --no-changelog --no-metadata pear://') +test.todo('pear info --no-changelog --no-metadata --json pear://') +test.todo('pear info --no-changelog --no-key pear://') +test.todo('pear info --no-changelog --no-key --json pear://') +test.todo('pear info --no-key --no-metadata pear://') +test.todo('pear info --no-key --no-metadata --json pear://') +test.todo('pear info --no-changelog --no-metadata --no-key pear://') +test.todo('pear info --no-changelog --no-metadata --no-key --json pear://') + +test.todo('pear dump pear:// ') +test.todo('pear dump pear:// ') +test.todo('pear dump --checkout pear:// ') +test.todo('pear dump --checkout staged pear:// ') +test.todo('pear dump --checkout release pear:// ') +test.todo('pear dump --json pear:// ') + +test.todo('pear shift ') +test.todo('pear shift --json ') +test.todo('pear shift --force ') +test.todo('pear shift --force --json ') + +test.todo('pear gc releases') +test.todo('pear gc releases --json') +test.todo('pear gc sidecars') +test.todo('pear gc sidecars --json') + +test.todo('pear versions') +test.todo('pear versions --json') +test.todo('pear -v') + +test('commands cleanup', rig.cleanup) From 79ebd9476933839529d5bcf85c9ba2ee77285a2a Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Tue, 6 Aug 2024 04:06:06 +0800 Subject: [PATCH 02/45] Enable commands test # Conflicts: # test/index.js --- test/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/index.js b/test/index.js index ea6f89fca..db1d0ccc8 100644 --- a/test/index.js +++ b/test/index.js @@ -13,6 +13,7 @@ async function runTests () { await import('./04-encrypted.test.js') await import('./05-updates.test.js') await import('./06-shutdown.test.js') + await import('./07-commands.test.js') test.resume() } From ab2f07d595bdbc75318ef81da062bf73caf36071 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Tue, 6 Aug 2024 05:36:15 +0800 Subject: [PATCH 03/45] Make names more consistent --- test/05-commands.test.js | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index ec7619a46..832b0d9df 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -504,7 +504,7 @@ test('pear stage --name ', async function ({ pla let completedStaging = false let stagedName - const stagingRegex = /Staging (.*) into test-\d+/ + const stagingRegex = /Staging (.*) into/ for await (const line of running.lineout) { if (line === 'Staging complete!') completedStaging = true @@ -575,7 +575,7 @@ test('pear stage --ignore --name ', async let addedIgnored = false let addedIndex = false let stagedName - const stagingRegex = /Staging (.*) into test-\d+/ + const stagingRegex = /Staging (.*) into/ for await (const line of running.lineout) { if (line === 'Staging complete!') completedStaging = true if (line.includes('/index.js')) addedIndex = true @@ -664,12 +664,12 @@ test('pear stage --dry-run --bare --ignore --truncate --name < teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-${testId}`, 'test-' + testId, relativePath] + const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, 'test-' + testId, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) - const stagingRegex = /Staging (.*) into test-\d+/ + const stagingRegex = /Staging (.*) into/ let completedStaging = false let readdedFile = false let addedIndex = false @@ -694,7 +694,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < is(readdedFile, true, 'should readd package.json after truncate') is(addedIgnored, false, 'should not add ignored.txt') is(addedIndex, true, 'should add index.js') - is(stagedName, 'test-' + testId, 'should use --name flag') + is(stagedName, 'test-name-' + testId, 'should use --name flag') const { code } = await stager2.until.exit is(code, 0, 'should have exit code 0') }) @@ -724,7 +724,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-${testId}`, '--json', 'test-' + testId, relativePath] + const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', 'test-' + testId, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -749,7 +749,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - is(files.includes('/package.json'), true, 'should readd package.json after truncate') is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') is(files.includes('/index.js'), true, 'should add index.js') - is(stagedName, 'test-' + testId, 'should use --name flag') + is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') const { code } = await stager2.until.exit is(code, 0, 'should have exit code 0') @@ -1250,13 +1250,13 @@ test('pear stage --name pear:// ', async function ({ plan, is is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - const argv = ['stage', '--name', `test-${testId}`, link, relativePath] + const argv = ['stage', '--name', `test-name-${testId}`, link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false - const stagingRegex = /Staging (.*) into test-\d+/ + const stagingRegex = /Staging (.*) into/ let stagedName for await (const line of stager2.lineout) { if (line === 'Staging complete!') completedStaging = true @@ -1270,7 +1270,7 @@ test('pear stage --name pear:// ', async function ({ plan, is await stager2.inspector.close() is(completedStaging, true, 'should complete staging') - is(stagedName, 'test-' + testId, 'should use --name flag') + is(stagedName, 'test-name-' + testId, 'should use --name flag') const { code } = await stager2.until.exit is(code, 0, 'should have exit code 0') }) @@ -1299,7 +1299,7 @@ test('pear stage --name --json pear:// ', async function ({ pl is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - const argv = ['stage', '--name', `test-${testId}`, '--json', link, relativePath] + const argv = ['stage', '--name', `test-name-${testId}`, '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -1319,7 +1319,7 @@ test('pear stage --name --json pear:// ', async function ({ pl await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) await stager2.inspector.close() - is(stagedName, 'test-' + testId, 'should use --name flag') + is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') const { code } = await stager2.until.exit is(code, 0, 'should have exit code 0') @@ -1352,14 +1352,14 @@ test('pear stage --ignore --name pear:// ', async funct const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) - const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-${testId}`, link, relativePath] + const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-name-${testId}`, link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false let addedIgnored = false - const stagingRegex = /Staging (.*) into test-\d+/ + const stagingRegex = /Staging (.*) into/ let stagedName for await (const line of stager2.lineout) { if (line === 'Staging complete!') completedStaging = true @@ -1375,7 +1375,7 @@ test('pear stage --ignore --name pear:// ', async funct is(completedStaging, true, 'should complete staging') is(addedIgnored, false, 'should not add ignored.txt') - is(stagedName, 'test-' + testId, 'should use --name flag') + is(stagedName, 'test-name-' + testId, 'should use --name flag') const { code } = await stager2.until.exit is(code, 0, 'should have exit code 0') }) @@ -1407,7 +1407,7 @@ test('pear stage --ignore --name --json pear:// ', asyn const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) - const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-${testId}`, '--json', link, relativePath] + const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-name-${testId}`, '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -1430,7 +1430,7 @@ test('pear stage --ignore --name --json pear:// ', asyn await stager2.inspector.close() is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') - is(stagedName, 'test-' + testId, 'should use --name flag') + is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') const { code } = await stager2.until.exit is(code, 0, 'should have exit code 0') @@ -1460,12 +1460,12 @@ test('pear stage --dry-run --bare --ignore --truncate --name p is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-${testId}`, link, relativePath] + const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) - const stagingRegex = /Staging (.*) into test-\d+/ + const stagingRegex = /Staging (.*) into/ let completedStaging = false let readdedFile = false let addedIndex = false @@ -1489,7 +1489,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p is(readdedFile, true, 'should readd package.json after truncate') is(addedIgnored, false, 'should not add ignored.txt') is(addedIndex, true, 'should add index.js') - is(stagedName, 'test-' + testId, 'should use --name flag') + is(stagedName, 'test-name-' + testId, 'should use --name flag') const { code } = await stager2.until.exit is(code, 0, 'should have exit code 0') }) @@ -1518,7 +1518,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-${testId}`, '--json', link, relativePath] + const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -1543,7 +1543,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - is(files.includes('/package.json'), true, 'should readd package.json after truncate') is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') is(files.includes('/index.js'), true, 'should add index.js') - is(stagedName, 'test-' + testId, 'should use --name flag') + is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') const { code } = await stager2.until.exit is(code, 0, 'should have exit code 0') From b67db6a05d71cf63f5dc39381d9c503da1b3f041 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Tue, 6 Aug 2024 05:49:06 +0800 Subject: [PATCH 04/45] Fix comment after test ends error --- test/05-commands.test.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 832b0d9df..85aa30243 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -19,10 +19,8 @@ class Rig { cleanup = async ({ comment }) => { comment('shutting down local sidecar') - setTimeout(async () => { - await this.helper.shutdown() - comment('local sidecar shut down') - }, 5000) + await this.helper.shutdown() + comment('local sidecar shut down') } } From fd2e334af9af75250603107b60dc2fe4804215f1 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Tue, 6 Aug 2024 08:17:21 +0800 Subject: [PATCH 05/45] Comment out tests that use --name --- test/05-commands.test.js | 1172 +++++++++++++++++++------------------- 1 file changed, 586 insertions(+), 586 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 85aa30243..5a77fe891 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -488,270 +488,270 @@ test('pear stage --truncate --json ', async functio is(code, 0, 'should have exit code 0') }) -test('pear stage --name ', async function ({ plan, is }) { - plan(3) - - const testId = Math.floor(Math.random() * 100000) - const relativePath = path.relative(harness, minimal) - const argv = ['stage', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] - - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) - - let completedStaging = false - let stagedName - const stagingRegex = /Staging (.*) into/ - for await (const line of running.lineout) { - if (line === 'Staging complete!') completedStaging = true - - const stagingMatch = line.match(stagingRegex) - if (stagingMatch) stagedName = stagingMatch[1] - - if (line.endsWith('Success')) break - } - await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await running.inspector.close() - - is(completedStaging, true, 'should complete staging') - is(stagedName, 'test-name-' + testId, 'should use --name flag') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') -}) - -test('pear stage --name --json ', async function ({ plan, alike, is }) { - plan(3) - - const testId = Math.floor(Math.random() * 100000) - const relativePath = path.relative(harness, minimal) - const argv = ['stage', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] - - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) - - const seen = new Set() - const tags = [] - let stagedName - for await (const line of running.lineout) { - const result = JSON.parse(line) - if (seen.has(result.tag)) continue - seen.add(result.tag) - tags.push(result.tag) - - if (result.tag === 'staging') stagedName = result.data.name - if (result.tag === 'final') break - } - await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await running.inspector.close() - - is(stagedName, 'test-name-' + testId, 'should use --name flag') - alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') -}) - -test('pear stage --ignore --name ', async function ({ plan, teardown, is }) { - plan(5) - - const testId = Math.floor(Math.random() * 100000) - const relativePath = path.relative(harness, minimal) - const ignoredFile = path.join(harness, 'ignored.txt') - fs.writeFileSync(ignoredFile, 'this file should be ignored') - teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) - - const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] - - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) - - let completedStaging = false - let addedIgnored = false - let addedIndex = false - let stagedName - const stagingRegex = /Staging (.*) into/ - for await (const line of running.lineout) { - if (line === 'Staging complete!') completedStaging = true - if (line.includes('/index.js')) addedIndex = true - if (line.includes('/ignored.txt')) addedIgnored = true - - const stagingMatch = line.match(stagingRegex) - if (stagingMatch) stagedName = stagingMatch[1] - - if (line.endsWith('Success')) break - } - await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await running.inspector.close() - - is(completedStaging, true, 'should complete staging') - is(addedIgnored, false, 'should not add ignored.txt') - is(addedIndex, true, 'should add index.js') - is(stagedName, 'test-name-' + testId, 'should use --name flag') - - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') -}) - -test('pear stage --ignore --name --json ', async function ({ plan, alike, teardown, is }) { - plan(5) - - const testId = Math.floor(Math.random() * 100000) - const relativePath = path.relative(harness, minimal) - const ignoredFile = path.join(harness, 'ignored.txt') - fs.writeFileSync(ignoredFile, 'this file should be ignored') - teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) - - const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] - - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) - - const seen = new Set() - const tags = [] - const files = [] - let stagedName - for await (const line of running.lineout) { - const result = JSON.parse(line) - if (result.tag === 'byte-diff') files.push(result.data.message) - if (seen.has(result.tag)) continue - seen.add(result.tag) - tags.push(result.tag) - - if (result.tag === 'staging') stagedName = result.data.name - if (result.tag === 'final') break - } - await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await running.inspector.close() - - is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') - is(files.includes('/index.js'), true, 'should add index.js') - is(stagedName, 'test-name-' + testId, 'should use --name flag') - alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') -}) - -test('pear stage --dry-run --bare --ignore --truncate --name ', async function ({ plan, teardown, is }) { - plan(7) - - const testId = Math.floor(Math.random() * 100000) - const relativePath = path.relative(harness, minimal) - const argvInit = ['stage', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) - - for await (const line of stager1.lineout) { - if (line.endsWith('Success')) break - } - - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') - - const ignoredFile = path.join(harness, 'ignored.txt') - fs.writeFileSync(ignoredFile, 'this file should be ignored') - teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) - - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, 'test-' + testId, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) - - const stagingRegex = /Staging (.*) into/ - let completedStaging = false - let readdedFile = false - let addedIndex = false - let addedIgnored = false - let stagedName - for await (const line of stager2.lineout) { - if (line === 'Staging dry run complete!') completedStaging = true - if (line.includes('/package.json')) readdedFile = true - if (line.includes('/index.js')) addedIndex = true - if (line.includes('/ignored.txt')) addedIgnored = true - - const stagingMatch = line.match(stagingRegex) - if (stagingMatch) stagedName = stagingMatch[1] - - if (line.endsWith('Success')) break - } - - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager2.inspector.close() - - is(completedStaging, true, 'should complete staging') - is(readdedFile, true, 'should readd package.json after truncate') - is(addedIgnored, false, 'should not add ignored.txt') - is(addedIndex, true, 'should add index.js') - is(stagedName, 'test-name-' + testId, 'should use --name flag') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') -}) - -test('pear stage --dry-run --bare --ignore --truncate --name --json ', async function ({ plan, alike, teardown, is }) { - plan(7) - - const testId = Math.floor(Math.random() * 100000) - const relativePath = path.relative(harness, minimal) - const argvInit = ['stage', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) - - for await (const line of stager1.lineout) { - if (line.endsWith('Success')) break - } - - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') - - const ignoredFile = path.join(harness, 'ignored.txt') - fs.writeFileSync(ignoredFile, 'this file should be ignored') - teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) - - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', 'test-' + testId, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) - - const seen = new Set() - const tags = [] - const files = [] - let stagedName - for await (const line of stager2.lineout) { - const result = JSON.parse(line) - if (result.tag === 'byte-diff') files.push(result.data.message) - if (seen.has(result.tag)) continue - seen.add(result.tag) - tags.push(result.tag) - - if (result.tag === 'staging') stagedName = result.data.name - if (result.tag === 'final') break - } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager2.inspector.close() - - is(files.includes('/package.json'), true, 'should readd package.json after truncate') - is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') - is(files.includes('/index.js'), true, 'should add index.js') - is(stagedName, 'test-name-' + testId, 'should use --name flag') - alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') -}) +// test('pear stage --name ', async function ({ plan, is }) { +// plan(3) +// +// const testId = Math.floor(Math.random() * 100000) +// const relativePath = path.relative(harness, minimal) +// const argv = ['stage', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] +// +// const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// await running.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argv)}) +// `, { returnByValue: false }) +// +// let completedStaging = false +// let stagedName +// const stagingRegex = /Staging (.*) into/ +// for await (const line of running.lineout) { +// if (line === 'Staging complete!') completedStaging = true +// +// const stagingMatch = line.match(stagingRegex) +// if (stagingMatch) stagedName = stagingMatch[1] +// +// if (line.endsWith('Success')) break +// } +// await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await running.inspector.close() +// +// is(completedStaging, true, 'should complete staging') +// is(stagedName, 'test-name-' + testId, 'should use --name flag') +// const { code } = await running.until.exit +// is(code, 0, 'should have exit code 0') +// }) + +// test('pear stage --name --json ', async function ({ plan, alike, is }) { +// plan(3) +// +// const testId = Math.floor(Math.random() * 100000) +// const relativePath = path.relative(harness, minimal) +// const argv = ['stage', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] +// +// const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// await running.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argv)}) +// `, { returnByValue: false }) +// +// const seen = new Set() +// const tags = [] +// let stagedName +// for await (const line of running.lineout) { +// const result = JSON.parse(line) +// if (seen.has(result.tag)) continue +// seen.add(result.tag) +// tags.push(result.tag) +// +// if (result.tag === 'staging') stagedName = result.data.name +// if (result.tag === 'final') break +// } +// await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await running.inspector.close() +// +// is(stagedName, 'test-name-' + testId, 'should use --name flag') +// alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') +// const { code } = await running.until.exit +// is(code, 0, 'should have exit code 0') +// }) + +// test('pear stage --ignore --name ', async function ({ plan, teardown, is }) { +// plan(5) +// +// const testId = Math.floor(Math.random() * 100000) +// const relativePath = path.relative(harness, minimal) +// const ignoredFile = path.join(harness, 'ignored.txt') +// fs.writeFileSync(ignoredFile, 'this file should be ignored') +// teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) +// +// const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] +// +// const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// await running.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argv)}) +// `, { returnByValue: false }) +// +// let completedStaging = false +// let addedIgnored = false +// let addedIndex = false +// let stagedName +// const stagingRegex = /Staging (.*) into/ +// for await (const line of running.lineout) { +// if (line === 'Staging complete!') completedStaging = true +// if (line.includes('/index.js')) addedIndex = true +// if (line.includes('/ignored.txt')) addedIgnored = true +// +// const stagingMatch = line.match(stagingRegex) +// if (stagingMatch) stagedName = stagingMatch[1] +// +// if (line.endsWith('Success')) break +// } +// await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await running.inspector.close() +// +// is(completedStaging, true, 'should complete staging') +// is(addedIgnored, false, 'should not add ignored.txt') +// is(addedIndex, true, 'should add index.js') +// is(stagedName, 'test-name-' + testId, 'should use --name flag') +// +// const { code } = await running.until.exit +// is(code, 0, 'should have exit code 0') +// }) + +// test('pear stage --ignore --name --json ', async function ({ plan, alike, teardown, is }) { +// plan(5) +// +// const testId = Math.floor(Math.random() * 100000) +// const relativePath = path.relative(harness, minimal) +// const ignoredFile = path.join(harness, 'ignored.txt') +// fs.writeFileSync(ignoredFile, 'this file should be ignored') +// teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) +// +// const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] +// +// const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// await running.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argv)}) +// `, { returnByValue: false }) +// +// const seen = new Set() +// const tags = [] +// const files = [] +// let stagedName +// for await (const line of running.lineout) { +// const result = JSON.parse(line) +// if (result.tag === 'byte-diff') files.push(result.data.message) +// if (seen.has(result.tag)) continue +// seen.add(result.tag) +// tags.push(result.tag) +// +// if (result.tag === 'staging') stagedName = result.data.name +// if (result.tag === 'final') break +// } +// await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await running.inspector.close() +// +// is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') +// is(files.includes('/index.js'), true, 'should add index.js') +// is(stagedName, 'test-name-' + testId, 'should use --name flag') +// alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') +// const { code } = await running.until.exit +// is(code, 0, 'should have exit code 0') +// }) + +// test('pear stage --dry-run --bare --ignore --truncate --name ', async function ({ plan, teardown, is }) { +// plan(7) +// +// const testId = Math.floor(Math.random() * 100000) +// const relativePath = path.relative(harness, minimal) +// const argvInit = ['stage', 'test-' + testId, relativePath] +// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// await stager1.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) +// `, { returnByValue: false }) +// +// for await (const line of stager1.lineout) { +// if (line.endsWith('Success')) break +// } +// +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.close() +// const { code: code1 } = await stager1.until.exit +// is(code1, 0, 'should have exit code 0 for initial stage') +// +// const ignoredFile = path.join(harness, 'ignored.txt') +// fs.writeFileSync(ignoredFile, 'this file should be ignored') +// teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) +// +// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, 'test-' + testId, relativePath] +// await stager2.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argv)}) +// `, { returnByValue: false }) +// +// const stagingRegex = /Staging (.*) into/ +// let completedStaging = false +// let readdedFile = false +// let addedIndex = false +// let addedIgnored = false +// let stagedName +// for await (const line of stager2.lineout) { +// if (line === 'Staging dry run complete!') completedStaging = true +// if (line.includes('/package.json')) readdedFile = true +// if (line.includes('/index.js')) addedIndex = true +// if (line.includes('/ignored.txt')) addedIgnored = true +// +// const stagingMatch = line.match(stagingRegex) +// if (stagingMatch) stagedName = stagingMatch[1] +// +// if (line.endsWith('Success')) break +// } +// +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.close() +// +// is(completedStaging, true, 'should complete staging') +// is(readdedFile, true, 'should readd package.json after truncate') +// is(addedIgnored, false, 'should not add ignored.txt') +// is(addedIndex, true, 'should add index.js') +// is(stagedName, 'test-name-' + testId, 'should use --name flag') +// const { code } = await stager2.until.exit +// is(code, 0, 'should have exit code 0') +// }) + +// test('pear stage --dry-run --bare --ignore --truncate --name --json ', async function ({ plan, alike, teardown, is }) { +// plan(7) +// +// const testId = Math.floor(Math.random() * 100000) +// const relativePath = path.relative(harness, minimal) +// const argvInit = ['stage', 'test-' + testId, relativePath] +// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// await stager1.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) +// `, { returnByValue: false }) +// +// for await (const line of stager1.lineout) { +// if (line.endsWith('Success')) break +// } +// +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.close() +// const { code: code1 } = await stager1.until.exit +// is(code1, 0, 'should have exit code 0 for initial stage') +// +// const ignoredFile = path.join(harness, 'ignored.txt') +// fs.writeFileSync(ignoredFile, 'this file should be ignored') +// teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) +// +// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', 'test-' + testId, relativePath] +// await stager2.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argv)}) +// `, { returnByValue: false }) +// +// const seen = new Set() +// const tags = [] +// const files = [] +// let stagedName +// for await (const line of stager2.lineout) { +// const result = JSON.parse(line) +// if (result.tag === 'byte-diff') files.push(result.data.message) +// if (seen.has(result.tag)) continue +// seen.add(result.tag) +// tags.push(result.tag) +// +// if (result.tag === 'staging') stagedName = result.data.name +// if (result.tag === 'final') break +// } +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.close() +// +// is(files.includes('/package.json'), true, 'should readd package.json after truncate') +// is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') +// is(files.includes('/index.js'), true, 'should add index.js') +// is(stagedName, 'test-name-' + testId, 'should use --name flag') +// alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') +// const { code } = await stager2.until.exit +// is(code, 0, 'should have exit code 0') +// }) test('pear stage pear:// ', async function ({ plan, is }) { plan(3) @@ -1224,328 +1224,328 @@ test('pear stage --truncate --json pear:// ', async function ({ p is(code, 0, 'should have exit code 0') }) -test('pear stage --name pear:// ', async function ({ plan, is }) { - plan(4) - - const testId = Math.floor(Math.random() * 100000) - const relativePath = path.relative(harness, minimal) - const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) - - let link - for await (const line of stager1.lineout) { - const result = JSON.parse(line) - if (result.tag === 'addendum') link = result.data.link - if (result.tag === 'final') break - } - - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') - - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - const argv = ['stage', '--name', `test-name-${testId}`, link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) - - let completedStaging = false - const stagingRegex = /Staging (.*) into/ - let stagedName - for await (const line of stager2.lineout) { - if (line === 'Staging complete!') completedStaging = true - - const stagingMatch = line.match(stagingRegex) - if (stagingMatch) stagedName = stagingMatch[1] - - if (line.endsWith('Success')) break - } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager2.inspector.close() - - is(completedStaging, true, 'should complete staging') - is(stagedName, 'test-name-' + testId, 'should use --name flag') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') -}) - -test('pear stage --name --json pear:// ', async function ({ plan, alike, is }) { - plan(4) - - const testId = Math.floor(Math.random() * 100000) - const relativePath = path.relative(harness, minimal) - const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) - - let link - for await (const line of stager1.lineout) { - const result = JSON.parse(line) - if (result.tag === 'addendum') link = result.data.link - if (result.tag === 'final') break - } - - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') - - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - const argv = ['stage', '--name', `test-name-${testId}`, '--json', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) - - const seen = new Set() - const tags = [] - let stagedName - for await (const line of stager2.lineout) { - const result = JSON.parse(line) - if (seen.has(result.tag)) continue - seen.add(result.tag) - tags.push(result.tag) - - if (result.tag === 'staging') stagedName = result.data.name - if (result.tag === 'final') break - } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager2.inspector.close() - - is(stagedName, 'test-name-' + testId, 'should use --name flag') - alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') -}) - -test('pear stage --ignore --name pear:// ', async function ({ plan, teardown, is }) { - plan(5) - - const testId = Math.floor(Math.random() * 100000) - const relativePath = path.relative(harness, minimal) - const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) - - let link - for await (const line of stager1.lineout) { - const result = JSON.parse(line) - if (result.tag === 'addendum') link = result.data.link - if (result.tag === 'final') break - } - - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') - - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - const ignoredFile = path.join(harness, 'ignored.txt') - fs.writeFileSync(ignoredFile, 'this file should be ignored') - teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) - const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-name-${testId}`, link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) - - let completedStaging = false - let addedIgnored = false - const stagingRegex = /Staging (.*) into/ - let stagedName - for await (const line of stager2.lineout) { - if (line === 'Staging complete!') completedStaging = true - - const stagingMatch = line.match(stagingRegex) - if (stagingMatch) stagedName = stagingMatch[1] - - if (line.includes('/ignored.txt')) addedIgnored = true - if (line.endsWith('Success')) break - } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager2.inspector.close() - - is(completedStaging, true, 'should complete staging') - is(addedIgnored, false, 'should not add ignored.txt') - is(stagedName, 'test-name-' + testId, 'should use --name flag') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') -}) - -test('pear stage --ignore --name --json pear:// ', async function ({ plan, alike, teardown, is }) { - plan(5) - - const testId = Math.floor(Math.random() * 100000) - const relativePath = path.relative(harness, minimal) - const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) - - let link - for await (const line of stager1.lineout) { - const result = JSON.parse(line) - if (result.tag === 'addendum') link = result.data.link - if (result.tag === 'final') break - } - - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') - - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - const ignoredFile = path.join(harness, 'ignored.txt') - fs.writeFileSync(ignoredFile, 'this file should be ignored') - teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) - const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-name-${testId}`, '--json', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) - - const seen = new Set() - const tags = [] - const files = [] - let stagedName - for await (const line of stager2.lineout) { - const result = JSON.parse(line) - if (result.tag === 'byte-diff') files.push(result.data.message) - if (seen.has(result.tag)) continue - seen.add(result.tag) - tags.push(result.tag) - - if (result.tag === 'staging') stagedName = result.data.name - if (result.tag === 'final') break - } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager2.inspector.close() - - is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') - is(stagedName, 'test-name-' + testId, 'should use --name flag') - alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') -}) - -test('pear stage --dry-run --bare --ignore --truncate --name pear:// ', async function ({ plan, is }) { - plan(7) - - const testId = Math.floor(Math.random() * 100000) - const relativePath = path.relative(harness, minimal) - const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) - - let link - for await (const line of stager1.lineout) { - const result = JSON.parse(line) - if (result.tag === 'addendum') link = result.data.link - if (result.tag === 'final') break - } - - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') - - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) - - const stagingRegex = /Staging (.*) into/ - let completedStaging = false - let readdedFile = false - let addedIndex = false - let addedIgnored = false - let stagedName - for await (const line of stager2.lineout) { - if (line === 'Staging dry run complete!') completedStaging = true - if (line.includes('/package.json')) readdedFile = true - if (line.includes('/index.js')) addedIndex = true - if (line.includes('/ignored.txt')) addedIgnored = true - - const stagingMatch = line.match(stagingRegex) - if (stagingMatch) stagedName = stagingMatch[1] - - if (line.endsWith('Success')) break - } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager2.inspector.close() - - is(completedStaging, true, 'should complete staging') - is(readdedFile, true, 'should readd package.json after truncate') - is(addedIgnored, false, 'should not add ignored.txt') - is(addedIndex, true, 'should add index.js') - is(stagedName, 'test-name-' + testId, 'should use --name flag') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') -}) - -test('pear stage --dry-run --bare --ignore --truncate --name --json pear:// ', async function ({ plan, alike, is }) { - plan(7) - - const testId = Math.floor(Math.random() * 100000) - const relativePath = path.relative(harness, minimal) - const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) - - let link - for await (const line of stager1.lineout) { - const result = JSON.parse(line) - if (result.tag === 'addendum') link = result.data.link - if (result.tag === 'final') break - } - - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') - - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) - - const seen = new Set() - const tags = [] - const files = [] - let stagedName - for await (const line of stager2.lineout) { - const result = JSON.parse(line) - if (result.tag === 'byte-diff') files.push(result.data.message) - if (seen.has(result.tag)) continue - seen.add(result.tag) - tags.push(result.tag) - - if (result.tag === 'staging') stagedName = result.data.name - if (result.tag === 'final') break - } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) - await stager2.inspector.close() - - is(files.includes('/package.json'), true, 'should readd package.json after truncate') - is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') - is(files.includes('/index.js'), true, 'should add index.js') - is(stagedName, 'test-name-' + testId, 'should use --name flag') - alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') -}) +// test('pear stage --name pear:// ', async function ({ plan, is }) { +// plan(4) +// +// const testId = Math.floor(Math.random() * 100000) +// const relativePath = path.relative(harness, minimal) +// const argvInit = ['stage', '--json', 'test-' + testId, relativePath] +// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// await stager1.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) +// `, { returnByValue: false }) +// +// let link +// for await (const line of stager1.lineout) { +// const result = JSON.parse(line) +// if (result.tag === 'addendum') link = result.data.link +// if (result.tag === 'final') break +// } +// +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.close() +// const { code: code1 } = await stager1.until.exit +// is(code1, 0, 'should have exit code 0 for initial stage') +// +// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// const argv = ['stage', '--name', `test-name-${testId}`, link, relativePath] +// await stager2.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argv)}) +// `, { returnByValue: false }) +// +// let completedStaging = false +// const stagingRegex = /Staging (.*) into/ +// let stagedName +// for await (const line of stager2.lineout) { +// if (line === 'Staging complete!') completedStaging = true +// +// const stagingMatch = line.match(stagingRegex) +// if (stagingMatch) stagedName = stagingMatch[1] +// +// if (line.endsWith('Success')) break +// } +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.close() +// +// is(completedStaging, true, 'should complete staging') +// is(stagedName, 'test-name-' + testId, 'should use --name flag') +// const { code } = await stager2.until.exit +// is(code, 0, 'should have exit code 0') +// }) + +// test('pear stage --name --json pear:// ', async function ({ plan, alike, is }) { +// plan(4) +// +// const testId = Math.floor(Math.random() * 100000) +// const relativePath = path.relative(harness, minimal) +// const argvInit = ['stage', '--json', 'test-' + testId, relativePath] +// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// await stager1.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) +// `, { returnByValue: false }) +// +// let link +// for await (const line of stager1.lineout) { +// const result = JSON.parse(line) +// if (result.tag === 'addendum') link = result.data.link +// if (result.tag === 'final') break +// } +// +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.close() +// const { code: code1 } = await stager1.until.exit +// is(code1, 0, 'should have exit code 0 for initial stage') +// +// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// const argv = ['stage', '--name', `test-name-${testId}`, '--json', link, relativePath] +// await stager2.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argv)}) +// `, { returnByValue: false }) +// +// const seen = new Set() +// const tags = [] +// let stagedName +// for await (const line of stager2.lineout) { +// const result = JSON.parse(line) +// if (seen.has(result.tag)) continue +// seen.add(result.tag) +// tags.push(result.tag) +// +// if (result.tag === 'staging') stagedName = result.data.name +// if (result.tag === 'final') break +// } +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.close() +// +// is(stagedName, 'test-name-' + testId, 'should use --name flag') +// alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') +// const { code } = await stager2.until.exit +// is(code, 0, 'should have exit code 0') +// }) + +// test('pear stage --ignore --name pear:// ', async function ({ plan, teardown, is }) { +// plan(5) +// +// const testId = Math.floor(Math.random() * 100000) +// const relativePath = path.relative(harness, minimal) +// const argvInit = ['stage', '--json', 'test-' + testId, relativePath] +// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// await stager1.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) +// `, { returnByValue: false }) +// +// let link +// for await (const line of stager1.lineout) { +// const result = JSON.parse(line) +// if (result.tag === 'addendum') link = result.data.link +// if (result.tag === 'final') break +// } +// +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.close() +// const { code: code1 } = await stager1.until.exit +// is(code1, 0, 'should have exit code 0 for initial stage') +// +// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// const ignoredFile = path.join(harness, 'ignored.txt') +// fs.writeFileSync(ignoredFile, 'this file should be ignored') +// teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) +// const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-name-${testId}`, link, relativePath] +// await stager2.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argv)}) +// `, { returnByValue: false }) +// +// let completedStaging = false +// let addedIgnored = false +// const stagingRegex = /Staging (.*) into/ +// let stagedName +// for await (const line of stager2.lineout) { +// if (line === 'Staging complete!') completedStaging = true +// +// const stagingMatch = line.match(stagingRegex) +// if (stagingMatch) stagedName = stagingMatch[1] +// +// if (line.includes('/ignored.txt')) addedIgnored = true +// if (line.endsWith('Success')) break +// } +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.close() +// +// is(completedStaging, true, 'should complete staging') +// is(addedIgnored, false, 'should not add ignored.txt') +// is(stagedName, 'test-name-' + testId, 'should use --name flag') +// const { code } = await stager2.until.exit +// is(code, 0, 'should have exit code 0') +// }) + +// test('pear stage --ignore --name --json pear:// ', async function ({ plan, alike, teardown, is }) { +// plan(5) +// +// const testId = Math.floor(Math.random() * 100000) +// const relativePath = path.relative(harness, minimal) +// const argvInit = ['stage', '--json', 'test-' + testId, relativePath] +// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// await stager1.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) +// `, { returnByValue: false }) +// +// let link +// for await (const line of stager1.lineout) { +// const result = JSON.parse(line) +// if (result.tag === 'addendum') link = result.data.link +// if (result.tag === 'final') break +// } +// +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.close() +// const { code: code1 } = await stager1.until.exit +// is(code1, 0, 'should have exit code 0 for initial stage') +// +// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// const ignoredFile = path.join(harness, 'ignored.txt') +// fs.writeFileSync(ignoredFile, 'this file should be ignored') +// teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) +// const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-name-${testId}`, '--json', link, relativePath] +// await stager2.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argv)}) +// `, { returnByValue: false }) +// +// const seen = new Set() +// const tags = [] +// const files = [] +// let stagedName +// for await (const line of stager2.lineout) { +// const result = JSON.parse(line) +// if (result.tag === 'byte-diff') files.push(result.data.message) +// if (seen.has(result.tag)) continue +// seen.add(result.tag) +// tags.push(result.tag) +// +// if (result.tag === 'staging') stagedName = result.data.name +// if (result.tag === 'final') break +// } +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.close() +// +// is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') +// is(stagedName, 'test-name-' + testId, 'should use --name flag') +// alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') +// const { code } = await stager2.until.exit +// is(code, 0, 'should have exit code 0') +// }) + +// test('pear stage --dry-run --bare --ignore --truncate --name pear:// ', async function ({ plan, is }) { +// plan(7) +// +// const testId = Math.floor(Math.random() * 100000) +// const relativePath = path.relative(harness, minimal) +// const argvInit = ['stage', '--json', 'test-' + testId, relativePath] +// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// await stager1.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) +// `, { returnByValue: false }) +// +// let link +// for await (const line of stager1.lineout) { +// const result = JSON.parse(line) +// if (result.tag === 'addendum') link = result.data.link +// if (result.tag === 'final') break +// } +// +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.close() +// const { code: code1 } = await stager1.until.exit +// is(code1, 0, 'should have exit code 0 for initial stage') +// +// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, link, relativePath] +// await stager2.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argv)}) +// `, { returnByValue: false }) +// +// const stagingRegex = /Staging (.*) into/ +// let completedStaging = false +// let readdedFile = false +// let addedIndex = false +// let addedIgnored = false +// let stagedName +// for await (const line of stager2.lineout) { +// if (line === 'Staging dry run complete!') completedStaging = true +// if (line.includes('/package.json')) readdedFile = true +// if (line.includes('/index.js')) addedIndex = true +// if (line.includes('/ignored.txt')) addedIgnored = true +// +// const stagingMatch = line.match(stagingRegex) +// if (stagingMatch) stagedName = stagingMatch[1] +// +// if (line.endsWith('Success')) break +// } +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.close() +// +// is(completedStaging, true, 'should complete staging') +// is(readdedFile, true, 'should readd package.json after truncate') +// is(addedIgnored, false, 'should not add ignored.txt') +// is(addedIndex, true, 'should add index.js') +// is(stagedName, 'test-name-' + testId, 'should use --name flag') +// const { code } = await stager2.until.exit +// is(code, 0, 'should have exit code 0') +// }) + +// test('pear stage --dry-run --bare --ignore --truncate --name --json pear:// ', async function ({ plan, alike, is }) { +// plan(7) +// +// const testId = Math.floor(Math.random() * 100000) +// const relativePath = path.relative(harness, minimal) +// const argvInit = ['stage', '--json', 'test-' + testId, relativePath] +// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// await stager1.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) +// `, { returnByValue: false }) +// +// let link +// for await (const line of stager1.lineout) { +// const result = JSON.parse(line) +// if (result.tag === 'addendum') link = result.data.link +// if (result.tag === 'final') break +// } +// +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.close() +// const { code: code1 } = await stager1.until.exit +// is(code1, 0, 'should have exit code 0 for initial stage') +// +// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) +// const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', link, relativePath] +// await stager2.inspector.evaluate(` +// __PEAR_TEST__.command(${JSON.stringify(argv)}) +// `, { returnByValue: false }) +// +// const seen = new Set() +// const tags = [] +// const files = [] +// let stagedName +// for await (const line of stager2.lineout) { +// const result = JSON.parse(line) +// if (result.tag === 'byte-diff') files.push(result.data.message) +// if (seen.has(result.tag)) continue +// seen.add(result.tag) +// tags.push(result.tag) +// +// if (result.tag === 'staging') stagedName = result.data.name +// if (result.tag === 'final') break +// } +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.close() +// +// is(files.includes('/package.json'), true, 'should readd package.json after truncate') +// is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') +// is(files.includes('/index.js'), true, 'should add index.js') +// is(stagedName, 'test-name-' + testId, 'should use --name flag') +// alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') +// const { code } = await stager2.until.exit +// is(code, 0, 'should have exit code 0') +// }) test.todo('pear seed ') test.todo('pear seed ') From eb87277dac3864cb496fead971918866a5e8bfc3 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Tue, 6 Aug 2024 10:02:56 +0800 Subject: [PATCH 06/45] Fix SIGPIPE error by switching to ipc destroy --- test/05-commands.test.js | 112 +++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 5a77fe891..0d3d142a0 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -48,7 +48,7 @@ test('pear stage --json ', async function ({ plan, alik tags.push(result.tag) if (result.tag === 'final') break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await running.inspector.close() alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') @@ -72,7 +72,7 @@ test('pear stage ', async function ({ plan, is }) { if (line === 'Staging complete!') completedStaging = true if (line.endsWith('Success')) break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await running.inspector.close() is(completedStaging, true, 'should complete staging') @@ -97,7 +97,7 @@ test('pear stage ', async function ({ plan, is }) { if (line === 'Staging complete!') completedStaging = true if (line.endsWith('Success')) break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await running.inspector.close() is(completedStaging, true, 'should complete staging') @@ -132,7 +132,7 @@ test('pear stage (package.json pear.config.stage.entry if (line === 'Staging complete!') completedStaging = true if (line.endsWith('Success')) break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await running.inspector.close() is(completedStaging, true, 'should complete staging') @@ -169,7 +169,7 @@ test('pear stage (package.json pear.stage.ignore ', async function ({ plan, alik tags.push(result.tag) if (result.tag === 'final') break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await running.inspector.close() alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') @@ -224,7 +224,7 @@ test('pear stage --dry-run ', async function ({ plan, i if (line === 'Staging dry run complete!') completedStaging = true if (line.endsWith('Success')) break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await running.inspector.close() is(completedStaging, true, 'should complete staging') @@ -256,7 +256,7 @@ test('pear stage --dry-run --json ', async function ({ if (result.tag === 'complete') completeTag = result if (result.tag === 'final') break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await running.inspector.close() is(completeTag?.data?.dryRun, true) @@ -284,7 +284,7 @@ test('pear stage --bare ', async function ({ plan, is } if (line.endsWith('Skipping warmup (bare)')) skippedWarmup = true if (line.endsWith('Success')) break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await running.inspector.close() is(completedStaging, true, 'should complete staging') @@ -317,7 +317,7 @@ test('pear stage --bare --json ', async function ({ pla if (result.tag === 'skipping') skipTag = result if (result.tag === 'final') break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await running.inspector.close() is(skipTag?.data?.reason, 'bare', 'should skip warmup') @@ -351,7 +351,7 @@ test('pear stage --ignore ', async function ({ p if (line.includes('/index.js')) addedIndex = true if (line.endsWith('Success')) break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await running.inspector.close() is(completedStaging, true, 'should complete staging') @@ -389,7 +389,7 @@ test('pear stage --ignore --json ', async functi if (result.tag === 'final') break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await running.inspector.close() is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') @@ -414,7 +414,7 @@ test('pear stage --truncate ', async function ({ pl if (line.endsWith('Success')) break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -432,7 +432,7 @@ test('pear stage --truncate ', async function ({ pl if (line.includes('/index.js')) readdedFile = true if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -456,7 +456,7 @@ test('pear stage --truncate --json ', async functio if (line.endsWith('Success')) break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -479,7 +479,7 @@ test('pear stage --truncate --json ', async functio if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager2.inspector.close() is(files.includes('/index.js'), true, 'should readd index.js') @@ -511,7 +511,7 @@ test('pear stage --truncate --json ', async functio // // if (line.endsWith('Success')) break // } -// await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await running.inspector.close() // // is(completedStaging, true, 'should complete staging') @@ -544,7 +544,7 @@ test('pear stage --truncate --json ', async functio // if (result.tag === 'staging') stagedName = result.data.name // if (result.tag === 'final') break // } -// await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await running.inspector.close() // // is(stagedName, 'test-name-' + testId, 'should use --name flag') @@ -584,7 +584,7 @@ test('pear stage --truncate --json ', async functio // // if (line.endsWith('Success')) break // } -// await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await running.inspector.close() // // is(completedStaging, true, 'should complete staging') @@ -626,7 +626,7 @@ test('pear stage --truncate --json ', async functio // if (result.tag === 'staging') stagedName = result.data.name // if (result.tag === 'final') break // } -// await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await running.inspector.close() // // is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') @@ -652,7 +652,7 @@ test('pear stage --truncate --json ', async functio // if (line.endsWith('Success')) break // } // -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager1.inspector.close() // const { code: code1 } = await stager1.until.exit // is(code1, 0, 'should have exit code 0 for initial stage') @@ -685,7 +685,7 @@ test('pear stage --truncate --json ', async functio // if (line.endsWith('Success')) break // } // -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager2.inspector.close() // // is(completedStaging, true, 'should complete staging') @@ -712,7 +712,7 @@ test('pear stage --truncate --json ', async functio // if (line.endsWith('Success')) break // } // -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager1.inspector.close() // const { code: code1 } = await stager1.until.exit // is(code1, 0, 'should have exit code 0 for initial stage') @@ -741,7 +741,7 @@ test('pear stage --truncate --json ', async functio // if (result.tag === 'staging') stagedName = result.data.name // if (result.tag === 'final') break // } -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager2.inspector.close() // // is(files.includes('/package.json'), true, 'should readd package.json after truncate') @@ -771,7 +771,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -787,7 +787,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { if (line === 'Staging complete!') completedStaging = true if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -813,7 +813,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -834,7 +834,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager2.inspector.close() alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') @@ -860,7 +860,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -876,7 +876,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { if (line === 'Staging dry run complete!') completedStaging = true if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -902,7 +902,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -925,7 +925,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, if (result.tag === 'complete') completeTag = result if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager2.inspector.close() alike(tags, ['staging', 'dry', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') @@ -952,7 +952,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -970,7 +970,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { if (line.endsWith('Skipping warmup (bare)')) skippedWarmup = true if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -997,7 +997,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1020,7 +1020,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali if (result.tag === 'skipping') skipTag = result if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager2.inspector.close() is(skipTag?.data?.reason, 'bare', 'should skip warmup') @@ -1047,7 +1047,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1068,7 +1068,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t if (line.includes('/ignored.txt')) addedIgnored = true if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -1095,7 +1095,7 @@ test('pear stage --ignore --json pear:// ', async function ({ if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1121,7 +1121,7 @@ test('pear stage --ignore --json pear:// ', async function ({ if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager2.inspector.close() is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') @@ -1147,7 +1147,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1165,7 +1165,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is if (line.includes('/package.json')) readdedFile = true if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -1192,7 +1192,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1215,7 +1215,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager2.inspector.close() is(files.includes('/package.json'), true, 'should readd package.json after truncate') @@ -1242,7 +1242,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // if (result.tag === 'final') break // } // -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager1.inspector.close() // const { code: code1 } = await stager1.until.exit // is(code1, 0, 'should have exit code 0 for initial stage') @@ -1264,7 +1264,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // // if (line.endsWith('Success')) break // } -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager2.inspector.close() // // is(completedStaging, true, 'should complete staging') @@ -1291,7 +1291,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // if (result.tag === 'final') break // } // -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager1.inspector.close() // const { code: code1 } = await stager1.until.exit // is(code1, 0, 'should have exit code 0 for initial stage') @@ -1314,7 +1314,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // if (result.tag === 'staging') stagedName = result.data.name // if (result.tag === 'final') break // } -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager2.inspector.close() // // is(stagedName, 'test-name-' + testId, 'should use --name flag') @@ -1341,7 +1341,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // if (result.tag === 'final') break // } // -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager1.inspector.close() // const { code: code1 } = await stager1.until.exit // is(code1, 0, 'should have exit code 0 for initial stage') @@ -1368,7 +1368,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // if (line.includes('/ignored.txt')) addedIgnored = true // if (line.endsWith('Success')) break // } -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager2.inspector.close() // // is(completedStaging, true, 'should complete staging') @@ -1396,7 +1396,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // if (result.tag === 'final') break // } // -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager1.inspector.close() // const { code: code1 } = await stager1.until.exit // is(code1, 0, 'should have exit code 0 for initial stage') @@ -1424,7 +1424,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // if (result.tag === 'staging') stagedName = result.data.name // if (result.tag === 'final') break // } -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager2.inspector.close() // // is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') @@ -1452,7 +1452,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // if (result.tag === 'final') break // } // -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager1.inspector.close() // const { code: code1 } = await stager1.until.exit // is(code1, 0, 'should have exit code 0 for initial stage') @@ -1480,7 +1480,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // // if (line.endsWith('Success')) break // } -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager2.inspector.close() // // is(completedStaging, true, 'should complete staging') @@ -1510,7 +1510,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // if (result.tag === 'final') break // } // -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager1.inspector.close() // const { code: code1 } = await stager1.until.exit // is(code1, 0, 'should have exit code 0 for initial stage') @@ -1535,7 +1535,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // if (result.tag === 'staging') stagedName = result.data.name // if (result.tag === 'final') break // } -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) +// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) // await stager2.inspector.close() // // is(files.includes('/package.json'), true, 'should readd package.json after truncate') From e48630ed524d7098a11fe20e2a6e8169d928d58d Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Wed, 7 Aug 2024 02:13:45 +0800 Subject: [PATCH 07/45] Fix wrong package.json being used --- test/05-commands.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 0d3d142a0..6b70fa9cd 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -147,7 +147,7 @@ test('pear stage (package.json pear.stage.ignore Date: Wed, 7 Aug 2024 02:35:20 +0800 Subject: [PATCH 08/45] Add ignoring of unparseable JSON --- test/05-commands.test.js | 99 ++++++++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 33 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 6b70fa9cd..2ec1a4069 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -42,7 +42,8 @@ test('pear stage --json ', async function ({ plan, alik const seen = new Set() const tags = [] for await (const line of running.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (seen.has(result.tag)) continue seen.add(result.tag) tags.push(result.tag) @@ -193,7 +194,8 @@ test('pear stage --json ', async function ({ plan, alik const seen = new Set() const tags = [] for await (const line of running.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (seen.has(result.tag)) continue seen.add(result.tag) tags.push(result.tag) @@ -248,7 +250,8 @@ test('pear stage --dry-run --json ', async function ({ const tags = [] let completeTag for await (const line of running.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (seen.has(result.tag)) continue seen.add(result.tag) tags.push(result.tag) @@ -309,7 +312,8 @@ test('pear stage --bare --json ', async function ({ pla const tags = [] let skipTag for await (const line of running.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (seen.has(result.tag)) continue seen.add(result.tag) tags.push(result.tag) @@ -381,7 +385,8 @@ test('pear stage --ignore --json ', async functi const tags = [] const files = [] for await (const line of running.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (result.tag === 'byte-diff') files.push(result.data.message) if (seen.has(result.tag)) continue seen.add(result.tag) @@ -471,7 +476,8 @@ test('pear stage --truncate --json ', async functio const tags = [] const files = [] for await (const line of stager2.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (result.tag === 'byte-diff') files.push(result.data.message) if (seen.has(result.tag)) continue seen.add(result.tag) @@ -536,7 +542,8 @@ test('pear stage --truncate --json ', async functio // const tags = [] // let stagedName // for await (const line of running.lineout) { -// const result = JSON.parse(line) +// let result +// try { result = JSON.parse(line) } catch (e) { continue } // if (seen.has(result.tag)) continue // seen.add(result.tag) // tags.push(result.tag) @@ -617,7 +624,8 @@ test('pear stage --truncate --json ', async functio // const files = [] // let stagedName // for await (const line of running.lineout) { -// const result = JSON.parse(line) +// let result +// try { result = JSON.parse(line) } catch (e) { continue } // if (result.tag === 'byte-diff') files.push(result.data.message) // if (seen.has(result.tag)) continue // seen.add(result.tag) @@ -732,7 +740,8 @@ test('pear stage --truncate --json ', async functio // const files = [] // let stagedName // for await (const line of stager2.lineout) { -// const result = JSON.parse(line) +// let result +// try { result = JSON.parse(line) } catch (e) { continue } // if (result.tag === 'byte-diff') files.push(result.data.message) // if (seen.has(result.tag)) continue // seen.add(result.tag) @@ -766,7 +775,8 @@ test('pear stage pear:// ', async function ({ plan, is }) { let link for await (const line of stager1.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -808,7 +818,8 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is let link for await (const line of stager1.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -827,7 +838,8 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is const seen = new Set() const tags = [] for await (const line of stager2.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (seen.has(result.tag)) continue seen.add(result.tag) tags.push(result.tag) @@ -855,7 +867,8 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { let link for await (const line of stager1.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -897,7 +910,8 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, let link for await (const line of stager1.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -917,7 +931,8 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, const tags = [] let completeTag for await (const line of stager2.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (seen.has(result.tag)) continue seen.add(result.tag) tags.push(result.tag) @@ -947,7 +962,8 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { let link for await (const line of stager1.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -992,7 +1008,8 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali let link for await (const line of stager1.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -1012,7 +1029,8 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali const tags = [] let skipTag for await (const line of stager2.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (seen.has(result.tag)) continue seen.add(result.tag) tags.push(result.tag) @@ -1042,7 +1060,8 @@ test('pear stage --ignore pear:// ', async function ({ plan, t let link for await (const line of stager1.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -1090,7 +1109,8 @@ test('pear stage --ignore --json pear:// ', async function ({ let link for await (const line of stager1.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -1113,7 +1133,8 @@ test('pear stage --ignore --json pear:// ', async function ({ const tags = [] const files = [] for await (const line of stager2.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (result.tag === 'byte-diff') files.push(result.data.message) if (seen.has(result.tag)) continue seen.add(result.tag) @@ -1142,7 +1163,8 @@ test('pear stage --truncate pear:// ', async function ({ plan, is let link for await (const line of stager1.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -1187,7 +1209,8 @@ test('pear stage --truncate --json pear:// ', async function ({ p let link for await (const line of stager1.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -1207,7 +1230,8 @@ test('pear stage --truncate --json pear:// ', async function ({ p const tags = [] const files = [] for await (const line of stager2.lineout) { - const result = JSON.parse(line) + let result + try { result = JSON.parse(line) } catch (e) { continue } if (result.tag === 'byte-diff') files.push(result.data.message) if (seen.has(result.tag)) continue seen.add(result.tag) @@ -1237,7 +1261,8 @@ test('pear stage --truncate --json pear:// ', async function ({ p // // let link // for await (const line of stager1.lineout) { -// const result = JSON.parse(line) +// let result +// try { result = JSON.parse(line) } catch (e) { continue } // if (result.tag === 'addendum') link = result.data.link // if (result.tag === 'final') break // } @@ -1286,7 +1311,8 @@ test('pear stage --truncate --json pear:// ', async function ({ p // // let link // for await (const line of stager1.lineout) { -// const result = JSON.parse(line) +// let result +// try { result = JSON.parse(line) } catch (e) { continue } // if (result.tag === 'addendum') link = result.data.link // if (result.tag === 'final') break // } @@ -1306,7 +1332,8 @@ test('pear stage --truncate --json pear:// ', async function ({ p // const tags = [] // let stagedName // for await (const line of stager2.lineout) { -// const result = JSON.parse(line) +// let result +// try { result = JSON.parse(line) } catch (e) { continue } // if (seen.has(result.tag)) continue // seen.add(result.tag) // tags.push(result.tag) @@ -1336,7 +1363,8 @@ test('pear stage --truncate --json pear:// ', async function ({ p // // let link // for await (const line of stager1.lineout) { -// const result = JSON.parse(line) +// let result +// try { result = JSON.parse(line) } catch (e) { continue } // if (result.tag === 'addendum') link = result.data.link // if (result.tag === 'final') break // } @@ -1391,7 +1419,8 @@ test('pear stage --truncate --json pear:// ', async function ({ p // // let link // for await (const line of stager1.lineout) { -// const result = JSON.parse(line) +// let result +// try { result = JSON.parse(line) } catch (e) { continue } // if (result.tag === 'addendum') link = result.data.link // if (result.tag === 'final') break // } @@ -1415,7 +1444,8 @@ test('pear stage --truncate --json pear:// ', async function ({ p // const files = [] // let stagedName // for await (const line of stager2.lineout) { -// const result = JSON.parse(line) +// let result +// try { result = JSON.parse(line) } catch (e) { continue } // if (result.tag === 'byte-diff') files.push(result.data.message) // if (seen.has(result.tag)) continue // seen.add(result.tag) @@ -1447,7 +1477,8 @@ test('pear stage --truncate --json pear:// ', async function ({ p // // let link // for await (const line of stager1.lineout) { -// const result = JSON.parse(line) +// let result +// try { result = JSON.parse(line) } catch (e) { continue } // if (result.tag === 'addendum') link = result.data.link // if (result.tag === 'final') break // } @@ -1505,7 +1536,8 @@ test('pear stage --truncate --json pear:// ', async function ({ p // // let link // for await (const line of stager1.lineout) { -// const result = JSON.parse(line) +// let result +// try { result = JSON.parse(line) } catch (e) { continue } // if (result.tag === 'addendum') link = result.data.link // if (result.tag === 'final') break // } @@ -1526,7 +1558,8 @@ test('pear stage --truncate --json pear:// ', async function ({ p // const files = [] // let stagedName // for await (const line of stager2.lineout) { -// const result = JSON.parse(line) +// let result +// try { result = JSON.parse(line) } catch (e) { continue } // if (result.tag === 'byte-diff') files.push(result.data.message) // if (seen.has(result.tag)) continue // seen.add(result.tag) From 92771ae1340f438349b06a023e251edb551218bd Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Thu, 8 Aug 2024 02:08:25 +0800 Subject: [PATCH 09/45] Revert "Add ignoring of unparseable JSON" This reverts commit 420bd44e901028a102b539fabc942344f4939f8b. --- test/05-commands.test.js | 99 ++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 66 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 2ec1a4069..6b70fa9cd 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -42,8 +42,7 @@ test('pear stage --json ', async function ({ plan, alik const seen = new Set() const tags = [] for await (const line of running.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (seen.has(result.tag)) continue seen.add(result.tag) tags.push(result.tag) @@ -194,8 +193,7 @@ test('pear stage --json ', async function ({ plan, alik const seen = new Set() const tags = [] for await (const line of running.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (seen.has(result.tag)) continue seen.add(result.tag) tags.push(result.tag) @@ -250,8 +248,7 @@ test('pear stage --dry-run --json ', async function ({ const tags = [] let completeTag for await (const line of running.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (seen.has(result.tag)) continue seen.add(result.tag) tags.push(result.tag) @@ -312,8 +309,7 @@ test('pear stage --bare --json ', async function ({ pla const tags = [] let skipTag for await (const line of running.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (seen.has(result.tag)) continue seen.add(result.tag) tags.push(result.tag) @@ -385,8 +381,7 @@ test('pear stage --ignore --json ', async functi const tags = [] const files = [] for await (const line of running.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (result.tag === 'byte-diff') files.push(result.data.message) if (seen.has(result.tag)) continue seen.add(result.tag) @@ -476,8 +471,7 @@ test('pear stage --truncate --json ', async functio const tags = [] const files = [] for await (const line of stager2.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (result.tag === 'byte-diff') files.push(result.data.message) if (seen.has(result.tag)) continue seen.add(result.tag) @@ -542,8 +536,7 @@ test('pear stage --truncate --json ', async functio // const tags = [] // let stagedName // for await (const line of running.lineout) { -// let result -// try { result = JSON.parse(line) } catch (e) { continue } +// const result = JSON.parse(line) // if (seen.has(result.tag)) continue // seen.add(result.tag) // tags.push(result.tag) @@ -624,8 +617,7 @@ test('pear stage --truncate --json ', async functio // const files = [] // let stagedName // for await (const line of running.lineout) { -// let result -// try { result = JSON.parse(line) } catch (e) { continue } +// const result = JSON.parse(line) // if (result.tag === 'byte-diff') files.push(result.data.message) // if (seen.has(result.tag)) continue // seen.add(result.tag) @@ -740,8 +732,7 @@ test('pear stage --truncate --json ', async functio // const files = [] // let stagedName // for await (const line of stager2.lineout) { -// let result -// try { result = JSON.parse(line) } catch (e) { continue } +// const result = JSON.parse(line) // if (result.tag === 'byte-diff') files.push(result.data.message) // if (seen.has(result.tag)) continue // seen.add(result.tag) @@ -775,8 +766,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { let link for await (const line of stager1.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -818,8 +808,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is let link for await (const line of stager1.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -838,8 +827,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is const seen = new Set() const tags = [] for await (const line of stager2.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (seen.has(result.tag)) continue seen.add(result.tag) tags.push(result.tag) @@ -867,8 +855,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { let link for await (const line of stager1.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -910,8 +897,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, let link for await (const line of stager1.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -931,8 +917,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, const tags = [] let completeTag for await (const line of stager2.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (seen.has(result.tag)) continue seen.add(result.tag) tags.push(result.tag) @@ -962,8 +947,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { let link for await (const line of stager1.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -1008,8 +992,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali let link for await (const line of stager1.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -1029,8 +1012,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali const tags = [] let skipTag for await (const line of stager2.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (seen.has(result.tag)) continue seen.add(result.tag) tags.push(result.tag) @@ -1060,8 +1042,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t let link for await (const line of stager1.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -1109,8 +1090,7 @@ test('pear stage --ignore --json pear:// ', async function ({ let link for await (const line of stager1.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -1133,8 +1113,7 @@ test('pear stage --ignore --json pear:// ', async function ({ const tags = [] const files = [] for await (const line of stager2.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (result.tag === 'byte-diff') files.push(result.data.message) if (seen.has(result.tag)) continue seen.add(result.tag) @@ -1163,8 +1142,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is let link for await (const line of stager1.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -1209,8 +1187,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p let link for await (const line of stager1.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (result.tag === 'addendum') link = result.data.link if (result.tag === 'final') break } @@ -1230,8 +1207,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p const tags = [] const files = [] for await (const line of stager2.lineout) { - let result - try { result = JSON.parse(line) } catch (e) { continue } + const result = JSON.parse(line) if (result.tag === 'byte-diff') files.push(result.data.message) if (seen.has(result.tag)) continue seen.add(result.tag) @@ -1261,8 +1237,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // // let link // for await (const line of stager1.lineout) { -// let result -// try { result = JSON.parse(line) } catch (e) { continue } +// const result = JSON.parse(line) // if (result.tag === 'addendum') link = result.data.link // if (result.tag === 'final') break // } @@ -1311,8 +1286,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // // let link // for await (const line of stager1.lineout) { -// let result -// try { result = JSON.parse(line) } catch (e) { continue } +// const result = JSON.parse(line) // if (result.tag === 'addendum') link = result.data.link // if (result.tag === 'final') break // } @@ -1332,8 +1306,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // const tags = [] // let stagedName // for await (const line of stager2.lineout) { -// let result -// try { result = JSON.parse(line) } catch (e) { continue } +// const result = JSON.parse(line) // if (seen.has(result.tag)) continue // seen.add(result.tag) // tags.push(result.tag) @@ -1363,8 +1336,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // // let link // for await (const line of stager1.lineout) { -// let result -// try { result = JSON.parse(line) } catch (e) { continue } +// const result = JSON.parse(line) // if (result.tag === 'addendum') link = result.data.link // if (result.tag === 'final') break // } @@ -1419,8 +1391,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // // let link // for await (const line of stager1.lineout) { -// let result -// try { result = JSON.parse(line) } catch (e) { continue } +// const result = JSON.parse(line) // if (result.tag === 'addendum') link = result.data.link // if (result.tag === 'final') break // } @@ -1444,8 +1415,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // const files = [] // let stagedName // for await (const line of stager2.lineout) { -// let result -// try { result = JSON.parse(line) } catch (e) { continue } +// const result = JSON.parse(line) // if (result.tag === 'byte-diff') files.push(result.data.message) // if (seen.has(result.tag)) continue // seen.add(result.tag) @@ -1477,8 +1447,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // // let link // for await (const line of stager1.lineout) { -// let result -// try { result = JSON.parse(line) } catch (e) { continue } +// const result = JSON.parse(line) // if (result.tag === 'addendum') link = result.data.link // if (result.tag === 'final') break // } @@ -1536,8 +1505,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // // let link // for await (const line of stager1.lineout) { -// let result -// try { result = JSON.parse(line) } catch (e) { continue } +// const result = JSON.parse(line) // if (result.tag === 'addendum') link = result.data.link // if (result.tag === 'final') break // } @@ -1558,8 +1526,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p // const files = [] // let stagedName // for await (const line of stager2.lineout) { -// let result -// try { result = JSON.parse(line) } catch (e) { continue } +// const result = JSON.parse(line) // if (result.tag === 'byte-diff') files.push(result.data.message) // if (seen.has(result.tag)) continue // seen.add(result.tag) From 109f9d9bb93a9498cce6b543638c195f7edeaa32 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Tue, 20 Aug 2024 22:50:47 +0800 Subject: [PATCH 10/45] Update tests that edit package.json to use temp dir --- test/05-commands.test.js | 55 +++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 6b70fa9cd..227f13014 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -2,9 +2,11 @@ const test = require('brittle') const path = require('bare-path') const Helper = require('./helper') const fs = require('bare-fs') +const LocalDrive = require('localdrive') -const harness = path.join(Helper.root, 'test', 'fixtures', 'harness') -const minimal = path.join(Helper.root, 'test', 'fixtures', 'minimal') +const fixtures = path.join(Helper.root, 'test', 'fixtures') +const harness = path.join(fixtures, 'harness') +const minimal = path.join(fixtures, 'minimal') class Rig { setup = async ({ comment }) => { @@ -109,18 +111,24 @@ test('pear stage (package.json pear.config.stage.entry plan(2) const testId = Math.floor(Math.random() * 100000) - const relativePath = path.relative(harness, minimal) - const argv = ['stage', 'test-' + testId, relativePath] - const originalPackageJson = fs.readFileSync(path.join(minimal, 'package.json'), 'utf8') + const tmp = path.join(fixtures, '.tmp') + const targetDir = path.join(tmp, `pear-test-${testId}`) + const sourceDrive = new LocalDrive(minimal) + const targetDrive = new LocalDrive(targetDir) + const mirror = sourceDrive.mirror(targetDrive, { prune: false }) + // eslint-disable-next-line no-unused-vars + for await (const val of mirror) { /* ignore */ } + + const originalPackageJson = fs.readFileSync(path.join(targetDir, 'package.json'), 'utf8') const packageJson = JSON.parse(originalPackageJson) packageJson.pear.stage = { entrypoints: ['index.js'] } - fs.writeFileSync(path.join(minimal, 'run.js'), 'console.log("run")') - fs.writeFileSync(path.join(minimal, 'package.json'), JSON.stringify(packageJson, null, 2)) - teardown(() => { - fs.writeFileSync(path.join(minimal, 'package.json'), originalPackageJson) - fs.unlinkSync(path.join(minimal, 'run.js')) - }) + fs.writeFileSync(path.join(targetDir, 'run.js'), 'console.log("run")') + fs.writeFileSync(path.join(targetDir, 'package.json'), JSON.stringify(packageJson, null, 2)) + teardown(async () => { await fs.promises.rm(targetDir, { recursive: true }) }) + + const relativePath = path.relative(harness, targetDir) + const argv = ['stage', 'test-' + testId, relativePath] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` @@ -144,18 +152,25 @@ test('pear stage (package.json pear.stage.ignore { - fs.writeFileSync(path.join(minimal, 'package.json'), originalPackageJson) - fs.unlinkSync(path.join(minimal, 'ignoreinner.txt')) - }) + fs.writeFileSync(path.join(targetDir, 'ignoreinner.txt'), 'this file should be ignored') + fs.writeFileSync(path.join(targetDir, 'package.json'), JSON.stringify(packageJson, null, 2)) + teardown(async () => { await fs.promises.rm(targetDir, { recursive: true }) }) + + const relativePath = path.relative(harness, targetDir) + const argv = ['stage', 'test-' + testId, relativePath] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` From 8088482b4b2441af29865ef109eef25f14ac2176 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Fri, 23 Aug 2024 04:12:13 +0800 Subject: [PATCH 11/45] Uncomment --name tests --- test/05-commands.test.js | 1172 +++++++++++++++++++------------------- 1 file changed, 586 insertions(+), 586 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 227f13014..19b3b2c54 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -503,270 +503,270 @@ test('pear stage --truncate --json ', async functio is(code, 0, 'should have exit code 0') }) -// test('pear stage --name ', async function ({ plan, is }) { -// plan(3) -// -// const testId = Math.floor(Math.random() * 100000) -// const relativePath = path.relative(harness, minimal) -// const argv = ['stage', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] -// -// const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// await running.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argv)}) -// `, { returnByValue: false }) -// -// let completedStaging = false -// let stagedName -// const stagingRegex = /Staging (.*) into/ -// for await (const line of running.lineout) { -// if (line === 'Staging complete!') completedStaging = true -// -// const stagingMatch = line.match(stagingRegex) -// if (stagingMatch) stagedName = stagingMatch[1] -// -// if (line.endsWith('Success')) break -// } -// await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await running.inspector.close() -// -// is(completedStaging, true, 'should complete staging') -// is(stagedName, 'test-name-' + testId, 'should use --name flag') -// const { code } = await running.until.exit -// is(code, 0, 'should have exit code 0') -// }) - -// test('pear stage --name --json ', async function ({ plan, alike, is }) { -// plan(3) -// -// const testId = Math.floor(Math.random() * 100000) -// const relativePath = path.relative(harness, minimal) -// const argv = ['stage', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] -// -// const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// await running.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argv)}) -// `, { returnByValue: false }) -// -// const seen = new Set() -// const tags = [] -// let stagedName -// for await (const line of running.lineout) { -// const result = JSON.parse(line) -// if (seen.has(result.tag)) continue -// seen.add(result.tag) -// tags.push(result.tag) -// -// if (result.tag === 'staging') stagedName = result.data.name -// if (result.tag === 'final') break -// } -// await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await running.inspector.close() -// -// is(stagedName, 'test-name-' + testId, 'should use --name flag') -// alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') -// const { code } = await running.until.exit -// is(code, 0, 'should have exit code 0') -// }) - -// test('pear stage --ignore --name ', async function ({ plan, teardown, is }) { -// plan(5) -// -// const testId = Math.floor(Math.random() * 100000) -// const relativePath = path.relative(harness, minimal) -// const ignoredFile = path.join(harness, 'ignored.txt') -// fs.writeFileSync(ignoredFile, 'this file should be ignored') -// teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) -// -// const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] -// -// const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// await running.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argv)}) -// `, { returnByValue: false }) -// -// let completedStaging = false -// let addedIgnored = false -// let addedIndex = false -// let stagedName -// const stagingRegex = /Staging (.*) into/ -// for await (const line of running.lineout) { -// if (line === 'Staging complete!') completedStaging = true -// if (line.includes('/index.js')) addedIndex = true -// if (line.includes('/ignored.txt')) addedIgnored = true -// -// const stagingMatch = line.match(stagingRegex) -// if (stagingMatch) stagedName = stagingMatch[1] -// -// if (line.endsWith('Success')) break -// } -// await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await running.inspector.close() -// -// is(completedStaging, true, 'should complete staging') -// is(addedIgnored, false, 'should not add ignored.txt') -// is(addedIndex, true, 'should add index.js') -// is(stagedName, 'test-name-' + testId, 'should use --name flag') -// -// const { code } = await running.until.exit -// is(code, 0, 'should have exit code 0') -// }) - -// test('pear stage --ignore --name --json ', async function ({ plan, alike, teardown, is }) { -// plan(5) -// -// const testId = Math.floor(Math.random() * 100000) -// const relativePath = path.relative(harness, minimal) -// const ignoredFile = path.join(harness, 'ignored.txt') -// fs.writeFileSync(ignoredFile, 'this file should be ignored') -// teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) -// -// const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] -// -// const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// await running.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argv)}) -// `, { returnByValue: false }) -// -// const seen = new Set() -// const tags = [] -// const files = [] -// let stagedName -// for await (const line of running.lineout) { -// const result = JSON.parse(line) -// if (result.tag === 'byte-diff') files.push(result.data.message) -// if (seen.has(result.tag)) continue -// seen.add(result.tag) -// tags.push(result.tag) -// -// if (result.tag === 'staging') stagedName = result.data.name -// if (result.tag === 'final') break -// } -// await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await running.inspector.close() -// -// is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') -// is(files.includes('/index.js'), true, 'should add index.js') -// is(stagedName, 'test-name-' + testId, 'should use --name flag') -// alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') -// const { code } = await running.until.exit -// is(code, 0, 'should have exit code 0') -// }) - -// test('pear stage --dry-run --bare --ignore --truncate --name ', async function ({ plan, teardown, is }) { -// plan(7) -// -// const testId = Math.floor(Math.random() * 100000) -// const relativePath = path.relative(harness, minimal) -// const argvInit = ['stage', 'test-' + testId, relativePath] -// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// await stager1.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) -// `, { returnByValue: false }) -// -// for await (const line of stager1.lineout) { -// if (line.endsWith('Success')) break -// } -// -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager1.inspector.close() -// const { code: code1 } = await stager1.until.exit -// is(code1, 0, 'should have exit code 0 for initial stage') -// -// const ignoredFile = path.join(harness, 'ignored.txt') -// fs.writeFileSync(ignoredFile, 'this file should be ignored') -// teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) -// -// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, 'test-' + testId, relativePath] -// await stager2.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argv)}) -// `, { returnByValue: false }) -// -// const stagingRegex = /Staging (.*) into/ -// let completedStaging = false -// let readdedFile = false -// let addedIndex = false -// let addedIgnored = false -// let stagedName -// for await (const line of stager2.lineout) { -// if (line === 'Staging dry run complete!') completedStaging = true -// if (line.includes('/package.json')) readdedFile = true -// if (line.includes('/index.js')) addedIndex = true -// if (line.includes('/ignored.txt')) addedIgnored = true -// -// const stagingMatch = line.match(stagingRegex) -// if (stagingMatch) stagedName = stagingMatch[1] -// -// if (line.endsWith('Success')) break -// } -// -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager2.inspector.close() -// -// is(completedStaging, true, 'should complete staging') -// is(readdedFile, true, 'should readd package.json after truncate') -// is(addedIgnored, false, 'should not add ignored.txt') -// is(addedIndex, true, 'should add index.js') -// is(stagedName, 'test-name-' + testId, 'should use --name flag') -// const { code } = await stager2.until.exit -// is(code, 0, 'should have exit code 0') -// }) - -// test('pear stage --dry-run --bare --ignore --truncate --name --json ', async function ({ plan, alike, teardown, is }) { -// plan(7) -// -// const testId = Math.floor(Math.random() * 100000) -// const relativePath = path.relative(harness, minimal) -// const argvInit = ['stage', 'test-' + testId, relativePath] -// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// await stager1.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) -// `, { returnByValue: false }) -// -// for await (const line of stager1.lineout) { -// if (line.endsWith('Success')) break -// } -// -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager1.inspector.close() -// const { code: code1 } = await stager1.until.exit -// is(code1, 0, 'should have exit code 0 for initial stage') -// -// const ignoredFile = path.join(harness, 'ignored.txt') -// fs.writeFileSync(ignoredFile, 'this file should be ignored') -// teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) -// -// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', 'test-' + testId, relativePath] -// await stager2.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argv)}) -// `, { returnByValue: false }) -// -// const seen = new Set() -// const tags = [] -// const files = [] -// let stagedName -// for await (const line of stager2.lineout) { -// const result = JSON.parse(line) -// if (result.tag === 'byte-diff') files.push(result.data.message) -// if (seen.has(result.tag)) continue -// seen.add(result.tag) -// tags.push(result.tag) -// -// if (result.tag === 'staging') stagedName = result.data.name -// if (result.tag === 'final') break -// } -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager2.inspector.close() -// -// is(files.includes('/package.json'), true, 'should readd package.json after truncate') -// is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') -// is(files.includes('/index.js'), true, 'should add index.js') -// is(stagedName, 'test-name-' + testId, 'should use --name flag') -// alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') -// const { code } = await stager2.until.exit -// is(code, 0, 'should have exit code 0') -// }) +test('pear stage --name ', async function ({ plan, is }) { + plan(3) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argv = ['stage', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + let stagedName + const stagingRegex = /Staging (.*) into/ + for await (const line of running.lineout) { + if (line === 'Staging complete!') completedStaging = true + + const stagingMatch = line.match(stagingRegex) + if (stagingMatch) stagedName = stagingMatch[1] + + if (line.endsWith('Success')) break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(stagedName, 'test-name-' + testId, 'should use --name flag') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --name --json ', async function ({ plan, alike, is }) { + plan(3) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argv = ['stage', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + let stagedName + for await (const line of running.lineout) { + const result = JSON.parse(line) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'staging') stagedName = result.data.name + if (result.tag === 'final') break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.close() + + is(stagedName, 'test-name-' + testId, 'should use --name flag') + alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --ignore --name ', async function ({ plan, teardown, is }) { + plan(5) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + + const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + let addedIgnored = false + let addedIndex = false + let stagedName + const stagingRegex = /Staging (.*) into/ + for await (const line of running.lineout) { + if (line === 'Staging complete!') completedStaging = true + if (line.includes('/index.js')) addedIndex = true + if (line.includes('/ignored.txt')) addedIgnored = true + + const stagingMatch = line.match(stagingRegex) + if (stagingMatch) stagedName = stagingMatch[1] + + if (line.endsWith('Success')) break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(addedIgnored, false, 'should not add ignored.txt') + is(addedIndex, true, 'should add index.js') + is(stagedName, 'test-name-' + testId, 'should use --name flag') + + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --ignore --name --json ', async function ({ plan, alike, teardown, is }) { + plan(5) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + + const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] + + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + const files = [] + let stagedName + for await (const line of running.lineout) { + const result = JSON.parse(line) + if (result.tag === 'byte-diff') files.push(result.data.message) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'staging') stagedName = result.data.name + if (result.tag === 'final') break + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.close() + + is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') + is(files.includes('/index.js'), true, 'should add index.js') + is(stagedName, 'test-name-' + testId, 'should use --name flag') + alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --dry-run --bare --ignore --truncate --name ', async function ({ plan, teardown, is }) { + plan(7) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + for await (const line of stager1.lineout) { + if (line.endsWith('Success')) break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, 'test-' + testId, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const stagingRegex = /Staging (.*) into/ + let completedStaging = false + let readdedFile = false + let addedIndex = false + let addedIgnored = false + let stagedName + for await (const line of stager2.lineout) { + if (line === 'Staging dry run complete!') completedStaging = true + if (line.includes('/package.json')) readdedFile = true + if (line.includes('/index.js')) addedIndex = true + if (line.includes('/ignored.txt')) addedIgnored = true + + const stagingMatch = line.match(stagingRegex) + if (stagingMatch) stagedName = stagingMatch[1] + + if (line.endsWith('Success')) break + } + + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(readdedFile, true, 'should readd package.json after truncate') + is(addedIgnored, false, 'should not add ignored.txt') + is(addedIndex, true, 'should add index.js') + is(stagedName, 'test-name-' + testId, 'should use --name flag') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --dry-run --bare --ignore --truncate --name --json ', async function ({ plan, alike, teardown, is }) { + plan(7) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + for await (const line of stager1.lineout) { + if (line.endsWith('Success')) break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', 'test-' + testId, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + const files = [] + let stagedName + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (result.tag === 'byte-diff') files.push(result.data.message) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'staging') stagedName = result.data.name + if (result.tag === 'final') break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.close() + + is(files.includes('/package.json'), true, 'should readd package.json after truncate') + is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') + is(files.includes('/index.js'), true, 'should add index.js') + is(stagedName, 'test-name-' + testId, 'should use --name flag') + alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) test('pear stage pear:// ', async function ({ plan, is }) { plan(3) @@ -1239,328 +1239,328 @@ test('pear stage --truncate --json pear:// ', async function ({ p is(code, 0, 'should have exit code 0') }) -// test('pear stage --name pear:// ', async function ({ plan, is }) { -// plan(4) -// -// const testId = Math.floor(Math.random() * 100000) -// const relativePath = path.relative(harness, minimal) -// const argvInit = ['stage', '--json', 'test-' + testId, relativePath] -// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// await stager1.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) -// `, { returnByValue: false }) -// -// let link -// for await (const line of stager1.lineout) { -// const result = JSON.parse(line) -// if (result.tag === 'addendum') link = result.data.link -// if (result.tag === 'final') break -// } -// -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager1.inspector.close() -// const { code: code1 } = await stager1.until.exit -// is(code1, 0, 'should have exit code 0 for initial stage') -// -// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// const argv = ['stage', '--name', `test-name-${testId}`, link, relativePath] -// await stager2.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argv)}) -// `, { returnByValue: false }) -// -// let completedStaging = false -// const stagingRegex = /Staging (.*) into/ -// let stagedName -// for await (const line of stager2.lineout) { -// if (line === 'Staging complete!') completedStaging = true -// -// const stagingMatch = line.match(stagingRegex) -// if (stagingMatch) stagedName = stagingMatch[1] -// -// if (line.endsWith('Success')) break -// } -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager2.inspector.close() -// -// is(completedStaging, true, 'should complete staging') -// is(stagedName, 'test-name-' + testId, 'should use --name flag') -// const { code } = await stager2.until.exit -// is(code, 0, 'should have exit code 0') -// }) - -// test('pear stage --name --json pear:// ', async function ({ plan, alike, is }) { -// plan(4) -// -// const testId = Math.floor(Math.random() * 100000) -// const relativePath = path.relative(harness, minimal) -// const argvInit = ['stage', '--json', 'test-' + testId, relativePath] -// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// await stager1.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) -// `, { returnByValue: false }) -// -// let link -// for await (const line of stager1.lineout) { -// const result = JSON.parse(line) -// if (result.tag === 'addendum') link = result.data.link -// if (result.tag === 'final') break -// } -// -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager1.inspector.close() -// const { code: code1 } = await stager1.until.exit -// is(code1, 0, 'should have exit code 0 for initial stage') -// -// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// const argv = ['stage', '--name', `test-name-${testId}`, '--json', link, relativePath] -// await stager2.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argv)}) -// `, { returnByValue: false }) -// -// const seen = new Set() -// const tags = [] -// let stagedName -// for await (const line of stager2.lineout) { -// const result = JSON.parse(line) -// if (seen.has(result.tag)) continue -// seen.add(result.tag) -// tags.push(result.tag) -// -// if (result.tag === 'staging') stagedName = result.data.name -// if (result.tag === 'final') break -// } -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager2.inspector.close() -// -// is(stagedName, 'test-name-' + testId, 'should use --name flag') -// alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') -// const { code } = await stager2.until.exit -// is(code, 0, 'should have exit code 0') -// }) - -// test('pear stage --ignore --name pear:// ', async function ({ plan, teardown, is }) { -// plan(5) -// -// const testId = Math.floor(Math.random() * 100000) -// const relativePath = path.relative(harness, minimal) -// const argvInit = ['stage', '--json', 'test-' + testId, relativePath] -// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// await stager1.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) -// `, { returnByValue: false }) -// -// let link -// for await (const line of stager1.lineout) { -// const result = JSON.parse(line) -// if (result.tag === 'addendum') link = result.data.link -// if (result.tag === 'final') break -// } -// -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager1.inspector.close() -// const { code: code1 } = await stager1.until.exit -// is(code1, 0, 'should have exit code 0 for initial stage') -// -// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// const ignoredFile = path.join(harness, 'ignored.txt') -// fs.writeFileSync(ignoredFile, 'this file should be ignored') -// teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) -// const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-name-${testId}`, link, relativePath] -// await stager2.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argv)}) -// `, { returnByValue: false }) -// -// let completedStaging = false -// let addedIgnored = false -// const stagingRegex = /Staging (.*) into/ -// let stagedName -// for await (const line of stager2.lineout) { -// if (line === 'Staging complete!') completedStaging = true -// -// const stagingMatch = line.match(stagingRegex) -// if (stagingMatch) stagedName = stagingMatch[1] -// -// if (line.includes('/ignored.txt')) addedIgnored = true -// if (line.endsWith('Success')) break -// } -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager2.inspector.close() -// -// is(completedStaging, true, 'should complete staging') -// is(addedIgnored, false, 'should not add ignored.txt') -// is(stagedName, 'test-name-' + testId, 'should use --name flag') -// const { code } = await stager2.until.exit -// is(code, 0, 'should have exit code 0') -// }) - -// test('pear stage --ignore --name --json pear:// ', async function ({ plan, alike, teardown, is }) { -// plan(5) -// -// const testId = Math.floor(Math.random() * 100000) -// const relativePath = path.relative(harness, minimal) -// const argvInit = ['stage', '--json', 'test-' + testId, relativePath] -// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// await stager1.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) -// `, { returnByValue: false }) -// -// let link -// for await (const line of stager1.lineout) { -// const result = JSON.parse(line) -// if (result.tag === 'addendum') link = result.data.link -// if (result.tag === 'final') break -// } -// -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager1.inspector.close() -// const { code: code1 } = await stager1.until.exit -// is(code1, 0, 'should have exit code 0 for initial stage') -// -// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// const ignoredFile = path.join(harness, 'ignored.txt') -// fs.writeFileSync(ignoredFile, 'this file should be ignored') -// teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) -// const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-name-${testId}`, '--json', link, relativePath] -// await stager2.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argv)}) -// `, { returnByValue: false }) -// -// const seen = new Set() -// const tags = [] -// const files = [] -// let stagedName -// for await (const line of stager2.lineout) { -// const result = JSON.parse(line) -// if (result.tag === 'byte-diff') files.push(result.data.message) -// if (seen.has(result.tag)) continue -// seen.add(result.tag) -// tags.push(result.tag) -// -// if (result.tag === 'staging') stagedName = result.data.name -// if (result.tag === 'final') break -// } -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager2.inspector.close() -// -// is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') -// is(stagedName, 'test-name-' + testId, 'should use --name flag') -// alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') -// const { code } = await stager2.until.exit -// is(code, 0, 'should have exit code 0') -// }) - -// test('pear stage --dry-run --bare --ignore --truncate --name pear:// ', async function ({ plan, is }) { -// plan(7) -// -// const testId = Math.floor(Math.random() * 100000) -// const relativePath = path.relative(harness, minimal) -// const argvInit = ['stage', '--json', 'test-' + testId, relativePath] -// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// await stager1.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) -// `, { returnByValue: false }) -// -// let link -// for await (const line of stager1.lineout) { -// const result = JSON.parse(line) -// if (result.tag === 'addendum') link = result.data.link -// if (result.tag === 'final') break -// } -// -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager1.inspector.close() -// const { code: code1 } = await stager1.until.exit -// is(code1, 0, 'should have exit code 0 for initial stage') -// -// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, link, relativePath] -// await stager2.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argv)}) -// `, { returnByValue: false }) -// -// const stagingRegex = /Staging (.*) into/ -// let completedStaging = false -// let readdedFile = false -// let addedIndex = false -// let addedIgnored = false -// let stagedName -// for await (const line of stager2.lineout) { -// if (line === 'Staging dry run complete!') completedStaging = true -// if (line.includes('/package.json')) readdedFile = true -// if (line.includes('/index.js')) addedIndex = true -// if (line.includes('/ignored.txt')) addedIgnored = true -// -// const stagingMatch = line.match(stagingRegex) -// if (stagingMatch) stagedName = stagingMatch[1] -// -// if (line.endsWith('Success')) break -// } -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager2.inspector.close() -// -// is(completedStaging, true, 'should complete staging') -// is(readdedFile, true, 'should readd package.json after truncate') -// is(addedIgnored, false, 'should not add ignored.txt') -// is(addedIndex, true, 'should add index.js') -// is(stagedName, 'test-name-' + testId, 'should use --name flag') -// const { code } = await stager2.until.exit -// is(code, 0, 'should have exit code 0') -// }) - -// test('pear stage --dry-run --bare --ignore --truncate --name --json pear:// ', async function ({ plan, alike, is }) { -// plan(7) -// -// const testId = Math.floor(Math.random() * 100000) -// const relativePath = path.relative(harness, minimal) -// const argvInit = ['stage', '--json', 'test-' + testId, relativePath] -// const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// await stager1.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argvInit)}) -// `, { returnByValue: false }) -// -// let link -// for await (const line of stager1.lineout) { -// const result = JSON.parse(line) -// if (result.tag === 'addendum') link = result.data.link -// if (result.tag === 'final') break -// } -// -// await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager1.inspector.close() -// const { code: code1 } = await stager1.until.exit -// is(code1, 0, 'should have exit code 0 for initial stage') -// -// const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) -// const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', link, relativePath] -// await stager2.inspector.evaluate(` -// __PEAR_TEST__.command(${JSON.stringify(argv)}) -// `, { returnByValue: false }) -// -// const seen = new Set() -// const tags = [] -// const files = [] -// let stagedName -// for await (const line of stager2.lineout) { -// const result = JSON.parse(line) -// if (result.tag === 'byte-diff') files.push(result.data.message) -// if (seen.has(result.tag)) continue -// seen.add(result.tag) -// tags.push(result.tag) -// -// if (result.tag === 'staging') stagedName = result.data.name -// if (result.tag === 'final') break -// } -// await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) -// await stager2.inspector.close() -// -// is(files.includes('/package.json'), true, 'should readd package.json after truncate') -// is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') -// is(files.includes('/index.js'), true, 'should add index.js') -// is(stagedName, 'test-name-' + testId, 'should use --name flag') -// alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') -// const { code } = await stager2.until.exit -// is(code, 0, 'should have exit code 0') -// }) +test('pear stage --name pear:// ', async function ({ plan, is }) { + plan(4) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--name', `test-name-${testId}`, link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + const stagingRegex = /Staging (.*) into/ + let stagedName + for await (const line of stager2.lineout) { + if (line === 'Staging complete!') completedStaging = true + + const stagingMatch = line.match(stagingRegex) + if (stagingMatch) stagedName = stagingMatch[1] + + if (line.endsWith('Success')) break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(stagedName, 'test-name-' + testId, 'should use --name flag') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --name --json pear:// ', async function ({ plan, alike, is }) { + plan(4) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--name', `test-name-${testId}`, '--json', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + let stagedName + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'staging') stagedName = result.data.name + if (result.tag === 'final') break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.close() + + is(stagedName, 'test-name-' + testId, 'should use --name flag') + alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --ignore --name pear:// ', async function ({ plan, teardown, is }) { + plan(5) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-name-${testId}`, link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let completedStaging = false + let addedIgnored = false + const stagingRegex = /Staging (.*) into/ + let stagedName + for await (const line of stager2.lineout) { + if (line === 'Staging complete!') completedStaging = true + + const stagingMatch = line.match(stagingRegex) + if (stagingMatch) stagedName = stagingMatch[1] + + if (line.includes('/ignored.txt')) addedIgnored = true + if (line.endsWith('Success')) break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(addedIgnored, false, 'should not add ignored.txt') + is(stagedName, 'test-name-' + testId, 'should use --name flag') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --ignore --name --json pear:// ', async function ({ plan, alike, teardown, is }) { + plan(5) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const ignoredFile = path.join(harness, 'ignored.txt') + fs.writeFileSync(ignoredFile, 'this file should be ignored') + teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) + const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-name-${testId}`, '--json', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + const files = [] + let stagedName + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (result.tag === 'byte-diff') files.push(result.data.message) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'staging') stagedName = result.data.name + if (result.tag === 'final') break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.close() + + is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') + is(stagedName, 'test-name-' + testId, 'should use --name flag') + alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --dry-run --bare --ignore --truncate --name pear:// ', async function ({ plan, is }) { + plan(7) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const stagingRegex = /Staging (.*) into/ + let completedStaging = false + let readdedFile = false + let addedIndex = false + let addedIgnored = false + let stagedName + for await (const line of stager2.lineout) { + if (line === 'Staging dry run complete!') completedStaging = true + if (line.includes('/package.json')) readdedFile = true + if (line.includes('/index.js')) addedIndex = true + if (line.includes('/ignored.txt')) addedIgnored = true + + const stagingMatch = line.match(stagingRegex) + if (stagingMatch) stagedName = stagingMatch[1] + + if (line.endsWith('Success')) break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.close() + + is(completedStaging, true, 'should complete staging') + is(readdedFile, true, 'should readd package.json after truncate') + is(addedIgnored, false, 'should not add ignored.txt') + is(addedIndex, true, 'should add index.js') + is(stagedName, 'test-name-' + testId, 'should use --name flag') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear stage --dry-run --bare --ignore --truncate --name --json pear:// ', async function ({ plan, alike, is }) { + plan(7) + + const testId = Math.floor(Math.random() * 100000) + const relativePath = path.relative(harness, minimal) + const argvInit = ['stage', '--json', 'test-' + testId, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit)}) + `, { returnByValue: false }) + + let link + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') link = result.data.link + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.close() + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') + + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', link, relativePath] + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + const seen = new Set() + const tags = [] + const files = [] + let stagedName + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (result.tag === 'byte-diff') files.push(result.data.message) + if (seen.has(result.tag)) continue + seen.add(result.tag) + tags.push(result.tag) + + if (result.tag === 'staging') stagedName = result.data.name + if (result.tag === 'final') break + } + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.close() + + is(files.includes('/package.json'), true, 'should readd package.json after truncate') + is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') + is(files.includes('/index.js'), true, 'should add index.js') + is(stagedName, 'test-name-' + testId, 'should use --name flag') + alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') +}) test.todo('pear seed ') test.todo('pear seed ') From 3c8c11113346e07b106e325a44613fd1047b9e81 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Tue, 27 Aug 2024 03:14:24 +0800 Subject: [PATCH 12/45] Use tmp platform to run test commands --- test/05-commands.test.js | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 19b3b2c54..97f385ca4 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -3,26 +3,52 @@ const path = require('bare-path') const Helper = require('./helper') const fs = require('bare-fs') const LocalDrive = require('localdrive') +const os = require('bare-os') const fixtures = path.join(Helper.root, 'test', 'fixtures') const harness = path.join(fixtures, 'harness') const minimal = path.join(fixtures, 'minimal') +const tmp = fs.realpathSync(os.tmpdir()) class Rig { - setup = async ({ comment }) => { - this.helper = new Helper() + setup = async ({ comment, timeout }) => { + timeout(180000) + const helper = new Helper() + this.helper = helper comment('connecting local sidecar') - await this.helper.ready() - await this.helper.shutdown() - this.helper = new Helper() - await this.helper.ready() + await helper.ready() comment('local sidecar connected') + const id = Math.floor(Math.random() * 10000) + comment('staging platform...') + const staging = helper.stage({ channel: `test-${id}`, name: `test-${id}`, dir: Helper.root, dryRun: false, bare: true }) + await Helper.pick(staging, { tag: 'final' }) + comment('platform staged') + comment('seeding platform...') + const seeding = await helper.seed({ channel: `test-${id}`, name: `test-${id}`, dir: Helper.root, key: null, cmdArgs: [] }) + const until = await Helper.pick(seeding, [{ tag: 'key' }, { tag: 'announced' }]) + const key = await until.key + await until.announced + comment('platform seeding') + comment('bootstrapping tmp platform...') + const platformDir = path.join(tmp, 'tmp-pear') + this.platformDir = platformDir + await Helper.bootstrap(key, platformDir) + comment('tmp platform bootstrapped') + const bootstrapped = new Helper({ platformDir: this.platformDir }) + this.bootstrapped = bootstrapped + comment('connecting tmp sidecar...') + await bootstrapped.ready() + comment('tmp sidecar connected') + global.Pear.teardown(async () => Helper.gc(platformDir)) } cleanup = async ({ comment }) => { + comment('shutting down bootstrapped sidecar') + await this.bootstrapped.shutdown() + comment('bootstrapped sidecar shutdown') comment('shutting down local sidecar') await this.helper.shutdown() - comment('local sidecar shut down') + comment('local sidecar shutdown') } } From 85ca8c43bfd2ee71e5e26ea952a9a169dd1a1343 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Wed, 28 Aug 2024 22:31:16 +0800 Subject: [PATCH 13/45] Use localdev to run command tests --- test/05-commands.test.js | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 97f385ca4..4448c45a0 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -3,49 +3,21 @@ const path = require('bare-path') const Helper = require('./helper') const fs = require('bare-fs') const LocalDrive = require('localdrive') -const os = require('bare-os') const fixtures = path.join(Helper.root, 'test', 'fixtures') const harness = path.join(fixtures, 'harness') const minimal = path.join(fixtures, 'minimal') -const tmp = fs.realpathSync(os.tmpdir()) class Rig { setup = async ({ comment, timeout }) => { timeout(180000) - const helper = new Helper() + const helper = new Helper({ platformDir: path.join(Helper.root, 'pear') }) this.helper = helper comment('connecting local sidecar') await helper.ready() - comment('local sidecar connected') - const id = Math.floor(Math.random() * 10000) - comment('staging platform...') - const staging = helper.stage({ channel: `test-${id}`, name: `test-${id}`, dir: Helper.root, dryRun: false, bare: true }) - await Helper.pick(staging, { tag: 'final' }) - comment('platform staged') - comment('seeding platform...') - const seeding = await helper.seed({ channel: `test-${id}`, name: `test-${id}`, dir: Helper.root, key: null, cmdArgs: [] }) - const until = await Helper.pick(seeding, [{ tag: 'key' }, { tag: 'announced' }]) - const key = await until.key - await until.announced - comment('platform seeding') - comment('bootstrapping tmp platform...') - const platformDir = path.join(tmp, 'tmp-pear') - this.platformDir = platformDir - await Helper.bootstrap(key, platformDir) - comment('tmp platform bootstrapped') - const bootstrapped = new Helper({ platformDir: this.platformDir }) - this.bootstrapped = bootstrapped - comment('connecting tmp sidecar...') - await bootstrapped.ready() - comment('tmp sidecar connected') - global.Pear.teardown(async () => Helper.gc(platformDir)) } cleanup = async ({ comment }) => { - comment('shutting down bootstrapped sidecar') - await this.bootstrapped.shutdown() - comment('bootstrapped sidecar shutdown') comment('shutting down local sidecar') await this.helper.shutdown() comment('local sidecar shutdown') From a031cbbcff866ae5acce8a58cd8f9eb92c02cc4c Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Thu, 29 Aug 2024 06:30:16 +0800 Subject: [PATCH 14/45] Use localdev for all command test runners --- test/05-commands.test.js | 115 ++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 4448c45a0..199ca5046 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -11,7 +11,8 @@ const minimal = path.join(fixtures, 'minimal') class Rig { setup = async ({ comment, timeout }) => { timeout(180000) - const helper = new Helper({ platformDir: path.join(Helper.root, 'pear') }) + this.platformDir = path.join(Helper.root, 'pear') + const helper = new Helper({ platformDir: this.platformDir }) this.helper = helper comment('connecting local sidecar') await helper.ready() @@ -34,7 +35,7 @@ test('pear stage --json ', async function ({ plan, alik const testId = Math.floor(Math.random() * 100000) const argv = ['stage', '--json', 'test-' + testId, minimal] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -62,7 +63,7 @@ test('pear stage ', async function ({ plan, is }) { const testId = Math.floor(Math.random() * 100000) const argv = ['stage', 'test-' + testId, minimal] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -87,7 +88,7 @@ test('pear stage ', async function ({ plan, is }) { const relativePath = path.relative(harness, minimal) const argv = ['stage', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -128,7 +129,7 @@ test('pear stage (package.json pear.config.stage.entry const relativePath = path.relative(harness, targetDir) const argv = ['stage', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -170,7 +171,7 @@ test('pear stage (package.json pear.stage.ignore ', async function ({ plan, alik const relativePath = path.relative(harness, minimal) const argv = ['stage', '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -227,7 +228,7 @@ test('pear stage --dry-run ', async function ({ plan, i const relativePath = path.relative(harness, minimal) const argv = ['stage', '--dry-run', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -252,7 +253,7 @@ test('pear stage --dry-run --json ', async function ({ const relativePath = path.relative(harness, minimal) const argv = ['stage', '--dry-run', '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -285,7 +286,7 @@ test('pear stage --bare ', async function ({ plan, is } const relativePath = path.relative(harness, minimal) const argv = ['stage', '--bare', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -313,7 +314,7 @@ test('pear stage --bare --json ', async function ({ pla const relativePath = path.relative(harness, minimal) const argv = ['stage', '--bare', '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -350,7 +351,7 @@ test('pear stage --ignore ', async function ({ p const argv = ['stage', '--ignore', 'ignored.txt', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -385,7 +386,7 @@ test('pear stage --ignore --json ', async functi const argv = ['stage', '--ignore', 'ignored.txt', '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -418,7 +419,7 @@ test('pear stage --truncate ', async function ({ pl const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -432,7 +433,7 @@ test('pear stage --truncate ', async function ({ pl const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', '--truncate', '0', 'test-' + testId, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -460,7 +461,7 @@ test('pear stage --truncate --json ', async functio const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -474,7 +475,7 @@ test('pear stage --truncate --json ', async functio const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', '--truncate', '0', '--json', 'test-' + testId, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -508,7 +509,7 @@ test('pear stage --name ', async function ({ pla const relativePath = path.relative(harness, minimal) const argv = ['stage', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -540,7 +541,7 @@ test('pear stage --name --json ', async function const relativePath = path.relative(harness, minimal) const argv = ['stage', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -577,7 +578,7 @@ test('pear stage --ignore --name ', async const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -620,7 +621,7 @@ test('pear stage --ignore --name --json ' const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -656,7 +657,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -674,7 +675,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, 'test-' + testId, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -716,7 +717,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -734,7 +735,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', 'test-' + testId, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -772,7 +773,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -789,7 +790,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -814,7 +815,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -831,7 +832,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -861,7 +862,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -878,7 +879,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', '--dry-run', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -903,7 +904,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -920,7 +921,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', '--dry-run', '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -953,7 +954,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -970,7 +971,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', '--bare', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -998,7 +999,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1015,7 +1016,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', '--bare', '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -1048,7 +1049,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1065,7 +1066,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) @@ -1096,7 +1097,7 @@ test('pear stage --ignore --json pear:// ', async function ({ const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1113,7 +1114,7 @@ test('pear stage --ignore --json pear:// ', async function ({ const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) @@ -1148,7 +1149,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1165,7 +1166,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', '--truncate', '0', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -1193,7 +1194,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1210,7 +1211,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', '--truncate', '0', '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -1243,7 +1244,7 @@ test('pear stage --name pear:// ', async function ({ plan, is const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1260,7 +1261,7 @@ test('pear stage --name pear:// ', async function ({ plan, is const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', '--name', `test-name-${testId}`, link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -1292,7 +1293,7 @@ test('pear stage --name --json pear:// ', async function ({ pl const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1309,7 +1310,7 @@ test('pear stage --name --json pear:// ', async function ({ pl const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', '--name', `test-name-${testId}`, '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -1342,7 +1343,7 @@ test('pear stage --ignore --name pear:// ', async funct const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1359,7 +1360,7 @@ test('pear stage --ignore --name pear:// ', async funct const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) @@ -1397,7 +1398,7 @@ test('pear stage --ignore --name --json pear:// ', asyn const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1414,7 +1415,7 @@ test('pear stage --ignore --name --json pear:// ', asyn const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) @@ -1453,7 +1454,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1470,7 +1471,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -1511,7 +1512,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1528,7 +1529,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) From 5bd257e2b6508d10075f9777fc0e950f574d5f14 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Wed, 11 Sep 2024 21:54:34 +0800 Subject: [PATCH 15/45] Remove platformDir since we now have tests running with staged localdev --- test/05-commands.test.js | 115 +++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 58 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 199ca5046..38120d446 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -11,8 +11,7 @@ const minimal = path.join(fixtures, 'minimal') class Rig { setup = async ({ comment, timeout }) => { timeout(180000) - this.platformDir = path.join(Helper.root, 'pear') - const helper = new Helper({ platformDir: this.platformDir }) + const helper = new Helper() this.helper = helper comment('connecting local sidecar') await helper.ready() @@ -35,7 +34,7 @@ test('pear stage --json ', async function ({ plan, alik const testId = Math.floor(Math.random() * 100000) const argv = ['stage', '--json', 'test-' + testId, minimal] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -63,7 +62,7 @@ test('pear stage ', async function ({ plan, is }) { const testId = Math.floor(Math.random() * 100000) const argv = ['stage', 'test-' + testId, minimal] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -88,7 +87,7 @@ test('pear stage ', async function ({ plan, is }) { const relativePath = path.relative(harness, minimal) const argv = ['stage', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -129,7 +128,7 @@ test('pear stage (package.json pear.config.stage.entry const relativePath = path.relative(harness, targetDir) const argv = ['stage', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -171,7 +170,7 @@ test('pear stage (package.json pear.stage.ignore ', async function ({ plan, alik const relativePath = path.relative(harness, minimal) const argv = ['stage', '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -228,7 +227,7 @@ test('pear stage --dry-run ', async function ({ plan, i const relativePath = path.relative(harness, minimal) const argv = ['stage', '--dry-run', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -253,7 +252,7 @@ test('pear stage --dry-run --json ', async function ({ const relativePath = path.relative(harness, minimal) const argv = ['stage', '--dry-run', '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -286,7 +285,7 @@ test('pear stage --bare ', async function ({ plan, is } const relativePath = path.relative(harness, minimal) const argv = ['stage', '--bare', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -314,7 +313,7 @@ test('pear stage --bare --json ', async function ({ pla const relativePath = path.relative(harness, minimal) const argv = ['stage', '--bare', '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -351,7 +350,7 @@ test('pear stage --ignore ', async function ({ p const argv = ['stage', '--ignore', 'ignored.txt', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -386,7 +385,7 @@ test('pear stage --ignore --json ', async functi const argv = ['stage', '--ignore', 'ignored.txt', '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -419,7 +418,7 @@ test('pear stage --truncate ', async function ({ pl const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -433,7 +432,7 @@ test('pear stage --truncate ', async function ({ pl const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', 'test-' + testId, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -461,7 +460,7 @@ test('pear stage --truncate --json ', async functio const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -475,7 +474,7 @@ test('pear stage --truncate --json ', async functio const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', '--json', 'test-' + testId, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -509,7 +508,7 @@ test('pear stage --name ', async function ({ pla const relativePath = path.relative(harness, minimal) const argv = ['stage', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -541,7 +540,7 @@ test('pear stage --name --json ', async function const relativePath = path.relative(harness, minimal) const argv = ['stage', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -578,7 +577,7 @@ test('pear stage --ignore --name ', async const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -621,7 +620,7 @@ test('pear stage --ignore --name --json ' const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -657,7 +656,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -675,7 +674,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, 'test-' + testId, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -717,7 +716,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -735,7 +734,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', 'test-' + testId, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -773,7 +772,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -790,7 +789,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -815,7 +814,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -832,7 +831,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -862,7 +861,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -879,7 +878,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -904,7 +903,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -921,7 +920,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -954,7 +953,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -971,7 +970,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--bare', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -999,7 +998,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1016,7 +1015,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--bare', '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -1049,7 +1048,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1066,7 +1065,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) @@ -1097,7 +1096,7 @@ test('pear stage --ignore --json pear:// ', async function ({ const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1114,7 +1113,7 @@ test('pear stage --ignore --json pear:// ', async function ({ const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) @@ -1149,7 +1148,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1166,7 +1165,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -1194,7 +1193,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1211,7 +1210,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -1244,7 +1243,7 @@ test('pear stage --name pear:// ', async function ({ plan, is const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1261,7 +1260,7 @@ test('pear stage --name pear:// ', async function ({ plan, is const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--name', `test-name-${testId}`, link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -1293,7 +1292,7 @@ test('pear stage --name --json pear:// ', async function ({ pl const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1310,7 +1309,7 @@ test('pear stage --name --json pear:// ', async function ({ pl const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--name', `test-name-${testId}`, '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -1343,7 +1342,7 @@ test('pear stage --ignore --name pear:// ', async funct const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1360,7 +1359,7 @@ test('pear stage --ignore --name pear:// ', async funct const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) @@ -1398,7 +1397,7 @@ test('pear stage --ignore --name --json pear:// ', asyn const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1415,7 +1414,7 @@ test('pear stage --ignore --name --json pear:// ', asyn const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) @@ -1454,7 +1453,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1471,7 +1470,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) @@ -1512,7 +1511,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) @@ -1529,7 +1528,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) From c18b1f25add282e00b5449d141f1c700830448ea Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Thu, 12 Sep 2024 10:21:25 +0800 Subject: [PATCH 16/45] Remove exit code checks due until Windows exit code bug is fixed --- test/05-commands.test.js | 180 ++++++++++++++++----------------------- 1 file changed, 72 insertions(+), 108 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 38120d446..8f305ef9d 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -29,7 +29,7 @@ const rig = new Rig() test('commands setup', rig.setup) test('pear stage --json ', async function ({ plan, alike, is }) { - plan(2) + plan(1) const testId = Math.floor(Math.random() * 100000) const argv = ['stage', '--json', 'test-' + testId, minimal] @@ -52,12 +52,11 @@ test('pear stage --json ', async function ({ plan, alik await running.inspector.close() alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear stage ', async function ({ plan, is }) { - plan(2) + plan(1) const testId = Math.floor(Math.random() * 100000) const argv = ['stage', 'test-' + testId, minimal] @@ -76,12 +75,11 @@ test('pear stage ', async function ({ plan, is }) { await running.inspector.close() is(completedStaging, true, 'should complete staging') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear stage ', async function ({ plan, is }) { - plan(2) + plan(1) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -101,12 +99,11 @@ test('pear stage ', async function ({ plan, is }) { await running.inspector.close() is(completedStaging, true, 'should complete staging') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear stage (package.json pear.config.stage.entrypoints )', async function ({ plan, teardown, is }) { - plan(2) + plan(1) const testId = Math.floor(Math.random() * 100000) @@ -142,12 +139,11 @@ test('pear stage (package.json pear.config.stage.entry await running.inspector.close() is(completedStaging, true, 'should complete staging') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear stage (package.json pear.stage.ignore )', async function ({ plan, teardown, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) @@ -187,12 +183,11 @@ test('pear stage (package.json pear.stage.ignore ', async function ({ plan, alike, is }) { - plan(2) + plan(1) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -216,12 +211,11 @@ test('pear stage --json ', async function ({ plan, alik await running.inspector.close() alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear stage --dry-run ', async function ({ plan, is }) { - plan(2) + plan(1) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -241,12 +235,11 @@ test('pear stage --dry-run ', async function ({ plan, i await running.inspector.close() is(completedStaging, true, 'should complete staging') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear stage --dry-run --json ', async function ({ plan, alike, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -274,12 +267,11 @@ test('pear stage --dry-run --json ', async function ({ is(completeTag?.data?.dryRun, true) alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear stage --bare ', async function ({ plan, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -302,12 +294,11 @@ test('pear stage --bare ', async function ({ plan, is } is(completedStaging, true, 'should complete staging') is(skippedWarmup, true, 'should skip warmup') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear stage --bare --json ', async function ({ plan, alike, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -335,12 +326,11 @@ test('pear stage --bare --json ', async function ({ pla is(skipTag?.data?.reason, 'bare', 'should skip warmup') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear stage --ignore ', async function ({ plan, teardown, is }) { - plan(4) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -370,12 +360,11 @@ test('pear stage --ignore ', async function ({ p is(completedStaging, true, 'should complete staging') is(addedIgnored, false, 'should not add ignored.txt') is(addedIndex, true, 'should add index.js') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear stage --ignore --json ', async function ({ plan, alike, teardown, is }) { - plan(4) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -408,12 +397,11 @@ test('pear stage --ignore --json ', async functi is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') is(files.includes('/index.js'), true, 'should add index.js') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear stage --truncate ', async function ({ plan, is }) { - plan(4) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -450,12 +438,11 @@ test('pear stage --truncate ', async function ({ pl is(completedStaging, true, 'should complete staging') is(readdedFile, true, 'should readd index.js') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --truncate --json ', async function ({ plan, alike, is }) { - plan(4) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -497,12 +484,11 @@ test('pear stage --truncate --json ', async functio is(files.includes('/index.js'), true, 'should readd index.js') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --name ', async function ({ plan, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -529,12 +515,11 @@ test('pear stage --name ', async function ({ pla is(completedStaging, true, 'should complete staging') is(stagedName, 'test-name-' + testId, 'should use --name flag') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear stage --name --json ', async function ({ plan, alike, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -562,12 +547,11 @@ test('pear stage --name --json ', async function is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear stage --ignore --name ', async function ({ plan, teardown, is }) { - plan(5) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -605,12 +589,11 @@ test('pear stage --ignore --name ', async is(addedIndex, true, 'should add index.js') is(stagedName, 'test-name-' + testId, 'should use --name flag') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear stage --ignore --name --json ', async function ({ plan, alike, teardown, is }) { - plan(5) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -646,12 +629,11 @@ test('pear stage --ignore --name --json ' is(files.includes('/index.js'), true, 'should add index.js') is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear stage --dry-run --bare --ignore --truncate --name ', async function ({ plan, teardown, is }) { - plan(7) + plan(6) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -706,12 +688,11 @@ test('pear stage --dry-run --bare --ignore --truncate --name < is(addedIgnored, false, 'should not add ignored.txt') is(addedIndex, true, 'should add index.js') is(stagedName, 'test-name-' + testId, 'should use --name flag') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --dry-run --bare --ignore --truncate --name --json ', async function ({ plan, alike, teardown, is }) { - plan(7) + plan(6) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -762,12 +743,11 @@ test('pear stage --dry-run --bare --ignore --truncate --name - is(files.includes('/index.js'), true, 'should add index.js') is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage pear:// ', async function ({ plan, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -804,12 +784,11 @@ test('pear stage pear:// ', async function ({ plan, is }) { await stager2.inspector.close() is(completedStaging, true, 'should complete staging') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --json pear:// ', async function ({ plan, alike, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -851,12 +830,11 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is await stager2.inspector.close() alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --dry-run pear:// ', async function ({ plan, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -893,12 +871,11 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { await stager2.inspector.close() is(completedStaging, true, 'should complete staging') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --dry-run --json pear:// ', async function ({ plan, alike, is }) { - plan(4) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -943,12 +920,11 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, alike(tags, ['staging', 'dry', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') is(completeTag?.data?.dryRun, true, 'should be dry run') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --bare pear:// ', async function ({ plan, is }) { - plan(4) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -988,12 +964,11 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { is(completedStaging, true, 'should complete staging') is(skippedWarmup, true, 'should skip warmup') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --bare --json pear:// ', async function ({ plan, alike, is }) { - plan(4) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1038,12 +1013,11 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali is(skipTag?.data?.reason, 'bare', 'should skip warmup') alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --ignore pear:// ', async function ({ plan, teardown, is }) { - plan(4) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1086,12 +1060,11 @@ test('pear stage --ignore pear:// ', async function ({ plan, t is(completedStaging, true, 'should complete staging') is(addedIgnored, false, 'should not add ignored.txt') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --ignore --json pear:// ', async function ({ plan, teardown, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1138,12 +1111,11 @@ test('pear stage --ignore --json pear:// ', async function ({ await stager2.inspector.close() is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --truncate pear:// ', async function ({ plan, is }) { - plan(4) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1183,12 +1155,11 @@ test('pear stage --truncate pear:// ', async function ({ plan, is is(completedStaging, true, 'should complete staging') is(readdedFile, true, 'should readd package.json after truncate') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --truncate --json pear:// ', async function ({ plan, alike, is }) { - plan(4) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1233,12 +1204,11 @@ test('pear stage --truncate --json pear:// ', async function ({ p is(files.includes('/package.json'), true, 'should readd package.json after truncate') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --name pear:// ', async function ({ plan, is }) { - plan(4) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1282,12 +1252,11 @@ test('pear stage --name pear:// ', async function ({ plan, is is(completedStaging, true, 'should complete staging') is(stagedName, 'test-name-' + testId, 'should use --name flag') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --name --json pear:// ', async function ({ plan, alike, is }) { - plan(4) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1332,12 +1301,11 @@ test('pear stage --name --json pear:// ', async function ({ pl is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --ignore --name pear:// ', async function ({ plan, teardown, is }) { - plan(5) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1387,12 +1355,11 @@ test('pear stage --ignore --name pear:// ', async funct is(completedStaging, true, 'should complete staging') is(addedIgnored, false, 'should not add ignored.txt') is(stagedName, 'test-name-' + testId, 'should use --name flag') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --ignore --name --json pear:// ', async function ({ plan, alike, teardown, is }) { - plan(5) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1443,12 +1410,11 @@ test('pear stage --ignore --name --json pear:// ', asyn is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --dry-run --bare --ignore --truncate --name pear:// ', async function ({ plan, is }) { - plan(7) + plan(6) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1501,12 +1467,11 @@ test('pear stage --dry-run --bare --ignore --truncate --name p is(addedIgnored, false, 'should not add ignored.txt') is(addedIndex, true, 'should add index.js') is(stagedName, 'test-name-' + testId, 'should use --name flag') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test('pear stage --dry-run --bare --ignore --truncate --name --json pear:// ', async function ({ plan, alike, is }) { - plan(7) + plan(6) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1556,8 +1521,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - is(files.includes('/index.js'), true, 'should add index.js') is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') - const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + await stager2.until.exit }) test.todo('pear seed ') From f6fcdaed250f2cd98e2f1cf111fbadc88bdf93f1 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Thu, 12 Sep 2024 10:22:12 +0800 Subject: [PATCH 17/45] Add TODO for readding exit code checks --- test/05-commands.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 8f305ef9d..557f19464 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -26,6 +26,7 @@ class Rig { const rig = new Rig() +// TODO: Readd exit code checks once Windows bug is fixed test('commands setup', rig.setup) test('pear stage --json ', async function ({ plan, alike, is }) { From 0bc1a8702411ae200f2c6348d9e58cdd3a8a0fee Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Thu, 12 Sep 2024 10:47:57 +0800 Subject: [PATCH 18/45] Remove exit code checks for initial stage --- test/05-commands.test.js | 100 ++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 60 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 557f19464..bd2672a9c 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -402,7 +402,7 @@ test('pear stage --ignore --json ', async functi }) test('pear stage --truncate ', async function ({ plan, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -418,8 +418,7 @@ test('pear stage --truncate ', async function ({ pl await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', 'test-' + testId, relativePath] @@ -443,7 +442,7 @@ test('pear stage --truncate ', async function ({ pl }) test('pear stage --truncate --json ', async function ({ plan, alike, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -459,8 +458,7 @@ test('pear stage --truncate --json ', async functio await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', '--json', 'test-' + testId, relativePath] @@ -634,7 +632,7 @@ test('pear stage --ignore --name --json ' }) test('pear stage --dry-run --bare --ignore --truncate --name ', async function ({ plan, teardown, is }) { - plan(6) + plan(5) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -650,8 +648,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') @@ -693,7 +690,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < }) test('pear stage --dry-run --bare --ignore --truncate --name --json ', async function ({ plan, alike, teardown, is }) { - plan(6) + plan(5) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -709,8 +706,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') @@ -748,7 +744,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - }) test('pear stage pear:// ', async function ({ plan, is }) { - plan(2) + plan(1) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -767,8 +763,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', link, relativePath] @@ -789,7 +784,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { }) test('pear stage --json pear:// ', async function ({ plan, alike, is }) { - plan(2) + plan(1) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -808,8 +803,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--json', link, relativePath] @@ -835,7 +829,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is }) test('pear stage --dry-run pear:// ', async function ({ plan, is }) { - plan(2) + plan(1) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -854,8 +848,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', link, relativePath] @@ -876,7 +869,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { }) test('pear stage --dry-run --json pear:// ', async function ({ plan, alike, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -895,8 +888,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--json', link, relativePath] @@ -925,7 +917,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, }) test('pear stage --bare pear:// ', async function ({ plan, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -944,8 +936,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--bare', link, relativePath] @@ -969,7 +960,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { }) test('pear stage --bare --json pear:// ', async function ({ plan, alike, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -988,8 +979,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--bare', '--json', link, relativePath] @@ -1018,7 +1008,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali }) test('pear stage --ignore pear:// ', async function ({ plan, teardown, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1037,8 +1027,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') @@ -1065,7 +1054,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t }) test('pear stage --ignore --json pear:// ', async function ({ plan, teardown, is }) { - plan(2) + plan(1) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1084,8 +1073,7 @@ test('pear stage --ignore --json pear:// ', async function ({ await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') @@ -1116,7 +1104,7 @@ test('pear stage --ignore --json pear:// ', async function ({ }) test('pear stage --truncate pear:// ', async function ({ plan, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1135,8 +1123,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', link, relativePath] @@ -1160,7 +1147,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is }) test('pear stage --truncate --json pear:// ', async function ({ plan, alike, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1179,8 +1166,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', '--json', link, relativePath] @@ -1209,7 +1195,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p }) test('pear stage --name pear:// ', async function ({ plan, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1228,8 +1214,7 @@ test('pear stage --name pear:// ', async function ({ plan, is await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--name', `test-name-${testId}`, link, relativePath] @@ -1257,7 +1242,7 @@ test('pear stage --name pear:// ', async function ({ plan, is }) test('pear stage --name --json pear:// ', async function ({ plan, alike, is }) { - plan(3) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1276,8 +1261,7 @@ test('pear stage --name --json pear:// ', async function ({ pl await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--name', `test-name-${testId}`, '--json', link, relativePath] @@ -1306,7 +1290,7 @@ test('pear stage --name --json pear:// ', async function ({ pl }) test('pear stage --ignore --name pear:// ', async function ({ plan, teardown, is }) { - plan(4) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1325,8 +1309,7 @@ test('pear stage --ignore --name pear:// ', async funct await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') @@ -1360,7 +1343,7 @@ test('pear stage --ignore --name pear:// ', async funct }) test('pear stage --ignore --name --json pear:// ', async function ({ plan, alike, teardown, is }) { - plan(4) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1379,8 +1362,7 @@ test('pear stage --ignore --name --json pear:// ', asyn await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') @@ -1415,7 +1397,7 @@ test('pear stage --ignore --name --json pear:// ', asyn }) test('pear stage --dry-run --bare --ignore --truncate --name pear:// ', async function ({ plan, is }) { - plan(6) + plan(5) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1434,8 +1416,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, link, relativePath] @@ -1472,7 +1453,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p }) test('pear stage --dry-run --bare --ignore --truncate --name --json pear:// ', async function ({ plan, alike, is }) { - plan(6) + plan(5) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1491,8 +1472,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + await stager1.until.exit const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', link, relativePath] From 1c480ee906eaf0384b3d537b2873643e4e15df8f Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Sat, 14 Sep 2024 03:26:12 +0800 Subject: [PATCH 19/45] Revert "Remove exit code checks for initial stage" This reverts commit 2818a3753ba09b90a63ca6d8216f12ea1cecc00f. --- test/05-commands.test.js | 100 +++++++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 40 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index bd2672a9c..557f19464 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -402,7 +402,7 @@ test('pear stage --ignore --json ', async functi }) test('pear stage --truncate ', async function ({ plan, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -418,7 +418,8 @@ test('pear stage --truncate ', async function ({ pl await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', 'test-' + testId, relativePath] @@ -442,7 +443,7 @@ test('pear stage --truncate ', async function ({ pl }) test('pear stage --truncate --json ', async function ({ plan, alike, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -458,7 +459,8 @@ test('pear stage --truncate --json ', async functio await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', '--json', 'test-' + testId, relativePath] @@ -632,7 +634,7 @@ test('pear stage --ignore --name --json ' }) test('pear stage --dry-run --bare --ignore --truncate --name ', async function ({ plan, teardown, is }) { - plan(5) + plan(6) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -648,7 +650,8 @@ test('pear stage --dry-run --bare --ignore --truncate --name < await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') @@ -690,7 +693,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < }) test('pear stage --dry-run --bare --ignore --truncate --name --json ', async function ({ plan, alike, teardown, is }) { - plan(5) + plan(6) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -706,7 +709,8 @@ test('pear stage --dry-run --bare --ignore --truncate --name - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') @@ -744,7 +748,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - }) test('pear stage pear:// ', async function ({ plan, is }) { - plan(1) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -763,7 +767,8 @@ test('pear stage pear:// ', async function ({ plan, is }) { await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', link, relativePath] @@ -784,7 +789,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { }) test('pear stage --json pear:// ', async function ({ plan, alike, is }) { - plan(1) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -803,7 +808,8 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--json', link, relativePath] @@ -829,7 +835,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is }) test('pear stage --dry-run pear:// ', async function ({ plan, is }) { - plan(1) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -848,7 +854,8 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', link, relativePath] @@ -869,7 +876,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { }) test('pear stage --dry-run --json pear:// ', async function ({ plan, alike, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -888,7 +895,8 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--json', link, relativePath] @@ -917,7 +925,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, }) test('pear stage --bare pear:// ', async function ({ plan, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -936,7 +944,8 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--bare', link, relativePath] @@ -960,7 +969,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { }) test('pear stage --bare --json pear:// ', async function ({ plan, alike, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -979,7 +988,8 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--bare', '--json', link, relativePath] @@ -1008,7 +1018,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali }) test('pear stage --ignore pear:// ', async function ({ plan, teardown, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1027,7 +1037,8 @@ test('pear stage --ignore pear:// ', async function ({ plan, t await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') @@ -1054,7 +1065,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t }) test('pear stage --ignore --json pear:// ', async function ({ plan, teardown, is }) { - plan(1) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1073,7 +1084,8 @@ test('pear stage --ignore --json pear:// ', async function ({ await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') @@ -1104,7 +1116,7 @@ test('pear stage --ignore --json pear:// ', async function ({ }) test('pear stage --truncate pear:// ', async function ({ plan, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1123,7 +1135,8 @@ test('pear stage --truncate pear:// ', async function ({ plan, is await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', link, relativePath] @@ -1147,7 +1160,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is }) test('pear stage --truncate --json pear:// ', async function ({ plan, alike, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1166,7 +1179,8 @@ test('pear stage --truncate --json pear:// ', async function ({ p await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', '--json', link, relativePath] @@ -1195,7 +1209,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p }) test('pear stage --name pear:// ', async function ({ plan, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1214,7 +1228,8 @@ test('pear stage --name pear:// ', async function ({ plan, is await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--name', `test-name-${testId}`, link, relativePath] @@ -1242,7 +1257,7 @@ test('pear stage --name pear:// ', async function ({ plan, is }) test('pear stage --name --json pear:// ', async function ({ plan, alike, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1261,7 +1276,8 @@ test('pear stage --name --json pear:// ', async function ({ pl await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--name', `test-name-${testId}`, '--json', link, relativePath] @@ -1290,7 +1306,7 @@ test('pear stage --name --json pear:// ', async function ({ pl }) test('pear stage --ignore --name pear:// ', async function ({ plan, teardown, is }) { - plan(3) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1309,7 +1325,8 @@ test('pear stage --ignore --name pear:// ', async funct await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') @@ -1343,7 +1360,7 @@ test('pear stage --ignore --name pear:// ', async funct }) test('pear stage --ignore --name --json pear:// ', async function ({ plan, alike, teardown, is }) { - plan(3) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1362,7 +1379,8 @@ test('pear stage --ignore --name --json pear:// ', asyn await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') @@ -1397,7 +1415,7 @@ test('pear stage --ignore --name --json pear:// ', asyn }) test('pear stage --dry-run --bare --ignore --truncate --name pear:// ', async function ({ plan, is }) { - plan(5) + plan(6) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1416,7 +1434,8 @@ test('pear stage --dry-run --bare --ignore --truncate --name p await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, link, relativePath] @@ -1453,7 +1472,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p }) test('pear stage --dry-run --bare --ignore --truncate --name --json pear:// ', async function ({ plan, alike, is }) { - plan(5) + plan(6) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1472,7 +1491,8 @@ test('pear stage --dry-run --bare --ignore --truncate --name - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) await stager1.inspector.close() - await stager1.until.exit + const { code: code1 } = await stager1.until.exit + is(code1, 0, 'should have exit code 0 for initial stage') const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', link, relativePath] From 7fc2cb14c955933ddcb947a27d540a95a2c50c3f Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Sat, 14 Sep 2024 03:26:22 +0800 Subject: [PATCH 20/45] Revert "Add TODO for readding exit code checks" This reverts commit b20422ff8ec8c66ffc1bcd47505f74516afa19ec. --- test/05-commands.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 557f19464..8f305ef9d 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -26,7 +26,6 @@ class Rig { const rig = new Rig() -// TODO: Readd exit code checks once Windows bug is fixed test('commands setup', rig.setup) test('pear stage --json ', async function ({ plan, alike, is }) { From f48b3f267459e5ee164651c0dbf3d6b269999ca3 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Sat, 14 Sep 2024 03:26:29 +0800 Subject: [PATCH 21/45] Revert "Remove exit code checks due until Windows exit code bug is fixed" This reverts commit b65538fb5b3860c5a07f562ea95df438f1180b31. --- test/05-commands.test.js | 180 +++++++++++++++++++++++---------------- 1 file changed, 108 insertions(+), 72 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 8f305ef9d..38120d446 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -29,7 +29,7 @@ const rig = new Rig() test('commands setup', rig.setup) test('pear stage --json ', async function ({ plan, alike, is }) { - plan(1) + plan(2) const testId = Math.floor(Math.random() * 100000) const argv = ['stage', '--json', 'test-' + testId, minimal] @@ -52,11 +52,12 @@ test('pear stage --json ', async function ({ plan, alik await running.inspector.close() alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - await running.until.exit + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage ', async function ({ plan, is }) { - plan(1) + plan(2) const testId = Math.floor(Math.random() * 100000) const argv = ['stage', 'test-' + testId, minimal] @@ -75,11 +76,12 @@ test('pear stage ', async function ({ plan, is }) { await running.inspector.close() is(completedStaging, true, 'should complete staging') - await running.until.exit + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage ', async function ({ plan, is }) { - plan(1) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -99,11 +101,12 @@ test('pear stage ', async function ({ plan, is }) { await running.inspector.close() is(completedStaging, true, 'should complete staging') - await running.until.exit + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage (package.json pear.config.stage.entrypoints )', async function ({ plan, teardown, is }) { - plan(1) + plan(2) const testId = Math.floor(Math.random() * 100000) @@ -139,11 +142,12 @@ test('pear stage (package.json pear.config.stage.entry await running.inspector.close() is(completedStaging, true, 'should complete staging') - await running.until.exit + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage (package.json pear.stage.ignore )', async function ({ plan, teardown, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) @@ -183,11 +187,12 @@ test('pear stage (package.json pear.stage.ignore ', async function ({ plan, alike, is }) { - plan(1) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -211,11 +216,12 @@ test('pear stage --json ', async function ({ plan, alik await running.inspector.close() alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - await running.until.exit + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --dry-run ', async function ({ plan, is }) { - plan(1) + plan(2) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -235,11 +241,12 @@ test('pear stage --dry-run ', async function ({ plan, i await running.inspector.close() is(completedStaging, true, 'should complete staging') - await running.until.exit + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --dry-run --json ', async function ({ plan, alike, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -267,11 +274,12 @@ test('pear stage --dry-run --json ', async function ({ is(completeTag?.data?.dryRun, true) alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') - await running.until.exit + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --bare ', async function ({ plan, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -294,11 +302,12 @@ test('pear stage --bare ', async function ({ plan, is } is(completedStaging, true, 'should complete staging') is(skippedWarmup, true, 'should skip warmup') - await running.until.exit + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --bare --json ', async function ({ plan, alike, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -326,11 +335,12 @@ test('pear stage --bare --json ', async function ({ pla is(skipTag?.data?.reason, 'bare', 'should skip warmup') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - await running.until.exit + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --ignore ', async function ({ plan, teardown, is }) { - plan(3) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -360,11 +370,12 @@ test('pear stage --ignore ', async function ({ p is(completedStaging, true, 'should complete staging') is(addedIgnored, false, 'should not add ignored.txt') is(addedIndex, true, 'should add index.js') - await running.until.exit + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --ignore --json ', async function ({ plan, alike, teardown, is }) { - plan(3) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -397,11 +408,12 @@ test('pear stage --ignore --json ', async functi is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') is(files.includes('/index.js'), true, 'should add index.js') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - await running.until.exit + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --truncate ', async function ({ plan, is }) { - plan(3) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -438,11 +450,12 @@ test('pear stage --truncate ', async function ({ pl is(completedStaging, true, 'should complete staging') is(readdedFile, true, 'should readd index.js') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --truncate --json ', async function ({ plan, alike, is }) { - plan(3) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -484,11 +497,12 @@ test('pear stage --truncate --json ', async functio is(files.includes('/index.js'), true, 'should readd index.js') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --name ', async function ({ plan, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -515,11 +529,12 @@ test('pear stage --name ', async function ({ pla is(completedStaging, true, 'should complete staging') is(stagedName, 'test-name-' + testId, 'should use --name flag') - await running.until.exit + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --name --json ', async function ({ plan, alike, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -547,11 +562,12 @@ test('pear stage --name --json ', async function is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - await running.until.exit + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --ignore --name ', async function ({ plan, teardown, is }) { - plan(4) + plan(5) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -589,11 +605,12 @@ test('pear stage --ignore --name ', async is(addedIndex, true, 'should add index.js') is(stagedName, 'test-name-' + testId, 'should use --name flag') - await running.until.exit + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --ignore --name --json ', async function ({ plan, alike, teardown, is }) { - plan(4) + plan(5) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -629,11 +646,12 @@ test('pear stage --ignore --name --json ' is(files.includes('/index.js'), true, 'should add index.js') is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - await running.until.exit + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --dry-run --bare --ignore --truncate --name ', async function ({ plan, teardown, is }) { - plan(6) + plan(7) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -688,11 +706,12 @@ test('pear stage --dry-run --bare --ignore --truncate --name < is(addedIgnored, false, 'should not add ignored.txt') is(addedIndex, true, 'should add index.js') is(stagedName, 'test-name-' + testId, 'should use --name flag') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --dry-run --bare --ignore --truncate --name --json ', async function ({ plan, alike, teardown, is }) { - plan(6) + plan(7) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -743,11 +762,12 @@ test('pear stage --dry-run --bare --ignore --truncate --name - is(files.includes('/index.js'), true, 'should add index.js') is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage pear:// ', async function ({ plan, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -784,11 +804,12 @@ test('pear stage pear:// ', async function ({ plan, is }) { await stager2.inspector.close() is(completedStaging, true, 'should complete staging') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --json pear:// ', async function ({ plan, alike, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -830,11 +851,12 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is await stager2.inspector.close() alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --dry-run pear:// ', async function ({ plan, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -871,11 +893,12 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { await stager2.inspector.close() is(completedStaging, true, 'should complete staging') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --dry-run --json pear:// ', async function ({ plan, alike, is }) { - plan(3) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -920,11 +943,12 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, alike(tags, ['staging', 'dry', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') is(completeTag?.data?.dryRun, true, 'should be dry run') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --bare pear:// ', async function ({ plan, is }) { - plan(3) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -964,11 +988,12 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { is(completedStaging, true, 'should complete staging') is(skippedWarmup, true, 'should skip warmup') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --bare --json pear:// ', async function ({ plan, alike, is }) { - plan(3) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1013,11 +1038,12 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali is(skipTag?.data?.reason, 'bare', 'should skip warmup') alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --ignore pear:// ', async function ({ plan, teardown, is }) { - plan(3) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1060,11 +1086,12 @@ test('pear stage --ignore pear:// ', async function ({ plan, t is(completedStaging, true, 'should complete staging') is(addedIgnored, false, 'should not add ignored.txt') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --ignore --json pear:// ', async function ({ plan, teardown, is }) { - plan(2) + plan(3) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1111,11 +1138,12 @@ test('pear stage --ignore --json pear:// ', async function ({ await stager2.inspector.close() is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --truncate pear:// ', async function ({ plan, is }) { - plan(3) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1155,11 +1183,12 @@ test('pear stage --truncate pear:// ', async function ({ plan, is is(completedStaging, true, 'should complete staging') is(readdedFile, true, 'should readd package.json after truncate') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --truncate --json pear:// ', async function ({ plan, alike, is }) { - plan(3) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1204,11 +1233,12 @@ test('pear stage --truncate --json pear:// ', async function ({ p is(files.includes('/package.json'), true, 'should readd package.json after truncate') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --name pear:// ', async function ({ plan, is }) { - plan(3) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1252,11 +1282,12 @@ test('pear stage --name pear:// ', async function ({ plan, is is(completedStaging, true, 'should complete staging') is(stagedName, 'test-name-' + testId, 'should use --name flag') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --name --json pear:// ', async function ({ plan, alike, is }) { - plan(3) + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1301,11 +1332,12 @@ test('pear stage --name --json pear:// ', async function ({ pl is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --ignore --name pear:// ', async function ({ plan, teardown, is }) { - plan(4) + plan(5) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1355,11 +1387,12 @@ test('pear stage --ignore --name pear:// ', async funct is(completedStaging, true, 'should complete staging') is(addedIgnored, false, 'should not add ignored.txt') is(stagedName, 'test-name-' + testId, 'should use --name flag') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --ignore --name --json pear:// ', async function ({ plan, alike, teardown, is }) { - plan(4) + plan(5) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1410,11 +1443,12 @@ test('pear stage --ignore --name --json pear:// ', asyn is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --dry-run --bare --ignore --truncate --name pear:// ', async function ({ plan, is }) { - plan(6) + plan(7) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1467,11 +1501,12 @@ test('pear stage --dry-run --bare --ignore --truncate --name p is(addedIgnored, false, 'should not add ignored.txt') is(addedIndex, true, 'should add index.js') is(stagedName, 'test-name-' + testId, 'should use --name flag') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test('pear stage --dry-run --bare --ignore --truncate --name --json pear:// ', async function ({ plan, alike, is }) { - plan(6) + plan(7) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1521,7 +1556,8 @@ test('pear stage --dry-run --bare --ignore --truncate --name - is(files.includes('/index.js'), true, 'should add index.js') is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') - await stager2.until.exit + const { code } = await stager2.until.exit + is(code, 0, 'should have exit code 0') }) test.todo('pear seed ') From ff726f2baff2ca67ae1842c4627c879d583a5017 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Sat, 14 Sep 2024 03:51:18 +0800 Subject: [PATCH 22/45] Rename close to _close in harness to prevent overriding --- test/fixtures/harness/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixtures/harness/index.js b/test/fixtures/harness/index.js index 6b196c7f3..16014376b 100644 --- a/test/fixtures/harness/index.js +++ b/test/fixtures/harness/index.js @@ -18,7 +18,7 @@ class Harness extends ReadyResource { console.log(`{ "tag": "inspector", "data": { "key": "${this.inspectorKey}" }}`) } - async close () { + async _close () { await this.inspector.disable() await this.sub?.destroy() if (this._client) await this._client.close() From 71565e2121320759b1eaad0b8c55451fedf57a9e Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Sat, 14 Sep 2024 03:51:44 +0800 Subject: [PATCH 23/45] Use sync fs during brittle teardown --- test/05-commands.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 38120d446..51f17cb2c 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -123,7 +123,7 @@ test('pear stage (package.json pear.config.stage.entry packageJson.pear.stage = { entrypoints: ['index.js'] } fs.writeFileSync(path.join(targetDir, 'run.js'), 'console.log("run")') fs.writeFileSync(path.join(targetDir, 'package.json'), JSON.stringify(packageJson, null, 2)) - teardown(async () => { await fs.promises.rm(targetDir, { recursive: true }) }) + teardown(() => { fs.rmSync(targetDir, { recursive: true }) }) const relativePath = path.relative(harness, targetDir) const argv = ['stage', 'test-' + testId, relativePath] @@ -165,7 +165,7 @@ test('pear stage (package.json pear.stage.ignore { await fs.promises.rm(targetDir, { recursive: true }) }) + teardown(() => { fs.rmSync(targetDir, { recursive: true }) }) const relativePath = path.relative(harness, targetDir) const argv = ['stage', 'test-' + testId, relativePath] From fad6ab41db20d85455217459e95dbcf2f61a9571 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Thu, 19 Sep 2024 21:51:40 +0800 Subject: [PATCH 24/45] Rename commands test prefix from 05 to 07 --- test/{05-commands.test.js => 07-commands.test.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{05-commands.test.js => 07-commands.test.js} (100%) diff --git a/test/05-commands.test.js b/test/07-commands.test.js similarity index 100% rename from test/05-commands.test.js rename to test/07-commands.test.js From 22ea5c72f20567a4e7b16f3fa07247cfbc166d71 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Thu, 19 Sep 2024 21:53:21 +0800 Subject: [PATCH 25/45] Use Helper.localDir instead of Helper.root --- test/07-commands.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/07-commands.test.js b/test/07-commands.test.js index 51f17cb2c..515d1c941 100644 --- a/test/07-commands.test.js +++ b/test/07-commands.test.js @@ -4,7 +4,7 @@ const Helper = require('./helper') const fs = require('bare-fs') const LocalDrive = require('localdrive') -const fixtures = path.join(Helper.root, 'test', 'fixtures') +const fixtures = path.join(Helper.localDir, 'test', 'fixtures') const harness = path.join(fixtures, 'harness') const minimal = path.join(fixtures, 'minimal') From bb4875212cc90bb1e3ee2f2e8b2d6bf750e752ba Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Sat, 21 Sep 2024 00:43:53 +0800 Subject: [PATCH 26/45] Switch helper back to use pearDir --- test/helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/helper.js b/test/helper.js index 0e7f64cb9..60820a9c5 100644 --- a/test/helper.js +++ b/test/helper.js @@ -16,7 +16,7 @@ const updaterBootstrap = require('pear-updater-bootstrap') const b4a = require('b4a') const HOST = platform + '-' + arch const BY_ARCH = path.join('by-arch', HOST, 'bin', `pear-runtime${isWindows ? '.exe' : ''}`) -const { PLATFORM_DIR } = require('../constants') +const PLATFORM_DIR = global.Pear.config.pearDir const { pathname } = new URL(global.Pear.config.applink) const NO_GC = global.Pear.config.args.includes('--no-tmp-gc') const MAX_OP_STEP_WAIT = env.CI ? 360000 : 120000 From 5adc2bf06483b24b84acf17599d28dc27385018d Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Mon, 23 Sep 2024 22:21:34 +0800 Subject: [PATCH 27/45] Revert "Switch helper back to use pearDir" This reverts commit f03b1b63b3dc020cde69a1bc537b4882143b1ba9. --- test/helper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/helper.js b/test/helper.js index 60820a9c5..0e7f64cb9 100644 --- a/test/helper.js +++ b/test/helper.js @@ -16,7 +16,7 @@ const updaterBootstrap = require('pear-updater-bootstrap') const b4a = require('b4a') const HOST = platform + '-' + arch const BY_ARCH = path.join('by-arch', HOST, 'bin', `pear-runtime${isWindows ? '.exe' : ''}`) -const PLATFORM_DIR = global.Pear.config.pearDir +const { PLATFORM_DIR } = require('../constants') const { pathname } = new URL(global.Pear.config.applink) const NO_GC = global.Pear.config.args.includes('--no-tmp-gc') const MAX_OP_STEP_WAIT = env.CI ? 360000 : 120000 From 0050d82af0fe5f62cb7296135d891090230d2483 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Mon, 23 Sep 2024 22:36:47 +0800 Subject: [PATCH 28/45] Override platformDir when instantiating Helper from harness --- test/fixtures/harness/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixtures/harness/index.js b/test/fixtures/harness/index.js index 16014376b..a8810f17c 100644 --- a/test/fixtures/harness/index.js +++ b/test/fixtures/harness/index.js @@ -41,7 +41,7 @@ class Harness extends ReadyResource { const { default: cmd } = await import('pear/cmd') this.cmd = cmd } - return new this.Helper(opts) + return new this.Helper({ platformDir: global.Pear.config.pearDir, opts }) } nextUpdate () { From 32b547ea7979bf42a0383297df76fc26b3b64936 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Wed, 25 Sep 2024 11:42:46 +0800 Subject: [PATCH 29/45] Cleanup todos --- test/07-commands.test.js | 152 --------------------------------------- 1 file changed, 152 deletions(-) diff --git a/test/07-commands.test.js b/test/07-commands.test.js index 515d1c941..4b2a6e5b2 100644 --- a/test/07-commands.test.js +++ b/test/07-commands.test.js @@ -1560,156 +1560,4 @@ test('pear stage --dry-run --bare --ignore --truncate --name - is(code, 0, 'should have exit code 0') }) -test.todo('pear seed ') -test.todo('pear seed ') -test.todo('pear seed --json ') -test.todo('pear seed --seeders ') -test.todo('pear seed --seeders --json ') -test.todo('pear seed --name ') -test.todo('pear seed --name --json ') -test.todo('pear seed pear://') -test.todo('pear seed --json pear://') -test.todo('pear seed --seeders pear://') -test.todo('pear seed --seeders --json pear://') -test.todo('pear seed --name pear://') -test.todo('pear seed --name --json pear://') - -test.todo('pear run ') -test.todo('pear run ') -test.todo('pear run --tmp-store') -test.todo('pear run --store ') -test.todo('pear run --store ') -test.todo('pear run --unsafe-clear-app-storage') -test.todo('pear run --unsafe-clear-preferences') -test.todo('pear run file:///') -test.todo('pear run pear://') -test.todo('pear run pear:///') -test.todo('pear run pear:// --store ') -test.todo('pear run pear:// --tmp-store') -test.todo('pear run pear:// --unsafe-clear-app-storage') -test.todo('pear run pear:// --unsafe-clear-preferences') - -test.todo('pear run (package.json pear.config.previewFor )') -test.todo('pear run (package.json pear.config.links )') -test.todo('pear run (package.json pear.config.links )') -test.todo('pear run (package.json pear.config.type )') -test.todo('pear run --updates-diff') -test.todo('pear run --no-updates') -test.todo('pear run --link ') -// test.skip('pear run --updates-diff --no-updates') // TODO: after task Paparam flag relationships -// test.skip('pear run --tmp-store --store ') // TODO: after task Paparam flag relationships -test.todo('pear run pear:// --updates-diff') -test.todo('pear run pear:// --no-updates') -test.todo('pear run pear:// --link ') -test.todo('pear run pear:// --checkout ') -test.todo('pear run pear:// --checkout release') -test.todo('pear run pear:// --checkout staged') -test.todo('pear run pear:// --checkout --unsafe-clear-app-storage --unsafe-clear-preferences') - -test.todo('pear release ') -test.todo('pear release ') -test.todo('pear release --json ') -test.todo('pear release pear://') -test.todo('pear release --json pear://') -test.todo('pear release --checkout pear://') -test.todo('pear release --checkout --json pear://') -test.todo('pear release --checkout staged pear://') -test.todo('pear release --checkout staged --json pear://') -test.todo('pear release --checkout release pear://') -test.todo('pear release --checkout release --json pear://') - -test.todo('pear info') -test.todo('pear info --json') -test.todo('pear info ') -test.todo('pear info --json ') -test.todo('pear info --changelog ') -test.todo('pear info --changelog --json ') -test.todo('pear info --changelog --metadata ') -test.todo('pear info --changelog --metadata --json ') -test.todo('pear info --changelog --key ') -test.todo('pear info --changelog --key --json ') -test.todo('pear info --changelog --metadata --key ') -test.todo('pear info --changelog --metadata --key --json ') -test.todo('pear info --full-changelog ') -test.todo('pear info --full-changelog --metadata ') -test.todo('pear info --full-changelog --metadata --json ') -test.todo('pear info --full-changelog --metadata --key ') -test.todo('pear info --full-changelog --metadata --key --json ') -// test.skip('pear info --full-changelog --changelog') // TODO: after task Paparam flag relationships -test.todo('pear info --metadata ') -test.todo('pear info --metadata --key ') -test.todo('pear info --metadata --key --json ') -test.todo('pear info --key ') -test.todo('pear info --key --json ') -test.todo('pear info pear://') -test.todo('pear info --json pear://') -test.todo('pear info --changelog pear://') -test.todo('pear info --changelog --json pear://') -test.todo('pear info --changelog --metadata pear://') -test.todo('pear info --changelog --metadata --json pear://') -test.todo('pear info --changelog --key pear://') -test.todo('pear info --changelog --key --json pear://') -test.todo('pear info --changelog --metadata --key pear://') -test.todo('pear info --changelog --metadata --key --json pear://') -test.todo('pear info --full-changelog pear://') -test.todo('pear info --full-changelog --metadata pear://') -test.todo('pear info --full-changelog --metadata --json pear://') -test.todo('pear info --full-changelog --metadata --key pear://') -test.todo('pear info --full-changelog --metadata --key --json pear://') -test.todo('pear info --metadata pear://') -test.todo('pear info --metadata --key pear://') -test.todo('pear info --metadata --key --json pear://') -test.todo('pear info --key pear://') -test.todo('pear info --key --json pear://') - -test.todo('pear info --no-changelog ') -test.todo('pear info --no-changelog --json ') -test.todo('pear info --no-metadata ') -test.todo('pear info --no-metadata --json ') -test.todo('pear info --no-key ') -test.todo('pear info --no-key --json ') -test.todo('pear info --no-changelog --no-metadata ') -test.todo('pear info --no-changelog --no-metadata --json ') -test.todo('pear info --no-changelog --no-key ') -test.todo('pear info --no-changelog --no-key --json ') -test.todo('pear info --no-key --no-metadata ') -test.todo('pear info --no-key --no-metadata --json ') -test.todo('pear info --no-changelog --no-metadata --no-key ') -test.todo('pear info --no-changelog --no-metadata --no-key --json ') -test.todo('pear info --no-changelog pear://') -test.todo('pear info --no-changelog --json pear://') -test.todo('pear info --no-metadata pear://') -test.todo('pear info --no-metadata --json pear://') -test.todo('pear info --no-key pear://') -test.todo('pear info --no-key --json pear://') -test.todo('pear info --no-changelog --no-metadata pear://') -test.todo('pear info --no-changelog --no-metadata --json pear://') -test.todo('pear info --no-changelog --no-key pear://') -test.todo('pear info --no-changelog --no-key --json pear://') -test.todo('pear info --no-key --no-metadata pear://') -test.todo('pear info --no-key --no-metadata --json pear://') -test.todo('pear info --no-changelog --no-metadata --no-key pear://') -test.todo('pear info --no-changelog --no-metadata --no-key --json pear://') - -test.todo('pear dump pear:// ') -test.todo('pear dump pear:// ') -test.todo('pear dump --checkout pear:// ') -test.todo('pear dump --checkout staged pear:// ') -test.todo('pear dump --checkout release pear:// ') -test.todo('pear dump --json pear:// ') - -test.todo('pear shift ') -test.todo('pear shift --json ') -test.todo('pear shift --force ') -test.todo('pear shift --force --json ') - -test.todo('pear gc releases') -test.todo('pear gc releases --json') -test.todo('pear gc sidecars') -test.todo('pear gc sidecars --json') - -test.todo('pear versions') -test.todo('pear versions --json') -test.todo('pear -v') - test('commands cleanup', rig.cleanup) From ce8d175a5b317a15346692d97d7677c06281f4f9 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Tue, 8 Oct 2024 04:09:29 +0800 Subject: [PATCH 30/45] Disable helper teardown when loaded from harness --- test/fixtures/harness/index.js | 3 +++ test/helper.js | 21 ++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/test/fixtures/harness/index.js b/test/fixtures/harness/index.js index a8810f17c..e3e85f528 100644 --- a/test/fixtures/harness/index.js +++ b/test/fixtures/harness/index.js @@ -33,6 +33,8 @@ class Harness extends ReadyResource { } async client (opts) { + global.Pear.config.args.push('--no-helper-teardown') + if (this.Helper === null) { const { default: Helper } = await import('pear/test/helper') this.Helper = Helper @@ -41,6 +43,7 @@ class Harness extends ReadyResource { const { default: cmd } = await import('pear/cmd') this.cmd = cmd } + return new this.Helper({ platformDir: global.Pear.config.pearDir, opts }) } diff --git a/test/helper.js b/test/helper.js index 0e7f64cb9..18598943c 100644 --- a/test/helper.js +++ b/test/helper.js @@ -19,21 +19,24 @@ const BY_ARCH = path.join('by-arch', HOST, 'bin', `pear-runtime${isWindows ? '.e const { PLATFORM_DIR } = require('../constants') const { pathname } = new URL(global.Pear.config.applink) const NO_GC = global.Pear.config.args.includes('--no-tmp-gc') +const NO_TEARDOWN = global.Pear.config.args.includes('--no-helper-teardown') const MAX_OP_STEP_WAIT = env.CI ? 360000 : 120000 const tmp = fs.realpathSync(os.tmpdir()) Error.stackTraceLimit = Infinity const rigPear = path.join(tmp, 'rig-pear') -Pear.teardown(async () => { - console.log('# Teardown: Shutting Down Local Sidecar') - const local = new Helper() - console.log('# Teardown: Connecting Local Sidecar') - await local.ready() - console.log('# Teardown: Triggering Shutdown of Local Sidecar') - await local.shutdown() - console.log('# Teardown: Local Sidecar Shutdown') -}) +if (!NO_TEARDOWN) { + Pear.teardown(async () => { + console.log('# Teardown: Shutting Down Local Sidecar') + const local = new Helper() + console.log('# Teardown: Connecting Local Sidecar') + await local.ready() + console.log('# Teardown: Triggering Shutdown of Local Sidecar') + await local.shutdown() + console.log('# Teardown: Local Sidecar Shutdown') + }) +} class Rig { platformDir = rigPear From 47bf4bc77053e3a6895b2f12b478e677a7934496 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Tue, 8 Oct 2024 21:38:22 +0800 Subject: [PATCH 31/45] Add closing of the helper and use close instead of IPC destroy --- test/07-commands.test.js | 124 +++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 63 deletions(-) diff --git a/test/07-commands.test.js b/test/07-commands.test.js index 4b2a6e5b2..1769e10cc 100644 --- a/test/07-commands.test.js +++ b/test/07-commands.test.js @@ -11,16 +11,14 @@ const minimal = path.join(fixtures, 'minimal') class Rig { setup = async ({ comment, timeout }) => { timeout(180000) - const helper = new Helper() - this.helper = helper - comment('connecting local sidecar') - await helper.ready() + this.helper = new Helper() + comment('connecting to local sidecar') + await this.helper.ready() } cleanup = async ({ comment }) => { - comment('shutting down local sidecar') - await this.helper.shutdown() - comment('local sidecar shutdown') + comment('closing local sidecar connection') + await this.helper.close() } } @@ -48,7 +46,7 @@ test('pear stage --json ', async function ({ plan, alik tags.push(result.tag) if (result.tag === 'final') break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await running.inspector.close() alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') @@ -72,7 +70,7 @@ test('pear stage ', async function ({ plan, is }) { if (line === 'Staging complete!') completedStaging = true if (line.endsWith('Success')) break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await running.inspector.close() is(completedStaging, true, 'should complete staging') @@ -97,7 +95,7 @@ test('pear stage ', async function ({ plan, is }) { if (line === 'Staging complete!') completedStaging = true if (line.endsWith('Success')) break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await running.inspector.close() is(completedStaging, true, 'should complete staging') @@ -138,7 +136,7 @@ test('pear stage (package.json pear.config.stage.entry if (line === 'Staging complete!') completedStaging = true if (line.endsWith('Success')) break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await running.inspector.close() is(completedStaging, true, 'should complete staging') @@ -182,7 +180,7 @@ test('pear stage (package.json pear.stage.ignore ', async function ({ plan, alik tags.push(result.tag) if (result.tag === 'final') break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await running.inspector.close() alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') @@ -237,7 +235,7 @@ test('pear stage --dry-run ', async function ({ plan, i if (line === 'Staging dry run complete!') completedStaging = true if (line.endsWith('Success')) break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await running.inspector.close() is(completedStaging, true, 'should complete staging') @@ -269,7 +267,7 @@ test('pear stage --dry-run --json ', async function ({ if (result.tag === 'complete') completeTag = result if (result.tag === 'final') break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await running.inspector.close() is(completeTag?.data?.dryRun, true) @@ -297,7 +295,7 @@ test('pear stage --bare ', async function ({ plan, is } if (line.endsWith('Skipping warmup (bare)')) skippedWarmup = true if (line.endsWith('Success')) break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await running.inspector.close() is(completedStaging, true, 'should complete staging') @@ -330,7 +328,7 @@ test('pear stage --bare --json ', async function ({ pla if (result.tag === 'skipping') skipTag = result if (result.tag === 'final') break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await running.inspector.close() is(skipTag?.data?.reason, 'bare', 'should skip warmup') @@ -364,7 +362,7 @@ test('pear stage --ignore ', async function ({ p if (line.includes('/index.js')) addedIndex = true if (line.endsWith('Success')) break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await running.inspector.close() is(completedStaging, true, 'should complete staging') @@ -402,7 +400,7 @@ test('pear stage --ignore --json ', async functi if (result.tag === 'final') break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await running.inspector.close() is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') @@ -427,7 +425,7 @@ test('pear stage --truncate ', async function ({ pl if (line.endsWith('Success')) break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -445,7 +443,7 @@ test('pear stage --truncate ', async function ({ pl if (line.includes('/index.js')) readdedFile = true if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -469,7 +467,7 @@ test('pear stage --truncate --json ', async functio if (line.endsWith('Success')) break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -492,7 +490,7 @@ test('pear stage --truncate --json ', async functio if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(files.includes('/index.js'), true, 'should readd index.js') @@ -524,7 +522,7 @@ test('pear stage --name ', async function ({ pla if (line.endsWith('Success')) break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await running.inspector.close() is(completedStaging, true, 'should complete staging') @@ -557,7 +555,7 @@ test('pear stage --name --json ', async function if (result.tag === 'staging') stagedName = result.data.name if (result.tag === 'final') break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await running.inspector.close() is(stagedName, 'test-name-' + testId, 'should use --name flag') @@ -597,7 +595,7 @@ test('pear stage --ignore --name ', async if (line.endsWith('Success')) break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await running.inspector.close() is(completedStaging, true, 'should complete staging') @@ -639,7 +637,7 @@ test('pear stage --ignore --name --json ' if (result.tag === 'staging') stagedName = result.data.name if (result.tag === 'final') break } - await running.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await running.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await running.inspector.close() is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') @@ -665,7 +663,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < if (line.endsWith('Success')) break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -698,7 +696,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -725,7 +723,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - if (line.endsWith('Success')) break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -754,7 +752,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - if (result.tag === 'staging') stagedName = result.data.name if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(files.includes('/package.json'), true, 'should readd package.json after truncate') @@ -784,7 +782,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -800,7 +798,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { if (line === 'Staging complete!') completedStaging = true if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -826,7 +824,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -847,7 +845,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') @@ -873,7 +871,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -889,7 +887,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { if (line === 'Staging dry run complete!') completedStaging = true if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -915,7 +913,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -938,7 +936,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, if (result.tag === 'complete') completeTag = result if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() alike(tags, ['staging', 'dry', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') @@ -965,7 +963,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -983,7 +981,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { if (line.endsWith('Skipping warmup (bare)')) skippedWarmup = true if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -1010,7 +1008,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1033,7 +1031,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali if (result.tag === 'skipping') skipTag = result if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(skipTag?.data?.reason, 'bare', 'should skip warmup') @@ -1060,7 +1058,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1081,7 +1079,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t if (line.includes('/ignored.txt')) addedIgnored = true if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -1108,7 +1106,7 @@ test('pear stage --ignore --json pear:// ', async function ({ if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1134,7 +1132,7 @@ test('pear stage --ignore --json pear:// ', async function ({ if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') @@ -1160,7 +1158,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1178,7 +1176,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is if (line.includes('/package.json')) readdedFile = true if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -1205,7 +1203,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1228,7 +1226,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(files.includes('/package.json'), true, 'should readd package.json after truncate') @@ -1255,7 +1253,7 @@ test('pear stage --name pear:// ', async function ({ plan, is if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1277,7 +1275,7 @@ test('pear stage --name pear:// ', async function ({ plan, is if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -1304,7 +1302,7 @@ test('pear stage --name --json pear:// ', async function ({ pl if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1327,7 +1325,7 @@ test('pear stage --name --json pear:// ', async function ({ pl if (result.tag === 'staging') stagedName = result.data.name if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(stagedName, 'test-name-' + testId, 'should use --name flag') @@ -1354,7 +1352,7 @@ test('pear stage --ignore --name pear:// ', async funct if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1381,7 +1379,7 @@ test('pear stage --ignore --name pear:// ', async funct if (line.includes('/ignored.txt')) addedIgnored = true if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -1409,7 +1407,7 @@ test('pear stage --ignore --name --json pear:// ', asyn if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1437,7 +1435,7 @@ test('pear stage --ignore --name --json pear:// ', asyn if (result.tag === 'staging') stagedName = result.data.name if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') @@ -1465,7 +1463,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1493,7 +1491,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p if (line.endsWith('Success')) break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(completedStaging, true, 'should complete staging') @@ -1523,7 +1521,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - if (result.tag === 'final') break } - await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') @@ -1548,7 +1546,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - if (result.tag === 'staging') stagedName = result.data.name if (result.tag === 'final') break } - await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() is(files.includes('/package.json'), true, 'should readd package.json after truncate') From c842a4f476c0212def85dd6f7ff30b0569647fdf Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Thu, 10 Oct 2024 06:38:40 +0800 Subject: [PATCH 32/45] Remove rig --- test/07-commands.test.js | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/test/07-commands.test.js b/test/07-commands.test.js index 1769e10cc..484a27361 100644 --- a/test/07-commands.test.js +++ b/test/07-commands.test.js @@ -8,23 +8,6 @@ const fixtures = path.join(Helper.localDir, 'test', 'fixtures') const harness = path.join(fixtures, 'harness') const minimal = path.join(fixtures, 'minimal') -class Rig { - setup = async ({ comment, timeout }) => { - timeout(180000) - this.helper = new Helper() - comment('connecting to local sidecar') - await this.helper.ready() - } - - cleanup = async ({ comment }) => { - comment('closing local sidecar connection') - await this.helper.close() - } -} - -const rig = new Rig() - -test('commands setup', rig.setup) test('pear stage --json ', async function ({ plan, alike, is }) { plan(2) @@ -1557,5 +1540,3 @@ test('pear stage --dry-run --bare --ignore --truncate --name - const { code } = await stager2.until.exit is(code, 0, 'should have exit code 0') }) - -test('commands cleanup', rig.cleanup) From b462adb0eb446289318bb70583776d849cddb125 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Thu, 10 Oct 2024 06:52:19 +0800 Subject: [PATCH 33/45] Remove newlines in evaluate calls --- test/07-commands.test.js | 225 ++++++++++----------------------------- 1 file changed, 56 insertions(+), 169 deletions(-) diff --git a/test/07-commands.test.js b/test/07-commands.test.js index 484a27361..4af90e86e 100644 --- a/test/07-commands.test.js +++ b/test/07-commands.test.js @@ -8,7 +8,6 @@ const fixtures = path.join(Helper.localDir, 'test', 'fixtures') const harness = path.join(fixtures, 'harness') const minimal = path.join(fixtures, 'minimal') - test('pear stage --json ', async function ({ plan, alike, is }) { plan(2) @@ -16,9 +15,7 @@ test('pear stage --json ', async function ({ plan, alik const argv = ['stage', '--json', 'test-' + testId, minimal] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -44,9 +41,7 @@ test('pear stage ', async function ({ plan, is }) { const argv = ['stage', 'test-' + testId, minimal] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false for await (const line of running.lineout) { @@ -69,9 +64,7 @@ test('pear stage ', async function ({ plan, is }) { const argv = ['stage', 'test-' + testId, relativePath] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false for await (const line of running.lineout) { @@ -110,9 +103,7 @@ test('pear stage (package.json pear.config.stage.entry const argv = ['stage', 'test-' + testId, relativePath] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false for await (const line of running.lineout) { @@ -152,9 +143,7 @@ test('pear stage (package.json pear.stage.ignore ', async function ({ plan, alik const argv = ['stage', '--json', 'test-' + testId, relativePath] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -209,9 +196,7 @@ test('pear stage --dry-run ', async function ({ plan, i const argv = ['stage', '--dry-run', 'test-' + testId, relativePath] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false for await (const line of running.lineout) { @@ -234,9 +219,7 @@ test('pear stage --dry-run --json ', async function ({ const argv = ['stage', '--dry-run', '--json', 'test-' + testId, relativePath] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -267,9 +250,7 @@ test('pear stage --bare ', async function ({ plan, is } const argv = ['stage', '--bare', 'test-' + testId, relativePath] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false let skippedWarmup = false @@ -295,9 +276,7 @@ test('pear stage --bare --json ', async function ({ pla const argv = ['stage', '--bare', '--json', 'test-' + testId, relativePath] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -332,9 +311,7 @@ test('pear stage --ignore ', async function ({ p const argv = ['stage', '--ignore', 'ignored.txt', 'test-' + testId, relativePath] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false let addedIgnored = false @@ -367,9 +344,7 @@ test('pear stage --ignore --json ', async functi const argv = ['stage', '--ignore', 'ignored.txt', '--json', 'test-' + testId, relativePath] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -400,9 +375,7 @@ test('pear stage --truncate ', async function ({ pl const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) for await (const line of stager1.lineout) { if (line.endsWith('Success')) break @@ -415,9 +388,7 @@ test('pear stage --truncate ', async function ({ pl const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', 'test-' + testId, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false let readdedFile = false @@ -442,9 +413,7 @@ test('pear stage --truncate --json ', async functio const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) for await (const line of stager1.lineout) { if (line.endsWith('Success')) break @@ -457,9 +426,7 @@ test('pear stage --truncate --json ', async functio const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', '--json', 'test-' + testId, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -490,9 +457,7 @@ test('pear stage --name ', async function ({ pla const argv = ['stage', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false let stagedName @@ -522,9 +487,7 @@ test('pear stage --name --json ', async function const argv = ['stage', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -559,9 +522,7 @@ test('pear stage --ignore --name ', async const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false let addedIgnored = false @@ -602,9 +563,7 @@ test('pear stage --ignore --name --json ' const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await running.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -638,9 +597,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) for await (const line of stager1.lineout) { if (line.endsWith('Success')) break @@ -657,9 +614,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, 'test-' + testId, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const stagingRegex = /Staging (.*) into/ let completedStaging = false @@ -698,9 +653,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) for await (const line of stager1.lineout) { if (line.endsWith('Success')) break @@ -717,9 +670,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', 'test-' + testId, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -754,9 +705,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -772,9 +721,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false for await (const line of stager2.lineout) { @@ -796,9 +743,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -814,9 +759,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--json', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -843,9 +786,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -861,9 +802,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false for await (const line of stager2.lineout) { @@ -885,9 +824,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -903,9 +840,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--json', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -935,9 +870,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -953,9 +886,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--bare', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false let skippedWarmup = false @@ -980,9 +911,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -998,9 +927,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--bare', '--json', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -1030,9 +957,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -1051,9 +976,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) const argv = ['stage', '--ignore', 'ignored.txt', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false let addedIgnored = false @@ -1078,9 +1001,7 @@ test('pear stage --ignore --json pear:// ', async function ({ const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -1099,9 +1020,7 @@ test('pear stage --ignore --json pear:// ', async function ({ fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) const argv = ['stage', '--ignore', 'ignored.txt', '--json', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -1130,9 +1049,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -1148,9 +1065,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false let readdedFile = false @@ -1175,9 +1090,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -1193,9 +1106,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--truncate', '0', '--json', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -1225,9 +1136,7 @@ test('pear stage --name pear:// ', async function ({ plan, is const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -1243,9 +1152,7 @@ test('pear stage --name pear:// ', async function ({ plan, is const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--name', `test-name-${testId}`, link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false const stagingRegex = /Staging (.*) into/ @@ -1274,9 +1181,7 @@ test('pear stage --name --json pear:// ', async function ({ pl const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -1292,9 +1197,7 @@ test('pear stage --name --json pear:// ', async function ({ pl const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--name', `test-name-${testId}`, '--json', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -1324,9 +1227,7 @@ test('pear stage --ignore --name pear:// ', async funct const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -1345,9 +1246,7 @@ test('pear stage --ignore --name pear:// ', async funct fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-name-${testId}`, link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false let addedIgnored = false @@ -1379,9 +1278,7 @@ test('pear stage --ignore --name --json pear:// ', asyn const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -1400,9 +1297,7 @@ test('pear stage --ignore --name --json pear:// ', asyn fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) const argv = ['stage', '--ignore', 'ignored.txt', '--name', `test-name-${testId}`, '--json', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] @@ -1435,9 +1330,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -1453,9 +1346,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const stagingRegex = /Staging (.*) into/ let completedStaging = false @@ -1493,9 +1384,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) - await stager1.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argvInit)}) - `, { returnByValue: false }) + await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link for await (const line of stager1.lineout) { @@ -1511,9 +1400,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', link, relativePath] - await stager2.inspector.evaluate(` - __PEAR_TEST__.command(${JSON.stringify(argv)}) - `, { returnByValue: false }) + await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() const tags = [] From b38eca1a3ed7a6ff926b78fb666baa90d4a6629a Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Thu, 10 Oct 2024 22:07:28 +0800 Subject: [PATCH 34/45] Add missing tags check --- test/07-commands.test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/07-commands.test.js b/test/07-commands.test.js index 4af90e86e..12e2308f8 100644 --- a/test/07-commands.test.js +++ b/test/07-commands.test.js @@ -994,8 +994,8 @@ test('pear stage --ignore pear:// ', async function ({ plan, t is(code, 0, 'should have exit code 0') }) -test('pear stage --ignore --json pear:// ', async function ({ plan, teardown, is }) { - plan(3) +test('pear stage --ignore --json pear:// ', async function ({ plan, alike, teardown, is }) { + plan(4) const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) @@ -1037,6 +1037,7 @@ test('pear stage --ignore --json pear:// ', async function ({ await stager2.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager2.inspector.close() + alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') const { code } = await stager2.until.exit is(code, 0, 'should have exit code 0') From b693b580944d00de930484b78c04f191ef6da4cb Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Thu, 10 Oct 2024 22:08:30 +0800 Subject: [PATCH 35/45] Use Helper static field to signal if teardown should be skipped --- test/fixtures/harness/index.js | 4 ++-- test/helper.js | 23 +++++++++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/test/fixtures/harness/index.js b/test/fixtures/harness/index.js index e3e85f528..08bd01e58 100644 --- a/test/fixtures/harness/index.js +++ b/test/fixtures/harness/index.js @@ -33,8 +33,6 @@ class Harness extends ReadyResource { } async client (opts) { - global.Pear.config.args.push('--no-helper-teardown') - if (this.Helper === null) { const { default: Helper } = await import('pear/test/helper') this.Helper = Helper @@ -44,6 +42,8 @@ class Harness extends ReadyResource { this.cmd = cmd } + this.Helper.skipTeardown = true + return new this.Helper({ platformDir: global.Pear.config.pearDir, opts }) } diff --git a/test/helper.js b/test/helper.js index 18598943c..b38991161 100644 --- a/test/helper.js +++ b/test/helper.js @@ -19,24 +19,23 @@ const BY_ARCH = path.join('by-arch', HOST, 'bin', `pear-runtime${isWindows ? '.e const { PLATFORM_DIR } = require('../constants') const { pathname } = new URL(global.Pear.config.applink) const NO_GC = global.Pear.config.args.includes('--no-tmp-gc') -const NO_TEARDOWN = global.Pear.config.args.includes('--no-helper-teardown') const MAX_OP_STEP_WAIT = env.CI ? 360000 : 120000 const tmp = fs.realpathSync(os.tmpdir()) Error.stackTraceLimit = Infinity const rigPear = path.join(tmp, 'rig-pear') -if (!NO_TEARDOWN) { - Pear.teardown(async () => { - console.log('# Teardown: Shutting Down Local Sidecar') - const local = new Helper() - console.log('# Teardown: Connecting Local Sidecar') - await local.ready() - console.log('# Teardown: Triggering Shutdown of Local Sidecar') - await local.shutdown() - console.log('# Teardown: Local Sidecar Shutdown') - }) -} +Pear.teardown(async () => { + if (Helper.skipTeardown) return + + console.log('# Teardown: Shutting Down Local Sidecar') + const local = new Helper() + console.log('# Teardown: Connecting Local Sidecar') + await local.ready() + console.log('# Teardown: Triggering Shutdown of Local Sidecar') + await local.shutdown() + console.log('# Teardown: Local Sidecar Shutdown') +}) class Rig { platformDir = rigPear From 3e90fcb436b23ac557b5edb26daeff07c2ec7cbe Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Fri, 11 Oct 2024 00:38:38 +0800 Subject: [PATCH 36/45] Remove skipping of teardown --- test/fixtures/harness/index.js | 2 -- test/helper.js | 2 -- 2 files changed, 4 deletions(-) diff --git a/test/fixtures/harness/index.js b/test/fixtures/harness/index.js index 08bd01e58..00b212078 100644 --- a/test/fixtures/harness/index.js +++ b/test/fixtures/harness/index.js @@ -42,8 +42,6 @@ class Harness extends ReadyResource { this.cmd = cmd } - this.Helper.skipTeardown = true - return new this.Helper({ platformDir: global.Pear.config.pearDir, opts }) } diff --git a/test/helper.js b/test/helper.js index b38991161..0e7f64cb9 100644 --- a/test/helper.js +++ b/test/helper.js @@ -26,8 +26,6 @@ Error.stackTraceLimit = Infinity const rigPear = path.join(tmp, 'rig-pear') Pear.teardown(async () => { - if (Helper.skipTeardown) return - console.log('# Teardown: Shutting Down Local Sidecar') const local = new Helper() console.log('# Teardown: Connecting Local Sidecar') From 9247d1904ebf2990444e11246ba164fec3831737 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Fri, 11 Oct 2024 00:40:35 +0800 Subject: [PATCH 37/45] Use staged rig for all tests --- test/07-commands.test.js | 118 ++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 56 deletions(-) diff --git a/test/07-commands.test.js b/test/07-commands.test.js index 12e2308f8..7349956b9 100644 --- a/test/07-commands.test.js +++ b/test/07-commands.test.js @@ -8,13 +8,17 @@ const fixtures = path.join(Helper.localDir, 'test', 'fixtures') const harness = path.join(fixtures, 'harness') const minimal = path.join(fixtures, 'minimal') +const rig = new Helper.Rig() + +test.hook('commands setup', rig.setup) + test('pear stage --json ', async function ({ plan, alike, is }) { plan(2) const testId = Math.floor(Math.random() * 100000) const argv = ['stage', '--json', 'test-' + testId, minimal] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() @@ -40,7 +44,7 @@ test('pear stage ', async function ({ plan, is }) { const testId = Math.floor(Math.random() * 100000) const argv = ['stage', 'test-' + testId, minimal] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false @@ -63,7 +67,7 @@ test('pear stage ', async function ({ plan, is }) { const relativePath = path.relative(harness, minimal) const argv = ['stage', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false @@ -102,7 +106,7 @@ test('pear stage (package.json pear.config.stage.entry const relativePath = path.relative(harness, targetDir) const argv = ['stage', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false @@ -142,7 +146,7 @@ test('pear stage (package.json pear.stage.ignore ', async function ({ plan, alik const relativePath = path.relative(harness, minimal) const argv = ['stage', '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() @@ -195,7 +199,7 @@ test('pear stage --dry-run ', async function ({ plan, i const relativePath = path.relative(harness, minimal) const argv = ['stage', '--dry-run', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false @@ -218,7 +222,7 @@ test('pear stage --dry-run --json ', async function ({ const relativePath = path.relative(harness, minimal) const argv = ['stage', '--dry-run', '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() @@ -249,7 +253,7 @@ test('pear stage --bare ', async function ({ plan, is } const relativePath = path.relative(harness, minimal) const argv = ['stage', '--bare', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false @@ -275,7 +279,7 @@ test('pear stage --bare --json ', async function ({ pla const relativePath = path.relative(harness, minimal) const argv = ['stage', '--bare', '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() @@ -310,7 +314,7 @@ test('pear stage --ignore ', async function ({ p const argv = ['stage', '--ignore', 'ignored.txt', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false @@ -343,7 +347,7 @@ test('pear stage --ignore --json ', async functi const argv = ['stage', '--ignore', 'ignored.txt', '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() @@ -374,7 +378,7 @@ test('pear stage --truncate ', async function ({ pl const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) for await (const line of stager1.lineout) { @@ -386,7 +390,7 @@ test('pear stage --truncate ', async function ({ pl const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--truncate', '0', 'test-' + testId, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -412,7 +416,7 @@ test('pear stage --truncate --json ', async functio const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) for await (const line of stager1.lineout) { @@ -424,7 +428,7 @@ test('pear stage --truncate --json ', async functio const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--truncate', '0', '--json', 'test-' + testId, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -456,7 +460,7 @@ test('pear stage --name ', async function ({ pla const relativePath = path.relative(harness, minimal) const argv = ['stage', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false @@ -486,7 +490,7 @@ test('pear stage --name --json ', async function const relativePath = path.relative(harness, minimal) const argv = ['stage', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() @@ -521,7 +525,7 @@ test('pear stage --ignore --name ', async const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) let completedStaging = false @@ -562,7 +566,7 @@ test('pear stage --ignore --name --json ' const argv = ['stage', '--ignore', 'ignored.txt', '--name', 'test-name-' + testId, '--json', 'test-' + testId, relativePath] - const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const running = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await running.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) const seen = new Set() @@ -596,7 +600,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) for await (const line of stager1.lineout) { @@ -612,7 +616,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, 'test-' + testId, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -652,7 +656,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) for await (const line of stager1.lineout) { @@ -668,7 +672,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', 'test-' + testId, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -704,7 +708,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -719,7 +723,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -742,7 +746,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -757,7 +761,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -785,7 +789,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -800,7 +804,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--dry-run', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -823,7 +827,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -838,7 +842,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--dry-run', '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -869,7 +873,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -884,7 +888,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--bare', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -910,7 +914,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -925,7 +929,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--bare', '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -956,7 +960,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -971,7 +975,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) @@ -1000,7 +1004,7 @@ test('pear stage --ignore --json pear:// ', async function ({ const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -1015,7 +1019,7 @@ test('pear stage --ignore --json pear:// ', async function ({ const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) @@ -1049,7 +1053,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -1064,7 +1068,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--truncate', '0', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -1090,7 +1094,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -1105,7 +1109,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--truncate', '0', '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -1136,7 +1140,7 @@ test('pear stage --name pear:// ', async function ({ plan, is const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -1151,7 +1155,7 @@ test('pear stage --name pear:// ', async function ({ plan, is const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--name', `test-name-${testId}`, link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -1181,7 +1185,7 @@ test('pear stage --name --json pear:// ', async function ({ pl const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -1196,7 +1200,7 @@ test('pear stage --name --json pear:// ', async function ({ pl const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--name', `test-name-${testId}`, '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -1227,7 +1231,7 @@ test('pear stage --ignore --name pear:// ', async funct const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -1242,7 +1246,7 @@ test('pear stage --ignore --name pear:// ', async funct const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) @@ -1278,7 +1282,7 @@ test('pear stage --ignore --name --json pear:// ', asyn const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -1293,7 +1297,7 @@ test('pear stage --ignore --name --json pear:// ', asyn const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') teardown(() => { try { fs.unlinkSync(ignoredFile) } catch { /* ignore */ } }) @@ -1330,7 +1334,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -1345,7 +1349,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -1384,7 +1388,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - const testId = Math.floor(Math.random() * 100000) const relativePath = path.relative(harness, minimal) const argvInit = ['stage', '--json', 'test-' + testId, relativePath] - const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) await stager1.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit)}) `, { returnByValue: false }) let link @@ -1399,7 +1403,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - const { code: code1 } = await stager1.until.exit is(code1, 0, 'should have exit code 0 for initial stage') - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', link, relativePath] await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argv)}) `, { returnByValue: false }) @@ -1428,3 +1432,5 @@ test('pear stage --dry-run --bare --ignore --truncate --name - const { code } = await stager2.until.exit is(code, 0, 'should have exit code 0') }) + +test.hook('commands cleanup', rig.cleanup) From e6d9465458d981f9d407ce1a9e46ef5e2bab6c36 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Fri, 11 Oct 2024 01:09:33 +0800 Subject: [PATCH 38/45] A logging of actual exit code --- test/07-commands.test.js | 112 +++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/test/07-commands.test.js b/test/07-commands.test.js index 7349956b9..f6ce6c5f4 100644 --- a/test/07-commands.test.js +++ b/test/07-commands.test.js @@ -35,7 +35,7 @@ test('pear stage --json ', async function ({ plan, alik alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage ', async function ({ plan, is }) { @@ -57,7 +57,7 @@ test('pear stage ', async function ({ plan, is }) { is(completedStaging, true, 'should complete staging') const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage ', async function ({ plan, is }) { @@ -80,7 +80,7 @@ test('pear stage ', async function ({ plan, is }) { is(completedStaging, true, 'should complete staging') const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage (package.json pear.config.stage.entrypoints )', async function ({ plan, teardown, is }) { @@ -119,7 +119,7 @@ test('pear stage (package.json pear.config.stage.entry is(completedStaging, true, 'should complete staging') const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage (package.json pear.stage.ignore )', async function ({ plan, teardown, is }) { @@ -162,7 +162,7 @@ test('pear stage (package.json pear.stage.ignore ', async function ({ plan, alike, is }) { @@ -189,7 +189,7 @@ test('pear stage --json ', async function ({ plan, alik alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --dry-run ', async function ({ plan, is }) { @@ -212,7 +212,7 @@ test('pear stage --dry-run ', async function ({ plan, i is(completedStaging, true, 'should complete staging') const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --dry-run --json ', async function ({ plan, alike, is }) { @@ -243,7 +243,7 @@ test('pear stage --dry-run --json ', async function ({ is(completeTag?.data?.dryRun, true) alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --bare ', async function ({ plan, is }) { @@ -269,7 +269,7 @@ test('pear stage --bare ', async function ({ plan, is } is(completedStaging, true, 'should complete staging') is(skippedWarmup, true, 'should skip warmup') const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --bare --json ', async function ({ plan, alike, is }) { @@ -300,7 +300,7 @@ test('pear stage --bare --json ', async function ({ pla is(skipTag?.data?.reason, 'bare', 'should skip warmup') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --ignore ', async function ({ plan, teardown, is }) { @@ -333,7 +333,7 @@ test('pear stage --ignore ', async function ({ p is(addedIgnored, false, 'should not add ignored.txt') is(addedIndex, true, 'should add index.js') const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --ignore --json ', async function ({ plan, alike, teardown, is }) { @@ -369,7 +369,7 @@ test('pear stage --ignore --json ', async functi is(files.includes('/index.js'), true, 'should add index.js') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --truncate ', async function ({ plan, is }) { @@ -388,7 +388,7 @@ test('pear stage --truncate ', async function ({ pl await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--truncate', '0', 'test-' + testId, relativePath] @@ -407,7 +407,7 @@ test('pear stage --truncate ', async function ({ pl is(completedStaging, true, 'should complete staging') is(readdedFile, true, 'should readd index.js') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --truncate --json ', async function ({ plan, alike, is }) { @@ -426,7 +426,7 @@ test('pear stage --truncate --json ', async functio await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--truncate', '0', '--json', 'test-' + testId, relativePath] @@ -450,7 +450,7 @@ test('pear stage --truncate --json ', async functio is(files.includes('/index.js'), true, 'should readd index.js') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --name ', async function ({ plan, is }) { @@ -480,7 +480,7 @@ test('pear stage --name ', async function ({ pla is(completedStaging, true, 'should complete staging') is(stagedName, 'test-name-' + testId, 'should use --name flag') const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --name --json ', async function ({ plan, alike, is }) { @@ -511,7 +511,7 @@ test('pear stage --name --json ', async function is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --ignore --name ', async function ({ plan, teardown, is }) { @@ -552,7 +552,7 @@ test('pear stage --ignore --name ', async is(stagedName, 'test-name-' + testId, 'should use --name flag') const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --ignore --name --json ', async function ({ plan, alike, teardown, is }) { @@ -591,7 +591,7 @@ test('pear stage --ignore --name --json ' is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --dry-run --bare --ignore --truncate --name ', async function ({ plan, teardown, is }) { @@ -610,7 +610,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') @@ -647,7 +647,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name < is(addedIndex, true, 'should add index.js') is(stagedName, 'test-name-' + testId, 'should use --name flag') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --dry-run --bare --ignore --truncate --name --json ', async function ({ plan, alike, teardown, is }) { @@ -666,7 +666,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const ignoredFile = path.join(harness, 'ignored.txt') fs.writeFileSync(ignoredFile, 'this file should be ignored') @@ -699,7 +699,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage pear:// ', async function ({ plan, is }) { @@ -721,7 +721,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', link, relativePath] @@ -737,7 +737,7 @@ test('pear stage pear:// ', async function ({ plan, is }) { is(completedStaging, true, 'should complete staging') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --json pear:// ', async function ({ plan, alike, is }) { @@ -759,7 +759,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--json', link, relativePath] @@ -780,7 +780,7 @@ test('pear stage --json pear:// ', async function ({ plan, alike, is alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --dry-run pear:// ', async function ({ plan, is }) { @@ -802,7 +802,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--dry-run', link, relativePath] @@ -818,7 +818,7 @@ test('pear stage --dry-run pear:// ', async function ({ plan, is }) { is(completedStaging, true, 'should complete staging') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --dry-run --json pear:// ', async function ({ plan, alike, is }) { @@ -840,7 +840,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--dry-run', '--json', link, relativePath] @@ -864,7 +864,7 @@ test('pear stage --dry-run --json pear:// ', async function ({ plan, alike(tags, ['staging', 'dry', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') is(completeTag?.data?.dryRun, true, 'should be dry run') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --bare pear:// ', async function ({ plan, is }) { @@ -886,7 +886,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--bare', link, relativePath] @@ -905,7 +905,7 @@ test('pear stage --bare pear:// ', async function ({ plan, is }) { is(completedStaging, true, 'should complete staging') is(skippedWarmup, true, 'should skip warmup') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --bare --json pear:// ', async function ({ plan, alike, is }) { @@ -927,7 +927,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--bare', '--json', link, relativePath] @@ -951,7 +951,7 @@ test('pear stage --bare --json pear:// ', async function ({ plan, ali is(skipTag?.data?.reason, 'bare', 'should skip warmup') alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --ignore pear:// ', async function ({ plan, teardown, is }) { @@ -973,7 +973,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') @@ -995,7 +995,7 @@ test('pear stage --ignore pear:// ', async function ({ plan, t is(completedStaging, true, 'should complete staging') is(addedIgnored, false, 'should not add ignored.txt') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --ignore --json pear:// ', async function ({ plan, alike, teardown, is }) { @@ -1017,7 +1017,7 @@ test('pear stage --ignore --json pear:// ', async function ({ await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') @@ -1044,7 +1044,7 @@ test('pear stage --ignore --json pear:// ', async function ({ alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') is(files.includes('/ignored.txt'), false, 'should not add ignored.txt') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --truncate pear:// ', async function ({ plan, is }) { @@ -1066,7 +1066,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--truncate', '0', link, relativePath] @@ -1085,7 +1085,7 @@ test('pear stage --truncate pear:// ', async function ({ plan, is is(completedStaging, true, 'should complete staging') is(readdedFile, true, 'should readd package.json after truncate') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --truncate --json pear:// ', async function ({ plan, alike, is }) { @@ -1107,7 +1107,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--truncate', '0', '--json', link, relativePath] @@ -1131,7 +1131,7 @@ test('pear stage --truncate --json pear:// ', async function ({ p is(files.includes('/package.json'), true, 'should readd package.json after truncate') alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --name pear:// ', async function ({ plan, is }) { @@ -1153,7 +1153,7 @@ test('pear stage --name pear:// ', async function ({ plan, is await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--name', `test-name-${testId}`, link, relativePath] @@ -1176,7 +1176,7 @@ test('pear stage --name pear:// ', async function ({ plan, is is(completedStaging, true, 'should complete staging') is(stagedName, 'test-name-' + testId, 'should use --name flag') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --name --json pear:// ', async function ({ plan, alike, is }) { @@ -1198,7 +1198,7 @@ test('pear stage --name --json pear:// ', async function ({ pl await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--name', `test-name-${testId}`, '--json', link, relativePath] @@ -1222,7 +1222,7 @@ test('pear stage --name --json pear:// ', async function ({ pl is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --ignore --name pear:// ', async function ({ plan, teardown, is }) { @@ -1244,7 +1244,7 @@ test('pear stage --ignore --name pear:// ', async funct await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') @@ -1273,7 +1273,7 @@ test('pear stage --ignore --name pear:// ', async funct is(addedIgnored, false, 'should not add ignored.txt') is(stagedName, 'test-name-' + testId, 'should use --name flag') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --ignore --name --json pear:// ', async function ({ plan, alike, teardown, is }) { @@ -1295,7 +1295,7 @@ test('pear stage --ignore --name --json pear:// ', asyn await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const ignoredFile = path.join(harness, 'ignored.txt') @@ -1325,7 +1325,7 @@ test('pear stage --ignore --name --json pear:// ', asyn is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'summary', 'skipping', 'complete', 'addendum', 'final'], 'should output expected tags') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --dry-run --bare --ignore --truncate --name pear:// ', async function ({ plan, is }) { @@ -1347,7 +1347,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, link, relativePath] @@ -1379,7 +1379,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name p is(addedIndex, true, 'should add index.js') is(stagedName, 'test-name-' + testId, 'should use --name flag') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test('pear stage --dry-run --bare --ignore --truncate --name --json pear:// ', async function ({ plan, alike, is }) { @@ -1401,7 +1401,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - await stager1.inspector.evaluate('__PEAR_TEST__.close()', { returnByValue: false }) await stager1.inspector.close() const { code: code1 } = await stager1.until.exit - is(code1, 0, 'should have exit code 0 for initial stage') + is(code1, 0, `should have exit code 0 for initial stage, got ${code1}`) const stager2 = await Helper.open(harness, { tags: ['exit'] }, { ...rig, lineout: true }) const argv = ['stage', '--dry-run', '--bare', '--ignore', 'ignored.txt', '--truncate', '0', '--name', `test-name-${testId}`, '--json', link, relativePath] @@ -1430,7 +1430,7 @@ test('pear stage --dry-run --bare --ignore --truncate --name - is(stagedName, 'test-name-' + testId, 'should use --name flag') alike(tags, ['staging', 'dry', 'byte-diff', 'summary', 'skipping', 'complete', 'final'], 'should output expected tags') const { code } = await stager2.until.exit - is(code, 0, 'should have exit code 0') + is(code, 0, `should have exit code 0, got ${code}`) }) test.hook('commands cleanup', rig.cleanup) From f763bcfd5b02f671ba12c7f051ce5bbad1fe49f3 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Fri, 11 Oct 2024 01:25:04 +0800 Subject: [PATCH 39/45] Disable unused rig keepalive connection --- test/07-commands.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/07-commands.test.js b/test/07-commands.test.js index f6ce6c5f4..33fb76625 100644 --- a/test/07-commands.test.js +++ b/test/07-commands.test.js @@ -8,7 +8,7 @@ const fixtures = path.join(Helper.localDir, 'test', 'fixtures') const harness = path.join(fixtures, 'harness') const minimal = path.join(fixtures, 'minimal') -const rig = new Helper.Rig() +const rig = new Helper.Rig({ keepAlive: false }) test.hook('commands setup', rig.setup) From d5bbacb9aa6ac9992eca641291001b3d149c0580 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Fri, 11 Oct 2024 03:04:14 +0800 Subject: [PATCH 40/45] Temporarily disable non-failing tests --- .github/workflows/ci.yml | 12 ++++++------ test/index.js | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4eca576e..0dfcb670e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,12 +14,12 @@ jobs: strategy: matrix: include: - - os: ubuntu-latest - platform: linux - arch: x64 - - os: macos-latest - platform: darwin - arch: x64 +# - os: ubuntu-latest +# platform: linux +# arch: x64 +# - os: macos-latest +# platform: darwin +# arch: x64 - os: windows-latest platform: win32 arch: x64 diff --git a/test/index.js b/test/index.js index db1d0ccc8..17669ff26 100644 --- a/test/index.js +++ b/test/index.js @@ -7,12 +7,12 @@ async function runTests () { test.pause() - await import('./01-smoke.test.js') - await import('./02-teardown.test.js') - await import('./03-worker.test.js') - await import('./04-encrypted.test.js') - await import('./05-updates.test.js') - await import('./06-shutdown.test.js') + // await import('./01-smoke.test.js') + // await import('./02-teardown.test.js') + // await import('./03-worker.test.js') + // await import('./04-encrypted.test.js') + // await import('./05-updates.test.js') + // await import('./06-shutdown.test.js') await import('./07-commands.test.js') test.resume() From 4424ebd780be506e4bc95ea8b8d65af54527977a Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Fri, 11 Oct 2024 03:53:23 +0800 Subject: [PATCH 41/45] Fix harness teardown using a non-existent runtime --- test/fixtures/harness/index.js | 4 +++- test/helper.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/fixtures/harness/index.js b/test/fixtures/harness/index.js index 00b212078..4d54145f4 100644 --- a/test/fixtures/harness/index.js +++ b/test/fixtures/harness/index.js @@ -42,7 +42,9 @@ class Harness extends ReadyResource { this.cmd = cmd } - return new this.Helper({ platformDir: global.Pear.config.pearDir, opts }) + Helper.PLATFORM_DIR = global.Pear.config.pearDir + + return new this.Helper({ opts }) } nextUpdate () { diff --git a/test/helper.js b/test/helper.js index 0e7f64cb9..b77960729 100644 --- a/test/helper.js +++ b/test/helper.js @@ -108,7 +108,7 @@ class Helper extends IPC { // DO NOT UNDER ANY CIRCUMSTANCES ADD PUBLIC METHODS OR PROPERTIES TO HELPER (see pear-ipc) constructor (opts = {}) { const log = global.Pear.config.args.includes('--log') - const platformDir = opts.platformDir || PLATFORM_DIR + const platformDir = opts.platformDir || Helper.PLATFORM_DIR const runtime = path.join(platformDir, 'current', BY_ARCH) const dhtBootstrap = Pear.config.dht.bootstrap.map(e => `${e.host}:${e.port}`).join(',') const args = ['--sidecar', '--dht-bootstrap', dhtBootstrap] From 628e4949ea2c6b6024ed034e6f28b4e2eb789f0e Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Fri, 11 Oct 2024 03:56:53 +0800 Subject: [PATCH 42/45] Add missing this --- test/fixtures/harness/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixtures/harness/index.js b/test/fixtures/harness/index.js index 4d54145f4..f877812fa 100644 --- a/test/fixtures/harness/index.js +++ b/test/fixtures/harness/index.js @@ -42,7 +42,7 @@ class Harness extends ReadyResource { this.cmd = cmd } - Helper.PLATFORM_DIR = global.Pear.config.pearDir + this.Helper.PLATFORM_DIR = global.Pear.config.pearDir return new this.Helper({ opts }) } From 7ed5f003a7f1d306ca37bf050c6820b7b39ca577 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Tue, 22 Oct 2024 00:20:01 +0800 Subject: [PATCH 43/45] Revert "Temporarily disable non-failing tests" This reverts commit 82887b2ad1fecc6e19798785d69dfbe37ca8e2a3. --- .github/workflows/ci.yml | 12 ++++++------ test/index.js | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0dfcb670e..e4eca576e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,12 +14,12 @@ jobs: strategy: matrix: include: -# - os: ubuntu-latest -# platform: linux -# arch: x64 -# - os: macos-latest -# platform: darwin -# arch: x64 + - os: ubuntu-latest + platform: linux + arch: x64 + - os: macos-latest + platform: darwin + arch: x64 - os: windows-latest platform: win32 arch: x64 diff --git a/test/index.js b/test/index.js index 17669ff26..db1d0ccc8 100644 --- a/test/index.js +++ b/test/index.js @@ -7,12 +7,12 @@ async function runTests () { test.pause() - // await import('./01-smoke.test.js') - // await import('./02-teardown.test.js') - // await import('./03-worker.test.js') - // await import('./04-encrypted.test.js') - // await import('./05-updates.test.js') - // await import('./06-shutdown.test.js') + await import('./01-smoke.test.js') + await import('./02-teardown.test.js') + await import('./03-worker.test.js') + await import('./04-encrypted.test.js') + await import('./05-updates.test.js') + await import('./06-shutdown.test.js') await import('./07-commands.test.js') test.resume() From 0064f10fca82f1bbf196d2cedf76189567eda4b6 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Wed, 23 Oct 2024 01:04:38 +0800 Subject: [PATCH 44/45] Add ensuring that rig has been shut down --- test/06-shutdown.test.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/06-shutdown.test.js b/test/06-shutdown.test.js index 18fa04d44..51aebbf83 100644 --- a/test/06-shutdown.test.js +++ b/test/06-shutdown.test.js @@ -146,7 +146,12 @@ test('sidecar should not spindown until ongoing update is finished', async (t) = t.comment('\tStaging patched platform') const rigHelper = new Helper(rig) - t.teardown(() => rigHelper.close(), { order: Infinity }) + t.teardown(async () => { + if (!rigHelper.closing) { + await rigHelper.shutdown() + await rigHelper.close() + } + }, { order: Infinity }) await rigHelper.ready() const patchedStager = rigHelper.stage({ channel: 'test-spindown-throttled', name: 'test-spindown-throttled', dir: patchedArtefactDir, dryRun: false, bare: true }) @@ -166,6 +171,7 @@ test('sidecar should not spindown until ongoing update is finished', async (t) = t.teardown(() => Helper.gc(platformDirRcv)) await Helper.teardownStream(patchedSeeder) + await rigHelper.shutdown() await rigHelper.close() t.comment('2. Start patched rcv platform') From 5765ad3d2d6889400ce9cbb83c60b144733abbaa Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Wed, 23 Oct 2024 05:42:03 +0800 Subject: [PATCH 45/45] Use mirror.done instead of awaiting mirror output --- test/07-commands.test.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/07-commands.test.js b/test/07-commands.test.js index 33fb76625..43d1c63e6 100644 --- a/test/07-commands.test.js +++ b/test/07-commands.test.js @@ -93,8 +93,7 @@ test('pear stage (package.json pear.config.stage.entry const sourceDrive = new LocalDrive(minimal) const targetDrive = new LocalDrive(targetDir) const mirror = sourceDrive.mirror(targetDrive, { prune: false }) - // eslint-disable-next-line no-unused-vars - for await (const val of mirror) { /* ignore */ } + await mirror.done() const originalPackageJson = fs.readFileSync(path.join(targetDir, 'package.json'), 'utf8') const packageJson = JSON.parse(originalPackageJson) @@ -133,8 +132,7 @@ test('pear stage (package.json pear.stage.ignore