Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::path::PathBuf;
use std::thread;

use crate::prelude::*;
use crate::utils::cargo_process;
use crate::utils::{cargo_process, pkg};
use cargo_test_support::compare::assert_e2e;
use cargo_test_support::cross_compile;
use cargo_test_support::git;
Expand All @@ -21,16 +21,6 @@ use crate::utils::cross_compile::disabled as cross_compile_disabled;
use cargo_test_support::install::{assert_has_installed_exe, assert_has_not_installed_exe, exe};
use cargo_test_support::paths;

fn pkg(name: &str, vers: &str) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For myself, I'm not too much of a fan of us reusing like this as it hides in the test what is happening and gets annoying when you just need a little customization. Just directly publish the needed package inside of your test.

Package::new(name, vers)
.file("src/lib.rs", "")
.file(
"src/main.rs",
&format!("extern crate {}; fn main() {{}}", name),
)
.publish();
}

#[cargo_test]
fn simple() {
pkg("foo", "0.0.1");
Expand Down
11 changes: 11 additions & 0 deletions tests/testsuite/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::path::PathBuf;

use cargo_test_support::registry::Package;
use cargo_test_support::{ArgLineCommandExt, Execs, execs, process};

pub mod cross_compile;
Expand All @@ -19,3 +20,13 @@ pub fn cargo_process(arg_line: &str) -> Execs {
pub fn cargo_exe() -> PathBuf {
snapbox::cmd::cargo_bin!("cargo").to_path_buf()
}

pub fn pkg(name: &str, vers: &str) {
Package::new(name, vers)
.file("src/lib.rs", "")
.file(
"src/main.rs",
&format!("extern crate {}; fn main() {{}}", name),
)
.publish();
}