@@ -36,7 +36,6 @@ use syntax::diagnostic;
36
36
use target:: * ;
37
37
use package_source:: PkgSrc ;
38
38
use source_control:: { CheckedOutSources , DirToUse , safe_git_clone} ;
39
- use exit_codes:: { BAD_FLAG_CODE , COPY_FAILED_CODE } ;
40
39
use util:: datestamp;
41
40
42
41
fn fake_ctxt ( sysroot : Path , workspace : & Path ) -> BuildContext {
@@ -245,26 +244,14 @@ fn rustpkg_exec() -> Path {
245
244
fn command_line_test ( args : & [ ~str ] , cwd : & Path ) -> ProcessOutput {
246
245
match command_line_test_with_env ( args, cwd, None ) {
247
246
Success ( r) => r,
248
- Fail ( error ) => fail2 ! ( "Command line test failed with error {}" , error )
247
+ _ => fail2 ! ( "Command line test failed" )
249
248
}
250
249
}
251
250
252
251
fn command_line_test_partial ( args : & [ ~str ] , cwd : & Path ) -> ProcessResult {
253
252
command_line_test_with_env ( args, cwd, None )
254
253
}
255
254
256
- fn command_line_test_expect_fail ( args : & [ ~str ] ,
257
- cwd : & Path ,
258
- env : Option < ~[ ( ~str , ~str ) ] > ,
259
- expected_exitcode : int ) {
260
- match command_line_test_with_env ( args, cwd, env) {
261
- Success ( _) => fail2 ! ( "Should have failed with {}, but it succeeded" , expected_exitcode) ,
262
- Fail ( error) if error == expected_exitcode => ( ) , // ok
263
- Fail ( other) => fail2 ! ( "Expected to fail with {}, but failed with {} instead" ,
264
- expected_exitcode, other)
265
- }
266
- }
267
-
268
255
enum ProcessResult {
269
256
Success ( ProcessOutput ) ,
270
257
Fail ( int ) // exit code
@@ -1461,11 +1448,11 @@ fn compile_flag_fail() {
1461
1448
let p_id = PkgId :: new ( "foo" ) ;
1462
1449
let workspace = create_local_package ( & p_id) ;
1463
1450
let workspace = workspace. path ( ) ;
1464
- command_line_test_expect_fail ( [ test_sysroot ( ) . to_str ( ) ,
1451
+ command_line_test ( [ test_sysroot ( ) . to_str ( ) ,
1465
1452
~"install",
1466
1453
~"--no-link",
1467
1454
~"foo"] ,
1468
- workspace, None , BAD_FLAG_CODE ) ;
1455
+ workspace) ;
1469
1456
assert ! ( !built_executable_exists( workspace, "foo" ) ) ;
1470
1457
assert ! ( !object_file_exists( workspace, "foo" ) ) ;
1471
1458
}
@@ -1501,11 +1488,14 @@ fn notrans_flag_fail() {
1501
1488
let flags_to_test = [ ~"--no-trans", ~"--parse-only",
1502
1489
~"--pretty", ~"-S "] ;
1503
1490
for flag in flags_to_test. iter ( ) {
1504
- command_line_test_expect_fail ( [ test_sysroot ( ) . to_str ( ) ,
1491
+ command_line_test ( [ test_sysroot ( ) . to_str ( ) ,
1505
1492
~"install",
1506
1493
flag. clone ( ) ,
1507
1494
~"foo"] ,
1508
- workspace, None , BAD_FLAG_CODE ) ;
1495
+ workspace) ;
1496
+ // Ideally we'd test that rustpkg actually fails, but
1497
+ // since task failure doesn't set the exit code properly,
1498
+ // we can't tell
1509
1499
assert ! ( !built_executable_exists( workspace, "foo" ) ) ;
1510
1500
assert ! ( !object_file_exists( workspace, "foo" ) ) ;
1511
1501
assert ! ( !lib_exists( workspace, & Path ( "foo" ) , NoVersion ) ) ;
@@ -1532,11 +1522,11 @@ fn dash_S_fail() {
1532
1522
let p_id = PkgId :: new ( "foo" ) ;
1533
1523
let workspace = create_local_package ( & p_id) ;
1534
1524
let workspace = workspace. path ( ) ;
1535
- command_line_test_expect_fail ( [ test_sysroot ( ) . to_str ( ) ,
1525
+ command_line_test ( [ test_sysroot ( ) . to_str ( ) ,
1536
1526
~"install",
1537
1527
~"-S ",
1538
1528
~"foo"] ,
1539
- workspace, None , BAD_FLAG_CODE ) ;
1529
+ workspace) ;
1540
1530
assert ! ( !built_executable_exists( workspace, "foo" ) ) ;
1541
1531
assert ! ( !object_file_exists( workspace, "foo" ) ) ;
1542
1532
assert ! ( !assembly_file_exists( workspace, "foo" ) ) ;
@@ -1597,13 +1587,11 @@ fn test_emit_llvm_S_fail() {
1597
1587
let p_id = PkgId :: new ( "foo" ) ;
1598
1588
let workspace = create_local_package ( & p_id) ;
1599
1589
let workspace = workspace. path ( ) ;
1600
- command_line_test_expect_fail ( [ test_sysroot ( ) . to_str ( ) ,
1590
+ command_line_test ( [ test_sysroot ( ) . to_str ( ) ,
1601
1591
~"install",
1602
1592
~"-S ", ~"--emit-llvm",
1603
1593
~"foo"] ,
1604
- workspace,
1605
- None ,
1606
- BAD_FLAG_CODE ) ;
1594
+ workspace) ;
1607
1595
assert ! ( !built_executable_exists( workspace, "foo" ) ) ;
1608
1596
assert ! ( !object_file_exists( workspace, "foo" ) ) ;
1609
1597
assert ! ( !llvm_assembly_file_exists( workspace, "foo" ) ) ;
@@ -1632,13 +1620,11 @@ fn test_emit_llvm_fail() {
1632
1620
let p_id = PkgId :: new ( "foo" ) ;
1633
1621
let workspace = create_local_package ( & p_id) ;
1634
1622
let workspace = workspace. path ( ) ;
1635
- command_line_test_expect_fail ( [ test_sysroot ( ) . to_str ( ) ,
1623
+ command_line_test ( [ test_sysroot ( ) . to_str ( ) ,
1636
1624
~"install",
1637
1625
~"--emit-llvm",
1638
1626
~"foo"] ,
1639
- workspace,
1640
- None ,
1641
- BAD_FLAG_CODE ) ;
1627
+ workspace) ;
1642
1628
assert ! ( !built_executable_exists( workspace, "foo" ) ) ;
1643
1629
assert ! ( !object_file_exists( workspace, "foo" ) ) ;
1644
1630
assert ! ( !llvm_bitcode_file_exists( workspace, "foo" ) ) ;
@@ -1679,10 +1665,11 @@ fn test_build_install_flags_fail() {
1679
1665
~[ ~"--target", host_triple ( ) ] ,
1680
1666
~[ ~"--target-cpu", ~"generic"] ,
1681
1667
~[ ~"-Z ", ~"--time-passes"] ] ;
1682
- let cwd = os:: getcwd ( ) ;
1683
1668
for flag in forbidden. iter ( ) {
1684
- command_line_test_expect_fail ( [ test_sysroot ( ) . to_str ( ) ,
1685
- ~"list"] + * flag, & cwd, None , BAD_FLAG_CODE ) ;
1669
+ let output = command_line_test_output ( [ test_sysroot ( ) . to_str ( ) ,
1670
+ ~"list"] + * flag) ;
1671
+ assert ! ( output. len( ) > 1 ) ;
1672
+ assert ! ( output[ 1 ] . find_str( "can only be used with" ) . is_some( ) ) ;
1686
1673
}
1687
1674
}
1688
1675
@@ -1699,7 +1686,6 @@ fn test_optimized_build() {
1699
1686
assert ! ( built_executable_exists( workspace, "foo" ) ) ;
1700
1687
}
1701
1688
1702
- #[ test]
1703
1689
fn pkgid_pointing_to_subdir( ) {
1704
1690
// The actual repo is mocki.8713187.xyz/mozilla/some_repo
1705
1691
// rustpkg should recognize that and treat the part after some_repo/ as a subdir
@@ -1731,7 +1717,6 @@ fn pkgid_pointing_to_subdir() {
1731
1717
assert_executable_exists(workspace, " testpkg");
1732
1718
}
1733
1719
1734
- #[test]
1735
1720
fn test_recursive_deps() {
1736
1721
let a_id = PkgId::new(" a");
1737
1722
let b_id = PkgId::new(" b");
@@ -1777,7 +1762,6 @@ fn test_install_to_rust_path() {
1777
1762
assert!(!executable_exists(second_workspace, " foo"));
1778
1763
}
1779
1764
1780
- #[test]
1781
1765
fn test_target_specific_build_dir() {
1782
1766
let p_id = PkgId::new(" foo");
1783
1767
let workspace = create_local_package(&p_id);
@@ -1886,9 +1870,8 @@ fn correct_package_name_with_rust_path_hack() {
1886
1870
let rust_path = Some(~[(~" RUST_PATH ", format!(" { } : { } ", dest_workspace.to_str(),
1887
1871
foo_workspace.push_many([" src", " foo-0.1 "]).to_str()))]);
1888
1872
// bar doesn't exist, but we want to make sure rustpkg doesn't think foo is bar
1889
- command_line_test_expect_fail([~" install", ~" --rust-path-hack", ~" bar"],
1890
- // FIXME #3408: Should be NONEXISTENT_PACKAGE_CODE
1891
- dest_workspace, rust_path, COPY_FAILED_CODE);
1873
+ command_line_test_with_env([~" install", ~" --rust-path-hack", ~" bar"],
1874
+ dest_workspace, rust_path);
1892
1875
assert!(!executable_exists(dest_workspace, " bar"));
1893
1876
assert!(!lib_exists(dest_workspace, &bar_id.path.clone(), bar_id.version.clone()));
1894
1877
assert!(!executable_exists(dest_workspace, " foo"));
@@ -2067,23 +2050,6 @@ fn test_7402() {
2067
2050
assert_executable_exists(dest_workspace, " foo") ;
2068
2051
}
2069
2052
2070
- #[test]
2071
- fn test_compile_error() {
2072
- let foo_id = PkgId::new(" foo");
2073
- let foo_workspace = create_local_package(&foo_id);
2074
- let foo_workspace = foo_workspace.path();
2075
- let main_crate = foo_workspace.push_many([" src", " foo-0.1 ", " main. rs"]);
2076
- // Write something bogus
2077
- writeFile(&main_crate, " pub fn main( ) { if 42 != ~\" the answer\" { fail!( ) ; } } ");
2078
- let result = command_line_test_partial([~" build", ~" foo"], foo_workspace);
2079
- match result {
2080
- Success(*) => fail2!(" Failed by succeeding!"), // should be a compile error
2081
- Fail(status) => {
2082
- debug2!(" Failed with status { : ?} ... that' s good, right?" , status) ;
2083
- }
2084
- }
2085
- }
2086
-
2087
2053
/// Returns true if p exists and is executable
2088
2054
fn is_executable( p: & Path ) -> bool {
2089
2055
use std:: libc:: consts:: os:: posix88:: { S_IXUSR } ;
0 commit comments