From 549e5a9be9611a5df7037e70a3fc60d2d38ab8dc Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Thu, 5 Jul 2018 14:27:26 -0700 Subject: [PATCH] tests: Pull the `project()` builder out into its own crate The WebIDL-based -sys crate will also use this, but I want its tests to be a separate suite that we can run separately and in parallel in CI. Therefore, this testing infrastructure code needs to be share-able between them :) --- Cargo.toml | 3 +-- crates/test-project-builder/Cargo.toml | 8 ++++++++ .../test-project-builder/src/lib.rs | 11 ++++++----- .../test-project-builder/src}/run-headless.js | 0 tests/all/main.rs | 5 +---- 5 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 crates/test-project-builder/Cargo.toml rename tests/all/project_builder.rs => crates/test-project-builder/src/lib.rs (99%) rename {tests/all => crates/test-project-builder/src}/run-headless.js (100%) diff --git a/Cargo.toml b/Cargo.toml index 8781510d..6b57144e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,8 +33,7 @@ serde = { version = "1.0", optional = true } serde_json = { version = "1.0", optional = true } [dev-dependencies] -lazy_static = "1" -wasm-bindgen-cli-support = { path = "crates/cli-support", version = '=0.2.11' } +wasm-bindgen-test-project-builder = { path = "crates/test-project-builder", version = '=0.2.11' } [workspace] members = [ diff --git a/crates/test-project-builder/Cargo.toml b/crates/test-project-builder/Cargo.toml new file mode 100644 index 00000000..74e51f1e --- /dev/null +++ b/crates/test-project-builder/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "wasm-bindgen-test-project-builder" +version = "0.2.11" +authors = ["Nick Fitzgerald "] + +[dependencies] +lazy_static = "1" +wasm-bindgen-cli-support = { path = "../cli-support", version = '=0.2.11' } diff --git a/tests/all/project_builder.rs b/crates/test-project-builder/src/lib.rs similarity index 99% rename from tests/all/project_builder.rs rename to crates/test-project-builder/src/lib.rs index 45c2f207..7528bba8 100644 --- a/tests/all/project_builder.rs +++ b/crates/test-project-builder/src/lib.rs @@ -1,4 +1,6 @@ -use wasm_bindgen_cli_support as cli; +#[macro_use] +extern crate lazy_static; +extern crate wasm_bindgen_cli_support as cli; use std::env; use std::fs::{self, File}; @@ -29,7 +31,7 @@ pub struct Project { } pub fn project() -> Project { - let dir = Path::new(env!("CARGO_MANIFEST_DIR")); + let dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("../.."); let mut lockfile = String::new(); fs::File::open(&dir.join("Cargo.lock")) .unwrap() @@ -217,7 +219,7 @@ impl Project { manifest.push_str("[build-dependencies]\n"); manifest.push_str("wasm-bindgen-webidl = { path = '"); manifest.push_str(env!("CARGO_MANIFEST_DIR")); - manifest.push_str("/crates/webidl' }\n"); + manifest.push_str("/../webidl' }\n"); manifest.push_str("[dependencies]\n"); for dep in self.deps.iter() { @@ -226,7 +228,7 @@ impl Project { } manifest.push_str("wasm-bindgen = { path = '"); manifest.push_str(env!("CARGO_MANIFEST_DIR")); - manifest.push_str("'"); + manifest.push_str("/../..'"); if self.no_std { manifest.push_str(", default-features = false"); } @@ -826,4 +828,3 @@ fn run_in_background(cmd: &mut Command, name: String) -> BackgroundChild { stdin: Some(stdin), } } - diff --git a/tests/all/run-headless.js b/crates/test-project-builder/src/run-headless.js similarity index 100% rename from tests/all/run-headless.js rename to crates/test-project-builder/src/run-headless.js diff --git a/tests/all/main.rs b/tests/all/main.rs index 5d31bc22..3d06a784 100644 --- a/tests/all/main.rs +++ b/tests/all/main.rs @@ -1,8 +1,5 @@ -#[macro_use] -extern crate lazy_static; -extern crate wasm_bindgen_cli_support; +extern crate wasm_bindgen_test_project_builder as project_builder; -mod project_builder; use project_builder::{project, run}; mod api;