cargo/tests/testsuite/version.rs

55 lines
1.3 KiB
Rust
Raw Normal View History

2019-11-25 02:42:45 +00:00
//! Tests for displaying the cargo version.
use cargo_test_support::{cargo_process, project};
2014-07-17 20:00:58 +00:00
#[cargo_test]
fn simple() {
let p = project().build();
2014-07-17 20:00:58 +00:00
p.cargo("version")
2021-07-26 19:18:22 +00:00
.with_stdout(&format!("cargo {}\n", cargo::version()))
.run();
2018-03-14 15:17:44 +00:00
p.cargo("--version")
2021-07-26 19:18:22 +00:00
.with_stdout(&format!("cargo {}\n", cargo::version()))
.run();
}
#[cargo_test]
2016-07-15 17:14:34 +00:00
fn version_works_without_rustc() {
let p = project().build();
p.cargo("version").env("PATH", "").run();
}
#[cargo_test]
fn version_works_with_bad_config() {
let p = project().file(".cargo/config", "this is not toml").build();
p.cargo("version").run();
}
#[cargo_test]
fn version_works_with_bad_target_dir() {
let p = project()
2018-03-14 15:17:44 +00:00
.file(
".cargo/config",
r#"
2020-09-27 00:59:58 +00:00
[build]
target-dir = 4
"#,
2018-12-08 11:19:47 +00:00
)
.build();
p.cargo("version").run();
}
#[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: [..]")
.run();
}