Skip to content

Commit fd387ee

Browse files
committed
Unnest rustup's mock crate into the tests
1 parent c1ee429 commit fd387ee

16 files changed

+42
-69
lines changed

Cargo.lock

-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ winreg = "0.5.0"
6363
gcc = "0.3.50"
6464

6565
[dev-dependencies]
66-
rustup-mock = { path = "src/rustup-mock", version = "1.1.0" }
6766
lazy_static = "1.0.0"
6867

6968
[workspace]

src/rustup-mock/Cargo.toml

-26
This file was deleted.

tests/cli-exact.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
//! Yet more cli test cases. These are testing that the output
22
//! is exactly as expected.
33
4-
use rustup_mock::clitools::{
4+
pub mod mock;
5+
6+
use crate::mock::clitools::{
57
self, expect_err_ex, expect_ok, expect_ok_ex, this_host_triple, Config, Scenario,
68
};
79

tests/cli-inst-interactive.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
//! Tests of the interactive console installer
22
3+
pub mod mock;
4+
5+
use crate::mock::clitools::{self, expect_stdout_ok, Config, SanitizedOutput, Scenario};
6+
use crate::mock::{get_path, restore_path};
37
use lazy_static::lazy_static;
4-
use rustup_mock::clitools::{self, expect_stdout_ok, Config, SanitizedOutput, Scenario};
5-
use rustup_mock::{get_path, restore_path};
68
use std::io::Write;
79
use std::process::Stdio;
810
use std::sync::Mutex;

tests/cli-misc.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
//! Test cases of the rustup command that do not depend on the
22
//! dist server, mostly derived from multirust/test-v2.sh
33
4-
use rustup::dist::errors::TOOLSTATE_MSG;
5-
use rustup::utils::{raw, utils};
6-
use rustup_mock::clitools::{
4+
pub mod mock;
5+
6+
use crate::mock::clitools::{
77
self, expect_err, expect_ok, expect_ok_ex, expect_stderr_ok, expect_stdout_ok, run,
88
set_current_dist_date, this_host_triple, Config, Scenario,
99
};
10+
use rustup::dist::errors::TOOLSTATE_MSG;
11+
use rustup::utils::{raw, utils};
1012

1113
use std::env::consts::EXE_SUFFIX;
1214
use tempdir::TempDir;

tests/cli-rustup.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
//! Test cases for new rustup UI
22
3-
use rustup::utils::raw;
4-
use rustup_mock::clitools::{
3+
pub mod mock;
4+
5+
use crate::mock::clitools::{
56
self, expect_err, expect_ok, expect_ok_ex, expect_stderr_ok, expect_stdout_ok, run,
67
set_current_dist_date, this_host_triple, Config, Scenario,
78
};
9+
use rustup::utils::raw;
810
use std::env::consts::EXE_SUFFIX;
911
use std::fs;
1012
use std::path::MAIN_SEPARATOR;

tests/cli-self-upd.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
//! Testing self install, uninstall and update
22
3-
use lazy_static::lazy_static;
4-
use remove_dir_all::remove_dir_all;
5-
use rustup::utils::{raw, utils};
6-
use rustup_mock::clitools::{
3+
pub mod mock;
4+
5+
use crate::mock::clitools::{
76
self, expect_err, expect_err_ex, expect_ok, expect_ok_contains, expect_ok_ex, expect_stderr_ok,
87
expect_stdout_ok, this_host_triple, Config, Scenario,
98
};
10-
use rustup_mock::dist::calc_hash;
11-
use rustup_mock::{get_path, restore_path};
9+
use crate::mock::dist::calc_hash;
10+
use crate::mock::{get_path, restore_path};
11+
use lazy_static::lazy_static;
12+
use remove_dir_all::remove_dir_all;
13+
use rustup::utils::{raw, utils};
1214
use std::env;
1315
use std::env::consts::EXE_SUFFIX;
1416
use std::fs;

tests/cli-v1.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
//! Test cases of the rustup command, using v1 manifests, mostly
22
//! derived from multirust/test-v2.sh
33
4-
use rustup_mock::clitools::{
4+
pub mod mock;
5+
6+
use crate::mock::clitools::{
57
self, expect_err, expect_ok, expect_stderr_ok, expect_stdout_ok, set_current_dist_date,
68
this_host_triple, Config, Scenario,
79
};

tests/cli-v2.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
//! Test cases of the rustup command, using v2 manifests, mostly
22
//! derived from multirust/test-v2.sh
33
4-
use rustup_mock::clitools::{
4+
pub mod mock;
5+
6+
use crate::mock::clitools::{
57
self, expect_err, expect_not_stdout_ok, expect_ok, expect_stderr_ok, expect_stdout_ok,
68
set_current_dist_date, this_host_triple, Config, Scenario,
79
};
@@ -807,8 +809,8 @@ fn remove_target_missing_update_hash() {
807809
}
808810

809811
fn make_component_unavailable(config: &Config, name: &str, target: &TargetTriple) {
812+
use crate::mock::dist::create_hash;
810813
use rustup::dist::manifest::Manifest;
811-
use rustup_mock::dist::create_hash;
812814

813815
let ref manifest_path = config.distdir.join("dist/channel-rust-nightly.toml");
814816
let ref manifest_str = rustup::utils::raw::read_file(manifest_path).unwrap();

tests/dist.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// Tests of installation and updates from a v2 Rust distribution
22
// server (mocked on the file system)
33

4+
pub mod mock;
5+
6+
use crate::mock::dist::*;
7+
use crate::mock::{MockComponentBuilder, MockFile, MockInstallerBuilder};
48
use rustup::dist::dist::{TargetTriple, ToolchainDesc, DEFAULT_DIST_SERVER};
59
use rustup::dist::download::DownloadCfg;
610
use rustup::dist::errors::Result;
@@ -12,8 +16,6 @@ use rustup::dist::ErrorKind;
1216
use rustup::dist::Notification;
1317
use rustup::utils::raw as utils_raw;
1418
use rustup::utils::utils;
15-
use rustup_mock::dist::*;
16-
use rustup_mock::{MockComponentBuilder, MockFile, MockInstallerBuilder};
1719
use std::cell::Cell;
1820
use std::collections::HashMap;
1921
use std::fs;

tests/dist_install.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
pub mod mock;
2+
3+
use crate::mock::{MockComponentBuilder, MockFile, MockInstallerBuilder};
14
use rustup::dist::component::Components;
25
use rustup::dist::component::Transaction;
36
use rustup::dist::component::{DirectoryPackage, Package};
@@ -7,7 +10,6 @@ use rustup::dist::temp;
710
use rustup::dist::ErrorKind;
811
use rustup::dist::Notification;
912
use rustup::utils::utils;
10-
use rustup_mock::{MockComponentBuilder, MockFile, MockInstallerBuilder};
1113
use std::fs::File;
1214
use std::io::Write;
1315
use tempdir::TempDir;

src/rustup-mock/src/clitools.rs renamed to tests/mock/clitools.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//! A mock distribution server used by tests/cli-v1.rs and
22
//! tests/cli-v2.rs
33
4-
use crate::dist::{
4+
use crate::mock::dist::{
55
change_channel_date, ManifestVersion, MockChannel, MockComponent, MockDistServer, MockPackage,
66
MockTargetedPackage,
77
};
8-
use crate::{MockComponentBuilder, MockFile, MockInstallerBuilder};
8+
use crate::mock::{MockComponentBuilder, MockFile, MockInstallerBuilder};
99
use lazy_static::lazy_static;
1010
use std::cell::RefCell;
1111
use std::collections::HashMap;

src/rustup-mock/src/dist.rs renamed to tests/mock/dist.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Tools for building and working with the filesystem of a mock Rust
22
//! distribution server, with v1 and v2 manifests.
33
4-
use crate::MockInstallerBuilder;
4+
use crate::mock::MockInstallerBuilder;
55
use lazy_static::lazy_static;
66
use sha2::{Digest, Sha256};
77
use std::collections::HashMap;
@@ -12,7 +12,7 @@ use std::sync::Mutex;
1212
use tempdir::TempDir;
1313
use url::Url;
1414

15-
use crate::clitools::hard_link;
15+
use crate::mock::clitools::hard_link;
1616

1717
// This function changes the mock manifest for a given channel to that
1818
// of a particular date. For advancing the build from e.g. 2016-02-1
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)