Skip to content

Commit ac74956

Browse files
committed
Evolve[Tests]: minitrace-tests
Signed-off-by: Mark Van de Vyver <[email protected]>
1 parent 1c5b9b8 commit ac74956

File tree

7 files changed

+42
-34
lines changed

7 files changed

+42
-34
lines changed

minitrace-tests/Cargo.toml

+9-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ edition = "2021"
1111
default = []
1212
ci = []
1313
as = ["async-std"]
14-
ea = ["embassy"]
14+
# ea = ["embassy"]
1515
tk = ["tokio"]
1616

1717
[lib]
1818

1919
# Avoid adding crates, this is widely used in tests. It should compile fast!
2020
[dependencies]
2121
async-std = { version = "1.11.0", features = ["attributes"], optional = true }
22-
embassy = { version = "0.1.0", path = "./embassy/embassy", features = ["defmt", "nightly"], optional = true }
22+
# embassy = { version = "0.1.0", path = "./embassy/embassy", features = ["defmt", "nightly"], optional = true }
2323
futures = "0.3.21"
2424
futures-timer = "3.0.2"
2525
macrotest = "1"
@@ -38,7 +38,13 @@ inventory = "0.2.2"
3838
# cargo test --features minitrace-tests/tk --manifest-path minitrace-tests/Cargo.toml default2 -- --nocapture
3939
#
4040
[[test]]
41-
name = "defaults-indev-tokio"
41+
name = "indev-tokio"
4242
path = "integration/indev.rs"
4343
harness = false
4444
required-features = ["tk"]
45+
46+
# [[test]]
47+
# name = "dev-tokio"
48+
# path = "src/main.rs"
49+
# harness = false
50+
# required-features = ["tk"]

minitrace-tests/README.md

+13-11
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,24 @@ fraught exercise to change this (working) test harness - here be dragons.
1111

1212
We aren't the first to bang our heads on this:
1313

