Skip to content

Commit e482856

Browse files
committed
auto merge of #7409 : alexcrichton/rust/threadsafe, r=cmr
@catamorphism, this re-enables threadsafe rustpkg tests, @brson this will fail unless the bots have LLVM rebuilt, so this is a good indicator of whether that happened or not.
2 parents b44953b + 5183a6c commit e482856

File tree

4 files changed

+67
-54
lines changed

4 files changed

+67
-54
lines changed

src/librustc/middle/trans/base.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -2901,6 +2901,10 @@ pub fn trans_crate(sess: session::Session,
29012901
reachable_map: @mut HashSet<ast::node_id>,
29022902
maps: astencode::Maps)
29032903
-> (ContextRef, ModuleRef, LinkMeta) {
2904+
// Before we touch LLVM, make sure that multithreading is enabled.
2905+
if unsafe { !llvm::LLVMRustStartMultithreading() } {
2906+
sess.bug("couldn't enable multi-threaded LLVM");
2907+
}
29042908
29052909
let mut symbol_hasher = hash::default_state();
29062910
let link_meta = link::build_link_meta(sess, crate, output, &mut symbol_hasher);
@@ -2915,12 +2919,6 @@ pub fn trans_crate(sess: session::Session,
29152919
// 1. http://llvm.org/bugs/show_bug.cgi?id=11479
29162920
let llmod_id = link_meta.name.to_owned() + ".rc";
29172921
2918-
// FIXME(#6511): get LLVM building with --enable-threads so this
2919-
// function can be called
2920-
// if !llvm::LLVMRustStartMultithreading() {
2921-
// sess.bug("couldn't enable multi-threaded LLVM");
2922-
// }
2923-
29242922
let ccx = @mut CrateContext::new(sess,
29252923
llmod_id,
29262924
tcx,

src/librusti/rusti.rs

+49-34
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@ mod tests {
528528
}
529529
}
530530

531+
// FIXME: #7220 rusti on 32bit mac doesn't work.
532+
#[cfg(not(target_word_size="32"))]
533+
#[cfg(not(target_os="macos"))]
531534
fn run_program(prog: &str) {
532535
let mut r = repl();
533536
for prog.split_iter('\n').advance |cmd| {
@@ -536,63 +539,66 @@ mod tests {
536539
r = result.expect(fmt!("the command '%s' failed", cmd));
537540
}
538541
}
542+
#[cfg(target_word_size="32", target_os="macos")]
543+
fn run_program(_: &str) {}
539544

540545
#[test]
541-
// FIXME: #7220 rusti on 32bit mac doesn't work.
542-
#[cfg(not(target_word_size="32",
543-
target_os="macos"))]
544-
fn run_all() {
545-
// FIXME(#7071):
546-
// By default, unit tests are run in parallel. Rusti, on the other hand,
547-
// does not enjoy doing this. I suspect that it is because the LLVM
548-
// bindings are not thread-safe (when running parallel tests, some tests
549-
// were triggering assertions in LLVM (or segfaults). Hence, this
550-
// function exists to run everything serially (sadface).
551-
//
552-
// To get some interesting output, run with RUST_LOG=rusti::tests
553-
554-
debug!("hopefully this runs");
546+
fn super_basic() {
555547
run_program("");
548+
}
556549

557-
debug!("regression test for #5937");
550+
#[test]
551+
fn regression_5937() {
558552
run_program("use std::hashmap;");
553+
}
559554

560-
debug!("regression test for #5784");
555+
#[test]
556+
fn regression_5784() {
561557
run_program("let a = 3;");
558+
}
562559

560+
#[test] #[ignore]
561+
fn new_tasks() {
563562
// XXX: can't spawn new tasks because the JIT code is cleaned up
564563
// after the main function is done.
565-
// debug!("regression test for #5803");
566-
// run_program("
567-
// spawn( || println(\"Please don't segfault\") );
568-
// do spawn { println(\"Please?\"); }
569-
// ");
564+
run_program("
565+
spawn( || println(\"Please don't segfault\") );
566+
do spawn { println(\"Please?\"); }
567+
");
568+
}
570569

571-
debug!("inferred integers are usable");
570+
#[test]
571+
fn inferred_integers_usable() {
572572
run_program("let a = 2;\n()\n");
573573
run_program("
574574
let a = 3;
575575
let b = 4u;
576576
assert!((a as uint) + b == 7)
577577
");
578+
}
578579

579-
debug!("local variables can be shadowed");
580+
#[test]
581+
fn local_variables_allow_shadowing() {
580582
run_program("
581583
let a = 3;
582584
let a = 5;
583585
assert!(a == 5)
584586
");
587+
}
585588

586-
debug!("strings are usable");
589+
#[test]
590+
fn string_usable() {
587591
run_program("
588592
let a = ~\"\";
589593
let b = \"\";
590594
let c = @\"\";
591595
let d = a + b + c;
592596
assert!(d.len() == 0);
593597
");
598+
}
594599

595-
debug!("vectors are usable");
600+
#[test]
601+
fn vectors_usable() {
596602
run_program("
597603
let a = ~[1, 2, 3];
598604
let b = &[1, 2, 3];
@@ -601,15 +607,19 @@ mod tests {
601607
assert!(d.len() == 9);
602608
let e: &[int] = [];
603609
");
610+
}
604611

605-
debug!("structs are usable");
612+
#[test]
613+
fn structs_usable() {
606614
run_program("
607615
struct A{ a: int }
608616
let b = A{ a: 3 };
609617
assert!(b.a == 3)
610618
");
619+
}
611620

612-
debug!("mutable variables");
621+
#[test]
622+
fn mutable_variables_work() {
613623
run_program("
614624
let mut a = 3;
615625
a = 5;
@@ -618,29 +628,37 @@ mod tests {
618628
assert!(b.contains(&5))
619629
assert!(b.len() == 1)
620630
");
631+
}
621632

622-
debug!("functions are cached");
633+
#[test]
634+
fn functions_saved() {
623635
run_program("
624636
fn fib(x: int) -> int { if x < 2 {x} else { fib(x - 1) + fib(x - 2) } }
625637
let a = fib(3);
626638
let a = a + fib(4);
627639
assert!(a == 5)
628640
");
641+
}
629642

630-
debug!("modules are cached");
643+
#[test]
644+
fn modules_saved() {
631645
run_program("
632646
mod b { pub fn foo() -> uint { 3 } }
633647
assert!(b::foo() == 3)
634648
");
649+
}
635650

636-
debug!("multiple function definitions are allowed");
651+
#[test]
652+
fn multiple_functions() {
637653
run_program("
638654
fn f() {}
639655
fn f() {}
640656
f()
641657
");
658+
}
642659

643-
debug!("multiple item definitions are allowed");
660+
#[test]
661+
fn multiple_items_same_name() {
644662
run_program("
645663
fn f() {}
646664
mod f {}
@@ -657,9 +675,6 @@ mod tests {
657675
}
658676

659677
#[test]
660-
// FIXME: #7220 rusti on 32bit mac doesn't work.
661-
#[cfg(not(target_word_size="32",
662-
target_os="macos"))]
663678
fn exit_quits() {
664679
let mut r = repl();
665680
assert!(r.running);

src/librustpkg/tests.rs

+10-14
Original file line numberDiff line numberDiff line change
@@ -307,18 +307,10 @@ fn frob_source_file(workspace: &Path, pkgid: &PkgId) {
307307
}
308308
}
309309

310-
#[test] #[ignore] //FIXME(#7249)
311-
fn test_all() {
312-
// FIXME(#7071): these tests use rustc, so they can't be run in parallel
313-
// until this issue is resolved
314-
test_make_dir_rwx();
315-
test_install_valid();
316-
test_install_invalid();
317-
test_install_url();
318-
test_package_ids_must_be_relative_path_like();
319-
test_package_version();
320-
}
310+
// FIXME(#7249): these tests fail on multi-platform builds, so for now they're
311+
// only run one x86
321312

313+
#[test] #[ignore(cfg(target_arch = "x86"))]
322314
fn test_make_dir_rwx() {
323315
let temp = &os::tmpdir();
324316
let dir = temp.push("quux");
@@ -331,6 +323,7 @@ fn test_make_dir_rwx() {
331323
assert!(os::remove_dir_recursive(&dir));
332324
}
333325

326+
#[test] #[ignore(cfg(target_arch = "x86"))]
334327
fn test_install_valid() {
335328
use path_util::installed_library_in_workspace;
336329

@@ -360,6 +353,7 @@ fn test_install_valid() {
360353
assert!(!os::path_exists(&bench));
361354
}
362355

356+
#[test] #[ignore(cfg(target_arch = "x86"))]
363357
fn test_install_invalid() {
364358
use conditions::nonexistent_package::cond;
365359
use cond1 = conditions::missing_pkg_files::cond;
@@ -382,6 +376,7 @@ fn test_install_invalid() {
382376
assert!(error_occurred && error1_occurred);
383377
}
384378

379+
#[test] #[ignore(cfg(target_arch = "x86"))]
385380
fn test_install_url() {
386381
let workspace = mkdtemp(&os::tmpdir(), "test").expect("couldn't create temp dir");
387382
let sysroot = test_sysroot();
@@ -417,6 +412,7 @@ fn test_install_url() {
417412
assert!(!os::path_exists(&bench));
418413
}
419414

415+
#[test] #[ignore(cfg(target_arch = "x86"))]
420416
fn test_package_ids_must_be_relative_path_like() {
421417
use conditions::bad_pkg_id::cond;
422418

@@ -457,6 +453,7 @@ fn test_package_ids_must_be_relative_path_like() {
457453
458454
}
459455
456+
#[test] #[ignore(cfg(target_arch = "x86"))]
460457
fn test_package_version() {
461458
let temp_pkg_id = PkgId::new("github.com/catamorphism/test_pkg_version");
462459
match temp_pkg_id.version {
@@ -479,9 +476,8 @@ fn test_package_version() {
479476
push("test_pkg_version")));
480477
}
481478
482-
// FIXME #7006: Fails on linux for some reason
483-
#[test]
484-
#[ignore]
479+
// FIXME #7006: Fails on linux/mac for some reason
480+
#[test] #[ignore]
485481
fn test_package_request_version() {
486482
let temp_pkg_id = PkgId::new("github.com/catamorphism/test_pkg_version#0.3");
487483
let temp = mk_empty_workspace(&LocalPath(Path("test_pkg_version")), &ExactRevision(~"0.3"));

src/rustllvm/llvm-auto-clean-trigger

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# If this file is modified, then llvm will be forcibly cleaned and then rebuilt.
2+
# The actual contents of this file do not matter, but to trigger a change on the
3+
# build bots then the contents should be changed so git updates the mtime.
4+
6-29-2013

0 commit comments

Comments
 (0)