Skip to content

Commit

Permalink
Introduce next-dev-tests to rebuild automatically on test input chang…
Browse files Browse the repository at this point in the history
…es (#3288)

I verified that the crate is rebuilt if I make a change of inputs.

Co-authored-by: Tobias Koppers <[email protected]>
  • Loading branch information
kdy1 and sokra authored Jan 20, 2023
1 parent 0a1fe68 commit dc54647
Show file tree
Hide file tree
Showing 167 changed files with 117 additions and 33 deletions.
40 changes: 36 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ members = [
"crates/next-core",
"crates/next-dev",
"crates/next-transform-dynamic",
"crates/next-dev-tests",
"crates/next-transform-strip-page-exports",
"crates/node-file-trace",
"crates/swc-ast-explorer",
Expand Down
50 changes: 50 additions & 0 deletions crates/next-dev-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[package]
name = "next-dev-tests"
version = "0.1.0"
description = "TBD"
license = "MPL-2.0"
edition = "2021"
autobenches = false

# don't publish this crate
publish = false

[dev-dependencies]
anyhow = "1.0.47"
chromiumoxide = { version = "0.4.0", features = [
"tokio-runtime",
], default-features = false }
futures = "0.3.25"
httpmock = { version = "0.6.6", features = ["standalone"] }
lazy_static = "1.4.0"
mime = "0.3.16"
next-core = { path = "../next-core" }
next-dev = { path = "../next-dev" }
once_cell = "1.13.0"
owo-colors = "3"
parking_lot = "0.12.1"
rand = "0.8.5"
regex = "1.6.0"
serde = "1.0.136"
serde_json = "1.0.85"
test-generator = "0.3.0"
tokio = { version = "1.21.2", features = ["full"] }
# For matching on errors from chromiumoxide. Keep in
# sync with chromiumoxide's tungstenite requirement.
tungstenite = "0.17.3"
turbo-malloc = { path = "../turbo-malloc", default-features = false, features = [
"custom_allocator",
] }
turbo-tasks = { path = "../turbo-tasks" }
turbo-tasks-fs = { path = "../turbo-tasks-fs" }
turbo-tasks-memory = { path = "../turbo-tasks-memory" }
turbo-tasks-testing = { path = "../turbo-tasks-testing" }
turbopack-cli-utils = { path = "../turbopack-cli-utils" }
turbopack-core = { path = "../turbopack-core" }
turbopack-dev-server = { path = "../turbopack-dev-server" }
turbopack-node = { path = "../turbopack-node" }
url = "2.2.2"
webbrowser = "0.7.1"

[build-dependencies]
turbo-tasks-build = { path = "../turbo-tasks-build" }
8 changes: 8 additions & 0 deletions crates/next-dev-tests/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use turbo_tasks_build::rerun_if_glob;

fn main() {
// The test/integration crate need to be rebuilt if any test input is changed.
// Unfortunately, we can't have the build.rs file operate differently on
// each file, so the entire next-dev crate needs to be rebuilt.
rerun_if_glob("tests/integration/*/*", "tests/integration");
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ struct JestTestResult {

lazy_static! {
// Allows for interactive manual debugging of a test case in a browser with:
// `TURBOPACK_DEBUG_BROWSER=1 cargo test -p next-dev -- test_my_pattern --nocapture`
// `TURBOPACK_DEBUG_BROWSER=1 cargo test -p next-dev-tests -- test_my_pattern --nocapture`
static ref DEBUG_BROWSER: bool = env::var("TURBOPACK_DEBUG_BROWSER").is_ok();
}

#[test_resources("crates/next-dev/tests/integration/*/*/*")]
#[test_resources("crates/next-dev-tests/tests/integration/*/*/*")]
#[tokio::main(flavor = "current_thread")]
async fn test(resource: &str) {
if resource.ends_with("__skipped__") || resource.ends_with("__flakey__") {
Expand Down Expand Up @@ -90,7 +90,7 @@ async fn test(resource: &str) {
};
}

#[test_resources("crates/next-dev/tests/integration/*/*/__skipped__/*")]
#[test_resources("crates/next-dev-tests/tests/integration/*/*/__skipped__/*")]
#[should_panic]
#[tokio::main]
async fn test_skipped_fails(resource: &str) {
Expand All @@ -114,7 +114,7 @@ async fn run_test(resource: &str) -> JestRunResult {
let path = Path::new(resource)
// test_resources matches and returns relative paths from the workspace root,
// but pwd in cargo tests is the crate under test.
.strip_prefix("crates/next-dev")
.strip_prefix("crates/next-dev-tests")
.unwrap();
assert!(path.exists(), "{} does not exist", resource);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function runTests() {
it("returns structured data about the font styles from the font function", () => {
expect(interNoArgs).toEqual({
className:
"className◽[project-with-next]/crates/next-dev/tests/integration/next/font-google/basic/[embedded_modules]/@vercel/turbopack-next/internal/font/google/inter_34ab8b4d.module.css",
"className◽[project-with-next]/crates/next-dev-tests/tests/integration/next/font-google/basic/[embedded_modules]/@vercel/turbopack-next/internal/font/google/inter_34ab8b4d.module.css",
style: {
fontFamily: "'__Inter_34ab8b4d'",
fontStyle: "normal",
Expand Down
File renamed without changes.
4 changes: 0 additions & 4 deletions crates/next-dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,13 @@ chromiumoxide = { version = "0.4.0", features = [
"tokio-runtime",
], default-features = false }
criterion = { version = "0.4.0", features = ["async_tokio"] }
fs_extra = "1.2.0"
httpmock = { version = "0.6.6", features = ["standalone"] }
lazy_static = "1.4.0"
once_cell = "1.13.0"
parking_lot = "0.12.1"
portpicker = "0.1.1"
rand = "0.8.5"
regex = "1.6.0"
serde_json = "1.0.85"
tempfile = "3.3.0"
test-generator = "0.3.0"
# For matching on errors from chromiumoxide. Keep in
# sync with chromiumoxide's tungstenite requirement.
tungstenite = "0.17.3"
Expand Down
35 changes: 16 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ packages:
# Intentionally exclude the `npm` `turbo` package from the workspaces.
- "!packages/turbo"
- "packages/turbo-tracing-next-plugin/test/with-mongodb-mongoose"
- "crates/next-dev/tests"
- "crates/next-dev/test-harness"
- "crates/next-dev-tests/tests"
- "crates/*/js"

1 comment on commit dc54647

@vercel
Copy link

@vercel vercel bot commented on dc54647 Jan 20, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.