]> git.proxmox.com Git - cargo.git/blob - tests/testsuite/version.rs
a5e4676dd46ed2e08f4a8f0262f90ba35bc87c03
[cargo.git] / tests / testsuite / version.rs
1 //! Tests for displaying the cargo version.
2
3 use cargo_test_support::{cargo_process, project};
4
5 #[cargo_test]
6 fn simple() {
7 let p = project().build();
8
9 p.cargo("version")
10 .with_stdout(&format!("cargo {}\n", cargo::version()))
11 .run();
12
13 p.cargo("--version")
14 .with_stdout(&format!("cargo {}\n", cargo::version()))
15 .run();
16 }
17
18 #[cargo_test]
19 #[cfg_attr(target_os = "windows", ignore)]
20 fn version_works_without_rustc() {
21 let p = project().build();
22 p.cargo("version").env("PATH", "").run();
23 }
24
25 #[cargo_test]
26 fn version_works_with_bad_config() {
27 let p = project().file(".cargo/config", "this is not toml").build();
28 p.cargo("version").run();
29 }
30
31 #[cargo_test]
32 fn version_works_with_bad_target_dir() {
33 let p = project()
34 .file(
35 ".cargo/config",
36 r#"
37 [build]
38 target-dir = 4
39 "#,
40 )
41 .build();
42 p.cargo("version").run();
43 }
44
45 #[cargo_test]
46 fn verbose() {
47 // This is mainly to check that it doesn't explode.
48 cargo_process("-vV")
49 .with_stdout_contains(&format!("cargo {}", cargo::version()))
50 .with_stdout_contains("host: [..]")
51 .with_stdout_contains("libgit2: [..]")
52 .with_stdout_contains("libcurl: [..]")
53 .with_stdout_contains("os: [..]")
54 .run();
55 }