Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic @next/font/google integration test #3170

Merged
merged 38 commits into from Jan 19, 2023

Conversation

wbinnssmith
Copy link
Member

@wbinnssmith wbinnssmith commented Jan 4, 2023

This:

  • Implements a basic http server to mock returning a stylesheet from the Google Fonts API (Note: This importantly does not mock returning the font resources themselves, which are currently loaded by the browser. We should implement something to do this when we implement caching arbitrary http resources traced from url() and this is no longer loaded by the test browser)
  • Adds an integration test that asserts the basic shape of the JS object returned by font functions
  • Adds an integration test that asserts the browser correctly loads a font for the ascii unicode range, along with the appropriate font-display, variant, etc. Unfortunately document.fonts is not reliable with different font-display loading patterns as any of them can fall back.

As noted, this does not mock responses from Google for the font resources themselves, which are currently loaded by the test browser. This means that we'll be dependent on this external service for passing integration tests until we implement caching of url()s in Turbopack. We should monitor the reliability of this test.

@wbinnssmith wbinnssmith requested a review from a team as a code owner January 4, 2023 00:39
@vercel
Copy link

vercel bot commented Jan 4, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
examples-designsystem-docs 🔄 Building (Inspect) Visit Preview Jan 19, 2023 at 8:55PM (UTC)
9 Ignored Deployments
Name Status Preview Comments Updated
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Jan 19, 2023 at 8:55PM (UTC)
examples-cra-web ⬜️ Ignored (Inspect) Visit Preview Jan 19, 2023 at 8:55PM (UTC)
examples-kitchensink-blog ⬜️ Ignored (Inspect) Jan 19, 2023 at 8:55PM (UTC)
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Jan 19, 2023 at 8:55PM (UTC)
examples-nonmonorepo ⬜️ Ignored (Inspect) Visit Preview Jan 19, 2023 at 8:55PM (UTC)
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Jan 19, 2023 at 8:55PM (UTC)
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Jan 19, 2023 at 8:55PM (UTC)
turbo-site ⬜️ Ignored (Inspect) Visit Preview Jan 19, 2023 at 8:55PM (UTC)
turbo-vite-web ⬜️ Ignored (Inspect) Visit Preview Jan 19, 2023 at 8:55PM (UTC)

