Skip to content

Commit 26b73d1

Browse files
committed
Auto merge of #12117 - ehuss:semver-check-doc, r=weihanglo
Update the semver-check script to be able to run in any directory. When semver-check was moved into the workspace, that changed how semver-check is expected to be run. This updates the script so that it can more easily be run from any directory. This also updates the documentation for the correct way to run it, along with some clarification on why it uses the stable release.
2 parents 5ad4cf4 + dd25e89 commit 26b73d1

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

crates/semver-check/src/main.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ fn main() {
2323
const SEPARATOR: &str = "///////////////////////////////////////////////////////////";
2424

2525
fn doit() -> Result<(), Box<dyn Error>> {
26-
let filename = std::env::args()
27-
.nth(1)
28-
.unwrap_or_else(|| "src/doc/src/reference/semver.md".to_string());
26+
let filename = std::env::args().nth(1).unwrap_or_else(|| {
27+
Path::new(env!("CARGO_MANIFEST_DIR"))
28+
.join("../../src/doc/src/reference/semver.md")
29+
.to_str()
30+
.unwrap()
31+
.to_string()
32+
});
2933
let contents = fs::read_to_string(filename)?;
3034
let mut lines = contents.lines().enumerate();
3135

src/doc/README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ To rebuild the man pages, run `cargo build-man` inside the workspace.
5555
### SemVer chapter tests
5656

5757
There is a script to verify that the examples in the SemVer chapter work as
58-
intended. To run the tests, go into the `semver-check` directory and run
59-
`cargo run`.
58+
intended. To run the tests, run `cargo +stable run -p semver-check`.
59+
60+
Note that these tests run on the most recent stable release because they
61+
validate the output of the compiler diagnostics. The output can change between
62+
releases, so we pin to a specific release to avoid frequent and unexpected
63+
breakage.
6064

6165
## Contributing
6266

0 commit comments

Comments
 (0)