From d86aab4bc0c8a4f4256a5ecc4ea05fa32fb2a649 Mon Sep 17 00:00:00 2001 From: unsc9 <438590997@qq.com> Date: Fri, 6 Nov 2026 14:51:39 +0800 Subject: [PATCH] =?UTF-8?q?test(archive):=20=E5=90=88=E5=B9=B6=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E7=9A=84=20argv=20=E6=96=AD=E8=A8=80=EF=BC=8C?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=86=97=E4=BD=99=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/archive-tools.spec.ts | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/tests/archive-tools.spec.ts b/tests/archive-tools.spec.ts index 6743e632..c12afdc4 100644 --- a/tests/archive-tools.spec.ts +++ b/tests/archive-tools.spec.ts @@ -192,7 +192,11 @@ describe('planArchive', () => { const ws = join(PLAN_ROOT, 'ws') const plan = planArchive([join(ws, 'src', 'index.ts'), join(ws, 'lib', 'util.ts')], spec) expect(plan.cwd).toBe(ws) + expect(plan.args.slice(0, spec.flags.length)).toEqual([...spec.flags]) + expect(plan.args).not.toContain('--') expect(plan.args.slice(spec.flags.length)).toEqual(['./src/index.ts', './lib/util.ts']) + // The `-` stdout archive name must stay in flags, ahead of every operand. + expect(plan.args[spec.flags.length - 1]).toBe('-') // The separator is normalized whatever the platform produced: the tool // gets in-archive names, not host paths. expect(plan.args.every(arg => !arg.includes('\\'))).toBe(true) @@ -214,6 +218,7 @@ describe('planArchive', () => { const spec = await specOf('tar') const plan = planArchive([join(PLAN_ROOT, 'ws', 'notes.md')], spec) expect(plan.args).toEqual(['-czf', '-', '--', 'notes.md']) + expect(plan.args.indexOf('--')).toBe(spec.flags.length) expect(plan.spec.ext).toBe('.tar.gz') }) @@ -257,23 +262,6 @@ describe('planArchive', () => { expect(thrown).toMatchObject({ code: 'bad-request' }) }) - it('pins the tar argv shape: `--` between flags and operands', async () => { - const spec = await specOf('tar') - const plan = planArchive([join(PLAN_ROOT, 'ws', 'notes.md')], spec) - expect(plan.args).toEqual(['-czf', '-', '--', 'notes.md']) - expect(plan.args.indexOf('--')).toBe(spec.flags.length) - }) - - it('pins the zip argv shape: `./` operands, no `--` (zip 3.0 has no portable `--`)', async () => { - const spec = await specOf('zip') - const ws = join(PLAN_ROOT, 'ws') - const plan = planArchive([join(ws, 'src', 'index.ts'), join(ws, 'lib', 'util.ts')], spec) - expect(plan.args.slice(0, spec.flags.length)).toEqual([...spec.flags]) - expect(plan.args).not.toContain('--') - expect(plan.args.slice(spec.flags.length)).toEqual(['./src/index.ts', './lib/util.ts']) - // The `-` stdout archive name must stay in flags, ahead of every operand. - expect(plan.args[spec.flags.length - 1]).toBe('-') - }) }) describe('archiveFileName', () => {