diff --git a/.cargo/config b/.cargo/config.toml similarity index 100% rename from .cargo/config rename to .cargo/config.toml diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 9e79ce44..c303fd2b 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -11,41 +11,39 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: actions-rs/cargo@v1 + - uses: actions/checkout@v2 - - name: Latest Rust Nightly - uses: actions-rs/toolchain@v1 - with: + - uses: actions-rs/toolchain@v1 + with: toolchain: nightly override: true # Used when testing with `wasm-pack test` target: wasm32-unknown-unknown - - name: Rust Version Info - run: rustc --version && cargo --version && echo $CARGO_HOME - - - name: Install wasm-pack - run: > - curl -L https://github.com/rustwasm/wasm-pack/releases/download/v0.10.0/wasm-pack-v0.10.0-x86_64-unknown-linux-musl.tar.gz - | tar --strip-components=1 --wildcards -xzf - "*/wasm-pack" - && chmod +x wasm-pack - && mv wasm-pack $HOME/.cargo/bin/ - - - name: Browser versions - run: wasm-pack --version && firefox --version - - - uses: actions/cache@v2 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - - name: Run all tests - run: ./test.sh - - # NOTE: We can start running the full test suite on stable after https://github.com/rust-lang/rust/issues/54725 - - name: Check that Stable can compile - run: cargo +stable check --all + - name: Rust Version Info + run: rustc --version && cargo --version && echo $CARGO_HOME + + - name: Install wasm-pack + run: > + curl -L https://github.com/rustwasm/wasm-pack/releases/download/v0.10.0/wasm-pack-v0.10.0-x86_64-unknown-linux-musl.tar.gz + | tar --strip-components=1 --wildcards -xzf - "*/wasm-pack" + && chmod +x wasm-pack + && mv wasm-pack $HOME/.cargo/bin/ + + - name: Browser versions + run: wasm-pack --version && firefox --version + + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Run all tests + run: ./test.sh + + # NOTE: We can start running the full test suite on stable after https://github.com/rust-lang/rust/issues/54725 + - name: Check that Stable can compile + run: cargo +stable check --all diff --git a/crates/html-macro-test/src/tests/all_tests.rs b/crates/html-macro-test/src/tests/all_tests.rs index 39fab197..dcbac239 100644 --- a/crates/html-macro-test/src/tests/all_tests.rs +++ b/crates/html-macro-test/src/tests/all_tests.rs @@ -9,6 +9,7 @@ use html_macro::html; use std::collections::HashMap; use virtual_node::{IterableNodes, VElement, VText, View, VirtualNode}; +#[must_use] pub(crate) struct HtmlMacroTest { pub generated: VirtualNode, pub expected: VirtualNode, @@ -17,7 +18,7 @@ pub(crate) struct HtmlMacroTest { impl HtmlMacroTest { /// Ensure that the generated and the expected virtual node are equal. pub fn test(self) { - assert_eq!(self.expected, self.generated); + assert_eq!(self.generated, self.expected); } } @@ -27,7 +28,7 @@ fn empty_div() { generated: html! {
}, expected: VirtualNode::element("div"), } - .test(); + .test(); } #[test] @@ -42,7 +43,7 @@ fn one_attr() { generated: html! {
}, expected: expected.into(), } - .test(); + .test(); } #[test] @@ -54,7 +55,7 @@ fn child_node() { generated: html! {
}, expected: expected.into(), } - .test(); + .test(); } #[test] @@ -66,7 +67,7 @@ fn sibling_child_nodes() { generated: html! {
}, expected: expected.into(), } - .test(); + .test(); } /// Nested 3 nodes deep @@ -82,20 +83,22 @@ fn three_nodes_deep() { generated: html! {
}, expected: expected.into(), } - .test() + .test() } -#[test] -fn sibling_text_nodes() { - let mut expected = VElement::new("div"); - expected.children = vec![VirtualNode::text("This is a text node")]; - HtmlMacroTest { - generated: html! {
This is a text node
}, - expected: expected.into(), - } - .test(); -} +// TODO: Requires proc macro APIs that are currently unstable - https://github.com/rust-lang/rust/issues/54725 +// #[test] +// fn sibling_text_nodes() { +// let mut expected = VElement::new("div"); +// expected.children = vec![VirtualNode::text("This is a text node")]; +// +// HtmlMacroTest { +// generated: html! {
This is a text node
}, +// expected: expected.into(), +// } +// .test(); +// } #[test] fn nested_macro() { @@ -113,7 +116,7 @@ fn nested_macro() { }, expected: expected.into(), } - .test(); + .test(); } /// If the first thing we see is a block then we grab whatever is inside it. @@ -129,44 +132,46 @@ fn block_root() { }, expected, } - .test(); -} - -/// Text followed by a block -#[test] -fn text_next_to_block() { - let child = html! { }; - - let mut expected = VElement::new("div"); - expected.children = vec![ - VirtualNode::text(" A bit of text "), - VirtualNode::element("ul"), - ]; - - HtmlMacroTest { - generated: html! { -
- A bit of text - { child } -
- }, - expected: expected.into(), - } - .test(); + .test(); } -/// Ensure that we maintain the correct spacing around punctuation tokens, since -/// they resolve into a separate TokenStream during parsing. -#[test] -fn punctuation_token() { - let text = "Hello, World"; - - HtmlMacroTest { - generated: html! { Hello, World }, - expected: VirtualNode::text(text), - } - .test() -} +// TODO: Requires proc macro APIs that are currently unstable - https://github.com/rust-lang/rust/issues/54725 +// /// Text followed by a block +// #[test] +// fn text_next_to_block() { +// let child = html! { }; +// +// let mut expected = VElement::new("div"); +// expected.children = vec![ +// VirtualNode::text(" A bit of text "), +// VirtualNode::element("ul"), +// ]; +// +// HtmlMacroTest { +// generated: html! { +//
+// A bit of text +// { child } +//
+// }, +// expected: expected.into(), +// } +// .test(); +// } + +// TODO: Requires proc macro APIs that are currently unstable - https://github.com/rust-lang/rust/issues/54725 +// /// Ensure that we maintain the correct spacing around punctuation tokens, since +// /// they resolve into a separate TokenStream during parsing. +// #[test] +// fn punctuation_token() { +// let text = "Hello, World"; +// +// HtmlMacroTest { +// generated: html! { Hello, World }, +// expected: VirtualNode::text(text), +// } +// .test() +// } #[test] fn vec_of_nodes() { @@ -179,17 +184,22 @@ fn vec_of_nodes() { generated: html! {
{ children }
}, expected: expected.into(), } - .test(); + .test(); } /// Just make sure that this compiles since as, async, for, loop, and type are keywords #[test] fn keyword_attribute() { - html! { }; - html! {