Skip to content

Commit

Permalink
Run cargo test in doc test command
Browse files Browse the repository at this point in the history
  • Loading branch information
Brezak committed Dec 24, 2024
1 parent 4c49ca7 commit e312441
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions tools/ci/src/commands/compile_check_no_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::process::Command;

use argh::FromArgs;

use super::{run_cargo_command, RustChannel};
use super::{run_cargo_command, RustToolchain};

/// Checks that the project compiles for a `no_std` target.
/// Note that this tool will attempt to install the target via rustup.
Expand Down Expand Up @@ -58,7 +58,7 @@ impl CompileCheckNoStdCommand {
flags.extend_from_slice(&["--target", lib]);
flags.extend_from_slice(additional);

run_cargo_command("check", RustChannel::Stable, &flags, &[])?;
run_cargo_command("check", RustToolchain::Active, &flags, &[])?;

for _ in 0..(flags.len() + 2) {
flags.pop();
Expand Down
4 changes: 2 additions & 2 deletions tools/ci/src/commands/doc_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl DocTestCommand {
flags.push("--no-fail-fast");
}

run_cargo_command("doc", RustToolchain::Active, &flags, Self::ENV_VARS)
run_cargo_command("test", RustToolchain::Active, &flags, Self::ENV_VARS)
}

/// Runs this command with json output.
Expand All @@ -38,7 +38,7 @@ impl DocTestCommand {
}

run_cargo_command_with_json(
"doc",
"test",
"doc-test",
RustToolchain::Active,
&flags,
Expand Down
5 changes: 3 additions & 2 deletions tools/ci/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ pub enum RustToolchain {
// Whichever toolchain the user has set as their preferred one
Active,
// The nightly toolchain
#[allow(dead_code, reason = "We might want to use this in the future")]
Nightly,
}

impl RustToolchain {
/// Returns a toolchain string usable with rustup
pub fn as_toolchain_string(&self) -> String {
match *self {
// TODO: Test if this supports nightly pinning using `NIGHTLY_TOOLCHAIN` env variable.
// TODO: Test if this supports nightly pinning using the `NIGHTLY_TOOLCHAIN` env variable.
Self::Nightly => "nightly".to_string(),
Self::Active => {
let out = Command::new("rustup")
Expand All @@ -56,7 +57,7 @@ impl RustToolchain {
// This suffix will be separated by a space.
let toolchain = out.stdout.split(|c| *c == b' ').next().unwrap();

let toolchain = std::str::from_utf8(toolchain).unwrap().to_string();
let toolchain = core::str::from_utf8(toolchain).unwrap().to_string();

toolchain
}
Expand Down
7 changes: 3 additions & 4 deletions tools/ci/src/json.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//! Everything we need to handle json output and input.
use std::{
error::Error,
io::{BufRead, BufReader, Read},
};
use core::error::Error;

use std::io::{BufRead, BufReader, Read};

use serde::Serialize;
use serde_json::{Map, Value};
Expand Down

0 comments on commit e312441

Please sign in to comment.