mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-04 18:10:18 +00:00
Merge #1367
1367: Move `dev-utils` crate into `tests` r=MarkMcCaskey a=MarkMcCaskey <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> # Description <!-- Provide details regarding the change including motivation, links to related issues, and the context of the PR. --> # Review - [ ] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Mark McCaskey <mark@wasmer.io> Co-authored-by: Mark McCaskey <5770194+MarkMcCaskey@users.noreply.github.com>
This commit is contained in:
commit
cd4706fbac
9
Cargo.lock
generated
9
Cargo.lock
generated
@ -2753,6 +2753,7 @@ dependencies = [
|
||||
"generate-emscripten-tests",
|
||||
"generate-wasi-tests",
|
||||
"glob 0.3.0",
|
||||
"libc",
|
||||
"log",
|
||||
"rustc_version",
|
||||
"serde",
|
||||
@ -2761,7 +2762,6 @@ dependencies = [
|
||||
"wabt",
|
||||
"wasmer",
|
||||
"wasmer-clif-backend",
|
||||
"wasmer-dev-utils",
|
||||
"wasmer-emscripten",
|
||||
"wasmer-kernel-loader",
|
||||
"wasmer-llvm-backend",
|
||||
@ -2824,13 +2824,6 @@ dependencies = [
|
||||
"wasmparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-dev-utils"
|
||||
version = "0.16.2"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-emscripten"
|
||||
version = "0.16.2"
|
||||
|
@ -37,7 +37,6 @@ wasmer-emscripten = { path = "lib/emscripten" }
|
||||
wasmer-llvm-backend = { path = "lib/llvm-backend", optional = true }
|
||||
wasmer-wasi = { path = "lib/wasi", optional = true }
|
||||
wasmer-kernel-loader = { path = "lib/kernel-loader", optional = true }
|
||||
wasmer-dev-utils = { path = "lib/dev-utils", optional = true }
|
||||
wasmer-wasi-experimental-io-devices = { path = "lib/wasi-experimental-io-devices", optional = true }
|
||||
|
||||
[workspace]
|
||||
@ -55,7 +54,6 @@ members = [
|
||||
"lib/middleware-common",
|
||||
"lib/kernel-loader",
|
||||
"lib/kernel-net",
|
||||
"lib/dev-utils",
|
||||
"lib/wasi-experimental-io-devices",
|
||||
"lib/interface-types",
|
||||
"examples/parallel",
|
||||
@ -75,10 +73,10 @@ rustc_version = "0.2"
|
||||
[dev-dependencies]
|
||||
criterion = "0.3"
|
||||
glob = "0.3"
|
||||
libc = "0.2.60" # for `tests/dev-utils`'s Stdout capturing
|
||||
serde = { version = "1", features = ["derive"] } # used by the plugin example
|
||||
typetag = "0.1" # used by the plugin example
|
||||
wabt = "0.9.1"
|
||||
wasmer-dev-utils = { path = "lib/dev-utils" }
|
||||
|
||||
[features]
|
||||
default = ["fast-tests", "wasi", "backend-cranelift", "wabt"]
|
||||
|
5
Makefile
5
Makefile
@ -156,7 +156,6 @@ test-capi: test-capi-singlepass test-capi-cranelift test-capi-llvm test-capi-ems
|
||||
capi-test: test-capi
|
||||
|
||||
test-rest:
|
||||
cargo test --release -p wasmer-dev-utils
|
||||
cargo test --release -p wasmer-interface-types
|
||||
cargo test --release -p wasmer-kernel-loader
|
||||
cargo test --release -p kernel-net
|
||||
@ -210,7 +209,7 @@ check-bench: check-bench-singlepass check-bench-llvm
|
||||
|
||||
# TODO: We wanted `--workspace --exclude wasmer-runtime`, but can't due
|
||||
# to https://github.com/rust-lang/cargo/issues/6745 .
|
||||
NOT_RUNTIME_CRATES = -p wasmer-clif-backend -p wasmer-singlepass-backend -p wasmer-middleware-common -p wasmer-runtime-core -p wasmer-emscripten -p wasmer-llvm-backend -p wasmer-wasi -p wasmer-kernel-loader -p wasmer-dev-utils -p wasmer-interface-types
|
||||
NOT_RUNTIME_CRATES = -p wasmer-clif-backend -p wasmer-singlepass-backend -p wasmer-middleware-common -p wasmer-runtime-core -p wasmer-emscripten -p wasmer-llvm-backend -p wasmer-wasi -p wasmer-kernel-loader -p wasmer-interface-types
|
||||
RUNTIME_CHECK = cargo check --manifest-path lib/runtime/Cargo.toml --no-default-features
|
||||
check: check-bench
|
||||
cargo check $(NOT_RUNTIME_CRATES)
|
||||
@ -348,7 +347,7 @@ publish-release:
|
||||
# cargo install cargo-deps
|
||||
# must install graphviz for `dot`
|
||||
dep-graph:
|
||||
cargo deps --optional-deps --filter wasmer-wasi wasmer-kernel-loader wasmer-dev-utils wasmer-llvm-backend wasmer-emscripten wasmer-runtime-core wasmer-runtime wasmer-middleware-common wasmer-singlepass-backend wasmer-clif-backend wasmer --manifest-path Cargo.toml | dot -Tpng > wasmer_depgraph.png
|
||||
cargo deps --optional-deps --filter wasmer-wasi wasmer-kernel-loader wasmer-llvm-backend wasmer-emscripten wasmer-runtime-core wasmer-runtime wasmer-middleware-common wasmer-singlepass-backend wasmer-clif-backend wasmer --manifest-path Cargo.toml | dot -Tpng > wasmer_depgraph.png
|
||||
|
||||
docs-capi:
|
||||
cd lib/runtime-c-api/ && doxygen doxyfile
|
||||
|
@ -1,12 +0,0 @@
|
||||
[package]
|
||||
name = "wasmer-dev-utils"
|
||||
version = "0.16.2"
|
||||
description = "Wasmer runtime core library"
|
||||
license = "MIT"
|
||||
authors = ["The Wasmer Engineering Team <engineering@wasmer.io>"]
|
||||
edition = "2018"
|
||||
repository = "https://github.com/wasmerio/wasmer"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
libc = "0.2.60"
|
@ -1,3 +0,0 @@
|
||||
# Dev Utils
|
||||
|
||||
This is shared code between the modules for testing and development only. Code in this crate will not be shipped.
|
@ -1,5 +0,0 @@
|
||||
#![doc(html_favicon_url = "https://wasmer.io/static/icons/favicon.ico")]
|
||||
#![doc(html_logo_url = "https://avatars3.githubusercontent.com/u/44205449?s=200&v=4")]
|
||||
|
||||
pub mod file_descriptor;
|
||||
pub mod stdio;
|
@ -1,9 +1,11 @@
|
||||
use crate::common::{get_cache_dir, PrestandardFeatures};
|
||||
use crate::utils::read_file_contents;
|
||||
use std::collections::HashMap;
|
||||
use std::fs::read_to_string;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::fs;
|
||||
#[cfg(feature = "managed")]
|
||||
use std::io::Read;
|
||||
#[cfg(any(feature = "backend-llvm", feature = "managed"))]
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use std::process::exit;
|
||||
use std::str::FromStr;
|
||||
@ -363,7 +365,7 @@ fn execute_wasi(
|
||||
module.info(),
|
||||
&_wasm_binary,
|
||||
if let Some(ref path) = options.resume {
|
||||
let mut f = File::open(path).unwrap();
|
||||
let mut f = fs::File::open(path).unwrap();
|
||||
let mut out: Vec<u8> = vec![];
|
||||
f.read_to_end(&mut out).unwrap();
|
||||
wasmer_runtime_core::state::InstanceImage::from_bytes(&out)
|
||||
@ -461,7 +463,7 @@ impl LLVMCallbacks for LLVMCLIOptions {
|
||||
fn obj_memory_buffer_callback(&mut self, memory_buffer: &InkwellMemoryBuffer) {
|
||||
if let Some(filename) = &self.obj_file {
|
||||
let mem_buf_slice = memory_buffer.as_slice();
|
||||
let mut file = File::create(filename).unwrap();
|
||||
let mut file = fs::File::create(filename).unwrap();
|
||||
let mut pos = 0;
|
||||
while pos < mem_buf_slice.len() {
|
||||
pos += file.write(&mem_buf_slice[pos..]).unwrap();
|
||||
@ -493,7 +495,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
||||
})?;
|
||||
|
||||
let em_symbol_map = if let Some(em_symbol_map_path) = options.em_symbol_map.clone() {
|
||||
let em_symbol_map_content: String = read_to_string(&em_symbol_map_path)
|
||||
let em_symbol_map_content: String = fs::read_to_string(&em_symbol_map_path)
|
||||
.map_err(|err| {
|
||||
format!(
|
||||
"Can't read symbol map file {}: {}",
|
||||
@ -860,7 +862,7 @@ fn interactive_shell(mut ctx: InteractiveShellContext) -> ShellExitOperation {
|
||||
|
||||
if let Some(ref image) = ctx.image {
|
||||
let buf = image.to_bytes();
|
||||
let mut f = match File::create(path) {
|
||||
let mut f = match fs::File::create(path) {
|
||||
Ok(x) => x,
|
||||
Err(e) => {
|
||||
println!("Cannot open output file at {}: {:?}", path, e);
|
||||
|
2
tests/dev_utils/mod.rs
Normal file
2
tests/dev_utils/mod.rs
Normal file
@ -0,0 +1,2 @@
|
||||
pub mod file_descriptor;
|
||||
pub mod stdio;
|
@ -1 +1,2 @@
|
||||
pub mod dev_utils;
|
||||
mod emtests;
|
||||
|
@ -37,7 +37,7 @@ macro_rules! assert_emscripten_output {
|
||||
EmscriptenGlobals,
|
||||
generate_emscripten_env,
|
||||
};
|
||||
use wasmer_dev_utils::stdio::StdioCapturer;
|
||||
use crate::dev_utils::stdio::StdioCapturer;
|
||||
|
||||
let wasm_bytes = include_bytes!($file);
|
||||
let backend = $crate::emtests::_common::get_backend().expect("Please set one of `WASMER_TEST_CRANELIFT`, `WASMER_TEST_LLVM`, or `WASMER_TEST_SINGELPASS` to `1`.");
|
||||
|
@ -1 +1,2 @@
|
||||
pub mod dev_utils;
|
||||
mod wasitests;
|
||||
|
@ -32,7 +32,7 @@ pub fn get_backend() -> Option<Backend> {
|
||||
|
||||
macro_rules! assert_wasi_output {
|
||||
($file:expr, $name:expr, $po_dir_args: expr, $mapdir_args:expr, $envvar_args:expr, $expected:expr) => {{
|
||||
use wasmer_dev_utils::stdio::StdioCapturer;
|
||||
use crate::dev_utils::stdio::StdioCapturer;
|
||||
use wasmer_runtime::Func;
|
||||
use wasmer_wasi::{generate_import_object_for_version, get_wasi_version};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user