From 270baae7dca3c1b80f1132b6ee4503d7a75674b7 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Fri, 9 Aug 2024 11:08:27 +0800 Subject: [PATCH 01/10] Add tests for pear shift # Conflicts: # test/05-commands.test.js # test/index.js --- test/05-commands.test.js | 558 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 558 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..6440d5dc2 --- /dev/null +++ b/test/05-commands.test.js @@ -0,0 +1,558 @@ +const test = require('brittle') +const path = require('bare-path') +const Helper = require('./helper') +const { discoveryKey } = require('hypercore-crypto') +const fs = require('bare-fs') +const parseLink = require('../lib/parse-link') + +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') + await this.helper.shutdown() + comment('local sidecar shut down') + } +} + +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']) + const { code } = await running.until.exit + is(code, 0) +}) +test.todo('pear stage ') +test.todo('pear stage ') +test.todo('pear stage (package.json pear.config.stage.entrypoints )') +test.todo('pear stage (package.json pear.config.stage.ignore )') +test.todo('pear stage --json ') +test.todo('pear stage --dry-run ') +test.todo('pear stage --dry-run --json ') +test.todo('pear stage --bare ') +test.todo('pear stage --bare --json ') +test.todo('pear stage --ignore ') +test.todo('pear stage --ignore --json ') +test.todo('pear stage --truncate ') +test.todo('pear stage --truncate --json ') +test.todo('pear stage --name ') +test.todo('pear stage --name --json ') +test.todo('pear stage --ignore --name ') +test.todo('pear stage --ignore --name --json ') +test.todo('pear stage --dry-run --bare --ignore --truncate --name ') +test.todo('pear stage --dry-run --bare --ignore --truncate --name --json ') +test.todo('pear stage pear://') +test.todo('pear stage --json pear://') +test.todo('pear stage --dry-run pear://') +test.todo('pear stage --dry-run --json pear://') +test.todo('pear stage --bare pear://') +test.todo('pear stage --bare --json pear://') +test.todo('pear stage --ignore pear://') +test.todo('pear stage --ignore --json pear://') +test.todo('pear stage --truncate pear://') +test.todo('pear stage --truncate --json pear://') +test.todo('pear stage --name pear://') +test.todo('pear stage --name --json pear://') +test.todo('pear stage --ignore --name pear://') +test.todo('pear stage --ignore --name --json pear://') +test.todo('pear stage --dry-run --bare --ignore --truncate --name pear://') +test.todo('pear stage --dry-run --bare --ignore --truncate --name --json pear://') + +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.todo('pear run --updates-diff --no-updates') // TODO: after task Paparam flag relationships +test.todo('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.todo('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('pear shift ', async function ({ plan, is, teardown }) { + plan(3) + + const relativePath = path.relative(harness, minimal) + + const testId1 = Math.floor(Math.random() * 100000) + const argvInit1 = ['stage', '--json', `test-${testId1}`, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit1)}) + `, { returnByValue: false }) + + let staged1 + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') staged1 = result.data + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.close() + await stager1.until.exit + + const testId2 = Math.floor(Math.random() * 100000) + const argvInit2 = ['stage', '--json', `test-${testId2}`, relativePath] + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit2)}) + `, { returnByValue: false }) + + let staged2 + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') staged2 = result.data + if (result.tag === 'final') break + } + + const pearDir = (await stager2.inspector.evaluate('Pear.config.pearDir')).value + + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.close() + await stager2.until.exit + + const storageDir = path.join(pearDir, 'app-storage', 'by-dkey') + const appStorage1 = path.join(storageDir, discoveryKey(parseLink(staged1.link).drive.key).toString('hex')) + const appStorage2 = path.join(storageDir, discoveryKey(parseLink(staged2.link).drive.key).toString('hex')) + + fs.mkdirSync(appStorage1, { recursive: true }) + fs.writeFileSync(path.join(appStorage1, 'test.txt'), 'test') + teardown(async () => { + await fs.promises.rm(appStorage1, { recursive: true }).catch(() => {}) + await fs.promises.rm(appStorage2, { recursive: true }).catch(() => {}) + }) + + const argv = ['shift', staged1.link, staged2.link] + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let shiftSuccess = false + for await (const line of running.lineout) { + if (line.endsWith('Success')) { + shiftSuccess = true + break + } + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(shiftSuccess, true, 'should successfully shift app storage') + is(fs.existsSync(path.join(appStorage2, 'test.txt')), true, 'should move app storage file to destination') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear shift --json ', async function ({ plan, is, alike, teardown }) { + plan(3) + + const relativePath = path.relative(harness, minimal) + + const testId1 = Math.floor(Math.random() * 100000) + const argvInit1 = ['stage', '--json', `test-${testId1}`, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit1)}) + `, { returnByValue: false }) + + let staged1 + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') staged1 = result.data + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.close() + await stager1.until.exit + + const testId2 = Math.floor(Math.random() * 100000) + const argvInit2 = ['stage', '--json', `test-${testId2}`, relativePath] + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit2)}) + `, { returnByValue: false }) + + let staged2 + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') staged2 = result.data + if (result.tag === 'final') break + } + + const pearDir = (await stager2.inspector.evaluate('Pear.config.pearDir')).value + + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.close() + await stager2.until.exit + + const storageDir = path.join(pearDir, 'app-storage', 'by-dkey') + const appStorage1 = path.join(storageDir, discoveryKey(parseLink(staged1.link).drive.key).toString('hex')) + const appStorage2 = path.join(storageDir, discoveryKey(parseLink(staged2.link).drive.key).toString('hex')) + + fs.mkdirSync(appStorage1, { recursive: true }) + fs.writeFileSync(path.join(appStorage1, 'test.txt'), 'test') + teardown(async () => { + await fs.promises.rm(appStorage1, { recursive: true }).catch(() => {}) + await fs.promises.rm(appStorage2, { recursive: true }).catch(() => {}) + }) + + const argv = ['shift', '--json', staged1.link, staged2.link] + 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, ['moving', 'stdout', 'complete', 'final'], 'should output correct tags') + is(fs.existsSync(path.join(appStorage2, 'test.txt')), true, 'should move app storage file to destination') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear shift --force ', async function ({ plan, is, teardown }) { + plan(4) + + const relativePath = path.relative(harness, minimal) + + const testId1 = Math.floor(Math.random() * 100000) + const argvInit1 = ['stage', '--json', `test-${testId1}`, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit1)}) + `, { returnByValue: false }) + + let staged1 + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') staged1 = result.data + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.close() + await stager1.until.exit + + const testId2 = Math.floor(Math.random() * 100000) + const argvInit2 = ['stage', '--json', `test-${testId2}`, relativePath] + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit2)}) + `, { returnByValue: false }) + + let staged2 + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') staged2 = result.data + if (result.tag === 'final') break + } + + const pearDir = (await stager2.inspector.evaluate('Pear.config.pearDir')).value + + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.close() + await stager2.until.exit + + const storageDir = path.join(pearDir, 'app-storage', 'by-dkey') + const appStorage1 = path.join(storageDir, discoveryKey(parseLink(staged1.link).drive.key).toString('hex')) + const appStorage2 = path.join(storageDir, discoveryKey(parseLink(staged2.link).drive.key).toString('hex')) + + fs.mkdirSync(appStorage1, { recursive: true }) + fs.mkdirSync(appStorage2, { recursive: true }) + fs.writeFileSync(path.join(appStorage1, 'test.txt'), 'test') + fs.writeFileSync(path.join(appStorage2, 'testold.txt'), 'test') + teardown(async () => { + await fs.promises.rm(appStorage1, { recursive: true }).catch(() => {}) + await fs.promises.rm(appStorage2, { recursive: true }).catch(() => {}) + }) + + const argv = ['shift', '--force', staged1.link, staged2.link] + const running = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await running.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argv)}) + `, { returnByValue: false }) + + let shiftSuccess = false + for await (const line of running.lineout) { + if (line.endsWith('Success')) { + shiftSuccess = true + break + } + } + await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) + await running.inspector.close() + + is(shiftSuccess, true, 'should successfully shift app storage') + is(fs.existsSync(path.join(appStorage2, 'test.txt')), true, 'should move app storage file to destination') + is(fs.existsSync(path.join(appStorage2, 'testold.txt')), false, 'should delete existing app storage file at destination') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +test('pear shift --force --json ', async function ({ plan, is, teardown, alike }) { + plan(4) + + const relativePath = path.relative(harness, minimal) + + const testId1 = Math.floor(Math.random() * 100000) + const argvInit1 = ['stage', '--json', `test-${testId1}`, relativePath] + const stager1 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager1.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit1)}) + `, { returnByValue: false }) + + let staged1 + for await (const line of stager1.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') staged1 = result.data + if (result.tag === 'final') break + } + + await stager1.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager1.inspector.close() + await stager1.until.exit + + const testId2 = Math.floor(Math.random() * 100000) + const argvInit2 = ['stage', '--json', `test-${testId2}`, relativePath] + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + await stager2.inspector.evaluate(` + __PEAR_TEST__.command(${JSON.stringify(argvInit2)}) + `, { returnByValue: false }) + + let staged2 + for await (const line of stager2.lineout) { + const result = JSON.parse(line) + if (result.tag === 'addendum') staged2 = result.data + if (result.tag === 'final') break + } + + const pearDir = (await stager2.inspector.evaluate('Pear.config.pearDir')).value + + await stager2.inspector.evaluate('__PEAR_TEST__.ipc.destroy()', { returnByValue: false }) + await stager2.inspector.close() + await stager2.until.exit + + const storageDir = path.join(pearDir, 'app-storage', 'by-dkey') + const appStorage1 = path.join(storageDir, discoveryKey(parseLink(staged1.link).drive.key).toString('hex')) + const appStorage2 = path.join(storageDir, discoveryKey(parseLink(staged2.link).drive.key).toString('hex')) + + fs.mkdirSync(appStorage1, { recursive: true }) + fs.mkdirSync(appStorage2, { recursive: true }) + fs.writeFileSync(path.join(appStorage1, 'test.txt'), 'test') + fs.writeFileSync(path.join(appStorage2, 'testold.txt'), 'test') + teardown(async () => { + await fs.promises.rm(appStorage1, { recursive: true }).catch(() => {}) + await fs.promises.rm(appStorage2, { recursive: true }).catch(() => {}) + }) + + const argv = ['shift', '--force', '--json', staged1.link, staged2.link] + 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, ['moving', 'stdout', 'complete', 'final'], 'should output correct tags') + is(fs.existsSync(path.join(appStorage2, 'test.txt')), true, 'should move app storage file to destination') + is(fs.existsSync(path.join(appStorage2, 'testold.txt')), false, 'should delete existing app storage file at destination') + const { code } = await running.until.exit + is(code, 0, 'should have exit code 0') +}) + +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 cd8d04d2812858d4646f7df6081d8383ba31f643 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Wed, 21 Aug 2024 21:29:08 +0800 Subject: [PATCH 02/10] Remove stdout from expected tags --- 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 6440d5dc2..1ce7f428f 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -380,7 +380,7 @@ test('pear shift --json ', async function ({ plan, is, ali await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) await running.inspector.close() - alike(tags, ['moving', 'stdout', 'complete', 'final'], 'should output correct tags') + alike(tags, ['moving', 'complete', 'final'], 'should output correct tags') is(fs.existsSync(path.join(appStorage2, 'test.txt')), true, 'should move app storage file to destination') const { code } = await running.until.exit is(code, 0, 'should have exit code 0') @@ -539,7 +539,7 @@ test('pear shift --force --json ', async function ({ plan, await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) await running.inspector.close() - alike(tags, ['moving', 'stdout', 'complete', 'final'], 'should output correct tags') + alike(tags, ['moving', 'complete', 'final'], 'should output correct tags') is(fs.existsSync(path.join(appStorage2, 'test.txt')), true, 'should move app storage file to destination') is(fs.existsSync(path.join(appStorage2, 'testold.txt')), false, 'should delete existing app storage file at destination') const { code } = await running.until.exit From ffaecd9fdad1b82b267e5745da8cba080c83ed58 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Thu, 29 Aug 2024 20:42:10 +0800 Subject: [PATCH 03/10] Use localdev to run tests --- test/05-commands.test.js | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 1ce7f428f..db386fc66 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -9,14 +9,13 @@ 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() + setup = async ({ comment, timeout }) => { + timeout(180000) + this.platformDir = path.join(Helper.root, 'pear') + const helper = new Helper({ platformDir: this.platformDir }) + this.helper = 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') + await helper.ready() } cleanup = async ({ comment }) => { @@ -37,7 +36,7 @@ test('pear stage --json ', async function ({ plan, alike, is }) { 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)}) @@ -239,7 +238,7 @@ test('pear shift ', async function ({ plan, is, teardown } const testId1 = Math.floor(Math.random() * 100000) const argvInit1 = ['stage', '--json', `test-${testId1}`, 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(argvInit1)}) `, { returnByValue: false }) @@ -257,7 +256,7 @@ test('pear shift ', async function ({ plan, is, teardown } const testId2 = Math.floor(Math.random() * 100000) const argvInit2 = ['stage', '--json', `test-${testId2}`, relativePath] - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit2)}) `, { returnByValue: false }) @@ -287,7 +286,7 @@ test('pear shift ', async function ({ plan, is, teardown } }) const argv = ['shift', staged1.link, staged2.link] - 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 }) @@ -315,7 +314,7 @@ test('pear shift --json ', async function ({ plan, is, ali const testId1 = Math.floor(Math.random() * 100000) const argvInit1 = ['stage', '--json', `test-${testId1}`, 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(argvInit1)}) `, { returnByValue: false }) @@ -333,7 +332,7 @@ test('pear shift --json ', async function ({ plan, is, ali const testId2 = Math.floor(Math.random() * 100000) const argvInit2 = ['stage', '--json', `test-${testId2}`, relativePath] - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit2)}) `, { returnByValue: false }) @@ -363,7 +362,7 @@ test('pear shift --json ', async function ({ plan, is, ali }) const argv = ['shift', '--json', staged1.link, staged2.link] - 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 }) @@ -393,7 +392,7 @@ test('pear shift --force ', async function ({ plan, is, te const testId1 = Math.floor(Math.random() * 100000) const argvInit1 = ['stage', '--json', `test-${testId1}`, 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(argvInit1)}) `, { returnByValue: false }) @@ -411,7 +410,7 @@ test('pear shift --force ', async function ({ plan, is, te const testId2 = Math.floor(Math.random() * 100000) const argvInit2 = ['stage', '--json', `test-${testId2}`, relativePath] - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit2)}) `, { returnByValue: false }) @@ -443,7 +442,7 @@ test('pear shift --force ', async function ({ plan, is, te }) const argv = ['shift', '--force', staged1.link, staged2.link] - 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 }) @@ -472,7 +471,7 @@ test('pear shift --force --json ', async function ({ plan, const testId1 = Math.floor(Math.random() * 100000) const argvInit1 = ['stage', '--json', `test-${testId1}`, 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(argvInit1)}) `, { returnByValue: false }) @@ -490,7 +489,7 @@ test('pear shift --force --json ', async function ({ plan, const testId2 = Math.floor(Math.random() * 100000) const argvInit2 = ['stage', '--json', `test-${testId2}`, relativePath] - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit2)}) `, { returnByValue: false }) @@ -522,7 +521,7 @@ test('pear shift --force --json ', async function ({ plan, }) const argv = ['shift', '--force', '--json', staged1.link, staged2.link] - 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 }) From 49fbd0966b68e6062e592d6dd0585c5043fe29e7 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Tue, 10 Sep 2024 22:58:24 +0800 Subject: [PATCH 04/10] Increase timeout of pear shift tests --- test/05-commands.test.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index db386fc66..25a040453 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -231,8 +231,9 @@ test.todo('pear dump --checkout staged pear:// ') test.todo('pear dump --checkout release pear:// ') test.todo('pear dump --json pear:// ') -test('pear shift ', async function ({ plan, is, teardown }) { +test('pear shift ', async function ({ plan, is, teardown, timeout }) { plan(3) + timeout(180000) const relativePath = path.relative(harness, minimal) @@ -307,8 +308,9 @@ test('pear shift ', async function ({ plan, is, teardown } is(code, 0, 'should have exit code 0') }) -test('pear shift --json ', async function ({ plan, is, alike, teardown }) { +test('pear shift --json ', async function ({ plan, is, alike, teardown, timeout }) { plan(3) + timeout(180000) const relativePath = path.relative(harness, minimal) @@ -385,8 +387,9 @@ test('pear shift --json ', async function ({ plan, is, ali is(code, 0, 'should have exit code 0') }) -test('pear shift --force ', async function ({ plan, is, teardown }) { +test('pear shift --force ', async function ({ plan, is, teardown, timeout }) { plan(4) + timeout(180000) const relativePath = path.relative(harness, minimal) @@ -464,8 +467,9 @@ test('pear shift --force ', async function ({ plan, is, te is(code, 0, 'should have exit code 0') }) -test('pear shift --force --json ', async function ({ plan, is, teardown, alike }) { +test('pear shift --force --json ', async function ({ plan, is, teardown, timeout, alike }) { plan(4) + timeout(180000) const relativePath = path.relative(harness, minimal) From 55244028d924643882b3c3807bf87e4483086bdf Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Thu, 12 Sep 2024 12:02:11 +0800 Subject: [PATCH 05/10] Remove platformDir since we now have tests running with staged localdev --- test/05-commands.test.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 25a040453..36bdcb16f 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -11,8 +11,7 @@ const minimal = path.join(Helper.root, 'test', '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() @@ -36,7 +35,7 @@ test('pear stage --json ', async function ({ plan, alike, is }) { 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)}) @@ -239,7 +238,7 @@ test('pear shift ', async function ({ plan, is, teardown, const testId1 = Math.floor(Math.random() * 100000) const argvInit1 = ['stage', '--json', `test-${testId1}`, 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(argvInit1)}) `, { returnByValue: false }) @@ -257,7 +256,7 @@ test('pear shift ', async function ({ plan, is, teardown, const testId2 = Math.floor(Math.random() * 100000) const argvInit2 = ['stage', '--json', `test-${testId2}`, relativePath] - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit2)}) `, { returnByValue: false }) @@ -287,7 +286,7 @@ test('pear shift ', async function ({ plan, is, teardown, }) const argv = ['shift', staged1.link, staged2.link] - 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 }) @@ -316,7 +315,7 @@ test('pear shift --json ', async function ({ plan, is, ali const testId1 = Math.floor(Math.random() * 100000) const argvInit1 = ['stage', '--json', `test-${testId1}`, 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(argvInit1)}) `, { returnByValue: false }) @@ -334,7 +333,7 @@ test('pear shift --json ', async function ({ plan, is, ali const testId2 = Math.floor(Math.random() * 100000) const argvInit2 = ['stage', '--json', `test-${testId2}`, relativePath] - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit2)}) `, { returnByValue: false }) @@ -364,7 +363,7 @@ test('pear shift --json ', async function ({ plan, is, ali }) const argv = ['shift', '--json', staged1.link, staged2.link] - 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 }) @@ -395,7 +394,7 @@ test('pear shift --force ', async function ({ plan, is, te const testId1 = Math.floor(Math.random() * 100000) const argvInit1 = ['stage', '--json', `test-${testId1}`, 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(argvInit1)}) `, { returnByValue: false }) @@ -413,7 +412,7 @@ test('pear shift --force ', async function ({ plan, is, te const testId2 = Math.floor(Math.random() * 100000) const argvInit2 = ['stage', '--json', `test-${testId2}`, relativePath] - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit2)}) `, { returnByValue: false }) @@ -445,7 +444,7 @@ test('pear shift --force ', async function ({ plan, is, te }) const argv = ['shift', '--force', staged1.link, staged2.link] - 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 }) @@ -475,7 +474,7 @@ test('pear shift --force --json ', async function ({ plan, const testId1 = Math.floor(Math.random() * 100000) const argvInit1 = ['stage', '--json', `test-${testId1}`, 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(argvInit1)}) `, { returnByValue: false }) @@ -493,7 +492,7 @@ test('pear shift --force --json ', async function ({ plan, const testId2 = Math.floor(Math.random() * 100000) const argvInit2 = ['stage', '--json', `test-${testId2}`, relativePath] - const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true, platformDir: rig.platformDir }) + const stager2 = await Helper.open(harness, { tags: ['exit'] }, { lineout: true }) await stager2.inspector.evaluate(` __PEAR_TEST__.command(${JSON.stringify(argvInit2)}) `, { returnByValue: false }) @@ -525,7 +524,7 @@ test('pear shift --force --json ', async function ({ plan, }) const argv = ['shift', '--force', '--json', staged1.link, staged2.link] - 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 }) From fb101c3b69c78333352ce49fea0432ab1435b0d3 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Thu, 12 Sep 2024 12:18:30 +0800 Subject: [PATCH 06/10] Remove exit code checks --- test/05-commands.test.js | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/test/05-commands.test.js b/test/05-commands.test.js index 36bdcb16f..e7804b7fb 100644 --- a/test/05-commands.test.js +++ b/test/05-commands.test.js @@ -28,8 +28,8 @@ const rig = new Rig() test('commands setup', rig.setup) -test('pear stage --json ', async function ({ plan, alike, is }) { - plan(2) +test('pear stage --json ', async function ({ plan, alike }) { + plan(1) const testId = Math.floor(Math.random() * 100000) @@ -53,8 +53,7 @@ test('pear stage --json ', async function ({ plan, alike, is }) { await running.inspector.evaluate('__PEAR_TEST__.ipc.close()', { returnByValue: false }) await running.inspector.close() alike(tags, ['staging', 'byte-diff', 'summary', 'skipping', 'complete', 'addendum', 'final']) - const { code } = await running.until.exit - is(code, 0) + await running.until.exit }) test.todo('pear stage ') test.todo('pear stage ') @@ -231,7 +230,7 @@ test.todo('pear dump --checkout release pear:// ') test.todo('pear dump --json pear:// ') test('pear shift ', async function ({ plan, is, teardown, timeout }) { - plan(3) + plan(2) timeout(180000) const relativePath = path.relative(harness, minimal) @@ -298,17 +297,16 @@ test('pear shift ', async function ({ plan, is, teardown, 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(shiftSuccess, true, 'should successfully shift app storage') is(fs.existsSync(path.join(appStorage2, 'test.txt')), true, 'should move app storage file to destination') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear shift --json ', async function ({ plan, is, alike, teardown, timeout }) { - plan(3) + plan(2) timeout(180000) const relativePath = path.relative(harness, minimal) @@ -377,17 +375,16 @@ test('pear shift --json ', async function ({ plan, is, ali 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, ['moving', 'complete', 'final'], 'should output correct tags') is(fs.existsSync(path.join(appStorage2, 'test.txt')), true, 'should move app storage file to destination') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear shift --force ', async function ({ plan, is, teardown, timeout }) { - plan(4) + plan(3) timeout(180000) const relativePath = path.relative(harness, minimal) @@ -456,18 +453,17 @@ test('pear shift --force ', async function ({ plan, is, te 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(shiftSuccess, true, 'should successfully shift app storage') is(fs.existsSync(path.join(appStorage2, 'test.txt')), true, 'should move app storage file to destination') is(fs.existsSync(path.join(appStorage2, 'testold.txt')), false, 'should delete existing app storage file at destination') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test('pear shift --force --json ', async function ({ plan, is, teardown, timeout, alike }) { - plan(4) + plan(3) timeout(180000) const relativePath = path.relative(harness, minimal) @@ -538,14 +534,13 @@ test('pear shift --force --json ', async function ({ plan, 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, ['moving', 'complete', 'final'], 'should output correct tags') is(fs.existsSync(path.join(appStorage2, 'test.txt')), true, 'should move app storage file to destination') is(fs.existsSync(path.join(appStorage2, 'testold.txt')), false, 'should delete existing app storage file at destination') - const { code } = await running.until.exit - is(code, 0, 'should have exit code 0') + await running.until.exit }) test.todo('pear gc releases') From 9d8838a98c0db4b046ad2376ca11eba955b014c1 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Wed, 25 Sep 2024 04:01:22 +0800 Subject: [PATCH 07/10] Rename commands test prefix from 05 to 07 and add it to runTests --- test/{05-commands.test.js => 07-commands.test.js} | 0 test/index.js | 1 + 2 files changed, 1 insertion(+) 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 diff --git a/test/index.js b/test/index.js index 89ed01323..ad6c2b061 100644 --- a/test/index.js +++ b/test/index.js @@ -13,6 +13,7 @@ async function runTests () { await import('./04-worker.test.js') await import('./05-encrypted.test.js') await import('./06-updates.test.js') + await import('./07-commands.test.js') test.resume() } From 92a15271b1d5d3faf3c258aa732d9f589cc8433d Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Wed, 25 Sep 2024 04:01:39 +0800 Subject: [PATCH 08/10] Use Helper.localDir instead of Helper.root --- test/07-commands.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/07-commands.test.js b/test/07-commands.test.js index e7804b7fb..6f620a575 100644 --- a/test/07-commands.test.js +++ b/test/07-commands.test.js @@ -5,8 +5,8 @@ const { discoveryKey } = require('hypercore-crypto') const fs = require('bare-fs') const parseLink = require('../lib/parse-link') -const harness = path.join(Helper.root, 'test', 'fixtures', 'harness') -const minimal = path.join(Helper.root, 'test', 'fixtures', 'minimal') +const harness = path.join(Helper.localDir, 'test', 'fixtures', 'harness') +const minimal = path.join(Helper.localDir, 'test', 'fixtures', 'minimal') class Rig { setup = async ({ comment, timeout }) => { From 1a02ba3e4f1365d08e78a16eed1eb3de0183357e Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Wed, 25 Sep 2024 09:09:59 +0800 Subject: [PATCH 09/10] 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 71d2b8966..700fac9a4 100644 --- a/test/fixtures/harness/index.js +++ b/test/fixtures/harness/index.js @@ -40,7 +40,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 9541b58502da531739fb81ba426489d604093079 Mon Sep 17 00:00:00 2001 From: Jan Keith Darunday Date: Wed, 25 Sep 2024 11:43:35 +0800 Subject: [PATCH 10/10] Cleanup todos --- test/07-commands.test.js | 210 --------------------------------------- 1 file changed, 210 deletions(-) diff --git a/test/07-commands.test.js b/test/07-commands.test.js index 6f620a575..673d6d4e2 100644 --- a/test/07-commands.test.js +++ b/test/07-commands.test.js @@ -28,207 +28,6 @@ const rig = new Rig() test('commands setup', rig.setup) -test('pear stage --json ', async function ({ plan, alike }) { - plan(1) - - 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']) - await running.until.exit -}) -test.todo('pear stage ') -test.todo('pear stage ') -test.todo('pear stage (package.json pear.config.stage.entrypoints )') -test.todo('pear stage (package.json pear.config.stage.ignore )') -test.todo('pear stage --json ') -test.todo('pear stage --dry-run ') -test.todo('pear stage --dry-run --json ') -test.todo('pear stage --bare ') -test.todo('pear stage --bare --json ') -test.todo('pear stage --ignore ') -test.todo('pear stage --ignore --json ') -test.todo('pear stage --truncate ') -test.todo('pear stage --truncate --json ') -test.todo('pear stage --name ') -test.todo('pear stage --name --json ') -test.todo('pear stage --ignore --name ') -test.todo('pear stage --ignore --name --json ') -test.todo('pear stage --dry-run --bare --ignore --truncate --name ') -test.todo('pear stage --dry-run --bare --ignore --truncate --name --json ') -test.todo('pear stage pear://') -test.todo('pear stage --json pear://') -test.todo('pear stage --dry-run pear://') -test.todo('pear stage --dry-run --json pear://') -test.todo('pear stage --bare pear://') -test.todo('pear stage --bare --json pear://') -test.todo('pear stage --ignore pear://') -test.todo('pear stage --ignore --json pear://') -test.todo('pear stage --truncate pear://') -test.todo('pear stage --truncate --json pear://') -test.todo('pear stage --name pear://') -test.todo('pear stage --name --json pear://') -test.todo('pear stage --ignore --name pear://') -test.todo('pear stage --ignore --name --json pear://') -test.todo('pear stage --dry-run --bare --ignore --truncate --name pear://') -test.todo('pear stage --dry-run --bare --ignore --truncate --name --json pear://') - -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.todo('pear run --updates-diff --no-updates') // TODO: after task Paparam flag relationships -test.todo('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.todo('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('pear shift ', async function ({ plan, is, teardown, timeout }) { plan(2) timeout(180000) @@ -543,13 +342,4 @@ test('pear shift --force --json ', async function ({ plan, await running.until.exit }) -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)