Skip to content

Commit

Permalink
Run integration tests as a single binary
Browse files Browse the repository at this point in the history
Much of our test time is linking each test; a single bonanza binary lets
us maintain tests individually, but amortize build/link costs
effectively.
  • Loading branch information
rbtcollins authored and Darunada committed Feb 25, 2023
1 parent ffc6411 commit 5a9b7a0
Show file tree
Hide file tree
Showing 64 changed files with 36 additions and 61 deletions.
21 changes: 7 additions & 14 deletions ci/run.bash
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,17 @@ build_test() {
cmd="$1"
shift
download_pkg_test "${cmd}"
target_cargo "${cmd}" --bin rustup-init
target_cargo "${cmd}" --lib --all
if [ "build" != "${cmd}" ]; then
target_cargo "${cmd}" --doc --all
fi

if [ "build" = "${cmd}" ]; then
target_cargo "${cmd}" --test dist
if [ "build" = "${cmd}" ]; then
target_cargo "${cmd}" --workspace --all-targets
else
# free runners have 2 or 3(mac) cores
target_cargo "${cmd}" --test dist -- --test-threads 2
target_cargo "${cmd}" --workspace --tests -- --test-threads 2
fi

if [ "build" != "${cmd}" ]; then
target_cargo "${cmd}" --doc --workspace
fi

find tests -maxdepth 1 -type f ! -path '*/dist.rs' -name '*.rs' \
| sed -e 's@^tests/@@;s@\.rs$@@g' \
| while read -r test; do
target_cargo "${cmd}" --test "${test}"
done
}

if [ -z "$SKIP_TESTS" ]; then
Expand Down
18 changes: 0 additions & 18 deletions tests/mock/clitools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -806,24 +806,6 @@ where
!(run || self_cmd || version || (is_update && !no_self_update))
}

#[deprecated]
pub fn run<I, A>(config: &Config, name: &str, args: I, env: &[(&str, &str)]) -> SanitizedOutput
where
I: IntoIterator<Item = A> + Clone,
A: AsRef<OsStr>,
{
config.run(name, args, env)
}

#[deprecated]
pub fn run_subprocess<I, A>(config: &Config, name: &str, args: I, env: &[(&str, &str)]) -> Output
where
I: IntoIterator<Item = A>,
A: AsRef<OsStr>,
{
config.run_subprocess(name, args, env)
}

