fn command_line_test(args: &[~str], cwd: &Path) -> ProcessOutput {
match command_line_test_with_env(args, cwd, None) {
Success(r) => r,
- Fail(error) => fail!("Command line test failed with error {}", error)
+ Fail(error) => fail!("Command line test failed with error {}",
+ error.status)
}
}
expected_exitcode: int) {
match command_line_test_with_env(args, cwd, env) {
Success(_) => fail!("Should have failed with {}, but it succeeded", expected_exitcode),
- Fail(error) if error.matches_exit_status(expected_exitcode) => (), // ok
+ Fail(ref error) if error.status.matches_exit_status(expected_exitcode) => (), // ok
Fail(other) => fail!("Expected to fail with {}, but failed with {} instead",
- expected_exitcode, other)
+ expected_exitcode, other.status)
}
}
enum ProcessResult {
Success(ProcessOutput),
- Fail(ProcessExit)
+ Fail(ProcessOutput)
}
/// Runs `rustpkg` (based on the directory that this executable was
debug!("Command {} {:?} failed with exit code {:?}; its output was --- {} ---",
cmd, args, output.status,
str::from_utf8(output.output) + str::from_utf8(output.error));
- Fail(output.status)
+ Fail(output)
}
else {
Success(output)
match command_line_test_partial([~"build", ~"foo"], workspace) {
Success(*) => (), // ok
- Fail(status) if status.matches_exit_status(65) =>
+ Fail(ref status) if status.status.matches_exit_status(65) =>
fail!("no_rebuilding failed: it tried to rebuild bar"),
Fail(_) => fail!("no_rebuilding failed for some other reason")
}
match command_line_test_partial([~"install", ~"foo"], workspace) {
Success(*) => (), // ok
- Fail(process::ExitStatus(65)) => fail!("no_recopying failed: it tried to re-copy foo"),
+ Fail(ref status) if status.status.matches_exit_status(65) =>
+ fail!("no_recopying failed: it tried to re-copy foo"),
Fail(_) => fail!("no_copying failed for some other reason")
}
}
assert!(chmod_read_only(&bar_lib));
match command_line_test_partial([~"build", ~"foo"], workspace) {
Success(*) => (), // ok
- Fail(status) if status.matches_exit_status(65) =>
+ Fail(ref r) if r.status.matches_exit_status(65) =>
fail!("no_rebuilding_dep failed: it tried to rebuild bar"),
Fail(_) => fail!("no_rebuilding_dep failed for some other reason")
}
match command_line_test_partial([~"build", ~"foo"], workspace) {
Success(*) => fail!("do_rebuild_dep_dates_change failed: it didn't rebuild bar"),
- Fail(status) if status.matches_exit_status(65) => (), // ok
+ Fail(ref r) if r.status.matches_exit_status(65) => (), // ok
Fail(_) => fail!("do_rebuild_dep_dates_change failed for some other reason")
}
}
// should adjust the datestamp
match command_line_test_partial([~"build", ~"foo"], workspace) {
Success(*) => fail!("do_rebuild_dep_only_contents_change failed: it didn't rebuild bar"),
- Fail(status) if status.matches_exit_status(65) => (), // ok
+ Fail(ref r) if r.status.matches_exit_status(65) => (), // ok
Fail(_) => fail!("do_rebuild_dep_only_contents_change failed for some other reason")
}
}
chmod_read_only(&test_executable);
match command_line_test_partial([~"test", ~"foo"], foo_workspace) {
Success(*) => fail!("test_rebuild_when_needed didn't rebuild"),
- Fail(status) if status.matches_exit_status(65) => (), // ok
+ Fail(ref r) if r.status.matches_exit_status(65) => (), // ok
Fail(_) => fail!("test_rebuild_when_needed failed for some other reason")
}
}
chmod_read_only(&test_executable);
match command_line_test_partial([~"test", ~"foo"], foo_workspace) {
Success(*) => (), // ok
- Fail(status) if status.matches_exit_status(65) =>
+ Fail(ref r) if r.status.matches_exit_status(65) =>
fail!("test_no_rebuilding failed: it rebuilt the tests"),
Fail(_) => fail!("test_no_rebuilding failed for some other reason")
}
let result = command_line_test_partial([~"build", ~"foo"], foo_workspace);
match result {
Success(*) => fail!("Failed by succeeding!"), // should be a compile error
- Fail(status) => {
+ Fail(ref status) => {
debug!("Failed with status {:?}... that's good, right?", status);
}
}
match command_line_test_partial([~"build", ~"cdep"], dir) {
Success(*) => (), // ok
- Fail(status) if status.matches_exit_status(65) =>
+ Fail(ref r) if r.status.matches_exit_status(65) =>
fail!("test_c_dependency_no_rebuilding failed: \
it tried to rebuild foo.c"),
Fail(_) =>
match command_line_test_partial([~"build", ~"cdep"], dir) {
Success(*) => fail!("test_c_dependency_yes_rebuilding failed: \
it didn't rebuild and should have"),
- Fail(status) if status.matches_exit_status(65) => (),
+ Fail(ref r) if r.status.matches_exit_status(65) => (),
Fail(_) => fail!("test_c_dependency_yes_rebuilding failed for some other reason")
}
}
+// n.b. This might help with #10253, or at least the error will be different.
+#[test]
+fn correct_error_dependency() {
+ // Supposing a package we're trying to install via a dependency doesn't
+ // exist, we should throw a condition, and not ICE
+ let dir = create_local_package(&PkgId::new("badpkg"));
+
+ let dir = dir.path();
+ writeFile(&dir.join_many(["src", "badpkg-0.1", "main.rs"]),
+ "extern mod p = \"some_package_that_doesnt_exist\";
+ fn main() {}");
+
+ match command_line_test_partial([~"build", ~"badpkg"], dir) {
+ Fail(ProcessOutput{ error: error, output: output, _ }) => {
+ assert!(str::is_utf8(error));
+ assert!(str::is_utf8(output));
+ let error_str = str::from_utf8(error);
+ let out_str = str::from_utf8(output);
+ debug!("ss = {}", error_str);
+ debug!("out_str = {}", out_str);
+ if out_str.contains("Package badpkg depends on some_package_that_doesnt_exist") &&
+ !error_str.contains("nonexistent_package") {
+ // Ok
+ ()
+ } else {
+ fail!("Wrong error");
+ }
+ }
+ Success(*) => fail!("Test passed when it should have failed")
+ }
+}
+
/// Returns true if p exists and is executable
fn is_executable(p: &Path) -> bool {
p.exists() && p.stat().perm & io::UserExecute == io::UserExecute
use extra::treemap::TreeMap;
pub use target::{lib_name_of, lib_crate_filename, WhatToBuild, MaybeCustom, Inferred};
use workcache_support::{digest_file_with_date, digest_only_date};
+use messages::error;
// It would be nice to have the list of commands in just one place -- for example,
// you could update the match in rustpkg.rc but forget to update this list. I think
impl<'self> Visitor<()> for ViewItemVisitor<'self> {
fn visit_view_item(&mut self, vi: &ast::view_item, env: ()) {
+ use conditions::nonexistent_package::cond;
+
match vi.node {
// ignore metadata, I guess
ast::view_item_extern_mod(lib_ident, path_opt, _, _) => {
// and the `PkgSrc` constructor will detect that;
// or else it's already in a workspace and we'll build into that
// workspace
- let pkg_src = PkgSrc::new(source_workspace,
- dest_workspace,
- // Use the rust_path_hack to search for dependencies iff
- // we were already using it
- self.context.context.use_rust_path_hack,
- pkg_id.clone());
+ let pkg_src = do cond.trap(|_| {
+ // Nonexistent package? Then print a better error
+ error(format!("Package {} depends on {}, but I don't know \
+ how to find it",
+ self.parent.path.display(),
+ pkg_id.path.display()));
+ fail!()
+ }).inside {
+ PkgSrc::new(source_workspace.clone(),
+ dest_workspace.clone(),
+ // Use the rust_path_hack to search for dependencies iff
+ // we were already using it
+ self.context.context.use_rust_path_hack,
+ pkg_id.clone())
+ };
let (outputs_disc, inputs_disc) =
self.context.install(
pkg_src,