Skip to content

Commit c0037d7

Browse files
authored
Rollup merge of rust-lang#135948 - bjorn3:update_emscripten_std_tests, r=Mark-Simulacrum
Update emscripten std tests This disables a bunch of emscripten tests that test things emscripten doesn't support and re-enables a whole bunch of tests which now work just fine on emscripten. Tested with `EMCC_CFLAGS="-s MAXIMUM_MEMORY=2GB" ./x.py test library/ --target wasm32-unknown-emscripten`.
2 parents ca5e77e + a274dc0 commit c0037d7

File tree

22 files changed

+63
-67
lines changed

22 files changed

+63
-67
lines changed

alloc/benches/btree/map.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ pub fn iter_10k(b: &mut Bencher) {
353353
}
354354

355355
#[bench]
356+
#[cfg_attr(target_os = "emscripten", ignore)] // hits an OOM
356357
pub fn iter_1m(b: &mut Bencher) {
357358
bench_iter(b, 1_000, 1_000_000);
358359
}

alloc/benches/slice.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,25 @@ rotate!(rotate_medium_half, gen_random, 9158, 9158 / 2);
366366
rotate!(rotate_medium_half_plus_one, gen_random, 9158, 9158 / 2 + 1);
367367

368368
// Intended to use more RAM than the machine has cache
369+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
369370
rotate!(rotate_huge_by1, gen_random, 5 * 1024 * 1024, 1);
371+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
370372
rotate!(rotate_huge_by9199_u64, gen_random, 5 * 1024 * 1024, 9199);
373+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
371374
rotate!(rotate_huge_by9199_bytes, gen_random_bytes, 5 * 1024 * 1024, 9199);
375+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
372376
rotate!(rotate_huge_by9199_strings, gen_strings, 5 * 1024 * 1024, 9199);
377+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
373378
rotate!(rotate_huge_by9199_big, gen_big_random, 5 * 1024 * 1024, 9199);
379+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
374380
rotate!(rotate_huge_by1234577_u64, gen_random, 5 * 1024 * 1024, 1234577);
381+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
375382
rotate!(rotate_huge_by1234577_bytes, gen_random_bytes, 5 * 1024 * 1024, 1234577);
383+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
376384
rotate!(rotate_huge_by1234577_strings, gen_strings, 5 * 1024 * 1024, 1234577);
385+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
377386
rotate!(rotate_huge_by1234577_big, gen_big_random, 5 * 1024 * 1024, 1234577);
387+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
378388
rotate!(rotate_huge_half, gen_random, 5 * 1024 * 1024, 5 * 1024 * 1024 / 2);
389+
#[cfg(not(target_os = "emscripten"))] // hits an OOM
379390
rotate!(rotate_huge_half_plus_one, gen_random, 5 * 1024 * 1024, 5 * 1024 * 1024 / 2 + 1);

alloc/benches/vec.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,11 @@ fn bench_in_place_collect_droppable(b: &mut Bencher) {
547547
})
548548
}
549549

550+
// node.js gives out of memory error to use with length 1_100_000
551+
#[cfg(target_os = "emscripten")]
552+
const LEN: usize = 4096;
553+
554+
#[cfg(not(target_os = "emscripten"))]
550555
const LEN: usize = 16384;
551556

552557
#[bench]

alloc/tests/collections/binary_heap.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,7 @@ fn test_retain_catch_unwind() {
502502
// even if the order might not be correct.
503503
//
504504
// Destructors must be called exactly once per element.
505-
// FIXME: re-enable emscripten once it can unwind again
506505
#[test]
507-
#[cfg(not(target_os = "emscripten"))]
508506
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
509507
fn panic_safe() {
510508
use std::cmp;

alloc/tests/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ fn test_rng() -> rand_xorshift::XorShiftRng {
9494
rand::SeedableRng::from_seed(seed)
9595
}
9696

97-
// FIXME: Instantiated functions with i128 in the signature is not supported in Emscripten.
98-
// See https://github.com/kripken/emscripten-fastcomp/issues/169
99-
#[cfg(not(target_os = "emscripten"))]
10097
#[test]
10198
fn test_boxed_hasher() {
10299
let ordinary_hash = hash(&5u32);

alloc/tests/slice.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,6 @@ fn test_box_slice_clone() {
14141414

14151415
#[test]
14161416
#[allow(unused_must_use)] // here, we care about the side effects of `.clone()`
1417-
#[cfg_attr(target_os = "emscripten", ignore)]
14181417
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
14191418
fn test_box_slice_clone_panics() {
14201419
use std::sync::Arc;

alloc/tests/sort/tests.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ use crate::sort::{Sort, known_good_stable_sort, patterns};
1111
#[cfg(miri)]
1212
const TEST_LENGTHS: &[usize] = &[2, 3, 4, 7, 10, 15, 20, 24, 33, 50, 100, 171, 300];
1313

14-
#[cfg(not(miri))]
14+
// node.js gives out of memory error to use with length 1_100_000
15+
#[cfg(all(not(miri), target_os = "emscripten"))]
16+
const TEST_LENGTHS: &[usize] = &[
17+
2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 16, 17, 20, 24, 30, 32, 33, 35, 50, 100, 200, 500, 1_000,
18+
2_048, 5_000, 10_000, 100_000,
19+
];
20+
21+
#[cfg(all(not(miri), not(target_os = "emscripten")))]
1522
const TEST_LENGTHS: &[usize] = &[
1623
2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 16, 17, 20, 24, 30, 32, 33, 35, 50, 100, 200, 500, 1_000,
1724
2_048, 5_000, 10_000, 100_000, 1_100_000,

alloc/tests/sync.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ fn try_unwrap() {
128128
}
129129

130130
#[test]
131+
#[cfg_attr(any(target_os = "emscripten", target_os = "wasi"), ignore)] // no threads
131132
fn into_inner() {
132133
for _ in 0..100
133134
// ^ Increase chances of hitting potential race conditions

alloc/tests/vec.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,9 +1587,7 @@ fn extract_if_complex() {
15871587
}
15881588
}
15891589

1590-
// FIXME: re-enable emscripten once it can unwind again
15911590
#[test]
1592-
#[cfg(not(target_os = "emscripten"))]
15931591
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
15941592
fn extract_if_consumed_panic() {
15951593
use std::rc::Rc;
@@ -1640,9 +1638,7 @@ fn extract_if_consumed_panic() {
16401638
}
16411639
}
16421640

1643-
// FIXME: Re-enable emscripten once it can catch panics
16441641
#[test]
1645-
#[cfg(not(target_os = "emscripten"))]
16461642
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
16471643
fn extract_if_unconsumed_panic() {
16481644
use std::rc::Rc;

core/tests/hash/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ fn test_custom_state() {
141141
// const { assert!(hash(&Custom { hash: 6 }) == 6) };
142142
}
143143

144-
// FIXME: Instantiated functions with i128 in the signature is not supported in Emscripten.
145-
// See https://github.com/kripken/emscripten-fastcomp/issues/169
146-
#[cfg(not(target_os = "emscripten"))]
147144
#[test]
148145
fn test_indirect_hasher() {
149146
let mut hasher = MyHasher { hash: 0 };

0 commit comments

Comments
 (0)