Skip to content

Commit

Permalink
Most tests work again
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-F-Bryan committed Jun 8, 2023
1 parent 3d5cd69 commit 7b51d2a
Show file tree
Hide file tree
Showing 8 changed files with 225 additions and 227 deletions.
411 changes: 203 additions & 208 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ repository = "https://github.com/wasmerio/wasmer"
rust-version = "1.67"
version = "4.0.0-beta.1"

[workspace.dependencies]
webc = { version = "5.0.4", default-features = false }
wapm-targz-to-pirita = "0.3.0"
wasmer-toml = "0.6.0"

[build-dependencies]
test-generator = { path = "tests/lib/test-generator" }
build-deps = "0.1.4"
Expand Down
6 changes: 3 additions & 3 deletions lib/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ virtual-fs = { version = "0.4.0", path = "../virtual-fs", default-features = fa
virtual-net = { version = "0.3.0", path = "../virtual-net" }

# Wasmer-owned dependencies.
webc = { version = "5.0" }
wapm-targz-to-pirita = "0.2.1"
webc = { workspace = true }
wapm-targz-to-pirita = { workspace = true }
wasmer-deploy-cli = { version = "0.1.9", default-features = false }

# Third-party dependencies.
Expand All @@ -67,7 +67,7 @@ dirs = { version = "4.0" }
serde_json = { version = "1.0" }
target-lexicon = { version = "0.12", features = ["std"] }
prettytable-rs = "0.10.0"
wasmer-toml = "0.6.0"
wasmer-toml = { workspace = true }
indexmap = "1.9.2"
walkdir = "2.3.2"
regex = "1.6.0"
Expand Down
6 changes: 3 additions & 3 deletions lib/cli/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use sha2::{Digest, Sha256};
use tempfile::NamedTempFile;
use tokio::runtime::Handle;
use url::Url;
use wapm_targz_to_pirita::{FileMap, TransformManifestFunctions};
use wapm_targz_to_pirita::{webc::v1::DirOrFile, FileMap, TransformManifestFunctions};
use wasmer::{
DeserializeError, Engine, Function, Imports, Instance, Module, Store, Type, TypedFunction,
Value,
Expand All @@ -44,7 +44,7 @@ use wasmer_wasix::{
},
Runtime,
};
use webc::{metadata::Manifest, v1::DirOrFile, Container};
use webc::{metadata::Manifest, Container};

use crate::{commands::run::wasi::Wasi, error::PrettyError, store::StoreOptions};

Expand Down Expand Up @@ -610,7 +610,7 @@ fn construct_webc_in_memory(dir: &Path) -> Result<Vec<u8>, Error> {
}

let functions = TransformManifestFunctions::default();
let webc = wapm_targz_to_pirita::generate_webc_file(files, dir, None, &functions)?;
let webc = wapm_targz_to_pirita::generate_webc_file(files, dir, &functions)?;

Ok(webc)
}
Expand Down
4 changes: 2 additions & 2 deletions lib/wasix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bincode = { version = "1.3" }
chrono = { version = "^0.4", default-features = false, features = [ "wasmbind", "std", "clock" ], optional = true }
derivative = { version = "^2" }
bytes = "1"
webc = { version = "5.0.4", default-features = false }
webc = { workspace = true }
serde_cbor = { version = "0.11.2" }
anyhow = { version = "1.0.66" }
lazy_static = "1.4"
Expand Down Expand Up @@ -97,7 +97,7 @@ wasm-bindgen = ">= 0.2.74, < 0.2.85"
wasmer = { path = "../api", version = "=4.0.0-beta.1", default-features = false, features = ["wat", "js-serializable-module"] }
tokio = { version = "1", features = [ "sync", "macros", "rt" ], default_features = false }
pretty_assertions = "1.3.0"
wapm-targz-to-pirita = "0.2.1"
wapm-targz-to-pirita = { workspace = true }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3.0"
Expand Down
15 changes: 8 additions & 7 deletions lib/wasix/src/bin_factory/binary_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ mod tests {

use tempfile::TempDir;
use virtual_fs::AsyncReadExt;
use wapm_targz_to_pirita::{webc::v1::DirOrFile, FileMap, TransformManifestFunctions};

use crate::{runtime::task_manager::tokio::TokioTaskManager, PluggableRuntime};

Expand Down Expand Up @@ -189,22 +190,22 @@ mod tests {
let mut files = BTreeMap::new();
load_files_from_disk(&mut files, dir, dir);

let wasmer_toml = webc::v1::DirOrFile::File("wasmer.toml".into());
let wasmer_toml = DirOrFile::File("wasmer.toml".into());
if let Some(toml_data) = files.remove(&wasmer_toml) {
// HACK(Michael-F-Bryan): The version of wapm-targz-to-pirita we are
// using doesn't know we renamed "wapm.toml" to "wasmer.toml", so we
// manually patch things up if people have already migrated their
// projects.
files
.entry(webc::v1::DirOrFile::File("wapm.toml".into()))
.entry(DirOrFile::File("wapm.toml".into()))
.or_insert(toml_data);
}

let functions = wapm_targz_to_pirita::TransformManifestFunctions::default();
wapm_targz_to_pirita::generate_webc_file(files, dir, None, &functions).unwrap()
let functions = TransformManifestFunctions::default();
wapm_targz_to_pirita::generate_webc_file(files, dir, &functions).unwrap()
}

fn load_files_from_disk(files: &mut wapm_targz_to_pirita::FileMap, dir: &Path, base: &Path) {
fn load_files_from_disk(files: &mut FileMap, dir: &Path, base: &Path) {
let entries = dir.read_dir().unwrap();

for entry in entries {
Expand All @@ -213,10 +214,10 @@ mod tests {

if path.is_dir() {
load_files_from_disk(files, &path, base);
files.insert(webc::v1::DirOrFile::Dir(relative_path), Vec::new());
files.insert(DirOrFile::Dir(relative_path), Vec::new());
} else if path.is_file() {
let data = std::fs::read(&path).unwrap();
files.insert(webc::v1::DirOrFile::File(relative_path), data);
files.insert(DirOrFile::File(relative_path), data);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/wasix/src/runtime/package_loader/load_package_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ fn count_file_system(fs: &dyn FileSystem, path: &Path) -> u64 {
///
/// The TmpFileSystem *does* allow mounting at non-root paths, however it can't
/// handle nested paths (e.g. mounting to "/lib" and "/lib/python3.10" - see
/// https://github.com/wasmerio/wasmer/issues/3678 for more) and you aren't
/// <https://github.com/wasmerio/wasmer/issues/3678> for more) and you aren't
/// allowed to mount to "/" because it's a special directory that already
/// exists.
///
Expand Down
3 changes: 0 additions & 3 deletions lib/wasix/src/runtime/resolver/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ async fn discover_dependencies(
to_visit.push_back(root_index);

while let Some(index) = to_visit.pop_front() {
eprintln!("Checking {}", graph[index].id);
let mut to_add = Vec::new();

for dep in &graph[index].pkg.dependencies {
Expand Down Expand Up @@ -139,15 +138,13 @@ async fn discover_dependencies(

for (alias, node) in to_add {
let dep_id = node.id.clone();
eprintln!("{} -> {} (as {alias})", &graph[index].id, dep_id);

let dep_index = match nodes.get(&dep_id) {
Some(&ix) => ix,
None => {
// Create a new node and schedule its dependencies to be
// retrieved
let ix = graph.add_node(node);
eprintln!("Scheduling to check \"{dep_id}\"");
nodes.insert(dep_id, ix);
to_visit.push_back(ix);
ix
Expand Down

0 comments on commit 7b51d2a

Please sign in to comment.