Unverified Commit dd85daaf authored by OJ Kwon's avatar OJ Kwon Committed by GitHub

test(turbopack): script to sync latest test lists (#50008)

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

This PR adjusts manifests for the next.js test with Turbopack, as I
found upstream test keep changing and need to sync its latests state
into the manifest.

Manifest is now .js file contains 2 arrays, one for the enabled, and
others for the disabled. Disabled doesn't mean it's always failing
though.
parent 66a00832
......@@ -828,7 +828,7 @@ jobs:
NEXT_BINDINGS_BIN: /work/packages/next-swc/native/next-swc.linux-x64-gnu.node
# Glob pattern to run specific tests with --turbo.
NEXT_DEV_TEST_GLOB: '*'
NEXT_EXTERNAL_TESTS_FILTERS: /work/packages/next-swc/crates/next-dev-tests/tests-manifest.json
NEXT_EXTERNAL_TESTS_FILTERS: /work/packages/next-swc/crates/next-dev-tests/tests-manifest.js
strategy:
fail-fast: false
......
/// 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))
This diff is collapsed.
[
"test/development/acceptance-app/dynamic-error.test.ts",
"test/development/basic/legacy-decorators.test.ts",
"test/integration/plugin-mdx-rs/test/index.test.js",
"test/e2e/app-dir/underscore-ignore-app-paths/underscore-ignore-app-paths.test.ts",
"test/e2e/postcss-config-cjs/index.test.ts"
]
......@@ -15,7 +15,7 @@ const exec = promisify(execOrig)
// Try to read an external array-based json to filter tests to be executed.
// If process.argv contains a test to be executed, this'll append it to the list.
const externalTestsFilterLists = process.env.NEXT_EXTERNAL_TESTS_FILTERS
? require(process.env.NEXT_EXTERNAL_TESTS_FILTERS)
? require(process.env.NEXT_EXTERNAL_TESTS_FILTERS).enabledTests
: []
const timings = []
const DEFAULT_NUM_RETRIES = os.platform() === 'win32' ? 2 : 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment