Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the semver-check script to be able to run in any directory. #12117

Merged
merged 1 commit into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Member

@weihanglo weihanglo May 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is yet another evidence that we may need an environment variable for workspace directory #3946.

.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