mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-09 05:20:32 +00:00
run platform-independent tests from a dynamic lib
This commit is contained in:
parent
610f8784cc
commit
12027ee338
7 changed files with 54 additions and 43 deletions
|
@ -66,12 +66,15 @@ libc = "0.2.106"
|
|||
errno = "0.2.8"
|
||||
signal-hook = "0.3.14"
|
||||
ven_pretty = { path = "../vendor/pretty" }
|
||||
libloading = "0.7.1"
|
||||
|
||||
target-lexicon = "0.12.3"
|
||||
tempfile = "3.2.0"
|
||||
wasmer-wasi = { version = "2.2.1", optional = true }
|
||||
|
||||
libloading = "0.7.1"
|
||||
roc_gen_llvm = {path = "../compiler/gen_llvm"}
|
||||
inkwell = {path = "../vendor/inkwell"}
|
||||
|
||||
# Wasmer singlepass compiler only works on x86_64.
|
||||
[target.'cfg(target_arch = "x86_64")'.dependencies]
|
||||
wasmer = { version = "2.2.1", optional = true, default-features = false, features = ["singlepass", "universal"] }
|
||||
|
|
|
@ -8,6 +8,9 @@ use roc_build::link::{LinkType, LinkingStrategy};
|
|||
use roc_error_macros::{internal_error, user_error};
|
||||
use roc_load::{LoadingProblem, Threading};
|
||||
use roc_mono::ir::OptLevel;
|
||||
use roc_region::all::Region;
|
||||
use roc_repl_cli::expect_mono_module_to_dylib;
|
||||
use roc_reporting::report::{Palette, Report, RocDocAllocator, RocDocBuilder};
|
||||
use roc_target::TargetInfo;
|
||||
use std::env;
|
||||
use std::ffi::{CString, OsStr};
|
||||
|
@ -165,12 +168,22 @@ pub fn build_app<'a>() -> Command<'a> {
|
|||
)
|
||||
.subcommand(Command::new(CMD_TEST)
|
||||
.about("Run all top-level `expect`s in a root module and any modules it imports.")
|
||||
.arg(flag_optimize.clone())
|
||||
.arg(flag_max_threads.clone())
|
||||
.arg(flag_opt_size.clone())
|
||||
.arg(flag_dev.clone())
|
||||
.arg(flag_debug.clone())
|
||||
.arg(flag_time.clone())
|
||||
.arg(flag_linker.clone())
|
||||
.arg(flag_precompiled.clone())
|
||||
.arg(flag_valgrind.clone())
|
||||
.arg(
|
||||
Arg::new(ROC_FILE)
|
||||
.help("The .roc file for the root module")
|
||||
.allow_invalid_utf8(true)
|
||||
.required(true),
|
||||
)
|
||||
.arg(args_for_app.clone())
|
||||
)
|
||||
.subcommand(Command::new(CMD_REPL)
|
||||
.about("Launch the interactive Read Eval Print Loop (REPL)")
|
||||
|
@ -387,8 +400,17 @@ pub fn test(matches: &ArgMatches, triple: Triple) -> io::Result<i32> {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
// let expectations = std::mem::take(&mut loaded.expectations);
|
||||
let _interns = loaded.interns;
|
||||
let (lib, expects, subs) =
|
||||
expect_mono_module_to_dylib(arena, target.clone(), loaded, opt_level).unwrap();
|
||||
|
||||
use roc_gen_llvm::run_jit_function;
|
||||
|
||||
for expect in expects {
|
||||
println!("running: {}", expect);
|
||||
let result = run_jit_function!(lib, expect, bool, |v: bool| v);
|
||||
|
||||
dbg!(result);
|
||||
}
|
||||
|
||||
Ok(0)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue