Merge pull request #5417 from dlsmith/cli-ld-warning

Consistent handling of ld chained fixup warning in cli/glue tests
This commit is contained in:
Brendan Hansknecht 2023-05-17 15:27:53 +00:00 committed by GitHub
commit 481fc2b78c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 27 deletions

View file

@ -10,8 +10,9 @@ extern crate roc_module;
#[cfg(test)]
mod cli_run {
use cli_utils::helpers::{
extract_valgrind_errors, file_path_from_root, fixture_file, fixtures_dir, known_bad_file,
run_cmd, run_roc, run_with_valgrind, strip_colors, Out, ValgrindError, ValgrindErrorXWhat,
extract_valgrind_errors, file_path_from_root, fixture_file, fixtures_dir, has_error,
known_bad_file, run_cmd, run_roc, run_with_valgrind, strip_colors, Out, ValgrindError,
ValgrindErrorXWhat,
};
use const_format::concatcp;
use indoc::indoc;
@ -143,20 +144,8 @@ mod cli_run {
env,
);
let ignorable = "🔨 Rebuilding platform...\n";
let stderr = compile_out.stderr.replacen(ignorable, "", 1);
// for some reason, llvm prints out this warning when targeting windows
let ignorable = "warning: ignoring debug info with an invalid version (0) in app\r\n";
let stderr = stderr.replacen(ignorable, "", 1);
let is_reporting_runtime = stderr.starts_with("runtime: ") && stderr.ends_with("ms\n");
if !(stderr.is_empty() || is_reporting_runtime
// macOS ld reports this warning, but if we remove -undefined dynamic_lookup,
// linking stops working properly.
|| stderr.trim() == "ld: warning: -undefined dynamic_lookup may not work with chained fixups")
{
panic!("\n___________\nThe roc command:\n\n {:?}\n\nhad unexpected stderr:\n\n {}\n___________\n", compile_out.cmd_str, stderr);
if has_error(&compile_out.stderr) {
panic!("\n___________\nThe roc command:\n\n {:?}\n\nhad unexpected stderr:\n\n {}\n___________\n", compile_out.cmd_str, compile_out.stderr);
}
compile_out

View file

@ -104,6 +104,28 @@ where
run_roc_with_stdin(&path_to_roc_binary(), args, &[])
}
pub fn has_error(stderr: &str) -> bool {
let stderr_stripped = stderr
.replacen("🔨 Rebuilding platform...\n", "", 1)
// for some reason, llvm prints out this warning when targeting windows
.replacen(
"warning: ignoring debug info with an invalid version (0) in app\r\n",
"",
1,
);
let is_reporting_runtime =
stderr_stripped.starts_with("runtime: ") && stderr_stripped.ends_with("ms\n");
let is_clean = stderr_stripped.is_empty() ||
is_reporting_runtime ||
// macOS ld reports this warning, but if we remove -undefined dynamic_lookup,
// linking stops working properly.
stderr_stripped.trim() == "ld: warning: -undefined dynamic_lookup may not work with chained fixups";
!is_clean
}
pub fn path_to_roc_binary() -> PathBuf {
path_to_binary(if cfg!(windows) { "roc.exe" } else { "roc" })
}

View file

@ -12,7 +12,7 @@ mod helpers;
#[cfg(test)]
mod glue_cli_run {
use crate::helpers::fixtures_dir;
use cli_utils::helpers::{run_glue, run_roc, Out};
use cli_utils::helpers::{has_error, run_glue, run_roc, Out};
use std::fs;
use std::path::Path;
@ -213,11 +213,11 @@ mod glue_cli_run {
),
);
let ignorable = "🔨 Rebuilding platform...\n";
let stderr = glue_out.stderr.replacen(ignorable, "", 1);
let is_reporting_runtime = stderr.starts_with("runtime: ") && stderr.ends_with("ms\n");
if !(stderr.is_empty() || is_reporting_runtime) {
panic!("`roc glue` command had unexpected stderr: {}", stderr);
if has_error(&glue_out.stderr) {
panic!(
"`roc glue` command had unexpected stderr: {}",
glue_out.stderr
);
}
assert!(glue_out.status.success(), "bad status {:?}", glue_out);
@ -236,11 +236,11 @@ mod glue_cli_run {
&[],
);
let ignorable = "🔨 Rebuilding platform...\n";
let stderr = compile_out.stderr.replacen(ignorable, "", 1);
let is_reporting_runtime = stderr.starts_with("runtime: ") && stderr.ends_with("ms\n");
if !(stderr.is_empty() || is_reporting_runtime) {
panic!("`roc` command had unexpected stderr: {}", stderr);
if has_error(&compile_out.stderr) {
panic!(
"`roc` command had unexpected stderr: {}",
compile_out.stderr
);
}
assert!(compile_out.status.success(), "bad status {:?}", compile_out);