#[derive(Copy, Clone, Eq, PartialEq)]
enum RlsStatus {
Available,
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions tests/cli-exact.rs → tests/suite/cli_exact.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Yet more cli test cases. These are testing that the output
//! is exactly as expected.

pub mod mock;

use crate::mock::clitools::{self, set_current_dist_date, with_update_server, Config, Scenario};
use rustup::for_host;
use rustup::test::this_host_triple;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Tests of the interactive console installer

pub mod mock;

use std::env::consts::EXE_SUFFIX;
use std::io::Write;
use std::process::Stdio;
Expand Down
2 changes: 0 additions & 2 deletions tests/cli-misc.rs → tests/suite/cli_misc.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Test cases of the rustup command that do not depend on the
//! dist server, mostly derived from multirust/test-v2.sh

pub mod mock;

use std::str;
use std::{env::consts::EXE_SUFFIX, path::Path};

Expand Down
1 change: 0 additions & 1 deletion tests/cli-paths.rs → tests/suite/cli_paths.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! This file contains tests relevant to Rustup's handling of updating PATHs.
//! It depends on self-update working, so if absolutely everything here breaks,
//! check those tests as well.
pub mod mock;

// Prefer omitting actually unpacking content while just testing paths.
const INIT_NONE: [&str; 4] = ["rustup-init", "-y", "--default-toolchain", "none"];
Expand Down
7 changes: 4 additions & 3 deletions tests/cli-rustup.rs → tests/suite/cli_rustup.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Test cases for new rustup UI

pub mod mock;

use std::env::consts::EXE_SUFFIX;
use std::fs;
use std::path::{PathBuf, MAIN_SEPARATOR};
Expand All @@ -10,7 +8,10 @@ use rustup::for_host;
use rustup::test::this_host_triple;
use rustup::utils::raw;

use crate::mock::clitools::{self, Config, Scenario};
use crate::mock::{
self,
clitools::{self, Config, Scenario},
};

macro_rules! for_host_and_home {
($config:ident, $s: expr) => {
Expand Down
9 changes: 4 additions & 5 deletions tests/cli-self-upd.rs → tests/suite/cli_self_upd.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
//! Testing self install, uninstall and update

pub mod mock;

use std::env;
use std::env::consts::EXE_SUFFIX;
use std::fs;
Expand All @@ -14,9 +12,10 @@ use rustup::test::{this_host_triple, with_saved_path};
use rustup::utils::{raw, utils};
use rustup::{for_host, Notification, DUP_TOOLS, TOOLS};

use crate::clitools::output_release_file;
use crate::mock::clitools::{self, self_update_setup, Config, Scenario};
use crate::mock::dist::calc_hash;
use crate::mock::{
clitools::{self, output_release_file, self_update_setup, Config, Scenario},
dist::calc_hash,
};

const TEST_VERSION: &str = "1.1.1";

Expand Down
12 changes: 6 additions & 6 deletions tests/cli-ui.rs → tests/suite/cli_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ fn rustup_init_ui_doc_text_tests() {
let project_root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
t.register_bin("rustup-init", &rustup_init);
t.register_bin("rustup-init.sh", &project_root.join("rustup-init.sh"));
t.case("tests/cli-ui/rustup-init/*.toml");
t.case("tests/suite/cli-ui/rustup-init/*.toml");
#[cfg(target_os = "windows")]
{
// On non-windows, we don't use rustup-init.sh, so skip the test.
t.skip("tests/cli-ui/rustup-init/rustup-init_sh_help_flag_stdout.toml");
// On windows, we don't use rustup-init.sh, so skip the test.
t.skip("tests/suite/cli-ui/rustup-init/rustup-init_sh_help_flag_stdout.toml");
}

// On non-windows, we don't use rustup-init.sh, so skip the test.
#[cfg(not(target_os = "windows"))]
{
let rustup_init_help_toml =
project_root.join("tests/cli-ui/rustup-init/rustup-init_help_flag_stdout.toml");
let rustup_init_sh_help_toml =
project_root.join("tests/cli-ui/rustup-init/rustup-init_sh_help_flag_stdout.toml");
project_root.join("tests/suite/cli-ui/rustup-init/rustup-init_help_flag_stdout.toml");
let rustup_init_sh_help_toml = project_root
.join("tests/suite/cli-ui/rustup-init/rustup-init_sh_help_flag_stdout.toml");

#[derive(Debug, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
struct Stdout {
Expand Down
2 changes: 0 additions & 2 deletions tests/cli-v1.rs → tests/suite/cli_v1.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Test cases of the rustup command, using v1 manifests, mostly
//! derived from multirust/test-v2.sh

pub mod mock;

use std::fs;

use rustup::for_host;
Expand Down
2 changes: 0 additions & 2 deletions tests/cli-v2.rs → tests/suite/cli_v2.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Test cases of the rustup command, using v2 manifests, mostly
//! derived from multirust/test-v2.sh

pub mod mock;

use std::fs;
use std::io::Write;

Expand Down
2 changes: 0 additions & 2 deletions tests/dist.rs → tests/suite/dist.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Tests of installation and updates from a v2 Rust distribution
// server (mocked on the file system)

pub mod mock;

use std::cell::Cell;
use std::collections::HashMap;
use std::env;
Expand Down
2 changes: 0 additions & 2 deletions tests/dist_install.rs → tests/suite/dist_install.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
pub mod mock;

use std::fs::File;
use std::io::Write;

Expand Down
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions tests/suite/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mod cli_exact;
mod cli_inst_interactive;
mod cli_misc;
mod cli_paths;
mod cli_rustup;
mod cli_self_upd;
mod cli_ui;
mod cli_v1;
mod cli_v2;
mod dist;
mod dist_install;
mod dist_manifest;
mod dist_transactions;
2 changes: 2 additions & 0 deletions tests/test_bonanza.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod mock;
mod suite;

0 comments on commit 5a9b7a0

Please sign in to comment.