Skip to content

Commit

Permalink
Update the semver-check script to be able to run in any directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed May 9, 2023
1 parent 0e93732 commit dd25e89
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions crates/semver-check/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ fn main() {
const SEPARATOR: &str = "///////////////////////////////////////////////////////////";

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

Expand Down
8 changes: 6 additions & 2 deletions src/doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ To rebuild the man pages, run `cargo build-man` inside the workspace.
### SemVer chapter tests

There is a script to verify that the examples in the SemVer chapter work as
intended. To run the tests, go into the `semver-check` directory and run
`cargo run`.
intended. To run the tests, run `cargo +stable run -p semver-check`.

Note that these tests run on the most recent stable release because they
validate the output of the compiler diagnostics. The output can change between
releases, so we pin to a specific release to avoid frequent and unexpected
breakage.

## Contributing

Expand Down

0 comments on commit dd25e89

Please sign in to comment.