From ea518d7855b7c95fb20d925b08e912bd09c66d5a Mon Sep 17 00:00:00 2001 From: Chinedu Francis Nwafili Date: Fri, 18 Jan 2019 05:57:04 -0500 Subject: [PATCH] Fix failing tests --- .travis.yml | 8 ++--- Dockerfile | 16 ++++++---- crates/virtual-dom-rs/Cargo.toml | 4 +-- crates/virtual-dom-rs/src/patch.rs | 42 +++++++++++++-------------- crates/virtual-node/Cargo.toml | 2 +- crates/virtual-node/src/lib.rs | 4 +-- examples/isomorphic/client/Cargo.toml | 2 +- examples/isomorphic/client/src/lib.rs | 1 + test.sh | 2 +- 9 files changed, 44 insertions(+), 37 deletions(-) diff --git a/.travis.yml b/.travis.yml index a7b023ad..fdba3108 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,10 @@ INSTALL_DEPS: &INSTALL_DEPS - rustup default nightly - rustup target add wasm32-unknown-unknown # Install WASM bindgen CLI - - curl -OL https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.28/wasm-bindgen-0.2.28-x86_64-unknown-linux-musl.tar.gz - - tar xf wasm-bindgen-0.2.28-x86_64-unknown-linux-musl.tar.gz - - chmod +x wasm-bindgen-0.2.28-x86_64-unknown-linux-musl/wasm-bindgen - - mv wasm-bindgen-0.2.28-x86_64-unknown-linux-musl/wasm-bindgen* ~/.cargo/bin/ # wasm-bindgen and wasm-bindgen-test-runner binaries + - curl -OL https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.31/wasm-bindgen-0.2.31-x86_64-unknown-linux-musl.tar.gz + - tar xf wasm-bindgen-0.2.31-x86_64-unknown-linux-musl.tar.gz + - chmod +x wasm-bindgen-0.2.31-x86_64-unknown-linux-musl/wasm-bindgen + - mv wasm-bindgen-0.2.31-x86_64-unknown-linux-musl/wasm-bindgen* ~/.cargo/bin/ # wasm-bindgen and wasm-bindgen-test-runner binaries # Install Node.js - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash - source ~/.nvm/nvm.sh diff --git a/Dockerfile b/Dockerfile index eae3e259..0e9dae63 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,13 +9,18 @@ RUN rustup target add wasm32-unknown-unknown \ # Node.js & npm RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - -RUN apt-get install -y nodejs +RUN apt-get install -y nodejs # Install WASM bindgen CLI -RUN curl -L https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.25/wasm-bindgen-0.2.25-x86_64-unknown-linux-musl.tar.gz | tar --strip-components=1 --wildcards -xzf - "*/wasm-bindgen" &&\ +RUN curl -L https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.31/wasm-bindgen-0.2.31-x86_64-unknown-linux-musl.tar.gz | tar --strip-components=1 --wildcards -xzf - "*/wasm-bindgen" &&\ chmod +x wasm-bindgen* &&\ mv wasm-bindgen* /usr/local/bin/ +# Install WASM pack +RUN curl -L https://github.com/rustwasm/wasm-pack/releases/download/v0.6.0/wasm-pack-v0.6.0-x86_64-unknown-linux-musl.tar.gz | tar --strip-components=1 --wildcards -xzf - "*/wasm-pack" &&\ + chmod +x wasm-pack &&\ + mv wasm-pack /usr/local/bin/ + WORKDIR /usr/src COPY package.json package-lock.json ./ @@ -25,10 +30,11 @@ RUN npm install COPY . ./ -WORKDIR /usr/src/examples/isomorphic - # TODO: Unused.. the server code just expects this directory to be there at the moment..... -RUN mkdir client/build +RUN mkdir /usr/src/examples/isomorphic/client/build +RUN touch /usr/src/examples/isomorphic/client/build/unused.txt + +WORKDIR /usr/src/examples/isomorphic RUN ./build.release.sh diff --git a/crates/virtual-dom-rs/Cargo.toml b/crates/virtual-dom-rs/Cargo.toml index 728bc36a..8b1cc3ed 100644 --- a/crates/virtual-dom-rs/Cargo.toml +++ b/crates/virtual-dom-rs/Cargo.toml @@ -11,7 +11,7 @@ edition = "2018" [dependencies] js-sys = "0.3" -wasm-bindgen = {version = "0.2", features = ["default", "nightly"]} +wasm-bindgen = {version = "0.2.31", features = ["default", "nightly"]} virtual-node = { path = "../virtual-node", version = "0.0.1" } [dependencies.web-sys] @@ -33,7 +33,7 @@ features = [ ] [dev-dependencies] -wasm-bindgen-test = "0.2" +wasm-bindgen-test = "0.2.31" [dev-dependencies.web-sys] version = "0.3" diff --git a/crates/virtual-dom-rs/src/patch.rs b/crates/virtual-dom-rs/src/patch.rs index 01b6aee0..444353e7 100644 --- a/crates/virtual-dom-rs/src/patch.rs +++ b/crates/virtual-dom-rs/src/patch.rs @@ -7,37 +7,37 @@ use wasm_bindgen::JsCast; use web_sys; use web_sys::{Element, Node}; -use wasm_bindgen::JsValue; - -/// A `Patch` encodes an operation that modifies a real DOM element. +/// A Patch encodes an operation that modifies a real DOM element. /// /// To update the real DOM that a user sees you'll want to first diff your /// old virtual dom and new virtual dom. /// -/// This diff operation will generate `Vec` with zero or more patches that, when +/// This diff operation will generate Vec with zero or more patches that, when /// applied to your real DOM, will make your real DOM look like your new virtual dom. /// -/// Each `Patch` has a u32 node index that helps us identify the real DOM node that it applies to. +/// Each Patch has a u32 node index that helps us identify the real DOM node that it applies to. /// /// Our old virtual dom's nodes are indexed depth first, as shown in this illustration /// (0 being the root node, 1 being it's first child, 2 being it's first child's first child). /// -/// .─. -/// ( 0 ) -/// `┬' -/// ┌────┴──────┐ -/// │ │ -/// ▼ ▼ -/// .─. .─. -/// ( 1 ) ( 4 ) -/// `┬' `─' -/// ┌────┴───┐ │ -/// │ │ ├─────┬─────┐ -/// ▼ ▼ │ │ │ -/// .─. .─. ▼ ▼ ▼ -/// ( 2 ) ( 3 ) .─. .─. .─. -/// `─' `─' ( 5 ) ( 6 ) ( 7 ) -/// `─' `─' `─' +/// ```ignore +/// .─. +/// ( 0 ) +/// `┬' +/// ┌────┴──────┐ +/// │ │ +/// ▼ ▼ +/// .─. .─. +/// ( 1 ) ( 4 ) +/// `┬' `─' +/// ┌────┴───┐ │ +/// │ │ ├─────┬─────┐ +/// ▼ ▼ │ │ │ +/// .─. .─. ▼ ▼ ▼ +/// ( 2 ) ( 3 ) .─. .─. .─. +/// `─' `─' ( 5 ) ( 6 ) ( 7 ) +/// `─' `─' `─' +/// ``` /// /// We'll revisit our indexing in the future when we optimize our diff/patch process. #[derive(Debug, PartialEq)] diff --git a/crates/virtual-node/Cargo.toml b/crates/virtual-node/Cargo.toml index 8cd061bb..cf9dc18f 100644 --- a/crates/virtual-node/Cargo.toml +++ b/crates/virtual-node/Cargo.toml @@ -11,7 +11,7 @@ edition = "2018" [dependencies] js-sys = "0.3" -wasm-bindgen = {version = "0.2", features = ["default", "nightly"]} +wasm-bindgen = {version = "0.2.31", features = ["default", "nightly"]} [dependencies.web-sys] version = "0.3" diff --git a/crates/virtual-node/src/lib.rs b/crates/virtual-node/src/lib.rs index 26be063e..951e4802 100644 --- a/crates/virtual-node/src/lib.rs +++ b/crates/virtual-node/src/lib.rs @@ -148,7 +148,7 @@ impl VirtualNode { /// /// These get patched into the DOM using `document.createElement` /// - /// ``` + /// ```ignore /// use virtual_dom_rs::VirtualNode; /// /// let div = VirtualNode::new("div"); @@ -171,7 +171,7 @@ impl VirtualNode { /// /// These get patched into the DOM using `document.createTextNode` /// - /// ``` + /// ```ignore /// use virtual_dom_rs::VirtualNode; /// /// let div = VirtualNode::text("div"); diff --git a/examples/isomorphic/client/Cargo.toml b/examples/isomorphic/client/Cargo.toml index fa218999..253c12a1 100644 --- a/examples/isomorphic/client/Cargo.toml +++ b/examples/isomorphic/client/Cargo.toml @@ -13,7 +13,7 @@ isomorphic-app = { path = "../app" } virtual-dom-rs = { path = "../../../crates/virtual-dom-rs" } [dependencies.wasm-bindgen] -version = "0.2" +version = "0.2.31" features = ["default", "nightly"] [dependencies.web-sys] diff --git a/examples/isomorphic/client/src/lib.rs b/examples/isomorphic/client/src/lib.rs index 9ce35084..e8a68c31 100644 --- a/examples/isomorphic/client/src/lib.rs +++ b/examples/isomorphic/client/src/lib.rs @@ -1,3 +1,4 @@ + use wasm_bindgen; use wasm_bindgen::prelude::*; diff --git a/test.sh b/test.sh index 3a55fb2d..5bbb2eaa 100755 --- a/test.sh +++ b/test.sh @@ -4,4 +4,4 @@ cd $(git rev-parse --show-toplevel) cargo build --all && # Make sure examples compile cargo test --all && -cargo test -p virtual-dom-rs --target wasm32-unknown-unknown +wasm-pack test crates/virtual-dom-rs --firefox --headless