From 1d6643c4f69ba31f91a385c51f46d615bd2b0d66 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Mon, 14 Oct 2024 21:16:27 +0200 Subject: [PATCH] Fix most ui tests on emscripten target To fix the linker errors, we need to set the output extension to `.js` instead of `.wasm`. Setting the output to a `.wasm` file puts Emscripten into standalone mode which is effectively a distinct target. We need to set the runner to be `node` as well. This fixes most of the ui tests. I fixed a few more tests with simple problems: - `intrinsics/intrinsic-alignment.rs` and `structs-enums/rec-align-u64.rs` -- Two `#[cfg]` macros match for Emscripten so we got a duplicate definition of `mod m`. - `issues/issue-12699.rs` -- Seems to hang so I disabled it - `process/process-sigpipe.rs` -- Not expected to work on Emscripten so I disabled it --- src/bootstrap/src/core/config/config.rs | 3 +++ src/tools/compiletest/src/runtest.rs | 4 +++- src/tools/tidy/src/issues.txt | 1 - src/tools/tidy/src/ui_tests.rs | 2 +- tests/ui/intrinsics/intrinsic-alignment.rs | 1 - tests/ui/process/process-sigpipe.rs | 8 ++------ .../ui/{issues/issue-12699.rs => std/thread-sleep-ms.rs} | 3 +++ tests/ui/structs-enums/rec-align-u64.rs | 1 - 8 files changed, 12 insertions(+), 11 deletions(-) rename tests/ui/{issues/issue-12699.rs => std/thread-sleep-ms.rs} (59%) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index f768470c4ff..eb571f920df 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -612,6 +612,9 @@ pub fn from_triple(triple: &str) -> Self { if triple.contains("-none") || triple.contains("nvptx") || triple.contains("switch") { target.no_std = true; } + if triple.contains("emscripten") { + target.runner = Some("node".into()); + } target } } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 29f9925de16..69a47fcd0fb 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1643,7 +1643,9 @@ fn make_exe_name(&self) -> PathBuf { // double the length. let mut f = self.output_base_dir().join("a"); // FIXME: This is using the host architecture exe suffix, not target! - if self.config.target.starts_with("wasm") { + if self.config.target.contains("emscripten") { + f = f.with_extra_extension("js"); + } else if self.config.target.starts_with("wasm") { f = f.with_extra_extension("wasm"); } else if self.config.target.contains("spirv") { f = f.with_extra_extension("spv"); diff --git a/src/tools/tidy/src/issues.txt b/src/tools/tidy/src/issues.txt index 66c176c6f44..22126674c15 100644 --- a/src/tools/tidy/src/issues.txt +++ b/src/tools/tidy/src/issues.txt @@ -1520,7 +1520,6 @@ ui/issues/issue-12567.rs ui/issues/issue-12612.rs ui/issues/issue-12660.rs ui/issues/issue-12677.rs -ui/issues/issue-12699.rs ui/issues/issue-12729.rs ui/issues/issue-12744.rs ui/issues/issue-12860.rs diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 41f7778c952..11f9d5bb03d 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -17,7 +17,7 @@ const ENTRY_LIMIT: u32 = 901; // FIXME: The following limits should be reduced eventually. -const ISSUES_ENTRY_LIMIT: u32 = 1673; +const ISSUES_ENTRY_LIMIT: u32 = 1672; const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[ "rs", // test source files diff --git a/tests/ui/intrinsics/intrinsic-alignment.rs b/tests/ui/intrinsics/intrinsic-alignment.rs index 138273aadd2..4cb05f6a8df 100644 --- a/tests/ui/intrinsics/intrinsic-alignment.rs +++ b/tests/ui/intrinsics/intrinsic-alignment.rs @@ -13,7 +13,6 @@ mod rusti { #[cfg(any( target_os = "android", target_os = "dragonfly", - target_os = "emscripten", target_os = "freebsd", target_os = "fuchsia", target_os = "hurd", diff --git a/tests/ui/process/process-sigpipe.rs b/tests/ui/process/process-sigpipe.rs index 11f363d625f..9db130c26bd 100644 --- a/tests/ui/process/process-sigpipe.rs +++ b/tests/ui/process/process-sigpipe.rs @@ -15,11 +15,12 @@ //@ ignore-vxworks no 'sh' //@ ignore-fuchsia no 'sh' +//@ ignore-emscripten No threads +//@ only-unix SIGPIPE is a unix feature use std::process; use std::thread; -#[cfg(unix)] fn main() { // Just in case `yes` doesn't check for EPIPE... thread::spawn(|| { @@ -34,8 +35,3 @@ fn main() { assert!(output.status.success()); assert!(output.stderr.len() == 0); } - -#[cfg(not(unix))] -fn main() { - // Not worried about signal masks on other platforms -} diff --git a/tests/ui/issues/issue-12699.rs b/tests/ui/std/thread-sleep-ms.rs similarity index 59% rename from tests/ui/issues/issue-12699.rs rename to tests/ui/std/thread-sleep-ms.rs index 4fc93735c3c..0a3d0253a20 100644 --- a/tests/ui/issues/issue-12699.rs +++ b/tests/ui/std/thread-sleep-ms.rs @@ -1,6 +1,9 @@ //@ run-pass //@ ignore-sgx not supported +//@ ignore-emscripten +// FIXME: test hangs on emscripten #![allow(deprecated)] +#![allow(unused_imports)] use std::thread; diff --git a/tests/ui/structs-enums/rec-align-u64.rs b/tests/ui/structs-enums/rec-align-u64.rs index 8ea72fdf45c..313ce6d578d 100644 --- a/tests/ui/structs-enums/rec-align-u64.rs +++ b/tests/ui/structs-enums/rec-align-u64.rs @@ -33,7 +33,6 @@ struct Outer { #[cfg(any( target_os = "android", target_os = "dragonfly", - target_os = "emscripten", target_os = "freebsd", target_os = "fuchsia", target_os = "hurd",