if font_dir.exists() {
let server = create_font_server(&font_dir);
env::set_var(
"TURBOPACK_TEST_ONLY_GOOGLE_FONTS_STYLESHEET_URL",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be okay with the way cargo test/cargo nexttest run tests in parallel, with multiple threads but only one test running in serial within the thread (see unsetting this value below)

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2023

🟢 CI successful 🟢

Thanks

@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2023

Benchmark for 32f99d1

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 7907.71µs ± 66.17µs 8003.00µs ± 48.14µs +1.20%
bench_hmr_to_commit/Turbopack RCC/1000 modules 8173.27µs ± 88.71µs 8195.95µs ± 50.33µs +0.28%
bench_hmr_to_commit/Turbopack RSC/1000 modules 466.29ms ± 2.99ms 466.04ms ± 2.26ms -0.05%
bench_hmr_to_commit/Turbopack SSR/1000 modules 7948.67µs ± 38.90µs 7987.53µs ± 41.71µs +0.49%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7033.64µs ± 63.41µs 6968.40µs ± 38.77µs -0.93%
bench_hmr_to_eval/Turbopack RCC/1000 modules 7177.77µs ± 83.63µs 7203.46µs ± 59.78µs +0.36%
bench_hmr_to_eval/Turbopack SSR/1000 modules 7010.97µs ± 34.91µs 7104.57µs ± 36.91µs +1.34%
bench_hydration/Turbopack RCC/1000 modules 3305.40ms ± 13.97ms 3317.32ms ± 17.31ms +0.36%
bench_hydration/Turbopack RSC/1000 modules 2790.93ms ± 8.76ms 2797.40ms ± 8.09ms +0.23%
bench_hydration/Turbopack SSR/1000 modules 2628.09ms ± 10.65ms 2634.97ms ± 13.62ms +0.26%
bench_startup/Turbopack CSR/1000 modules 1626.22ms ± 3.11ms 1624.00ms ± 6.48ms -0.14%
bench_startup/Turbopack RCC/1000 modules 2508.40ms ± 6.65ms 2486.23ms ± 9.73ms -0.88%
bench_startup/Turbopack RSC/1000 modules 2358.25ms ± 7.08ms 2381.40ms ± 6.92ms +0.98%
bench_startup/Turbopack SSR/1000 modules 2043.92ms ± 6.44ms 2032.33ms ± 3.58ms -0.57%

@wbinnssmith wbinnssmith marked this pull request as draft January 4, 2023 02:49
@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2023

Benchmark for 49633dc

Test Base PR % Significant %
bench_hmr_to_commit/Turbopack RSC/1000 modules 464.15ms ± 1.42ms 455.47ms ± 2.08ms -1.87% -0.36%
bench_startup/Turbopack RSC/1000 modules 2329.91ms ± 7.35ms 2366.38ms ± 7.32ms +1.57% +0.30%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8011.15µs ± 79.65µs 7963.95µs ± 60.18µs -0.59%
bench_hmr_to_commit/Turbopack RCC/1000 modules 8215.82µs ± 54.37µs 8349.19µs ± 56.98µs +1.62%
bench_hmr_to_commit/Turbopack RSC/1000 modules 464.15ms ± 1.42ms 455.47ms ± 2.08ms -1.87% -0.36%
bench_hmr_to_commit/Turbopack SSR/1000 modules 8128.75µs ± 46.18µs 8096.05µs ± 52.30µs -0.40%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7017.00µs ± 42.97µs 7081.56µs ± 29.10µs +0.92%
bench_hmr_to_eval/Turbopack RCC/1000 modules 7230.44µs ± 79.03µs 7202.60µs ± 39.43µs -0.39%
bench_hmr_to_eval/Turbopack SSR/1000 modules 7108.35µs ± 64.05µs 7246.75µs ± 162.44µs +1.95%
bench_hydration/Turbopack RCC/1000 modules 3239.92ms ± 15.10ms 3255.98ms ± 13.18ms +0.50%
bench_hydration/Turbopack RSC/1000 modules 2749.53ms ± 8.10ms 2758.98ms ± 10.70ms +0.34%
bench_hydration/Turbopack SSR/1000 modules 2545.72ms ± 13.75ms 2580.04ms ± 5.44ms +1.35%
bench_startup/Turbopack CSR/1000 modules 1610.30ms ± 5.02ms 1601.85ms ± 5.25ms -0.52%
bench_startup/Turbopack RCC/1000 modules 2437.15ms ± 7.38ms 2457.58ms ± 13.00ms +0.84%
bench_startup/Turbopack RSC/1000 modules 2329.91ms ± 7.35ms 2366.38ms ± 7.32ms +1.57% +0.30%
bench_startup/Turbopack SSR/1000 modules 2005.02ms ± 4.17ms 2012.28ms ± 2.86ms +0.36%

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2023

Benchmark for 690d299

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8761.64µs ± 91.87µs 8814.47µs ± 81.88µs +0.60%
bench_hmr_to_commit/Turbopack RCC/1000 modules 9017.73µs ± 106.65µs 8898.34µs ± 71.55µs -1.32%
bench_hmr_to_commit/Turbopack RSC/1000 modules 482.84ms ± 3.09ms 487.52ms ± 1.06ms +0.97%
bench_hmr_to_commit/Turbopack SSR/1000 modules 8974.01µs ± 93.21µs 8995.93µs ± 82.72µs +0.24%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7826.80µs ± 67.69µs 7770.08µs ± 82.66µs -0.72%
bench_hmr_to_eval/Turbopack RCC/1000 modules 7949.46µs ± 80.20µs 7909.89µs ± 65.01µs -0.50%
bench_hmr_to_eval/Turbopack SSR/1000 modules 7894.73µs ± 84.96µs 7911.67µs ± 68.21µs +0.21%
bench_hydration/Turbopack RCC/1000 modules 3443.04ms ± 12.20ms 3467.47ms ± 11.82ms +0.71%
bench_hydration/Turbopack RSC/1000 modules 2922.77ms ± 11.31ms 2933.21ms ± 8.42ms +0.36%
bench_hydration/Turbopack SSR/1000 modules 2721.79ms ± 7.44ms 2724.81ms ± 9.72ms +0.11%
bench_startup/Turbopack CSR/1000 modules 1700.03ms ± 4.74ms 1685.04ms ± 8.03ms -0.88%
bench_startup/Turbopack RCC/1000 modules 2595.63ms ± 8.82ms 2615.96ms ± 11.07ms +0.78%
bench_startup/Turbopack RSC/1000 modules 2497.82ms ± 6.42ms 2507.77ms ± 4.84ms +0.40%
bench_startup/Turbopack SSR/1000 modules 2124.11ms ± 4.11ms 2120.11ms ± 4.74ms -0.19%

crates/next-dev/tests/integration.rs Outdated Show resolved Hide resolved
wbinnssmith and others added 3 commits January 9, 2023 15:06
Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
@github-actions
Copy link
Contributor

Benchmark for becd4c6

Test Base PR % Significant %
bench_hydration/Turbopack RSC/1000 modules 2717.56ms ± 8.90ms 2755.65ms ± 6.70ms +1.40% +0.25%
bench_startup/Turbopack RCC/1000 modules 2439.83ms ± 7.76ms 2473.83ms ± 5.58ms +1.39% +0.30%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8034.17µs ± 47.66µs 7857.08µs ± 43.68µs -2.20%
bench_hmr_to_commit/Turbopack RCC/1000 modules 8203.11µs ± 69.43µs 8273.07µs ± 78.78µs +0.85%
bench_hmr_to_commit/Turbopack RSC/1000 modules 458.51ms ± 3.42ms 459.43ms ± 2.38ms +0.20%
bench_hmr_to_commit/Turbopack SSR/1000 modules 8109.41µs ± 73.31µs 8084.49µs ± 85.06µs -0.31%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7072.41µs ± 53.71µs 7090.21µs ± 43.31µs +0.25%
bench_hmr_to_eval/Turbopack RCC/1000 modules 7111.89µs ± 121.95µs 7146.57µs ± 40.07µs +0.49%
bench_hmr_to_eval/Turbopack SSR/1000 modules 7048.22µs ± 46.53µs 7132.18µs ± 64.33µs +1.19%
bench_hydration/Turbopack RCC/1000 modules 3218.22ms ± 7.09ms 3250.55ms ± 9.53ms +1.00%
bench_hydration/Turbopack RSC/1000 modules 2717.56ms ± 8.90ms 2755.65ms ± 6.70ms +1.40% +0.25%
bench_hydration/Turbopack SSR/1000 modules 2575.97ms ± 10.81ms 2603.66ms ± 9.23ms +1.08%
bench_startup/Turbopack CSR/1000 modules 1606.70ms ± 4.64ms 1618.51ms ± 5.28ms +0.74%
bench_startup/Turbopack RCC/1000 modules 2439.83ms ± 7.76ms 2473.83ms ± 5.58ms +1.39% +0.30%
bench_startup/Turbopack RSC/1000 modules 2377.09ms ± 9.55ms 2386.25ms ± 9.69ms +0.39%
bench_startup/Turbopack SSR/1000 modules 2025.25ms ± 3.81ms 2022.86ms ± 5.49ms -0.12%

@github-actions
Copy link
Contributor

Benchmark for 7bc2b92

Test Base PR % Significant %
bench_startup/Turbopack RCC/1000 modules 2553.01ms ± 8.77ms 2512.45ms ± 8.56ms -1.59% -0.23%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8701.55µs ± 77.16µs 8739.13µs ± 43.02µs +0.43%
bench_hmr_to_commit/Turbopack RCC/1000 modules 8983.17µs ± 49.11µs 8944.33µs ± 87.55µs -0.43%
bench_hmr_to_commit/Turbopack RSC/1000 modules 474.77ms ± 3.27ms 473.86ms ± 1.96ms -0.19%
bench_hmr_to_commit/Turbopack SSR/1000 modules 8927.36µs ± 50.44µs 8804.44µs ± 59.13µs -1.38%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7690.88µs ± 34.62µs 7654.92µs ± 67.62µs -0.47%
bench_hmr_to_eval/Turbopack RCC/1000 modules 7845.50µs ± 56.91µs 7845.57µs ± 60.10µs +0.00%
bench_hmr_to_eval/Turbopack SSR/1000 modules 7793.38µs ± 83.46µs 7749.28µs ± 50.20µs -0.57%
bench_hydration/Turbopack RCC/1000 modules 3346.84ms ± 9.12ms 3351.25ms ± 8.99ms +0.13%
bench_hydration/Turbopack RSC/1000 modules 2854.99ms ± 10.79ms 2836.70ms ± 11.32ms -0.64%
bench_hydration/Turbopack SSR/1000 modules 2663.83ms ± 4.23ms 2665.57ms ± 11.92ms +0.07%
bench_startup/Turbopack CSR/1000 modules 1643.16ms ± 4.73ms 1642.50ms ± 5.34ms -0.04%
bench_startup/Turbopack RCC/1000 modules 2553.01ms ± 8.77ms 2512.45ms ± 8.56ms -1.59% -0.23%
bench_startup/Turbopack RSC/1000 modules 2393.05ms ± 5.90ms 2395.67ms ± 6.35ms +0.11%
bench_startup/Turbopack SSR/1000 modules 2068.19ms ± 6.23ms 2050.10ms ± 7.55ms -0.87%

@wbinnssmith
Copy link
Member Author

@alexkirsz it looks like this test caught a regression from #3184, which made the next-font transform no longer run.

@kodiakhq kodiakhq bot merged commit 18075dd into main Jan 19, 2023
@kodiakhq kodiakhq bot deleted the wbinnssmith/font-google-integration-tests branch January 19, 2023 22:11
jridgewell pushed a commit to vercel/next.js that referenced this pull request Mar 10, 2023
This:

* Implements a basic http server to mock returning a stylesheet from the Google Fonts API (**Note**: This importantly does *not* mock returning the font resources themselves, which are currently loaded by the browser. We should implement something to do this when we implement caching arbitrary http resources traced from `url()` and this is no longer loaded by the test browser)
* Adds an integration test that asserts the basic shape of the JS object returned by font functions
* ~Adds an integration test that asserts the browser correctly loads a font for the ascii unicode range, along with the appropriate `font-display`, variant, etc.~ Unfortunately `document.fonts` is not reliable with different font-display loading patterns as any of them can fall back.

As noted, this does not mock responses from Google for the font resources themselves, which are currently loaded by the test browser. This means that we'll be dependent on this external service for passing integration tests until we implement caching of `url()`s in Turbopack. We should monitor the reliability of this test.
sokra pushed a commit to vercel/next.js that referenced this pull request Mar 13, 2023
This:

* Implements a basic http server to mock returning a stylesheet from the Google Fonts API (**Note**: This importantly does *not* mock returning the font resources themselves, which are currently loaded by the browser. We should implement something to do this when we implement caching arbitrary http resources traced from `url()` and this is no longer loaded by the test browser)
* Adds an integration test that asserts the basic shape of the JS object returned by font functions
* ~Adds an integration test that asserts the browser correctly loads a font for the ascii unicode range, along with the appropriate `font-display`, variant, etc.~ Unfortunately `document.fonts` is not reliable with different font-display loading patterns as any of them can fall back.

As noted, this does not mock responses from Google for the font resources themselves, which are currently loaded by the test browser. This means that we'll be dependent on this external service for passing integration tests until we implement caching of `url()`s in Turbopack. We should monitor the reliability of this test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: automerge Kodiak will merge these automatically after checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants