@@ -239,7 +239,8 @@ fn rustpkg_exec() -> Path {
239
239
fn command_line_test ( args : & [ ~str ] , cwd : & Path ) -> ProcessOutput {
240
240
match command_line_test_with_env ( args, cwd, None ) {
241
241
Success ( r) => r,
242
- Fail ( error) => fail ! ( "Command line test failed with error {}" , error)
242
+ Fail ( error) => fail ! ( "Command line test failed with error {}" ,
243
+ error. status)
243
244
}
244
245
}
245
246
@@ -253,15 +254,15 @@ fn command_line_test_expect_fail(args: &[~str],
253
254
expected_exitcode : int ) {
254
255
match command_line_test_with_env ( args, cwd, env) {
255
256
Success ( _) => fail ! ( "Should have failed with {}, but it succeeded" , expected_exitcode) ,
256
- Fail ( error) if error. matches_exit_status ( expected_exitcode) => ( ) , // ok
257
+ Fail ( ref error) if error. status . matches_exit_status ( expected_exitcode) => ( ) , // ok
257
258
Fail ( other) => fail ! ( "Expected to fail with {}, but failed with {} instead" ,
258
- expected_exitcode, other)
259
+ expected_exitcode, other. status )
259
260
}
260
261
}
261
262
262
263
enum ProcessResult {
263
264
Success ( ProcessOutput ) ,
264
- Fail ( ProcessExit )
265
+ Fail ( ProcessOutput )
265
266
}
266
267
267
268
/// Runs `rustpkg` (based on the directory that this executable was
@@ -295,7 +296,7 @@ fn command_line_test_with_env(args: &[~str], cwd: &Path, env: Option<~[(~str, ~s
295
296
debug ! ( "Command {} {:?} failed with exit code {:?}; its output was --- {} ---" ,
296
297
cmd, args, output. status,
297
298
str :: from_utf8( output. output) + str :: from_utf8( output. error) ) ;
298
- Fail ( output. status )
299
+ Fail ( output)
299
300
}
300
301
else {
301
302
Success ( output)
@@ -1093,7 +1094,7 @@ fn no_rebuilding() {
1093
1094
1094
1095
match command_line_test_partial([~" build", ~" foo"], workspace) {
1095
1096
Success(*) => (), // ok
1096
- Fail(status) if status.matches_exit_status(65) =>
1097
+ Fail(ref status) if status. status.matches_exit_status(65) =>
1097
1098
fail!(" no_rebuilding failed: it tried to rebuild bar"),
1098
1099
Fail(_) => fail!(" no_rebuilding failed for some other reason")
1099
1100
}
@@ -1112,7 +1113,8 @@ fn no_recopying() {
1112
1113
1113
1114
match command_line_test_partial([~" install", ~" foo"], workspace) {
1114
1115
Success(*) => (), // ok
1115
- Fail(process::ExitStatus(65)) => fail!(" no_recopying failed: it tried to re-copy foo"),
1116
+ Fail(ref status) if status.status.matches_exit_status(65) =>
1117
+ fail!(" no_recopying failed: it tried to re-copy foo"),
1116
1118
Fail(_) => fail!(" no_copying failed for some other reason")
1117
1119
}
1118
1120
}
@@ -1130,7 +1132,7 @@ fn no_rebuilding_dep() {
1130
1132
assert!(chmod_read_only(&bar_lib));
1131
1133
match command_line_test_partial([~" build", ~" foo"], workspace) {
1132
1134
Success(*) => (), // ok
1133
- Fail(status ) if status.matches_exit_status(65) =>
1135
+ Fail(ref r ) if r. status.matches_exit_status(65) =>
1134
1136
fail!(" no_rebuilding_dep failed: it tried to rebuild bar"),
1135
1137
Fail(_) => fail!(" no_rebuilding_dep failed for some other reason")
1136
1138
}
@@ -1151,7 +1153,7 @@ fn do_rebuild_dep_dates_change() {
1151
1153
1152
1154
match command_line_test_partial([~" build", ~" foo"], workspace) {
1153
1155
Success(*) => fail!(" do_rebuild_dep_dates_change failed: it didn' t rebuild bar"),
1154
- Fail(status ) if status.matches_exit_status(65) => (), // ok
1156
+ Fail(ref r ) if r. status.matches_exit_status(65) => (), // ok
1155
1157
Fail(_) => fail!(" do_rebuild_dep_dates_change failed for some other reason")
1156
1158
}
1157
1159
}
@@ -1172,7 +1174,7 @@ fn do_rebuild_dep_only_contents_change() {
1172
1174
// should adjust the datestamp
1173
1175
match command_line_test_partial([~" build", ~" foo"], workspace) {
1174
1176
Success(*) => fail!(" do_rebuild_dep_only_contents_change failed: it didn' t rebuild bar"),
1175
- Fail(status ) if status.matches_exit_status(65) => (), // ok
1177
+ Fail(ref r ) if r. status.matches_exit_status(65) => (), // ok
1176
1178
Fail(_) => fail!(" do_rebuild_dep_only_contents_change failed for some other reason")
1177
1179
}
1178
1180
}
@@ -2148,7 +2150,7 @@ fn test_rebuild_when_needed() {
2148
2150
chmod_read_only(&test_executable);
2149
2151
match command_line_test_partial([~" test", ~" foo"], foo_workspace) {
2150
2152
Success(*) => fail!(" test_rebuild_when_needed didn' t rebuild"),
2151
- Fail(status ) if status.matches_exit_status(65) => (), // ok
2153
+ Fail(ref r ) if r. status.matches_exit_status(65) => (), // ok
2152
2154
Fail(_) => fail!(" test_rebuild_when_needed failed for some other reason")
2153
2155
}
2154
2156
}
@@ -2168,7 +2170,7 @@ fn test_no_rebuilding() {
2168
2170
chmod_read_only(&test_executable);
2169
2171
match command_line_test_partial([~" test", ~" foo"], foo_workspace) {
2170
2172
Success(*) => (), // ok
2171
- Fail(status ) if status.matches_exit_status(65) =>
2173
+ Fail(ref r ) if r. status.matches_exit_status(65) =>
2172
2174
fail!(" test_no_rebuilding failed: it rebuilt the tests"),
2173
2175
Fail(_) => fail!(" test_no_rebuilding failed for some other reason")
2174
2176
}
@@ -2296,7 +2298,7 @@ fn test_compile_error() {
2296
2298
let result = command_line_test_partial([~" build", ~" foo"], foo_workspace);
2297
2299
match result {
2298
2300
Success(*) => fail!(" Failed by succeeding!"), // should be a compile error
2299
- Fail(status) => {
2301
+ Fail(ref status) => {
2300
2302
debug!(" Failed with status { : ?} ... that' s good, right?", status);
2301
2303
}
2302
2304
}
@@ -2364,7 +2366,7 @@ fn test_c_dependency_no_rebuilding() {
2364
2366
2365
2367
match command_line_test_partial([~" build", ~" cdep"], dir) {
2366
2368
Success(*) => (), // ok
2367
- Fail(status ) if status.matches_exit_status(65) =>
2369
+ Fail(ref r ) if r. status.matches_exit_status(65) =>
2368
2370
fail!(" test_c_dependency_no_rebuilding failed: \
2369
2371
it tried to rebuild foo. c"),
2370
2372
Fail(_) =>
@@ -2403,11 +2405,43 @@ fn test_c_dependency_yes_rebuilding() {
2403
2405
match command_line_test_partial([~" build", ~" cdep"], dir) {
2404
2406
Success(*) => fail!(" test_c_dependency_yes_rebuilding failed: \
2405
2407
it didn' t rebuild and should have"),
2406
- Fail(status ) if status.matches_exit_status(65) => (),
2408
+ Fail(ref r ) if r. status.matches_exit_status(65) => (),
2407
2409
Fail(_) => fail!(" test_c_dependency_yes_rebuilding failed for some other reason")
2408
2410
}
2409
2411
}
2410
2412
2413
+ // n.b. This might help with #10253, or at least the error will be different.
2414
+ #[test]
2415
+ fn correct_error_dependency() {
2416
+ // Supposing a package we're trying to install via a dependency doesn't
2417
+ // exist, we should throw a condition, and not ICE
2418
+ let dir = create_local_package(&PkgId::new(" badpkg"));
2419
+
2420
+ let dir = dir.path();
2421
+ writeFile(&dir.join_many([" src", " badpkg-0.1 ", " main. rs"]),
2422
+ " extern mod p = \"some_package_that_doesnt_exist\" ;
2423
+ fn main( ) { } ");
2424
+
2425
+ match command_line_test_partial([~" build", ~" badpkg"], dir) {
2426
+ Fail(ProcessOutput{ error: error, output: output, _ }) => {
2427
+ assert!(str::is_utf8(error));
2428
+ assert!(str::is_utf8(output));
2429
+ let error_str = str::from_utf8(error);
2430
+ let out_str = str::from_utf8(output);
2431
+ debug!(" ss = { } ", error_str);
2432
+ debug!(" out_str = { } ", out_str);
2433
+ if out_str.contains(" Package badpkg depends on some_package_that_doesnt_exist") &&
2434
+ !error_str.contains(" nonexistent_package") {
2435
+ // Ok
2436
+ ()
2437
+ } else {
2438
+ fail!(" Wrong error");
2439
+ }
2440
+ }
2441
+ Success(*) => fail!(" Test passed when it should have failed")
2442
+ }
2443
+ }
2444
+
2411
2445
/// Returns true if p exists and is executable
2412
2446
fn is_executable( p: & Path ) -> bool {
2413
2447
p. exists( ) && p. stat( ) . perm & io:: UserExecute == io:: UserExecute
0 commit comments