mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Fix cargo make config and tests (#2640)
* remove pr-flow, run all the tests when asked * make tests that were never run pass * run tests cargo make properly * use wasm-pack-base test for running wasm tests * cargo make config should be good * update CI
This commit is contained in:
parent
b712f6ce9c
commit
18f004bc57
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
1
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -8,7 +8,6 @@ Fixes #0000 <!-- replace with issue number or remove if not applicable -->
|
||||
|
||||
<!-- For further details, please read CONTRIBUTING.md -->
|
||||
|
||||
- [ ] I have run `cargo make pr-flow`
|
||||
- [ ] I have reviewed my own code
|
||||
- [ ] I have added tests
|
||||
<!-- If this is a bug fix, these tests will fail if the bug is present (to stop it from cropping up again) -->
|
||||
|
||||
13
.github/workflows/main-checks.yml
vendored
13
.github/workflows/main-checks.yml
vendored
@ -87,7 +87,6 @@ jobs:
|
||||
sudo apt-get install aspell
|
||||
ci/spellcheck.sh list
|
||||
|
||||
|
||||
- name: Run doctest
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
@ -106,8 +105,6 @@ jobs:
|
||||
command: test
|
||||
args: --doc --features doc_test --features wasm_test
|
||||
|
||||
|
||||
|
||||
integration_tests:
|
||||
name: Integration Tests on ${{ matrix.toolchain }}
|
||||
runs-on: ubuntu-latest
|
||||
@ -134,7 +131,6 @@ jobs:
|
||||
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
|
||||
|
||||
- name: Run tests - yew
|
||||
run: |
|
||||
cd packages/yew
|
||||
@ -170,13 +166,17 @@ jobs:
|
||||
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
|
||||
- name: Run tests
|
||||
- name: Run native tests
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: --all-targets --workspace --exclude yew --exclude website-test
|
||||
|
||||
|
||||
- name: Run native tests for yew
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: test
|
||||
args: -p yew --features "csr,ssr,hydration"
|
||||
|
||||
test-lints:
|
||||
name: Test lints on nightly
|
||||
@ -192,7 +192,6 @@ jobs:
|
||||
|
||||
- uses: Swatinem/rust-cache@v1
|
||||
|
||||
|
||||
- name: Run tests
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
|
||||
@ -1,104 +1,90 @@
|
||||
######################
|
||||
#
|
||||
# public tasks:
|
||||
# * pr-flow
|
||||
# * lint
|
||||
# * lint-release
|
||||
# * tests
|
||||
# * checks-flow
|
||||
# * lint
|
||||
# * lint-release
|
||||
# * format
|
||||
# * test-flow
|
||||
# * test
|
||||
# * doc-test
|
||||
# * website-test
|
||||
#
|
||||
# packages/yew also contains `clippy-feature-soundness` to ensure everything is fine
|
||||
# Run `cargo make --list-all-steps` for more details.
|
||||
#
|
||||
######################
|
||||
[config]
|
||||
min_version = "0.32.4"
|
||||
skip_core_tasks = true
|
||||
default_to_workspace = false
|
||||
|
||||
[env]
|
||||
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
|
||||
CARGO_MAKE_CLIPPY_ARGS = "-- --deny=warnings"
|
||||
CARGO_MAKE_WORKSPACE_SKIP_MEMBERS = [
|
||||
"examples/*",
|
||||
"tools/*",
|
||||
]
|
||||
|
||||
[config.modify_core_tasks]
|
||||
private = true
|
||||
namespace = "core"
|
||||
|
||||
[tasks.pr-flow]
|
||||
toolchain = "stable"
|
||||
category = "Checks"
|
||||
description = "Lint and test"
|
||||
run_task = { name = ["lint", "lint-release", "tests"], fork = true }
|
||||
# checks
|
||||
|
||||
[tasks.lint]
|
||||
category = "Checks"
|
||||
description = "Check formatting and run Clippy"
|
||||
toolchain = "nightly"
|
||||
run_task = { name = ["lint-flow"], fork = true }
|
||||
|
||||
[tasks.tests]
|
||||
category = "Testing"
|
||||
description = "Run all tests"
|
||||
dependencies = ["tests-setup"]
|
||||
env = { CARGO_MAKE_WORKSPACE_SKIP_MEMBERS = ["**/examples/*", "**/packages/changelog"] }
|
||||
run_task = { name = ["test-flow", "doc-test-flow", "ssr-test", "website-test"], fork = true }
|
||||
|
||||
[tasks.lint-flow]
|
||||
private = true
|
||||
workspace = true
|
||||
dependencies = ["core::check-format-flow", "core::clippy-flow"]
|
||||
description = "Runs clippy"
|
||||
command = "cargo"
|
||||
args = ["clippy", "--", "--deny=warnings"]
|
||||
|
||||
# Needed, because we have some code differences between debug and release builds
|
||||
[tasks.lint-release]
|
||||
category = "Checks"
|
||||
workspace = true
|
||||
command = "cargo"
|
||||
args = ["clippy", "--all-targets", "--release", "--", "--deny=warnings"]
|
||||
|
||||
[tasks.tests-setup]
|
||||
private = true
|
||||
script_runner = "@duckscript"
|
||||
script = [
|
||||
"""
|
||||
test_flags = array --headless --firefox
|
||||
yew_test_features = set wasm_test
|
||||
[tasks.format]
|
||||
category = "Checks"
|
||||
toolchain = "nightly"
|
||||
env = { CARGO_MAKE_RUST_CHANNEL = "nightly" }
|
||||
|
||||
yew_test_flags = array_join ${test_flags} " "
|
||||
echo "running tests with flags: ${yew_test_flags} and features: ${yew_test_features}"
|
||||
|
||||
set_env YEW_TEST_FLAGS ${yew_test_flags}
|
||||
set_env YEW_TEST_FEATURES ${yew_test_features}
|
||||
""",
|
||||
]
|
||||
[tasks.checks-flow]
|
||||
category = "Checks"
|
||||
description = "Runs clippy in debug and release mode and format all the code"
|
||||
run_task = { name = ["lint", "lint-release", "format"], fork = true }
|
||||
|
||||
[tasks.test-flow]
|
||||
private = true
|
||||
workspace = true
|
||||
dependencies = ["test"]
|
||||
# Tests
|
||||
|
||||
[tasks.test]
|
||||
private = true
|
||||
command = "cargo"
|
||||
args = ["test", "--all-targets"]
|
||||
|
||||
[tasks.doc-test-flow]
|
||||
private = true
|
||||
workspace = true
|
||||
dependencies = ["doc-test"]
|
||||
|
||||
[tasks.doc-test]
|
||||
private = true
|
||||
command = "cargo"
|
||||
args = ["test", "--doc"]
|
||||
args = ["test", "--doc", "--all-features"]
|
||||
workspace = true
|
||||
|
||||
[tasks.website-test]
|
||||
command = "cargo"
|
||||
args = ["test", "-p", "website-test"]
|
||||
|
||||
[tasks.test-flow]
|
||||
category = "Testing"
|
||||
description = "Run all tests"
|
||||
run_task = { name = ["test", "doc-test", "website-test"], fork = true, parallel = true }
|
||||
|
||||
# misc
|
||||
|
||||
[tasks.generate-change-log]
|
||||
category = "Maintainer processes"
|
||||
toolchain = "stable"
|
||||
command = "cargo"
|
||||
args = ["run","-p","changelog", "--release", "${@}"]
|
||||
args = ["run", "-p", "changelog", "--release", "${@}"]
|
||||
|
||||
[tasks.ssr-test]
|
||||
env = { CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS = ["**/packages/yew"] }
|
||||
private = true
|
||||
workspace = true
|
||||
[tasks.default]
|
||||
#run_task = { name = ["checks-flow", "test-flow"], fork = true }
|
||||
dependencies = ["checks-flow", "test-flow"]
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[tasks.test]
|
||||
clear = true
|
||||
toolchain = ""
|
||||
toolchain = "1.56.0"
|
||||
command = "cargo"
|
||||
# test target can be optionally specified like `cargo make test html_macro`,
|
||||
args = ["test", "${@}"]
|
||||
@ -9,7 +9,7 @@ args = ["test", "${@}"]
|
||||
clear = true
|
||||
toolchain = "nightly"
|
||||
command = "cargo"
|
||||
args = ["test test_html_lints --features lints"]
|
||||
args = ["test", "test_html_lints", "--features", "lints"]
|
||||
|
||||
[tasks.test-overwrite]
|
||||
extend = "test"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[tasks.test]
|
||||
clear = true
|
||||
toolchain = "1.56"
|
||||
toolchain = "1.56.0"
|
||||
command = "cargo"
|
||||
args = ["test"]
|
||||
|
||||
|
||||
@ -1,10 +1,7 @@
|
||||
[tasks.test]
|
||||
extend = "core::wasm-pack-base"
|
||||
command = "wasm-pack"
|
||||
args = [
|
||||
"test",
|
||||
"@@split(YEW_TEST_FLAGS, )",
|
||||
"--",
|
||||
"--features",
|
||||
"${YEW_TEST_FEATURES}",
|
||||
"--firefox",
|
||||
"--headless",
|
||||
]
|
||||
|
||||
@ -1,37 +1,25 @@
|
||||
[tasks.native-test]
|
||||
command = "cargo"
|
||||
toolchain = "1.56"
|
||||
args = ["test", "native_"]
|
||||
args = ["test", "--features", "csr,ssr,hydration"]
|
||||
|
||||
[tasks.test]
|
||||
dependencies = ["native-test"]
|
||||
extend = "core::wasm-pack-base"
|
||||
[tasks.wasm-test]
|
||||
command = "wasm-pack"
|
||||
args = [
|
||||
"test",
|
||||
"@@split(YEW_TEST_FLAGS, )",
|
||||
"--firefox",
|
||||
"--headless",
|
||||
"--",
|
||||
"--features",
|
||||
"${YEW_TEST_FEATURES}",
|
||||
]
|
||||
|
||||
[tasks.doc-test]
|
||||
clear = true
|
||||
run_task = { name = ["doc-test-normal"], fork = true }
|
||||
|
||||
[tasks.doc-test-normal]
|
||||
command = "cargo"
|
||||
args = [
|
||||
"test",
|
||||
"--doc",
|
||||
"--features",
|
||||
"tokio,doc_test,wasm_test",
|
||||
"wasm_test"
|
||||
]
|
||||
|
||||
[tasks.ssr-test]
|
||||
command = "cargo"
|
||||
args = ["test", "ssr_tests", "--features", "ssr"]
|
||||
|
||||
[tasks.test]
|
||||
dependencies = ["native-test", "wasm-test"]
|
||||
|
||||
[tasks.clippy-feature-soundness]
|
||||
script = '''
|
||||
#!/usr/bin/env bash
|
||||
@ -48,6 +36,3 @@ cargo clippy --release --features=csr -- --deny=warnings
|
||||
cargo clippy --release --features=hydration -- --deny=warnings
|
||||
cargo clippy --release --all-features --all-targets -- --deny=warnings
|
||||
'''
|
||||
|
||||
[tasks.lint-flow]
|
||||
dependencies = ["clippy-feature-soundness"]
|
||||
|
||||
@ -504,7 +504,7 @@ mod feat_hydration {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(all(test, feature = "wasm_test"))]
|
||||
mod layout_tests {
|
||||
extern crate self as yew;
|
||||
|
||||
@ -514,7 +514,6 @@ mod layout_tests {
|
||||
use crate::html;
|
||||
use crate::tests::layout_tests::{diff_layouts, TestLayout};
|
||||
|
||||
#[cfg(feature = "wasm_test")]
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
#[test]
|
||||
@ -582,7 +581,7 @@ mod layout_tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(all(test, feature = "wasm_test"))]
|
||||
mod layout_tests_keys {
|
||||
extern crate self as yew;
|
||||
|
||||
@ -594,7 +593,6 @@ mod layout_tests_keys {
|
||||
use crate::virtual_dom::VNode;
|
||||
use crate::{html, Children, Component, Context, Html, Properties};
|
||||
|
||||
#[cfg(feature = "wasm_test")]
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
struct Comp {}
|
||||
|
||||
@ -291,7 +291,7 @@ mod feat_hydration {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(all(test, feature = "wasm_test"))]
|
||||
mod layout_tests {
|
||||
#[cfg(feature = "wasm_test")]
|
||||
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
|
||||
@ -299,7 +299,6 @@ mod layout_tests {
|
||||
use super::*;
|
||||
use crate::tests::layout_tests::{diff_layouts, TestLayout};
|
||||
|
||||
#[cfg(feature = "wasm_test")]
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
#[test]
|
||||
|
||||
@ -118,7 +118,7 @@ impl BPortal {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(all(test, feature = "wasm_test"))]
|
||||
mod layout_tests {
|
||||
extern crate self as yew;
|
||||
|
||||
@ -130,7 +130,6 @@ mod layout_tests {
|
||||
use crate::tests::layout_tests::{diff_layouts, TestLayout};
|
||||
use crate::virtual_dom::VNode;
|
||||
|
||||
#[cfg(feature = "wasm_test")]
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
#[test]
|
||||
|
||||
@ -933,7 +933,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(all(test, feature = "wasm_test"))]
|
||||
mod layout_tests {
|
||||
extern crate self as yew;
|
||||
|
||||
@ -943,7 +943,6 @@ mod layout_tests {
|
||||
use crate::html;
|
||||
use crate::tests::layout_tests::{diff_layouts, TestLayout};
|
||||
|
||||
#[cfg(feature = "wasm_test")]
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
#[test]
|
||||
@ -1041,7 +1040,11 @@ mod tests_without_browser {
|
||||
<div class="foo" />
|
||||
}
|
||||
},
|
||||
html! { <div class="foo" /> },
|
||||
html! {
|
||||
<>
|
||||
<div class="foo" />
|
||||
</>
|
||||
},
|
||||
);
|
||||
assert_eq!(
|
||||
html! {
|
||||
@ -1052,7 +1055,7 @@ mod tests_without_browser {
|
||||
}
|
||||
},
|
||||
html! {
|
||||
<div class="bar" />
|
||||
<><div class="bar" /></>
|
||||
},
|
||||
);
|
||||
assert_eq!(
|
||||
@ -1061,7 +1064,9 @@ mod tests_without_browser {
|
||||
<div class="foo" />
|
||||
}
|
||||
},
|
||||
html! {},
|
||||
html! {
|
||||
<></>
|
||||
},
|
||||
);
|
||||
|
||||
// non-root tests
|
||||
@ -1075,7 +1080,7 @@ mod tests_without_browser {
|
||||
},
|
||||
html! {
|
||||
<div>
|
||||
<div class="foo" />
|
||||
<><div class="foo" /></>
|
||||
</div>
|
||||
},
|
||||
);
|
||||
@ -1091,7 +1096,7 @@ mod tests_without_browser {
|
||||
},
|
||||
html! {
|
||||
<div>
|
||||
<div class="bar" />
|
||||
<><div class="bar" /></>
|
||||
</div>
|
||||
},
|
||||
);
|
||||
@ -1121,7 +1126,11 @@ mod tests_without_browser {
|
||||
<div class={class} />
|
||||
}
|
||||
},
|
||||
html! { <div class="foo" /> },
|
||||
html! {
|
||||
<>
|
||||
<div class={Some("foo")} />
|
||||
</>
|
||||
},
|
||||
);
|
||||
assert_eq!(
|
||||
html! {
|
||||
@ -1131,7 +1140,11 @@ mod tests_without_browser {
|
||||
<div class="bar" />
|
||||
}
|
||||
},
|
||||
html! { <div class="bar" /> },
|
||||
html! {
|
||||
<>
|
||||
<div class="bar" />
|
||||
</>
|
||||
},
|
||||
);
|
||||
assert_eq!(
|
||||
html! {
|
||||
@ -1139,7 +1152,9 @@ mod tests_without_browser {
|
||||
<div class={class} />
|
||||
}
|
||||
},
|
||||
html! {},
|
||||
html! {
|
||||
<></>
|
||||
},
|
||||
);
|
||||
|
||||
// non-root tests
|
||||
@ -1151,7 +1166,13 @@ mod tests_without_browser {
|
||||
}
|
||||
</div>
|
||||
},
|
||||
html! { <div><div class="foo" /></div> },
|
||||
html! {
|
||||
<div>
|
||||
<>
|
||||
<div class={Some("foo")} />
|
||||
</>
|
||||
</div>
|
||||
},
|
||||
);
|
||||
assert_eq!(
|
||||
html! {
|
||||
@ -1163,7 +1184,13 @@ mod tests_without_browser {
|
||||
}
|
||||
</div>
|
||||
},
|
||||
html! { <div><div class="bar" /></div> },
|
||||
html! {
|
||||
<div>
|
||||
<>
|
||||
<div class="bar" />
|
||||
</>
|
||||
</div>
|
||||
},
|
||||
);
|
||||
assert_eq!(
|
||||
html! {
|
||||
|
||||
@ -177,7 +177,7 @@ mod test {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[cfg(all(test, feature = "wasm_test"))]
|
||||
mod layout_tests {
|
||||
extern crate self as yew;
|
||||
|
||||
@ -187,7 +187,6 @@ mod layout_tests {
|
||||
use crate::html;
|
||||
use crate::tests::layout_tests::{diff_layouts, TestLayout};
|
||||
|
||||
#[cfg(feature = "wasm_test")]
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
#[test]
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
//! Snapshot testing of Yew components
|
||||
//!
|
||||
//! This tests must be run in browser and thus require the `csr` feature to be enabled
|
||||
use gloo::console::log;
|
||||
use yew::NodeRef;
|
||||
|
||||
|
||||
@ -1 +1,3 @@
|
||||
#[cfg(feature = "csr")]
|
||||
#[cfg_attr(documenting, doc(cfg(feature = "csr")))]
|
||||
pub mod layout_tests;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user