From 62ccde8b013e509e2f4520665c9886fb1e28b7b1 Mon Sep 17 00:00:00 2001 From: Lars Kappert Date: Sun, 7 Apr 2024 16:34:57 +0200 Subject: [PATCH] Support, organize & pick tests to run tests in Bun + Node --- .github/workflows/ci-bun.yml | 4 +++- .github/workflows/ci-ts-latest.yml | 4 +--- .github/workflows/ci.yml | 5 +---- bun.lockb | Bin 486544 -> 486576 bytes knip.ts | 1 + packages/knip/package.json | 2 ++ .../knip/test/plugins/lefthook-v1.test.ts | 5 ++++- .../test/self-reference-from-plugin.test.ts | 4 +++- .../test/workspaces-self-reference.test.ts | 4 +++- packages/knip/transform-test.js | 13 +++++++++++++ 10 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 packages/knip/transform-test.js diff --git a/.github/workflows/ci-bun.yml b/.github/workflows/ci-bun.yml index b847e80ed..4392e6759 100644 --- a/.github/workflows/ci-bun.yml +++ b/.github/workflows/ci-bun.yml @@ -22,8 +22,10 @@ jobs: steps: - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v1 + # With the lockfile, Bun collapses over the `sharp` dependency in docs + - run: rm bun.lockb - name: Install dependencies - run: bun install --frozen-lockfile + run: bun install - name: Build knip run: bun run build working-directory: packages/knip diff --git a/.github/workflows/ci-ts-latest.yml b/.github/workflows/ci-ts-latest.yml index c80288054..c3347ecfb 100644 --- a/.github/workflows/ci-ts-latest.yml +++ b/.github/workflows/ci-ts-latest.yml @@ -22,10 +22,8 @@ jobs: - name: Build knip run: npm run build working-directory: packages/knip - - name: QA (format, lint, organize imports) - run: npm run ci - name: Test knip - run: npm run test + run: npm run test:node working-directory: packages/knip - name: Run knip run: npx knip diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 878585dca..c217314db 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,8 +39,5 @@ jobs: - name: Run knip (production/strict) run: npx knip --production --strict - name: Test knip - run: npm run test + run: npm run test:node working-directory: packages/knip - - name: Build docs - run: npm run build - working-directory: pack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 zB0r-3cGi3FKKv8b!zx$363j2bSqjB&StcN$CIV^^Sa1V@! z3D6J<8}ZT@nm{$kgL2>m`g_;}@4{QK9yY)O@E~~etR>VV{xkXm{Ae25f{S2}0e{uu z3m8hTodtcsi8=Q-3R7RvO*_EF*)DZ|2@au0KHz93(vV4TE#!lrnA z!RHi5QR!y<55Z>zo8cu`4#Ozpvw~VwUKzZle-C&c-+S~&Qui~|JrunCeK@p+HgKfp zzX|wbgZWS%3g9bt4H=H<+3h2DPkCXDw+2eVxd;;vSo4$e!RbNYh|tgyk@hbZQDvtggw9;eqU0i4!C~0OB{Fu(tVOgR`ZV$_v=#Cz}s;irnk{LLl>CC=5wJO z@h>>OEwB|f!Y1$znUmss;XarSPKdqlP}1?+KhD$bqb=<7BkvWiCURd;m!0(?-WUAs z#a$fd5AY-W1m4K{1ybZyNB4$&ws{*~h5O+Ivb`B~GW3Uzc>6@A-nJ;#+@r|H_s0|-=ZK$#;-fne|0M9%kGFc(fwywJ zb@LxRR)}GDy~56Ifc!v9H^L$qPQ!|a>Hy*c;TPxtO`!>R*1acF+`wWjZbY%#qtCLh z+*4CnJT@1QVdk&3J4fODk>VpPuB-xGUm0wiL$Mk98jU!Qvgbl^xnli~qh>!bPTFRF z{$nnN*Z_ak`AP7+mei#;d-sEI(ERgW$#f_)f6lth*aHhr^*= { +skipIf('Find dependencies with the lefthook v1 plugin', async () => { const CI = process.env.CI; process.env.CI = ''; await fs.rename(join(cwd, '_git'), join(cwd, '.git')); // Can't add .git folder to repo diff --git a/packages/knip/test/self-reference-from-plugin.test.ts b/packages/knip/test/self-reference-from-plugin.test.ts index 171b5cd15..51954f119 100644 --- a/packages/knip/test/self-reference-from-plugin.test.ts +++ b/packages/knip/test/self-reference-from-plugin.test.ts @@ -5,9 +5,11 @@ import { resolve } from '../src/util/path.js'; import baseArguments from './helpers/baseArguments.js'; import baseCounters from './helpers/baseCounters.js'; +const skipIf = typeof Bun !== 'undefined' ? test.skip : test; + const cwd = resolve('fixtures/self-reference-from-plugin'); -test.skip('Allows self-references from plugin', async () => { +skipIf('Allows self-references from plugin', async () => { const { counters } = await main({ ...baseArguments, cwd, diff --git a/packages/knip/test/workspaces-self-reference.test.ts b/packages/knip/test/workspaces-self-reference.test.ts index 8f28e7e0a..5f0677007 100644 --- a/packages/knip/test/workspaces-self-reference.test.ts +++ b/packages/knip/test/workspaces-self-reference.test.ts @@ -5,7 +5,9 @@ import { resolve } from '../src/util/path.js'; import baseArguments from './helpers/baseArguments.js'; import baseCounters from './helpers/baseCounters.js'; -test.skip('Find unused files, dependencies and exports in workspaces with cross self-references', async () => { +const skipIf = typeof Bun !== 'undefined' ? test.skip : test; + +skipIf('Find unused files, dependencies and exports in workspaces with cross self-references', async () => { const cwd = resolve('fixtures/workspaces-self-reference'); const { counters } = await main({ diff --git a/packages/knip/transform-test.js b/packages/knip/transform-test.js new file mode 100644 index 000000000..f3f7de011 --- /dev/null +++ b/packages/knip/transform-test.js @@ -0,0 +1,13 @@ +import { readFile } from 'node:fs/promises'; +import module from 'node:module'; + +module.register('./transform-test.js', { parentURL: import.meta.url }); + +export async function load(url, context, next) { + if (url.endsWith('.test.ts')) { + const content = await readFile(new URL(url), 'utf8'); + const source = content.replace(/import { test } from 'bun:test';/, `import test from 'node:test';`); + return next(url, { ...context, source }); + } + return next(url, context); +}