-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(turbopack): script to sync latest test lists
- Loading branch information
Showing
5 changed files
with
795 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/next-swc/crates/next-dev-tests/sync-tests-manifest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/// A script to remove / add next.js tests into the lists if there are any changes. | ||
|
||
const fs = require('fs') | ||
const _glob = require('glob') | ||
const { promisify } = require('util') | ||
const glob = promisify(_glob) | ||
const path = require('path') | ||
|
||
const generateManifest = (enabledTests, disabledTests) => ` | ||
// Tests that are currently enabled with Turbopack in CI. | ||
// Add new test when Turbopack updates to fix / implement a feature. | ||
const enabledTests = ${enabledTests} | ||
// Tests that are currently disabled with Turbopack in CI. | ||
const disabledTests = ${disabledTests} | ||
module.exports = { | ||
enabledTests, | ||
disabledTests, | ||
}` | ||
|
||
const main = async () => { | ||
// Read existing manifests | ||
let enabledTests = [] | ||
let disabledTests = [] | ||
|
||
const manifestPath = path.resolve(__dirname, 'tests-manifest.js') | ||
if (fs.existsSync(manifestPath)) { | ||
const manifest = require(manifestPath) | ||
enabledTests = manifest.enabledTests | ||
disabledTests = manifest.disabledTests | ||
} else { | ||
throw new Error('a') | ||
} | ||
|
||
// Collect all test files | ||
const testFiles = ( | ||
await glob('**/*.test.{js,ts,tsx}', { | ||
nodir: true, | ||
cwd: path.resolve(__dirname, '../../../../test'), | ||
}) | ||
).map((file) => `test/${file}`) | ||
|
||
// Naively update enabled / disabled tests to the latest. | ||
// This is not the most efficient way to do this, but it's good enough for now. | ||
|
||
// First, remove enabled tests that are no longer in the test directory. | ||
enabledTests = enabledTests.filter((testFile) => testFiles.includes(testFile)) | ||
// Anything else are disabled. | ||
disabledTests = testFiles.filter( | ||
(testFile) => !enabledTests.includes(testFile) | ||
) | ||
|
||
fs.writeFileSync( | ||
manifestPath, | ||
generateManifest( | ||
JSON.stringify(enabledTests, null, 2), | ||
JSON.stringify(disabledTests, null, 2) | ||
), | ||
'utf-8' | ||
) | ||
} | ||
|
||
main().catch((e) => console.error(e)) |
Oops, something went wrong.