2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for displaying the cargo version.
|
|
|
|
|
2021-10-08 19:19:24 +00:00
|
|
|
use cargo_test_support::{cargo_process, project};
|
2014-07-17 20:00:58 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn simple() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project().build();
|
2014-07-17 20:00:58 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("version")
|
2021-07-26 19:18:22 +00:00
|
|
|
.with_stdout(&format!("cargo {}\n", cargo::version()))
|
2018-08-28 09:20:03 +00:00
|
|
|
.run();
|
2018-03-14 15:17:44 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("--version")
|
2021-07-26 19:18:22 +00:00
|
|
|
.with_stdout(&format!("cargo {}\n", cargo::version()))
|
2018-08-28 09:20:03 +00:00
|
|
|
.run();
|
2023-10-14 15:16:11 +00:00
|
|
|
|
|
|
|
p.cargo("-V")
|
|
|
|
.with_stdout(&format!("cargo {}\n", cargo::version()))
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2016-01-31 16:02:47 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-07-15 17:14:34 +00:00
|
|
|
fn version_works_without_rustc() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project().build();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("version").env("PATH", "").run();
|
2016-07-15 17:33:57 +00:00
|
|
|
}
|
2016-07-24 07:45:02 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-07-24 07:45:02 +00:00
|
|
|
fn version_works_with_bad_config() {
|
2024-01-26 19:40:46 +00:00
|
|
|
let p = project()
|
|
|
|
.file(".cargo/config.toml", "this is not toml")
|
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("version").run();
|
2016-07-24 07:45:02 +00:00
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-07-24 07:45:02 +00:00
|
|
|
fn version_works_with_bad_target_dir() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2018-03-14 15:17:44 +00:00
|
|
|
.file(
|
2024-01-26 19:40:46 +00:00
|
|
|
".cargo/config.toml",
|
2018-03-14 15:17:44 +00:00
|
|
|
r#"
|
2020-09-27 00:59:58 +00:00
|
|
|
[build]
|
|
|
|
target-dir = 4
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
|
|
|
.build();
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("version").run();
|
2016-07-24 07:45:02 +00:00
|
|
|
}
|
2021-10-08 19:19:24 +00:00
|
|
|
|
|
|
|
#[cargo_test]
|
|
|
|
fn verbose() {
|
|
|
|
// This is mainly to check that it doesn't explode.
|
|
|
|
cargo_process("-vV")
|
|
|
|
.with_stdout_contains(&format!("cargo {}", cargo::version()))
|
|
|
|
.with_stdout_contains("host: [..]")
|
|
|
|
.with_stdout_contains("libgit2: [..]")
|
|
|
|
.with_stdout_contains("libcurl: [..]")
|
2021-10-11 18:22:48 +00:00
|
|
|
.with_stdout_contains("os: [..]")
|
2021-10-08 19:19:24 +00:00
|
|
|
.run();
|
|
|
|
}
|