Merge branch 'trunk' into dict-more

This commit is contained in:
Richard Feldman 2021-02-17 23:47:13 -05:00 committed by GitHub
commit fe98229aa3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 691 additions and 193 deletions

View file

@ -117,22 +117,24 @@ pub fn build_file<'a>(
report_timing(buf, "Generate LLVM IR", code_gen_timing.code_gen);
report_timing(buf, "Emit .o file", code_gen_timing.emit_o_file);
println!(
"\n\nCompilation finished! Here's how long each module took to compile:\n\n{}",
buf
);
println!("\nSuccess! 🎉\n\n\t{}\n", app_o_file.display());
let compilation_end = compilation_start.elapsed().unwrap();
let size = std::fs::metadata(&app_o_file).unwrap().len();
println!(
"Finished compilation and code gen in {} ms\n\nProduced a app.o file of size {:?}\n",
compilation_end.as_millis(),
size,
);
if emit_debug_info {
println!(
"\n\nCompilation finished! Here's how long each module took to compile:\n\n{}",
buf
);
println!("\nSuccess! 🎉\n\n\t{}\n", app_o_file.display());
println!(
"Finished compilation and code gen in {} ms\n\nProduced a app.o file of size {:?}\n",
compilation_end.as_millis(),
size,
);
}
// Step 2: link the precompiled host and compiled app
let mut host_input_path = PathBuf::from(cwd);
@ -144,10 +146,13 @@ pub fn build_file<'a>(
let rebuild_host_start = SystemTime::now();
rebuild_host(host_input_path.as_path());
let rebuild_host_end = rebuild_host_start.elapsed().unwrap();
println!(
"Finished rebuilding the host in {} ms\n",
rebuild_host_end.as_millis()
);
if emit_debug_info {
println!(
"Finished rebuilding the host in {} ms\n",
rebuild_host_end.as_millis()
);
}
// TODO try to move as much of this linking as possible to the precompiled
// host, to minimize the amount of host-application linking required.
@ -168,7 +173,9 @@ pub fn build_file<'a>(
});
let link_end = link_start.elapsed().unwrap();
println!("Finished linking in {} ms\n", link_end.as_millis());
if emit_debug_info {
println!("Finished linking in {} ms\n", link_end.as_millis());
}
// Clean up the leftover .o file from the Roc, if possible.
// (If cleaning it up fails, that's fine. No need to take action.)

View file

@ -13,6 +13,7 @@ mod helpers;
mod cli_run {
use crate::helpers::{
example_file, extract_valgrind_errors, fixture_file, run_cmd, run_roc, run_with_valgrind,
ValgrindError, ValgrindErrorXWhat,
};
use serial_test::serial;
use std::path::Path;
@ -60,7 +61,24 @@ mod cli_run {
});
if !memory_errors.is_empty() {
panic!("{:?}", memory_errors);
for error in memory_errors {
let ValgrindError {
kind,
what: _,
xwhat,
} = error;
println!("Valgrind Error: {}\n", kind);
if let Some(ValgrindErrorXWhat {
text,
leakedbytes: _,
leakedblocks: _,
}) = xwhat
{
println!(" {}", text);
}
}
panic!("Valgrind reported memory errors");
}
} else {
let exit_code = match valgrind_out.status.code() {
@ -223,6 +241,69 @@ mod cli_run {
);
}
#[ignore]
#[test]
#[serial(closure1)]
fn closure1() {
check_output(
&example_file("benchmarks", "Closure1.roc"),
"closure1",
&[],
"",
true,
);
}
#[ignore]
#[test]
#[serial(closure2)]
fn closure2() {
check_output(
&example_file("benchmarks", "Closure2.roc"),
"closure2",
&[],
"",
true,
);
}
#[ignore]
#[test]
#[serial(closure3)]
fn closure3() {
check_output(
&example_file("benchmarks", "Closure3.roc"),
"closure3",
&[],
"",
true,
);
}
#[ignore]
#[test]
#[serial(closure4)]
fn closure4() {
check_output(
&example_file("benchmarks", "Closure4.roc"),
"closure4",
&[],
"",
true,
);
}
// #[test]
// #[serial(effect)]
// fn run_effect_unoptimized() {
// check_output(
// &example_file("effect", "Main.roc"),
// &[],
// "I am Dep2.str2\n",
// true,
// );
// }
#[test]
#[serial(multi_dep_str)]
fn run_multi_dep_str_unoptimized() {

View file

@ -192,20 +192,20 @@ struct ValgrindDummyStruct {}
#[derive(Debug, Deserialize, Clone)]
pub struct ValgrindError {
kind: String,
pub kind: String,
#[serde(default)]
what: Option<String>,
pub what: Option<String>,
#[serde(default)]
xwhat: Option<ValgrindErrorXWhat>,
pub xwhat: Option<ValgrindErrorXWhat>,
}
#[derive(Debug, Deserialize, Clone)]
pub struct ValgrindErrorXWhat {
text: String,
pub text: String,
#[serde(default)]
leakedbytes: Option<isize>,
pub leakedbytes: Option<isize>,
#[serde(default)]
leakedblocks: Option<isize>,
pub leakedblocks: Option<isize>,
}
#[allow(dead_code)]