]>
git.proxmox.com Git - rustc.git/blob - vendor/xshell/tests/it/compile_failures.rs
1 use xshell
::{cmd, Shell}
;
4 fn check(code
: &str, err_msg
: &str) {
5 let sh
= Shell
::new().unwrap();
6 let xshell_dir
= sh
.current_dir();
7 let temp_dir
= sh
.create_temp_dir().unwrap();
8 sh
.change_dir(temp_dir
.path());
10 let manifest
= format
!(
22 xshell = {{ path = {xshell_dir:?} }}
30 let sh = Shell::new().unwrap();
36 sh
.write_file("Cargo.toml", manifest
).unwrap();
37 sh
.write_file("main.rs", snip
).unwrap();
39 let stderr
= cmd
!(sh
, "cargo build").ignore_status().read_stderr().unwrap();
41 stderr
.contains(err_msg
),
42 "\n\nCompile fail fail!\n\nExpected:\n{}\n\nActual:\n{}\n",
49 fn not_a_string_literal() {
50 check("cmd!(sh, 92)", "expected a plain string literal");
54 fn not_raw_string_literal() {
55 check(r
#"cmd!(sh, r"raw")"#, "expected a plain string literal");
59 fn interpolate_complex_expression() {
61 r
#"cmd!(sh, "{echo.as_str()}")"#,
62 "error: can only interpolate simple variables, got this expression instead: `echo.as_str()`",
67 fn interpolate_splat_concat_prefix() {
69 r
#"cmd!(sh, "echo a{args...}")"#,
70 "error: can't combine splat with concatenation, add spaces around `{args...}`",
75 fn interpolate_splat_concat_suffix() {
77 r
#"cmd!(sh, "echo {args...}b")"#,
78 "error: can't combine splat with concatenation, add spaces around `{args...}`",
83 fn interpolate_splat_concat_mixfix() {
85 r
#"cmd!(sh, "echo a{args...}b")"#,
86 "error: can't combine splat with concatenation, add spaces around `{args...}`",
92 check(r
#"cmd!(sh, "")"#, "error: command can't be empty");
97 check(r
#"cmd!(sh, "{cmd...}")"#, "error: can't splat program name");
101 fn unclosed_quote() {
102 check(r
#"cmd!(sh, "echo 'hello world")"#, "error: unclosed `'` in command");
106 fn unclosed_curly() {
107 check(r
#"cmd!(sh, "echo {hello world")"#, "error: unclosed `{` in command");
111 fn interpolate_integer() {
115 cmd!(sh, "make -j {x}")"#,
116 r
#"is not implemented"#,
121 fn splat_fn_pointer() {
124 let dry_run: fn() -> Option<&'static str> = || None;
125 cmd!(sh, "make -j {dry_run...}")"#,
126 r
#"is not implemented"#,