Skip to content

Commit a60ce23

Browse files
committed
fix: Remove test thread argument for consistent build behavior
1 parent aa288dc commit a60ce23

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ jobs:
135135
uses: actions-rs/cargo@v1
136136
with:
137137
command: test
138-
args: --release -- --nocapture --test-threads=1
138+
args: --release -- --nocapture
139139

140140
- name: Cargo doc
141141
uses: actions-rs/cargo@v1

phper-test/src/cargo.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! Cargo build utilities for building and analyzing Rust libraries.
1212
1313
use cargo_metadata::Message;
14-
use log::debug;
14+
use log::{debug, trace};
1515
use std::{
1616
io::{self, BufReader},
1717
path::{Path, PathBuf},
@@ -31,9 +31,13 @@ pub struct CargoBuildResult {
3131
impl CargoBuilder {
3232
/// Create a new CargoBuilder instance
3333
pub fn new() -> Self {
34+
let mut args = vec!["build", "--lib", "--message-format", "json"];
35+
if !cfg!(debug_assertions) {
36+
args.push("--release");
37+
}
3438
let mut command = Command::new(env!("CARGO"));
3539
command
36-
.args(["build", "--lib", "--message-format", "json"])
40+
.args(&args)
3741
.stdin(Stdio::null())
3842
.stdout(Stdio::piped())
3943
.stderr(Stdio::null());
@@ -54,6 +58,14 @@ impl CargoBuilder {
5458

5559
/// Execute the cargo build command and return the result
5660
pub fn build(&mut self) -> io::Result<CargoBuildResult> {
61+
debug!(command:% = {
62+
let program = self.command.get_program();
63+
let args = self.command.get_args();
64+
let mut command = vec![program];
65+
command.extend(args);
66+
command.join(" ".as_ref()).to_string_lossy().to_string()
67+
}; "run cargo build command");
68+
5769
let mut child = self.command.spawn()?;
5870
let stdout = child
5971
.stdout
@@ -62,7 +74,7 @@ impl CargoBuilder {
6274
let reader = BufReader::new(stdout);
6375
let mut messages = Vec::new();
6476
for message in cargo_metadata::Message::parse_stream(reader) {
65-
debug!(message:?; "cargo build message");
77+
trace!(message:?; "cargo build message");
6678
let message = message?;
6779
messages.push(message);
6880
}

tests/integration/tests/common/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use std::{
1818

1919
pub static DYLIB_PATH: LazyLock<PathBuf> = LazyLock::new(|| {
2020
let result = CargoBuilder::new()
21-
.arg("-j1")
2221
.current_dir(env!("CARGO_MANIFEST_DIR"))
2322
.build()
2423
.unwrap();

0 commit comments

Comments
 (0)