fix test compilation

This commit is contained in:
Folkert 2022-02-14 21:09:51 +01:00
parent 957140df64
commit 04adbe75ca
8 changed files with 77 additions and 107 deletions

35
cli_utils/Cargo.lock generated
View file

@ -964,12 +964,6 @@ dependencies = [
"toml",
]
[[package]]
name = "fixedbitset"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
[[package]]
name = "flate2"
version = "1.0.22"
@ -2047,14 +2041,11 @@ version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
dependencies = [
"backtrace",
"cfg-if 1.0.0",
"instant",
"libc",
"petgraph",
"redox_syscall",
"smallvec",
"thread-id",
"winapi",
]
@ -2107,16 +2098,6 @@ dependencies = [
"sha-1",
]
[[package]]
name = "petgraph"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7"
dependencies = [
"fixedbitset",
"indexmap",
]
[[package]]
name = "phf"
version = "0.9.0"
@ -2799,6 +2780,7 @@ dependencies = [
"bumpalo",
"lazy_static",
"roc_collections",
"roc_error_macros",
"roc_ident",
"roc_region",
"snafu",
@ -2815,6 +2797,7 @@ dependencies = [
"roc_builtins",
"roc_can",
"roc_collections",
"roc_error_macros",
"roc_module",
"roc_problem",
"roc_region",
@ -2865,6 +2848,7 @@ dependencies = [
"inkwell 0.1.0",
"libloading 0.7.1",
"roc_build",
"roc_builtins",
"roc_collections",
"roc_gen_llvm",
"roc_load",
@ -2946,6 +2930,7 @@ version = "0.1.0"
dependencies = [
"bumpalo",
"roc_collections",
"roc_error_macros",
"roc_module",
"roc_region",
"static_assertions",
@ -2956,6 +2941,7 @@ dependencies = [
name = "roc_unify"
version = "0.1.0"
dependencies = [
"bitflags",
"roc_collections",
"roc_module",
"roc_types",
@ -3402,17 +3388,6 @@ dependencies = [
"syn",
]
[[package]]
name = "thread-id"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fdfe0627923f7411a43ec9ec9c39c3a9b4151be313e0922042581fb6c9b717f"
dependencies = [
"libc",
"redox_syscall",
"winapi",
]
[[package]]
name = "threadpool"
version = "1.8.1"

View file

@ -1074,71 +1074,24 @@ fn load<'a>(
// (since other threads need to reference it too).
let injector = &injector;
// Record this thread's handle so the main thread can join it later.
let res_join_handle = thread_scope
.builder()
.stack_size(EXPANDED_STACK_SIZE)
.spawn(move |_| {
// Keep listening until we receive a Shutdown msg
for msg in worker_msg_rx.iter() {
match msg {
WorkerMsg::Shutdown => {
// We've finished all our work. It's time to
// shut down the thread, so when the main thread
// blocks on joining with all the worker threads,
// it can finally exit too!
return Ok(());
}
WorkerMsg::TaskAdded => {
// Find a task - either from this thread's queue,
// or from the main queue, or from another worker's
// queue - and run it.
//
// There might be no tasks to work on! That could
// happen if another thread is working on a task
// which will later result in more tasks being
// added. In that case, do nothing, and keep waiting
// until we receive a Shutdown message.
if let Some(task) = find_task(&worker, injector, stealers) {
let result = run_task(
task,
// will process messages until we run out
worker_task(
worker_arena,
worker,
injector,
stealers,
worker_msg_rx,
msg_tx,
src_dir,
msg_tx.clone(),
target_info,
);
match result {
Ok(()) => {}
Err(LoadingProblem::MsgChannelDied) => {
panic!("Msg channel closed unexpectedly.")
}
Err(LoadingProblem::ParsingFailed(problem)) => {
msg_tx.send(Msg::FailedToParse(problem)).unwrap();
}
Err(LoadingProblem::FileProblem {
filename,
error,
}) => {
msg_tx
.send(Msg::FailedToReadFile { filename, error })
.unwrap();
}
Err(other) => {
return Err(other);
}
}
}
}
}
}
// Needed to prevent a borrow checker error about this closure
// outliving its enclosing function.
drop(worker_msg_rx);
Ok(())
)
});
res_join_handle.unwrap();
@ -1302,6 +1255,65 @@ fn load<'a>(
.unwrap()
}
#[allow(clippy::too_many_arguments)]
fn worker_task<'a>(
worker_arena: &'a Bump,
worker: Worker<BuildTask<'a>>,
injector: &Injector<BuildTask<'a>>,
stealers: &[Stealer<BuildTask<'a>>],
worker_msg_rx: crossbeam::channel::Receiver<WorkerMsg>,
msg_tx: MsgSender<'a>,
src_dir: &Path,
target_info: TargetInfo,
) -> Result<(), LoadingProblem<'a>> {
// Keep listening until we receive a Shutdown msg
for msg in worker_msg_rx.iter() {
match msg {
WorkerMsg::Shutdown => {
// We've finished all our work. It's time to
// shut down the thread, so when the main thread
// blocks on joining with all the worker threads,
// it can finally exit too!
return Ok(());
}
WorkerMsg::TaskAdded => {
// Find a task - either from this thread's queue,
// or from the main queue, or from another worker's
// queue - and run it.
//
// There might be no tasks to work on! That could
// happen if another thread is working on a task
// which will later result in more tasks being
// added. In that case, do nothing, and keep waiting
// until we receive a Shutdown message.
if let Some(task) = find_task(&worker, injector, stealers) {
let result = run_task(task, worker_arena, src_dir, msg_tx.clone(), target_info);
match result {
Ok(()) => {}
Err(LoadingProblem::MsgChannelDied) => {
panic!("Msg channel closed unexpectedly.")
}
Err(LoadingProblem::ParsingFailed(problem)) => {
msg_tx.send(Msg::FailedToParse(problem)).unwrap();
}
Err(LoadingProblem::FileProblem { filename, error }) => {
msg_tx
.send(Msg::FailedToReadFile { filename, error })
.unwrap();
}
Err(other) => {
return Err(other);
}
}
}
}
}
}
Ok(())
}
fn start_tasks<'a>(
arena: &'a Bump,
state: &mut State<'a>,

View file

@ -16,7 +16,6 @@ mod helpers;
mod test_load {
use crate::helpers::fixtures_dir;
use bumpalo::Bump;
use roc_can::builtins::builtin_defs_map;
use roc_can::def::Declaration::*;
use roc_can::def::Def;
use roc_collections::all::MutMap;
@ -111,7 +110,6 @@ mod test_load {
dir.path(),
exposed_types,
TARGET_INFO,
builtin_defs_map,
)
};
@ -135,7 +133,6 @@ mod test_load {
src_dir.as_path(),
subs_by_module,
TARGET_INFO,
builtin_defs_map,
);
let mut loaded_module = match loaded {
Ok(x) => x,
@ -301,7 +298,6 @@ mod test_load {
src_dir.as_path(),
subs_by_module,
TARGET_INFO,
builtin_defs_map,
);
let mut loaded_module = loaded.expect("Test module failed to load");

View file

@ -10,7 +10,6 @@ mod helpers;
#[cfg(test)]
mod solve_expr {
use crate::helpers::with_larger_debug_stack;
use roc_can::builtins::builtin_defs_map;
use roc_collections::all::MutMap;
use roc_types::pretty_print::{content_to_string, name_all_type_vars};
@ -64,7 +63,6 @@ mod solve_expr {
dir.path(),
exposed_types,
roc_target::TargetInfo::default_x86_64(),
builtin_defs_map,
);
dir.close()?;

View file

@ -1,7 +1,6 @@
use libloading::Library;
use roc_build::link::{link, LinkType};
use roc_builtins::bitcode;
use roc_can::builtins::builtin_defs_map;
use roc_collections::all::MutMap;
use roc_region::all::LineInfo;
use tempfile::tempdir;
@ -58,7 +57,6 @@ pub fn helper(
src_dir,
exposed_types,
roc_target::TargetInfo::default_x86_64(),
builtin_defs_map,
);
let mut loaded = loaded.expect("failed to load module");

View file

@ -3,7 +3,6 @@ use inkwell::module::Module;
use libloading::Library;
use roc_build::link::module_to_dylib;
use roc_build::program::FunctionIterator;
use roc_can::builtins::builtin_defs_map;
use roc_can::def::Def;
use roc_collections::all::{MutMap, MutSet};
use roc_gen_llvm::llvm::externs::add_default_roc_externs;
@ -25,9 +24,6 @@ fn promote_expr_to_module(src: &str) -> String {
buffer
}
pub fn test_builtin_defs(symbol: Symbol, var_store: &mut VarStore) -> Option<Def> {
builtin_defs_map(symbol, var_store)
}
#[allow(clippy::too_many_arguments)]
fn create_llvm_module<'a>(
@ -67,7 +63,6 @@ fn create_llvm_module<'a>(
src_dir,
exposed_types,
target_info,
test_builtin_defs,
);
let mut loaded = match loaded {

View file

@ -7,7 +7,6 @@ use std::path::{Path, PathBuf};
use wasmer::{Memory, WasmPtr};
use crate::helpers::from_wasmer_memory::FromWasmerMemory;
use roc_can::builtins::builtin_defs_map;
use roc_collections::all::{MutMap, MutSet};
use roc_gen_wasm::wasm32_result::Wasm32Result;
use roc_gen_wasm::{DEBUG_LOG_SETTINGS, MEMORY_NAME};
@ -94,7 +93,6 @@ fn compile_roc_to_wasm_bytes<'a, T: Wasm32Result>(
src_dir,
exposed_types,
roc_target::TargetInfo::default_wasm32(),
builtin_defs_map,
);
let loaded = loaded.expect("failed to load module");

View file

@ -18,7 +18,6 @@ const EXPANDED_STACK_SIZE: usize = 8 * 1024 * 1024;
use test_mono_macros::*;
use roc_can::builtins::builtin_defs_map;
use roc_collections::all::MutMap;
use roc_module::symbol::Symbol;
use roc_mono::ir::Proc;
@ -107,7 +106,6 @@ fn compiles_to_ir(test_name: &str, src: &str) {
src_dir,
exposed_types,
TARGET_INFO,
builtin_defs_map,
);
let mut loaded = match loaded {