14-
***Thanks to the [Fluvio project](https://github.com/infinyon/fluvio) team and
15-
[Infinyon](https://www.infinyon.com) for sharing the details about [how to do
16-
this](https://www.infinyon.com/blog/2021/04/rust-custom-test-harness/).***
14+
***
15+
Thanks to the following for [how to do this](https://www.infinyon.com/blog/2021/04/rust-custom-test-harness/)
16+
17+
- [Infinyon](https://www.infinyon.com) .
18+
- [Fluvio project](https://github.com/infinyon/fluvio)
19+
20+
***
1721

1822
## Developing against a test
1923

20-
1. Add the test file, say `build/issues/nnn.rs`.
24+
1. Add the test file, say `tests/issues/nnn.rs`.
2125
2. Point the in-development test runner to this file:
2226

2327
```rust
24-
// minitrace-tests/src/build/issues.rs
28+
// minitrace-tests/src/tests/issues.rs
2529
pub fn indev() {
2630
// To generate macro result files
27-
macrotest::expand("src/build/issues/nnn.rs");
31+
macrotest::expand("src/tests/issues/nnn.rs");
2832
build_indev();
2933
}
3034
```
@@ -34,16 +38,15 @@ this](https://www.infinyon.com/blog/2021/04/rust-custom-test-harness/).***
3438

3539
```bash
3640
cargo test --manifest-path minitrace-tests/Cargo.toml \
37-
build::issues::indev \
41+
tests::issues::indev \
3842
-- --nocapture
3943
```
4044

4145
or
4246

4347
```bash
4448
cd minitrace-tests
45-
cargo test build::issues::indev \
46-
-- --nocapture
49+
cargo test build::issues::indev -- --nocapture
4750
```
4851

4952
5. Iterate 3) and 4) until green.
@@ -58,8 +61,7 @@ Add several test cases (developed as above) in the issues category
5861
2. Generate the expanded Rust code:
5962

6063
```bash
61-
cargo test issues-dev-tokio \
62-
--no-fail-fast &>~/tmp/log.txt
64+
cargo test issues-dev-tokio --no-fail-fast &>~/tmp/log.txt
6365
```
6466

6567
3. Check the expanded code is as expected: `build/issues/nnn.expanded.rs`

minitrace-tests/integration/indev.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn teardown() {
1111
}
1212
// NOTE: This function is executed by `cargo test -- --list`.
1313
// Hence we guard it:
14-
#[cfg(any(feature = "as", feature = "ea", feature = "tk"))]
14+
#[cfg(any(feature = "as", feature = "tk"))]
1515
fn main() {
1616
// Setup test environment
1717
setup();

minitrace-tests/integration/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pub mod tests;
22

3-
use minitrace_tests::main_runtime;
4-
use minitrace_tests::main_tokio;
3+
// use minitrace_tests::main_runtime;
4+
// use minitrace_tests::main_tokio;
55
use tests::IntegrationTest;
66

77
fn setup() {
@@ -14,7 +14,7 @@ fn teardown() {
1414
// NOTE:
1515
// When this code is in src/main.rs, it is executed by `cargo test -- --list`.
1616
// In such cases you can guard it:
17-
// #[cfg(any(feature = "as", feature = "ea", feature = "tk"))]
17+
// #[cfg(any(feature = "as", feature = "tk"))]
1818
fn main() {
1919
// Setup test environment
2020
setup();

minitrace-tests/integration/tests/defaults.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ inventory::submit!(IntegrationTest {
1717
#[cfg(not(feature = "ci"))]
1818
pub fn indev() {
1919
// To generate macro result files
20-
let src = "src/tests/defaults/no-be-no-drop-local.rs";
21-
let srcx = "src/tests/defaults/no-be-no-drop-local.expanded.rs";
20+
let src = "integration/tests/defaults/no-be-no-drop-local.rs";
21+
let srcx = "integration/tests/defaults/no-be-no-drop-local.expanded.rs";
2222

2323
#[cfg(feature = "as")]
2424
macrotest::expand_args(src, &["--features", "minitrace-tests/as"]);
25-
#[cfg(feature = "ea")]
26-
macrotest::expand_args(src, &["--features", "minitrace-tests/ea"]);
25+
// #[cfg(feature = "ea")]
26+
// macrotest::expand_args(src, &["--features", "minitrace-tests/ea"]);
2727
#[cfg(feature = "tk")]
2828
macrotest::expand_args(
2929
src,
@@ -46,24 +46,24 @@ fn build_indev(src: &str) {
4646
#[cfg(not(feature = "ci"))]
4747
pub fn dev() {
4848
// To generate macro result files
49-
macrotest::expand("src/build/defaults/*.rs");
49+
macrotest::expand("integration/tests/defaults/*.rs");
5050
build_dev();
5151
}
5252

5353
fn build_dev() {
5454
let t = trybuild::TestCases::new();
55-
t.pass("src/build/defaults/*.expanded.rs");
55+
t.pass("integration/tests/defaults/*.expanded.rs");
5656
}
5757

5858
// #[test]
5959
#[cfg(feature = "ci")]
6060
pub fn ci() {
6161
// To test generated macro result files
62-
macrotest::expand_without_refresh("tests/expand/defaults/*.rs");
62+
macrotest::expand_without_refresh("src/tests/expand/defaults/*.rs");
6363
build_ci();
6464
}
6565

6666
fn build_ci() {
6767
let t = trybuild::TestCases::new();
68-
t.pass("tests/expand/defaults/*.expanded.rs");
68+
t.pass("scr/tests/expand/defaults/*.expanded.rs");
6969
}

minitrace-tests/integration/tests/defaults/no-be-no-drop-local.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use embassy::task;
1+
// use embassy::task;
22
use minitrace::trace;
33
use test_utilities::*;
44
use minitrace_tests::main_runtime;
@@ -17,10 +17,10 @@ main_runtime2!();
1717
// - https://github.com/tikv/minitrace-rust/issues/125
1818
// - https://github.com/tikv/minitrace-rust/issues/126
1919
#[trace]
20-
#[embassy::task]
21-
async fn test_esync(a: u32) -> u32 {
22-
a
23-
}
20+
// #[embassy::task]
21+
// async fn test_esync(a: u32) -> u32 {
22+
// a
23+
// }
2424

2525
async fn test_async(a: u32) -> u32 {
2626
a

minitrace-tests/integration/tests/issues.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
#[cfg(not(feature = "ci"))]
1111
pub fn indev() {
1212
// To generate macro result files
13-
macrotest::expand("src/build/issues/non-drop-local.rs");
13+
macrotest::expand("integration/tests/issues/non-drop-local.rs");
1414
build_indev();
1515
}
1616

1717
fn build_indev() {
1818
let t = trybuild::TestCases::new();
19-
t.pass("src/build/issues/*.expanded.rs");
19+
t.pass("integration/tests/issues/*.expanded.rs");
2020
}
2121

2222
#[test]
2323
#[cfg(not(feature = "ci"))]
2424
pub fn dev() {
2525
// To generate macro result files
26-
macrotest::expand("src/build/issues/*.rs");
26+
macrotest::expand("integration/tests/issues/*.rs");
2727
build_dev();
2828
}
2929

0 commit comments

Comments
 (0)