Skip to content

Commit 7cf9362

Browse files
committed
test-utils: Use serial_test re-export in tags macro
Now you don't need to remember to add `serial_test` to your `Cargo.toml`, just `test-utils`. Change-Id: I22be02666681bed7a3a581c86c2f4949f7965240 Reviewed-on: https://gerrit.readyset.name/c/readyset/+/9563 Tested-by: Buildkite CI Reviewed-by: Johnathan Davis <[email protected]>
1 parent d56fcee commit 7cf9362

File tree

15 files changed

+20
-31
lines changed

15 files changed

+20
-31
lines changed

Cargo.lock

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

data-generator/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ readyset-data = { path = "../readyset-data/" }
2424
test-strategy = { workspace = true }
2525
proptest = { workspace = true }
2626
mysql_async = { workspace = true }
27-
serial_test = { workspace = true }
2827
tokio = { workspace = true, features = ["full"] }
2928
test-utils = { path = "../test-utils" }
3029

dataflow-expression/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ postgres = { workspace = true, features = [
4343
] }
4444
readyset-sql-parsing = { path = "../readyset-sql-parsing" }
4545
regex = { workspace = true }
46-
serial_test = { workspace = true }
4746
test-utils = { path = "../test-utils" }
4847
tokio = { workspace = true, features = ["full"] }
4948
tokio-postgres = { workspace = true, features = [

psql-srv/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ readyset-tracing = { path = "../readyset-tracing" }
5959
postgres-native-tls = { workspace = true }
6060
criterion = { workspace = true, features = ["html_reports"] }
6161
test-utils = { path = "../test-utils" }
62-
serial_test = { workspace = true }
6362

6463
[[bench]]
6564
name = "parse"

query-generator/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ readyset-util = { path = "../readyset-util" }
2626

2727
[dev-dependencies]
2828
mysql_async.workspace = true
29-
serial_test = { workspace = true }
3029
tokio = { workspace = true, features = ["full"] }
3130
tokio-postgres.workspace = true
3231
test-utils = { path = "../test-utils" }

readyset-client/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ readyset-sql-passes = { path = "../readyset-sql-passes" }
8181
replication-offset = { path = "../replication-offset" }
8282

8383
[dev-dependencies]
84-
serial_test = { workspace = true }
8584
tempfile = { workspace = true }
8685
test-utils = { path = "../test-utils" }
8786

readyset-clustertest/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ readyset-client-metrics = { path = "../readyset-client-metrics" }
3737
readyset-clustertest-macros = { path = "./macros" }
3838
readyset-tracing = { path = "../readyset-tracing" }
3939
rust_decimal = { workspace = true }
40-
serial_test = { workspace = true }
4140
test-utils = { path = "../test-utils" }
4241

4342
[build-dependencies]

readyset-data/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ features = [
6666
derive_more = { workspace = true }
6767
bincode = { workspace = true }
6868
criterion = { workspace = true, features = ["async_tokio"] }
69-
serial_test = { workspace = true }
7069
tokio = { workspace = true, features = ["full"] }
7170
test-utils = { path = "../test-utils" }
7271

readyset-e2e-tests/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ readyset-client-test-helpers = { path = "../readyset-client-test-helpers", featu
2323
readyset-tracing = { path = "../readyset-tracing" }
2424
readyset-sql = { path = "../readyset-sql" }
2525
readyset-util = { path = "../readyset-util" }
26-
serial_test = { workspace = true }
2726
test-strategy = { workspace = true }
2827
test-utils = { path = "../test-utils" }
2928
tokio = { workspace = true, features = ["full"] }

readyset-mysql/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ readyset-client-metrics = { path = "../readyset-client-metrics" }
2626
tokio = { workspace = true, features = ["full"] }
2727
tracing = { workspace = true, features = ["release_max_level_debug"] }
2828
thiserror = { workspace = true }
29-
mysql_common = { workspace = true, features = ["bigdecimal","binlog"] }
29+
mysql_common = { workspace = true, features = ["bigdecimal", "binlog"] }
3030
itertools = { workspace = true }
3131
readyset-sql = { path = "../readyset-sql" }
3232
readyset-util = { path = "../readyset-util" }
@@ -40,7 +40,6 @@ readyset-telemetry-reporter = { path = "../readyset-telemetry-reporter", feature
4040
"test-util",
4141
] }
4242
readyset-server = { path = "../readyset-server" }
43-
serial_test = { workspace = true }
4443
test-utils = { path = "../test-utils" }
4544
chrono = { workspace = true }
4645
futures = { workspace = true }

readyset-psql/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ criterion = { workspace = true, features = ["async_tokio"] }
5959
readyset-sql-parsing = { path = "../readyset-sql-parsing" }
6060
readyset-tracing = { path = "../readyset-tracing" }
6161
test-utils = { path = "../test-utils" }
62-
serial_test = { workspace = true }
6362

6463
[[bench]]
6564
name = "proxy"

readyset/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ criterion = { workspace = true, features = ["html_reports"] }
5757
futures = { workspace = true }
5858
pprof = { workspace = true, features = ["flamegraph", "criterion"] }
5959
readyset-sql-parsing = { path = "../readyset-sql-parsing" }
60-
serial_test = { workspace = true }
6160
temp-dir = { workspace = true }
6261
test-utils = { path = "../test-utils" }
6362

replicators/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bit-vec = { workspace = true, features = ["serde"] }
2626
serde = { workspace = true, features = ["derive"] }
2727
nom_locate = { workspace = true }
2828
deadpool-postgres = { workspace = true }
29-
mysql_common = { workspace = true, features = ["binlog"] }
29+
mysql_common = { workspace = true, features = ["binlog"] }
3030

3131
tokio-postgres = { workspace = true, features = [
3232
"with-chrono-0_4",
@@ -38,7 +38,7 @@ postgres-types = { workspace = true, features = [
3838
] }
3939
postgres-native-tls = { workspace = true }
4040
postgres-protocol = { workspace = true }
41-
mysql_async = { workspace = true}
41+
mysql_async = { workspace = true }
4242

4343
nom-sql = { path = "../nom-sql" }
4444
readyset-client = { path = "../readyset-client" }
@@ -57,7 +57,6 @@ readyset-telemetry-reporter = { path = "../readyset-telemetry-reporter" }
5757
replication-offset = { path = "../replication-offset" }
5858

5959
[dev-dependencies]
60-
serial_test = { workspace = true }
6160
test-utils = { path = "../test-utils" }
6261
readyset-server = { path = "../readyset-server" }
6362
readyset-telemetry-reporter = { path = "../readyset-telemetry-reporter", features = [

test-utils/proc-macros/src/lib.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,28 @@ pub fn tags(args: TokenStream, item: TokenStream) -> TokenStream {
175175
}
176176

177177
// Special handling for `serial`: add the in-process mutex from `serial_test`
178-
if tags.iter().any(|tag| tag == "serial") {
178+
let uses_serial = tags.iter().any(|tag| tag == "serial");
179+
if uses_serial {
179180
let serial_attr = parse_quote! {
180-
#[serial_test::serial(#serial_groups)]
181+
#[::test_utils::serial_test::serial(#serial_groups)]
181182
};
182183
item.attrs.push(serial_attr);
183184
}
184185

185186
let test_name = mem::replace(&mut item.sig.ident, Ident::new("test", Span::call_site()));
186187
tags.insert(0, test_name);
187188

188-
let mut out = quote! {
189-
#item
189+
// In addition to adding the attribute, we also need to make `serial_test` resolve in scope,
190+
// because the macro adds a call out to the crate for a runtime function.
191+
let mut out = if uses_serial {
192+
quote! {
193+
use ::test_utils::serial_test;
194+
#item
195+
}
196+
} else {
197+
quote! {
198+
#item
199+
}
190200
};
191201

192202
for group in tags.into_iter().rev() {

test-utils/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
44
pub use test_utils_proc_macros::{skip_flaky_finder, slow, tags};
55

6+
// Re-export serial_test so we only need to add `readyset_utils` to `Cargo.toml` for packages that
7+
// use it.
68
pub use serial_test;
9+
710
/// Returns `false` if slow tests should not run, otherwise returns `true`.
811
pub fn skip_slow_tests() -> bool {
912
let should_skip = std::env::var("RUN_SLOW_TESTS").is_err();

0 commit comments

Comments
 (0)