From 377ec67c6473e7b24cd9d23d335cc0033dcc4668 Mon Sep 17 00:00:00 2001 From: ben little Date: Wed, 17 Jul 2024 22:49:50 -0600 Subject: [PATCH 1/7] add wasm-pack test for net to ci --- .github/workflows/tests.yml | 7 +++++++ Cargo.lock | 31 +++++++++++++++++++++---------- crates/net/tests/http.rs | 2 +- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 14e7df7e..335162f3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -263,3 +263,10 @@ jobs: WS_ECHO_SERVER_URL: 'ws://localhost:8081' SSE_ECHO_SERVER_URL: 'http://localhost:8081/.sse' run: cargo test -p gloo-net --all-features + + - name: Run node tests + env: + HTTPBIN_URL: 'http://localhost:8080' + WS_ECHO_SERVER_URL: 'ws://localhost:8081' + SSE_ECHO_SERVER_URL: 'http://localhost:8081/.sse' + run: wasm-pack test --node crates/gloo-net --all-features diff --git a/Cargo.lock b/Cargo.lock index 114c8d0b..9cbde3d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -598,7 +598,7 @@ dependencies = [ "futures-core", "futures-sink", "gloo-utils 0.1.7", - "http", + "http 0.2.11", "js-sys", "pin-project", "serde", @@ -619,7 +619,7 @@ dependencies = [ "futures-io", "futures-sink", "gloo-utils 0.2.0", - "http 1.0.0", + "http 1.1.0", "js-sys", "once_cell", "pin-project", @@ -785,7 +785,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.11", "indexmap 2.1.0", "slab", "tokio", @@ -814,7 +814,7 @@ dependencies = [ "base64", "bytes", "headers-core", - "http", + "http 0.2.11", "httpdate", "mime", "sha1", @@ -826,7 +826,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" dependencies = [ - "http", + "http 0.2.11", ] [[package]] @@ -852,6 +852,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -859,7 +870,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.11", "pin-project-lite", ] @@ -886,7 +897,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http", + "http 0.2.11", "http-body", "httparse", "httpdate", @@ -1049,7 +1060,7 @@ dependencies = [ "bytes", "encoding_rs", "futures-util", - "http", + "http 0.2.11", "httparse", "log", "memchr", @@ -1699,7 +1710,7 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http", + "http 0.2.11", "httparse", "log", "rand", @@ -1787,7 +1798,7 @@ dependencies = [ "futures-channel", "futures-util", "headers", - "http", + "http 0.2.11", "hyper", "log", "mime", diff --git a/crates/net/tests/http.rs b/crates/net/tests/http.rs index 7f956a6b..4bc6045b 100644 --- a/crates/net/tests/http.rs +++ b/crates/net/tests/http.rs @@ -3,7 +3,7 @@ use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; use wasm_bindgen_test::*; -wasm_bindgen_test_configure!(run_in_browser); +// wasm_bindgen_test_configure!(run_in_browser); static HTTPBIN_URL: Lazy<&'static str> = Lazy::new(|| option_env!("HTTPBIN_URL").expect("Did you set HTTPBIN_URL?")); From df289afc9414c64819ffbece9551b516df192386 Mon Sep 17 00:00:00 2001 From: ben little Date: Wed, 17 Jul 2024 22:53:09 -0600 Subject: [PATCH 2/7] remove commented line --- crates/net/tests/http.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/net/tests/http.rs b/crates/net/tests/http.rs index 4bc6045b..9dfc5f89 100644 --- a/crates/net/tests/http.rs +++ b/crates/net/tests/http.rs @@ -3,8 +3,6 @@ use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; use wasm_bindgen_test::*; -// wasm_bindgen_test_configure!(run_in_browser); - static HTTPBIN_URL: Lazy<&'static str> = Lazy::new(|| option_env!("HTTPBIN_URL").expect("Did you set HTTPBIN_URL?")); From 272323c17f18875272b3b1b953923e2965b72aea Mon Sep 17 00:00:00 2001 From: ben little Date: Thu, 18 Jul 2024 09:39:49 -0600 Subject: [PATCH 3/7] fix path to net crate --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 335162f3..8912e382 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -269,4 +269,4 @@ jobs: HTTPBIN_URL: 'http://localhost:8080' WS_ECHO_SERVER_URL: 'ws://localhost:8081' SSE_ECHO_SERVER_URL: 'http://localhost:8081/.sse' - run: wasm-pack test --node crates/gloo-net --all-features + run: wasm-pack test --node crates/net --all-features From 66fb93225b4d012041548f090e3cc129d750d5e7 Mon Sep 17 00:00:00 2001 From: ben little Date: Thu, 18 Jul 2024 10:35:57 -0600 Subject: [PATCH 4/7] enable query tests --- crates/net/tests/query.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/net/tests/query.rs b/crates/net/tests/query.rs index a16e061c..1522bef4 100644 --- a/crates/net/tests/query.rs +++ b/crates/net/tests/query.rs @@ -1,8 +1,6 @@ use gloo_net::http::QueryParams; use wasm_bindgen_test::*; -wasm_bindgen_test_configure!(run_in_browser); - #[wasm_bindgen_test] fn query_params_iter() { let params = QueryParams::new(); From 8294631eff93c8a3b373c4313d9f108e272cc069 Mon Sep 17 00:00:00 2001 From: ben little Date: Thu, 18 Jul 2024 14:22:22 -0600 Subject: [PATCH 5/7] cfg gate for browser tests --- crates/net/tests/http.rs | 3 +++ crates/net/tests/query.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/crates/net/tests/http.rs b/crates/net/tests/http.rs index 9dfc5f89..c63cb469 100644 --- a/crates/net/tests/http.rs +++ b/crates/net/tests/http.rs @@ -3,6 +3,9 @@ use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; use wasm_bindgen_test::*; +#[cfg(target_arch = "wasm32-unknown-unknown")] +wasm_bindgen_test_configure!(run_in_browser); + static HTTPBIN_URL: Lazy<&'static str> = Lazy::new(|| option_env!("HTTPBIN_URL").expect("Did you set HTTPBIN_URL?")); diff --git a/crates/net/tests/query.rs b/crates/net/tests/query.rs index 1522bef4..c649e446 100644 --- a/crates/net/tests/query.rs +++ b/crates/net/tests/query.rs @@ -1,6 +1,9 @@ use gloo_net::http::QueryParams; use wasm_bindgen_test::*; +#[cfg(target_arch = "wasm32")] +wasm_bindgen_test_configure!(run_in_browser); + #[wasm_bindgen_test] fn query_params_iter() { let params = QueryParams::new(); From 65dd70e6401cb811ba07840faa42151fa4184343 Mon Sep 17 00:00:00 2001 From: ben little Date: Thu, 18 Jul 2024 14:23:32 -0600 Subject: [PATCH 6/7] revert cargo.lock --- Cargo.lock | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9cbde3d0..114c8d0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -598,7 +598,7 @@ dependencies = [ "futures-core", "futures-sink", "gloo-utils 0.1.7", - "http 0.2.11", + "http", "js-sys", "pin-project", "serde", @@ -619,7 +619,7 @@ dependencies = [ "futures-io", "futures-sink", "gloo-utils 0.2.0", - "http 1.1.0", + "http 1.0.0", "js-sys", "once_cell", "pin-project", @@ -785,7 +785,7 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http 0.2.11", + "http", "indexmap 2.1.0", "slab", "tokio", @@ -814,7 +814,7 @@ dependencies = [ "base64", "bytes", "headers-core", - "http 0.2.11", + "http", "httpdate", "mime", "sha1", @@ -826,7 +826,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" dependencies = [ - "http 0.2.11", + "http", ] [[package]] @@ -852,17 +852,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - [[package]] name = "http-body" version = "0.4.6" @@ -870,7 +859,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http 0.2.11", + "http", "pin-project-lite", ] @@ -897,7 +886,7 @@ dependencies = [ "futures-core", "futures-util", "h2", - "http 0.2.11", + "http", "http-body", "httparse", "httpdate", @@ -1060,7 +1049,7 @@ dependencies = [ "bytes", "encoding_rs", "futures-util", - "http 0.2.11", + "http", "httparse", "log", "memchr", @@ -1710,7 +1699,7 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http 0.2.11", + "http", "httparse", "log", "rand", @@ -1798,7 +1787,7 @@ dependencies = [ "futures-channel", "futures-util", "headers", - "http 0.2.11", + "http", "hyper", "log", "mime", From 1e9e002cec9a0e1715209f1fd6b55907493462d6 Mon Sep 17 00:00:00 2001 From: ben little Date: Fri, 19 Jul 2024 11:21:10 -0600 Subject: [PATCH 7/7] add browser-test feature --- .github/workflows/tests.yml | 6 +++--- crates/net/Cargo.toml | 2 ++ crates/net/tests/http.rs | 2 +- crates/net/tests/query.rs | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8912e382..ee0c204c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -250,7 +250,7 @@ jobs: SSE_ECHO_SERVER_URL: 'http://localhost:8081/.sse' run: | cd crates/net - wasm-pack test --chrome --firefox --headless --all-features + wasm-pack test --chrome --firefox --headless --features=default,io-util,browser-test - uses: dtolnay/rust-toolchain@master with: @@ -262,11 +262,11 @@ jobs: HTTPBIN_URL: 'http://localhost:8080' WS_ECHO_SERVER_URL: 'ws://localhost:8081' SSE_ECHO_SERVER_URL: 'http://localhost:8081/.sse' - run: cargo test -p gloo-net --all-features + run: cargo test -p gloo-net --features=default,io-util - name: Run node tests env: HTTPBIN_URL: 'http://localhost:8080' WS_ECHO_SERVER_URL: 'ws://localhost:8081' SSE_ECHO_SERVER_URL: 'http://localhost:8081/.sse' - run: wasm-pack test --node crates/net --all-features + run: wasm-pack test --node crates/net --features=default,io-util diff --git a/crates/net/Cargo.toml b/crates/net/Cargo.toml index 73681ee5..a0614686 100644 --- a/crates/net/Cargo.toml +++ b/crates/net/Cargo.toml @@ -102,3 +102,5 @@ eventsource = [ ] # As of now, only implements `AsyncRead` and `AsyncWrite` on `WebSocket` io-util = ["futures-io"] +# For test runner only. Enables browser tests. +browser-test = [] diff --git a/crates/net/tests/http.rs b/crates/net/tests/http.rs index c63cb469..38198c79 100644 --- a/crates/net/tests/http.rs +++ b/crates/net/tests/http.rs @@ -3,7 +3,7 @@ use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; use wasm_bindgen_test::*; -#[cfg(target_arch = "wasm32-unknown-unknown")] +#[cfg(feature = "browser_test")] wasm_bindgen_test_configure!(run_in_browser); static HTTPBIN_URL: Lazy<&'static str> = diff --git a/crates/net/tests/query.rs b/crates/net/tests/query.rs index c649e446..4492066a 100644 --- a/crates/net/tests/query.rs +++ b/crates/net/tests/query.rs @@ -1,7 +1,7 @@ use gloo_net::http::QueryParams; use wasm_bindgen_test::*; -#[cfg(target_arch = "wasm32")] +#[cfg(feature = "browser_test")] wasm_bindgen_test_configure!(run_in_browser); #[wasm_bindgen_test]