Skip to content

Commit

Permalink
refactor(tests): Reduce cargo-remove setup load
Browse files Browse the repository at this point in the history
Benefits
- Clarifies a tests needs
- Speeds up testing, especially on Windows
- Reduces disk space issues within CI
  • Loading branch information
epage committed May 25, 2023
1 parent feb9bcf commit ad9a44d
Show file tree
Hide file tree
Showing 31 changed files with 396 additions and 148 deletions.
16 changes: 13 additions & 3 deletions tests/testsuite/cargo_remove/avoid_empty_tables/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

use crate::cargo_remove::init_registry;

#[cargo_test]
fn case() {
init_registry();
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("semver", "0.1.1")
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new("serde", "1.0.90")
.feature("std", &[])
.publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
16 changes: 13 additions & 3 deletions tests/testsuite/cargo_remove/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

use crate::cargo_remove::init_registry;

#[cargo_test]
fn case() {
init_registry();
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("semver", "0.1.1")
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new("serde", "1.0.90")
.feature("std", &[])
.publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
16 changes: 13 additions & 3 deletions tests/testsuite/cargo_remove/dev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

use crate::cargo_remove::init_registry;

#[cargo_test]
fn case() {
init_registry();
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("semver", "0.1.1")
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new("serde", "1.0.90")
.feature("std", &[])
.publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
16 changes: 13 additions & 3 deletions tests/testsuite/cargo_remove/dry_run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

use crate::cargo_remove::init_registry;

#[cargo_test]
fn case() {
init_registry();
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("semver", "0.1.1")
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new("serde", "1.0.90")
.feature("std", &[])
.publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
4 changes: 1 addition & 3 deletions tests/testsuite/cargo_remove/gc_patch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ use cargo_test_support::git;
use cargo_test_support::project;
use cargo_test_support::CargoCommand;

use crate::cargo_remove::init_registry;

#[cargo_test]
fn case() {
init_registry();
cargo_test_support::registry::init();

let git_project1 = git::new("bar1", |project| {
project
Expand Down
17 changes: 14 additions & 3 deletions tests/testsuite/cargo_remove/gc_profile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

use crate::cargo_remove::init_registry;

#[cargo_test]
fn case() {
init_registry();
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.2.3+my-package").publish();
cargo_test_support::registry::Package::new("semver", "0.1.1")
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new("serde", "1.0.90")
.feature("std", &[])
.publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
17 changes: 14 additions & 3 deletions tests/testsuite/cargo_remove/gc_replace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

use crate::cargo_remove::init_registry;

#[cargo_test]
fn case() {
init_registry();
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.2.3+my-package").publish();
cargo_test_support::registry::Package::new("semver", "0.1.1")
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new("serde", "1.0.90")
.feature("std", &[])
.publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
16 changes: 13 additions & 3 deletions tests/testsuite/cargo_remove/invalid_arg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

use crate::cargo_remove::init_registry;

#[cargo_test]
fn case() {
init_registry();
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("semver", "0.1.1")
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new("serde", "1.0.90")
.feature("std", &[])
.publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
16 changes: 13 additions & 3 deletions tests/testsuite/cargo_remove/invalid_dep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

use crate::cargo_remove::init_registry;

#[cargo_test]
fn case() {
init_registry();
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("semver", "0.1.1")
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new("serde", "1.0.90")
.feature("std", &[])
.publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
18 changes: 15 additions & 3 deletions tests/testsuite/cargo_remove/invalid_package/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

use crate::cargo_remove::init_registry;

#[cargo_test]
fn case() {
init_registry();
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("dbus", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("ncurses", "20.0.0+my-package").publish();
cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("semver", "0.1.1")
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new("serde", "1.0.90")
.feature("std", &[])
.publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
18 changes: 15 additions & 3 deletions tests/testsuite/cargo_remove/invalid_package_multiple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

use crate::cargo_remove::init_registry;

#[cargo_test]
fn case() {
init_registry();
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("dbus", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("ncurses", "20.0.0+my-package").publish();
cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("semver", "0.1.1")
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new("serde", "1.0.90")
.feature("std", &[])
.publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
16 changes: 13 additions & 3 deletions tests/testsuite/cargo_remove/invalid_section/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

use crate::cargo_remove::init_registry;

#[cargo_test]
fn case() {
init_registry();
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("semver", "0.1.1")
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new("serde", "1.0.90")
.feature("std", &[])
.publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
16 changes: 13 additions & 3 deletions tests/testsuite/cargo_remove/invalid_section_dep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

use crate::cargo_remove::init_registry;

#[cargo_test]
fn case() {
init_registry();
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("semver", "0.1.1")
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new("serde", "1.0.90")
.feature("std", &[])
.publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
18 changes: 15 additions & 3 deletions tests/testsuite/cargo_remove/invalid_target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

use crate::cargo_remove::init_registry;

#[cargo_test]
fn case() {
init_registry();
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("dbus", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("ncurses", "20.0.0+my-package").publish();
cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("semver", "0.1.1")
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new("serde", "1.0.90")
.feature("std", &[])
.publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
18 changes: 15 additions & 3 deletions tests/testsuite/cargo_remove/invalid_target_dep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@ use cargo_test_support::curr_dir;
use cargo_test_support::CargoCommand;
use cargo_test_support::Project;

use crate::cargo_remove::init_registry;

#[cargo_test]
fn case() {
init_registry();
cargo_test_support::registry::init();
cargo_test_support::registry::Package::new("clippy", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("dbus", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("docopt", "0.6.2+my-package").publish();
cargo_test_support::registry::Package::new("ncurses", "20.0.0+my-package").publish();
cargo_test_support::registry::Package::new("regex", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("rustc-serialize", "0.4.0+my-package").publish();
cargo_test_support::registry::Package::new("toml", "0.1.1+my-package").publish();
cargo_test_support::registry::Package::new("semver", "0.1.1")
.feature("std", &[])
.publish();
cargo_test_support::registry::Package::new("serde", "1.0.90")
.feature("std", &[])
.publish();

let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
Loading

0 comments on commit ad9a44d

Please sign in to comment.