description: &str, extra: &[u8],
partial: bool) -> ham::MatchResult {
let out = match expected {
- Some(out) => out,
+ Some(out) => substitute_macros(out),
None => return ham::success(),
};
let actual = match str::from_utf8(actual) {
Url::from_file_path(&*p).ok().unwrap()
}
+fn substitute_macros(input: &str) -> String {
+ let macros = [
+ ("[RUNNING]", " Running"),
+ ("[COMPILING]", " Compiling"),
+ ("[ERROR]", "error:"),
+ ("[DOCUMENTING]", " Documenting"),
+ ("[FRESH]", " Fresh"),
+ ("[UPDATING]", " Updating"),
+ ("[ADDING]", " Adding"),
+ ("[REMOVING]", " Removing"),
+ ("[DOCTEST]", " Doc-tests"),
+ ("[PACKAGING]", " Packaging"),
+ ("[DOWNLOADING]", " Downloading"),
+ ("[UPLOADING]", " Uploading"),
+ ("[VERIFYING]", " Verifying"),
+ ("[ARCHIVING]", " Archiving"),
+ ("[INSTALLING]", " Installing"),
+ ("[REPLACING]", " Replacing")
+ ];
+ let mut result = input.to_owned();
+ for &(pat, subst) in macros.iter() {
+ result = result.replace(pat, subst)
+ }
+ return result;
+}
+
pub static RUNNING: &'static str = " Running";
pub static COMPILING: &'static str = " Compiling";
pub static ERROR: &'static str = "error:";
-use support::{project, execs, ERROR};
+use support::{project, execs};
use support::registry::Package;
use hamcrest::assert_that;
"#);
assert_that(foo.cargo_process("build").arg("-v")
.arg("--target=nonexistent-target"),
- execs().with_status(101).with_stderr(&format!("\
-{error} expected table for configuration key `target.nonexistent-target`, \
+ execs().with_status(101).with_stderr("\
+[ERROR] expected table for configuration key `target.nonexistent-target`, \
but found string in [..]config
-",
- error = ERROR)));
+"));
});
test!(bad2 {
proxy = 3.0
"#);
assert_that(foo.cargo_process("publish").arg("-v"),
- execs().with_status(101).with_stderr(&format!("\
-{error} Couldn't load Cargo configuration
+ execs().with_status(101).with_stderr("\
+[ERROR] Couldn't load Cargo configuration
Caused by:
failed to load TOML configuration from `[..]config`
Caused by:
found TOML configuration value of unknown type `float`
-", error = ERROR)));
+"));
});
test!(bad3 {
proxy = true
"#);
assert_that(foo.cargo_process("publish").arg("-v"),
- execs().with_status(101).with_stderr(&format!("\
-{error} invalid configuration for key `http.proxy`
+ execs().with_status(101).with_stderr("\
+[ERROR] invalid configuration for key `http.proxy`
expected a string, but found a boolean in [..]config
-",
- error = ERROR)));
+"));
});
test!(bad4 {
name = false
"#);
assert_that(foo.cargo_process("new").arg("-v").arg("foo"),
- execs().with_status(101).with_stderr(&format!("\
-{error} Failed to create project `foo` at `[..]`
+ execs().with_status(101).with_stderr("\
+[ERROR] Failed to create project `foo` at `[..]`
Caused by:
invalid configuration for key `cargo-new.name`
expected a string, but found a boolean in [..]config
-",
- error = ERROR)));
+"));
});
test!(bad5 {
foo.build();
assert_that(foo.cargo("new")
.arg("-v").arg("foo").cwd(&foo.root().join("foo")),
- execs().with_status(101).with_stderr(&format!("\
-{error} Couldn't load Cargo configuration
+ execs().with_status(101).with_stderr("\
+[ERROR] Couldn't load Cargo configuration
Caused by:
failed to merge key `foo` between files:
Caused by:
expected integer, but found string
-",
- error = ERROR)));
+"));
});
test!(bad_cargo_config_jobs {
jobs = -1
"#);
assert_that(foo.cargo_process("build").arg("-v"),
- execs().with_status(101).with_stderr(&format!("\
-{error} build.jobs must be positive, but found -1 in [..]
-",
- error = ERROR)));
+ execs().with_status(101).with_stderr("\
+[ERROR] build.jobs must be positive, but found -1 in [..]
+"));
});
test!(default_cargo_config_jobs {
.file("src/lib.rs", "");
assert_that(foo.cargo_process("build").arg("-v"),
- execs().with_status(101).with_stderr(&format!("\
-{error} Couldn't load Cargo configuration
+ execs().with_status(101).with_stderr("\
+[ERROR] Couldn't load Cargo configuration
Caused by:
could not parse TOML configuration in `[..]config`
could not parse input as TOML
[..]config:1:2 expected `=`, but found eof
-",
- error = ERROR)));
+"));
});
test!(bad_cargo_lock {
.file("src/lib.rs", "");
assert_that(foo.cargo_process("build").arg("-v"),
- execs().with_status(101).with_stderr(&format!("\
-{error} failed to parse lock file at: [..]Cargo.lock
+ execs().with_status(101).with_stderr("\
+[ERROR] failed to parse lock file at: [..]Cargo.lock
Caused by:
expected a section for the key `root`
-",
- error = ERROR)));
+"));
});
test!(bad_git_dependency {
.file("src/lib.rs", "");
assert_that(foo.cargo_process("build").arg("-v"),
- execs().with_status(101).with_stderr(&format!("\
-{error} Unable to update file:///
+ execs().with_status(101).with_stderr("\
+[ERROR] Unable to update file:///
Caused by:
failed to clone into: [..]
Caused by:
[[..]] 'file:///' is not a valid local file URI
-",
- error = ERROR)));
+"));
});
test!(bad_crate_type {
.file("src/lib.rs", "");
assert_that(foo.cargo_process("build"),
- execs().with_status(101).with_stderr(&format!("\
-{error} failed to parse manifest at `[..]`
+ execs().with_status(101).with_stderr("\
+[ERROR] failed to parse manifest at `[..]`
Caused by:
could not parse input as TOML
Cargo.toml:[..]
-",
- error = ERROR)));
+"));
});
test!(duplicate_binary_names {
.file("b.rs", r#"fn main() -> () {}"#);
assert_that(foo.cargo_process("build"),
- execs().with_status(101).with_stderr(&format!("\
-{error} failed to parse manifest at `[..]`
+ execs().with_status(101).with_stderr("\
+[ERROR] failed to parse manifest at `[..]`
Caused by:
found duplicate binary name e, but all binary targets must have a unique name
-",
- error = ERROR)));
+"));
});
test!(duplicate_example_names {
.file("examples/ex2.rs", r#"fn main () -> () {}"#);
assert_that(foo.cargo_process("build").arg("--example").arg("ex"),
- execs().with_status(101).with_stderr(&format!("\
-{error} failed to parse manifest at `[..]`
+ execs().with_status(101).with_stderr("\
+[ERROR] failed to parse manifest at `[..]`
Caused by:
found duplicate example name ex, but all binary targets must have a unique name
-",
- error = ERROR)));
+"));
});
test!(duplicate_bench_names {
.file("benches/ex2.rs", r#"fn main () {}"#);
assert_that(foo.cargo_process("bench"),
- execs().with_status(101).with_stderr(&format!("\
-{error} failed to parse manifest at `[..]`
+ execs().with_status(101).with_stderr("\
+[ERROR] failed to parse manifest at `[..]`
Caused by:
found duplicate bench name ex, but all binary targets must have a unique name
-",
- error = ERROR)));
+"));
});
test!(duplicate_deps {
.file("src/main.rs", r#"fn main () {}"#);
assert_that(foo.cargo_process("build"),
- execs().with_status(101).with_stderr(&format!("\
-{error} failed to parse manifest at `[..]`
+ execs().with_status(101).with_stderr("\
+[ERROR] failed to parse manifest at `[..]`
Caused by:
found duplicate dependency name bar, but all dependencies must have a unique name
-",
- error = ERROR)));
+"));
});
test!(unused_keys {