Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/check_diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:

- name: Build check_diff binary
working-directory: ./check_diff
run: cargo build --release
run: cargo build --release --locked

- name: Run Diff Check
working-directory: ./check_diff
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ jobs:
- name: run integration tests
env:
TARGET: x86_64-unknown-linux-gnu
run: cargo run --manifest-path ci/Cargo.toml integration ${{ matrix.integration }}
run: cargo run --locked --manifest-path ci/Cargo.toml integration ${{ matrix.integration }}
continue-on-error: ${{ matrix.allow-failure == true }}
2 changes: 1 addition & 1 deletion .github/workflows/rustdoc_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
- name: document rustfmt
env:
RUSTDOCFLAGS: --document-private-items --enable-index-page --show-type-layout --generate-link-to-definition -Zunstable-options -Dwarnings
run: cargo doc -Zskip-rustdoc-fingerprint --no-deps -p rustfmt-nightly -p rustfmt-config_proc_macro
run: cargo doc --locked -Zskip-rustdoc-fingerprint --no-deps -p rustfmt-nightly -p rustfmt-config_proc_macro
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
env:
RUSTFLAGS: -D warnings
CARGO_UNSTABLE_BUILD_DIR_NEW_LAYOUT: true
run: cargo run --manifest-path ci/Cargo.toml build-and-test
run: cargo run --locked --manifest-path ci/Cargo.toml build-and-test

test-conclusion:
name: "test conclusion"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upload-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
shell: bash

- name: Build release binaries
run: cargo build --release
run: cargo build --release --locked

- name: Build archive
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ issues where it does something you don't expect.
Having a strong test suite for a tool like this is essential. It is very easy
to create regressions. Any tests you can add are very much appreciated.

The tests can be run with `cargo test`. This does a number of things:
The tests can be run with `cargo test --locked`. This does a number of things:
* runs the unit tests for a number of internal functions;
* makes sure that rustfmt run on every file in `./tests/source/` is equal to its
associated file in `./tests/target/`; this catches
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ language: rust
before_script:
- rustup component add rustfmt
script:
- cargo build
- cargo test
- cargo build --locked
- cargo test --locked
- cargo fmt --all -- --check
```

Expand All @@ -144,11 +144,11 @@ for more info.

## How to build and test

`cargo build` to build.
`cargo build --locked` to build.

`cargo test` to run all tests.
`cargo test --locked` to run all tests.

To run rustfmt after this, use `cargo run --bin rustfmt -- filename`. See the
To run rustfmt after this, use `cargo run --locked --bin rustfmt -- filename`. See the
notes above on running rustfmt.


Expand Down
2 changes: 1 addition & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# power comes great responsibility.
# We deliberately avoid reformatting files with rustfmt comment directives.

cargo build --release
cargo build --release --locked

target/release/rustfmt src/lib.rs
target/release/rustfmt src/bin/main.rs
Expand Down
2 changes: 1 addition & 1 deletion check_diff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ pub fn build_rustfmt_from_src<T: AsRef<str>>(
info!("Building rustfmt from source");
let Ok(_) = Command::new("cargo")
.current_dir(dir)
.args(["build", "-q", "--release", "--bin", "rustfmt"])
.args(["build", "--locked", "-q", "--release", "--bin", "rustfmt"])
.output()
else {
return Err(CheckDiffError::FailedSourceBuild(
Expand Down
4 changes: 2 additions & 2 deletions ci/src/build_and_test.rs

@jieyouxu jieyouxu Aug 24, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Discussion: I considered if we can use --locked for the ecosystem integration tests. My assessment is that we can't in the general case:

  • Some of these, like bitflags, are library crates that do not check in a lockfile. We can technically patch in a lockfile ourselves but that's a maintenance PITA.
  • We could consider using --locked iff the repo has a lockfile, but cf. no-lockfile case above.

View changes since the review

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::collections::HashMap;

fn run_tests_in_dir(env: &HashMap<&str, &str>, dir: &str) -> Result<(), String> {
run_command_with_env("cargo", &["build", "--locked"], dir, &env)?;
run_command_with_env("cargo", &["test"], dir, &env)
run_command_with_env("cargo", &["test", "--locked"], dir, &env)
}

pub fn runner() -> Result<(), String> {
Expand Down Expand Up @@ -39,7 +39,7 @@ pub fn runner() -> Result<(), String> {
&["build", "--locked"]
};
run_command_with_env("cargo", options, ".", &env)?;
run_command_with_env("cargo", &["test"], ".", &env)?;
run_command_with_env("cargo", &["test", "--locked"], ".", &env)?;

// Build and test config_proc_macro
run_tests_in_dir(&env, "config_proc_macro")?;
Expand Down
3 changes: 2 additions & 1 deletion src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,8 @@ fn rustfmt() -> PathBuf {
assert!(
me.is_file() || me.with_extension("exe").is_file(),
"{}",
"no rustfmt bin, try running `cargo build` or `cargo build --release` before testing"
"no rustfmt bin, try running `cargo build --locked` or `cargo build --locked --release` \
before testing"
);
me
}
Expand Down