Skip to content

Commit

Permalink
Remove .test.js from dist (#55946)
Browse files Browse the repository at this point in the history
Noticed a couple of directories had unit tests in `dist` which are being
run and reported during the Turbopack runs. These are generally quite
small so I'm not expecting this to have much effect on the package size
or CI runs, just making sure the data is correct.
<!-- 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

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating 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 #

-->
  • Loading branch information
timneutkens committed Sep 25, 2023
1 parent 82eb6e6 commit 60af196
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 155 deletions.
59 changes: 45 additions & 14 deletions packages/next/taskfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2451,26 +2451,43 @@ export async function server_esm(task, opts) {

export async function nextbuild(task, opts) {
await task
.source('src/build/**/!(*.test).+(js|ts|tsx)', {
ignore: ['**/fixture/**', '**/tests/**', '**/jest/**'],
.source('src/build/**/*.+(js|ts|tsx)', {
ignore: [
'**/fixture/**',
'**/tests/**',
'**/jest/**',
'**/*.test.d.ts',
'**/*.test.+(js|ts|tsx)',
],
})
.swc('server', { dev: opts.dev })
.target('dist/build')
}

export async function nextbuild_esm(task, opts) {
await task
.source('src/build/**/!(*.test).+(js|ts|tsx)', {
ignore: ['**/fixture/**', '**/tests/**', '**/jest/**'],
.source('src/build/**/*.+(js|ts|tsx)', {
ignore: [
'**/fixture/**',
'**/tests/**',
'**/jest/**',
'**/*.test.d.ts',
'**/*.test.+(js|ts|tsx)',
],
})
.swc('server', { dev: opts.dev, esm: true })
.target('dist/esm/build')
}

export async function nextbuildjest(task, opts) {
await task
.source('src/build/jest/**/!(*.test).+(js|ts|tsx)', {
ignore: ['**/fixture/**', '**/tests/**'],
.source('src/build/jest/**/*.+(js|ts|tsx)', {
ignore: [
'**/fixture/**',
'**/tests/**',
'**/*.test.d.ts',
'**/*.test.+(js|ts|tsx)',
],
})
.swc('server', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/build/jest')
Expand Down Expand Up @@ -2641,26 +2658,37 @@ export default async function (task) {

export async function shared(task, opts) {
await task
.source(
'src/shared/**/!(amp|config|constants|dynamic|app-dynamic|head|runtime-config).+(js|ts|tsx)'
)
.source('src/shared/**/*.+(js|ts|tsx)', {
ignore: [
'src/shared/**/{amp,config,constants,dynamic,app-dynamic,head,runtime-config}.+(js|ts|tsx)',
'**/*.test.d.ts',
'**/*.test.+(js|ts|tsx)',
],
})
.swc('client', { dev: opts.dev })
.target('dist/shared')
}

export async function shared_esm(task, opts) {
await task
.source(
'src/shared/**/!(amp|config|constants|dynamic|app-dynamic|head).+(js|ts|tsx)'
)
.source('src/shared/**/*.+(js|ts|tsx)', {
ignore: [
'src/shared/**/{amp,config,constants,dynamic,app-dynamic,head,runtime-config}.+(js|ts|tsx)',
'**/*.test.d.ts',
'**/*.test.+(js|ts|tsx)',
],
})
.swc('client', { dev: opts.dev, esm: true })
.target('dist/esm/shared')
}

export async function shared_re_exported(task, opts) {
await task
.source(
'src/shared/**/{amp,config,constants,dynamic,app-dynamic,head,runtime-config}.+(js|ts|tsx)'
'src/shared/**/{amp,config,constants,dynamic,app-dynamic,head,runtime-config}.+(js|ts|tsx)',
{
ignore: ['**/*.test.d.ts', '**/*.test.+(js|ts|tsx)'],
}
)
.swc('client', { dev: opts.dev, interopClientDefaultExport: true })
.target('dist/shared')
Expand All @@ -2669,7 +2697,10 @@ export async function shared_re_exported(task, opts) {
export async function shared_re_exported_esm(task, opts) {
await task
.source(
'src/shared/**/{amp,config,constants,app-dynamic,dynamic,head}.+(js|ts|tsx)'
'src/shared/**/{amp,config,constants,app-dynamic,dynamic,head}.+(js|ts|tsx)',
{
ignore: ['**/*.test.d.ts', '**/*.test.+(js|ts|tsx)'],
}
)
.swc('client', {
dev: opts.dev,
Expand Down
59 changes: 24 additions & 35 deletions test/build-turbopack-tests-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,31 @@ async function updatePassingTests() {
const runtimeError = result.data.numRuntimeErrorTestSuites > 0
for (const testResult of result.data.testResults) {
const filepath = stripWorkingPath(testResult.name)
for (const file of duplicateFileNames(filepath)) {
if (SKIPPED_TEST_SUITES.has(file)) continue
const fileResults = (passing[file] ??= {
passed: [],
failed: [],
pending: [],
runtimeError,
})

let initializationFailed = false
for (const testCase of testResult.assertionResults) {
let { fullName, status } = testCase
if (
status === 'failed' &&
INITIALIZING_TEST_CASES.some((name) => fullName.includes(name))
) {
initializationFailed = true
} else if (initializationFailed) {
status = 'failed'
}
const statusArray = fileResults[status]
if (!statusArray) {
throw new Error(`unexpected status "${status}"`)
}
statusArray.push(fullName)

if (SKIPPED_TEST_SUITES.has(filepath)) continue
const fileResults = (passing[filepath] ??= {
passed: [],
failed: [],
pending: [],
runtimeError,
})

let initializationFailed = false
for (const testCase of testResult.assertionResults) {
let { fullName, status } = testCase
if (
status === 'failed' &&
INITIALIZING_TEST_CASES.some((name) => fullName.includes(name))
) {
initializationFailed = true
} else if (initializationFailed) {
status = 'failed'
}
const statusArray = fileResults[status]
if (!statusArray) {
throw new Error(`unexpected status "${status}"`)
}
statusArray.push(fullName)
}
}
}
Expand Down Expand Up @@ -137,14 +136,4 @@ function stripWorkingPath(path) {
return path.slice(WORKING_PATH.length)
}

function duplicateFileNames(path) {
if (path.includes('/src/')) {
const dist = path.replace('/src/', '/dist/').replace(/.tsx?$/, '.js')
if (fs.existsSync(`${__dirname}/../${dist}`)) {
return [path, dist]
}
}
return [path]
}

updatePassingTests()
108 changes: 2 additions & 106 deletions test/turbopack-tests-manifest.json
Original file line number Diff line number Diff line change
@@ -1,108 +1,4 @@
{
"packages/font/dist/google/find-font-files-in-css.test.js": {
"passed": [
"findFontFilesInCss should find all font files and preload requested subsets",
"findFontFilesInCss should not return duplicate font files when several variants use the same font file"
],
"failed": [],
"pending": [],
"runtimeError": false
},
"packages/font/dist/google/get-font-axes.test.js": {
"passed": [
"getFontAxes errors Invalid axes value",
"getFontAxes errors Invalid value in axes array",
"getFontAxes errors Setting axes on font without definable axes"
],
"failed": [],
"pending": [],
"runtimeError": false
},
"packages/font/dist/google/loader.test.js": {
"passed": [
"next/font/google loader URL from options Albert_Sans",
"next/font/google loader URL from options Ballet",
"next/font/google loader URL from options Fraunces",
"next/font/google loader URL from options Inter",
"next/font/google loader URL from options Molle",
"next/font/google loader URL from options Nabla",
"next/font/google loader URL from options Oooh_Baby",
"next/font/google loader URL from options Poppins",
"next/font/google loader URL from options Roboto",
"next/font/google loader URL from options Roboto Mono",
"next/font/google loader URL from options Roboto_Flex",
"next/font/google loader URL from options Source_Sans_3"
],
"failed": [],
"pending": [],
"runtimeError": false
},
"packages/font/dist/google/sort-fonts-variant-values.test.js": {
"passed": [
"sortFontsVariantValues should correctly compare and return result for comma-separated values",
"sortFontsVariantValues should correctly compare and return result for plain integer values",
"sortFontsVariantValues should sort an array of plain integer values correctly",
"sortFontsVariantValues should sort an array of values with comma-separated values correctly"
],
"failed": [],
"pending": [],
"runtimeError": false
},
"packages/font/dist/google/validate-google-font-function-call.test.js": {
"passed": [
"validateFontFunctionCall errors Invalid display value",
"validateFontFunctionCall errors Invalid subset in call",
"validateFontFunctionCall errors Missing function name",
"validateFontFunctionCall errors Missing subsets in config and call",
"validateFontFunctionCall errors Missing weight for non variable font",
"validateFontFunctionCall errors Setting axes on non variable font",
"validateFontFunctionCall errors Unknown font",
"validateFontFunctionCall errors Unknown style",
"validateFontFunctionCall errors Unknown weight",
"validateFontFunctionCall errors Variable in weight array"
],
"failed": [],
"pending": [],
"runtimeError": false
},
"packages/font/dist/local/loader.test.js": {
"passed": [
"next/font/local loader generated CSS Default CSS",
"next/font/local loader generated CSS Multiple styles default weight",
"next/font/local loader generated CSS Multiple weights default style",
"next/font/local loader generated CSS Other properties",
"next/font/local loader generated CSS Weight and style"
],
"failed": [],
"pending": [],
"runtimeError": false
},
"packages/font/dist/local/pick-font-file-for-fallback-generation.test.js": {
"passed": [
"pickFontFileForFallbackGeneration Invalid variable weight in array",
"pickFontFileForFallbackGeneration should error on invalid weight in array",
"pickFontFileForFallbackGeneration should pick the thinner weight if both have the same distance to 400",
"pickFontFileForFallbackGeneration should pick the weight closest to 400",
"pickFontFileForFallbackGeneration should pick variable range closest to 400",
"pickFontFileForFallbackGeneration should prefer normal style over italic"
],
"failed": [],
"pending": [],
"runtimeError": false
},
"packages/font/dist/local/validate-local-font-function-call.test.js": {
"passed": [
"validateLocalFontFunctionCall Empty src array",
"validateLocalFontFunctionCall Invalid declaration",
"validateLocalFontFunctionCall Invalid display value",
"validateLocalFontFunctionCall Invalid file extension",
"validateLocalFontFunctionCall Missing src",
"validateLocalFontFunctionCall Not using default export"
],
"failed": [],
"pending": [],
"runtimeError": false
},
"packages/font/src/google/find-font-files-in-css.test.ts": {
"passed": [
"findFontFilesInCss should find all font files and preload requested subsets",
Expand Down Expand Up @@ -848,14 +744,14 @@
"ReactRefreshLogBox app turbo Should not show __webpack_exports__ when exporting anonymous arrow function",
"ReactRefreshLogBox app turbo Unhandled errors and rejections opens up in the minimized state",
"ReactRefreshLogBox app turbo boundaries",
"ReactRefreshLogBox app turbo client component can recover from error thrown in the module",
"ReactRefreshLogBox app turbo module init error not shown",
"ReactRefreshLogBox app turbo server component can recover from error thrown in the module",
"ReactRefreshLogBox app turbo should strip whitespace correctly with newline"
],
"failed": [
"ReactRefreshLogBox app turbo Call stack count is correct for client error",
"ReactRefreshLogBox app turbo Call stack count is correct for server error",
"ReactRefreshLogBox app turbo client component can recover from error thrown in the module",
"ReactRefreshLogBox app turbo conversion to class component (1)",
"ReactRefreshLogBox app turbo css syntax errors",
"ReactRefreshLogBox app turbo logbox: anchors links in error messages",
Expand Down Expand Up @@ -7136,7 +7032,6 @@
"Dynamic Routing production mode should allow calling Router.push on mount successfully",
"Dynamic Routing production mode should handle only hash on dynamic route",
"Dynamic Routing production mode should handle only query on dynamic route",
"Dynamic Routing production mode should have correct cache entries on prefetch",
"Dynamic Routing production mode should navigate optional dynamic page",
"Dynamic Routing production mode should navigate optional dynamic page with value",
"Dynamic Routing production mode should not error when requesting dynamic page with /api",
Expand Down Expand Up @@ -7176,6 +7071,7 @@
"Dynamic Routing production mode [ssg: catch-all] should pass params in getStaticProps during client navigation (multi) no as",
"Dynamic Routing production mode [ssg: catch-all] should pass params in getStaticProps during client navigation (single interpolated)",
"Dynamic Routing production mode [ssg: catch-all] should pass params in getStaticProps during client navigation (single)",
"Dynamic Routing production mode should have correct cache entries on prefetch",
"Dynamic Routing production mode should navigate to a dynamic page successfully",
"Dynamic Routing production mode should navigate to a dynamic page successfully interpolated",
"Dynamic Routing production mode should navigate to a dynamic page successfully interpolated with additional query values",
Expand Down

0 comments on commit 60af196

Please sign in to comment.