Skip to content

Commit

Permalink
Improve doc & warning for expandtest
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jan 11, 2021
1 parent 395f3e6 commit 176a15d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
16 changes: 7 additions & 9 deletions tests/expand/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
Similar to ui tests, but instead of checking the compiler output, this checks
the code generated by macros.

To run this test, run the following command:

```sh
cargo test -p expandtest
```
See [examples](https://github.com/taiki-e/pin-project/tree/master/examples) for
descriptions of what the generated code does, and why it needs to be generated.

Or if you want to run all the tests that include this test:
To run this test, run the following command:

```sh
bash scripts/ci.sh
cargo +nightly test -p expandtest
```

See [examples](https://github.com/taiki-e/pin-project/tree/master/examples) for
descriptions of what the generated code does, and why it needs to be generated.
Locally, this test updates the files in the `expand` directory if there are
changes to the generated code. If there are any changes to the files in the
`expand` directory after running the test, please commit them.
6 changes: 5 additions & 1 deletion tests/expand/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ fn main() {
}

let cargo = &*env::var("CARGO").unwrap_or_else(|_| "cargo".into());
if is_ci || has_command(&[cargo, "expand"]) && has_command(&[cargo, "fmt"]) {
if has_command(&[cargo, "expand"]) && has_command(&[cargo, "fmt"]) {
println!("cargo:rustc-cfg=expandtest");
} else if is_ci {
panic!("expandtest requires rustfmt and cargo-expand")
} else {
println!("cargo:warning=rustfmt or cargo-expand not found, skipping expandtest",);
}
}

Expand Down
5 changes: 2 additions & 3 deletions tests/expand/tests/expandtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ use std::env;
#[cfg_attr(not(expandtest), ignore)]
#[test]
fn expandtest() {
if !cfg!(ci) {
env::set_var("MACROTEST", "overwrite");
}
#[cfg(not(ci))]
env::set_var("MACROTEST", "overwrite");

expand("tests/expand/*.rs");
}

0 comments on commit 176a15d

Please sign in to comment.