From d0464fbff70ce5dee595d023fb81ba95d2e21cbd Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 2 Sep 2018 12:34:13 -0700 Subject: [PATCH 1/3] Add Emscripten build in Travis --- .travis.yml | 2 ++ test_suite/tests/test_de.rs | 7 ++++++- test_suite/tests/test_ser.rs | 1 + test_suite/tests/test_value.rs | 1 + travis.sh | 16 ++++++++++++++++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 87d36ff7..e20781a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,5 +18,7 @@ matrix: include: - rust: nightly env: CLIPPY=true + - rust: nightly + env: EMSCRIPTEN=true script: ./travis.sh diff --git a/test_suite/tests/test_de.rs b/test_suite/tests/test_de.rs index 95b419e2..4897abd0 100644 --- a/test_suite/tests/test_de.rs +++ b/test_suite/tests/test_de.rs @@ -156,8 +156,12 @@ macro_rules! declare_tests { )+ }; - ($($name:ident { $($value:expr => $tokens:expr,)+ })+) => { + ($( + $(#[$cfg:meta])* + $name:ident { $($value:expr => $tokens:expr,)+ } + )+) => { $( + $(#[$cfg])* #[test] fn $name() { $( @@ -260,6 +264,7 @@ declare_tests! { 0f32 => &[Token::F32(0.)], 0f64 => &[Token::F64(0.)], } + #[cfg(not(target_arch = "wasm32"))] test_small_int_to_128 { 1i128 => &[Token::I8(1)], 1i128 => &[Token::I16(1)], diff --git a/test_suite/tests/test_ser.rs b/test_suite/tests/test_ser.rs index 086029b5..231b6ee7 100644 --- a/test_suite/tests/test_ser.rs +++ b/test_suite/tests/test_ser.rs @@ -618,6 +618,7 @@ fn test_enum_skipped() { ); } +#[cfg(not(target_arch = "wasm32"))] #[test] fn test_integer128() { assert_ser_tokens_error(&1i128, &[], "i128 is not supported"); diff --git a/test_suite/tests/test_value.rs b/test_suite/tests/test_value.rs index d2d9e67c..d351ed54 100644 --- a/test_suite/tests/test_value.rs +++ b/test_suite/tests/test_value.rs @@ -26,6 +26,7 @@ fn test_u32_to_enum() { assert_eq!(E::B, e); } +#[cfg(not(target_arch = "wasm32"))] #[test] fn test_integer128() { let de_u128 = IntoDeserializer::::into_deserializer(1u128); diff --git a/travis.sh b/travis.sh index 8626e3e6..3b5b75ae 100755 --- a/travis.sh +++ b/travis.sh @@ -42,6 +42,22 @@ if [ -n "${CLIPPY}" ]; then cd "$DIR/test_suite/no_std" cargo clippy -- -Dclippy +elif [ -n "${EMSCRIPTEN}" ]; then + CARGO_WEB_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/koute/cargo-web/releases/latest) + CARGO_WEB_VERSION=$(echo "${CARGO_WEB_RELEASE}" | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/') + CARGO_WEB_URL="https://github.com/koute/cargo-web/releases/download/${CARGO_WEB_VERSION}/cargo-web-x86_64-unknown-linux-gnu.gz" + + mkdir -p ~/.cargo/bin + echo "Downloading cargo-web from: ${CARGO_WEB_URL}" + curl -L "${CARGO_WEB_URL}" | gzip -d > ~/.cargo/bin/cargo-web + chmod +x ~/.cargo/bin/cargo-web + + # Install Node.js + nvm install 9 + + cd "$DIR/test_suite" + cargo web test --target=asmjs-unknown-emscripten --nodejs + cargo web test --target=wasm32-unknown-emscripten --nodejs else CHANNEL=nightly cd "$DIR" From 2244b92eb022e613f808e656c42783c6eaf27bdb Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 2 Sep 2018 12:45:10 -0700 Subject: [PATCH 2/3] Nvm install in .travis.yml The one in travis.sh was failing: ./travis.sh: line 56: nvm: command not found The command "./travis.sh" exited with 127. --- .travis.yml | 1 + travis.sh | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index e20781a9..9124ebbb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,5 +20,6 @@ matrix: env: CLIPPY=true - rust: nightly env: EMSCRIPTEN=true + script: nvm install 9 && ./travis.sh script: ./travis.sh diff --git a/travis.sh b/travis.sh index 3b5b75ae..da7b8cc8 100755 --- a/travis.sh +++ b/travis.sh @@ -52,9 +52,6 @@ elif [ -n "${EMSCRIPTEN}" ]; then curl -L "${CARGO_WEB_URL}" | gzip -d > ~/.cargo/bin/cargo-web chmod +x ~/.cargo/bin/cargo-web - # Install Node.js - nvm install 9 - cd "$DIR/test_suite" cargo web test --target=asmjs-unknown-emscripten --nodejs cargo web test --target=wasm32-unknown-emscripten --nodejs From 33b784130041c04db028a15d86faedffc637055c Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 2 Sep 2018 13:21:36 -0700 Subject: [PATCH 3/3] Skip asmjs --- travis.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/travis.sh b/travis.sh index da7b8cc8..55b79508 100755 --- a/travis.sh +++ b/travis.sh @@ -53,7 +53,6 @@ elif [ -n "${EMSCRIPTEN}" ]; then chmod +x ~/.cargo/bin/cargo-web cd "$DIR/test_suite" - cargo web test --target=asmjs-unknown-emscripten --nodejs cargo web test --target=wasm32-unknown-emscripten --nodejs else CHANNEL=nightly