How to prevent cargo test --all-features
from executing after test task
#986
-
I am using a workspace with [tasks.unit]
command = "cargo"
args = ["test", "--all", "--lib", "--", "--nocapture"]
[tasks.integration]
command = "cargo"
args = ["test", "integration"]
[tasks.test]
dependencies = ["unit", "integration"] Then I like to run I have tried setting Any idea how I can prevent this command from executing after my tests? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
@tmpfs can you please share the makefile? |
Beta Was this translation helpful? Give feedback.
-
Thanks for taking a look @sagiegurari, I am using extend= [
{ path = "coverage_grcov.makefile.toml" }
]
[config]
default_to_workspace = false
skip_core_tasks = true
[env]
RUST_BACKTRACE = 0
BUILD_TARGET = "${CARGO_MAKE_RUST_TARGET_TRIPLE}"
# Increase time for integration tests as the CLI
# tests take a while due to so many exec calls
RUST_TEST_TIME_INTEGRATION = "120000,240000"
# NOTE: we use the --release flag to prevent a stack overflow on
# windows, see: https://github.com/clap-rs/clap/issues/5134
[tasks.gen-test-key]
command = "cargo"
args = [
"run",
"--release",
"--bin",
"sos-server",
"--",
"generate-keypair",
"tests/test.pem",
"--public-key",
"tests/server_public_key.txt"
]
[tasks.fix-all]
workspace = true
command = "cargo"
args = ["fix", "--all-features", "--allow-dirty"]
[tasks.fix-clippy]
workspace = true
command = "cargo"
args = ["clippy", "--fix", "--all-features"]
[tasks.fix]
dependencies = ["fix-clippy", "fix-all", "format"]
[tasks.format]
workspace = true
command = "cargo"
args = ["fmt"]
[tasks.format-check]
command = "cargo"
args = ["fmt", "--all", "--", "--check"]
[tasks.check]
workspace = true
command = "cargo"
args = ["check"]
[tasks.clippy]
workspace = true
command = "cargo"
args = ["clippy", "--all-features"]
[tasks.clean]
workspace = true
command = "cargo"
args = ["clean"]
[tasks.build]
workspace = true
command = "cargo"
args = ["build"]
dependencies = ["clean"]
[tasks.release]
command = "cargo"
args = ["build", "--bins", "--all", "--release"]
[tasks.doc]
toolchain = "nightly"
command = "cargo"
args = [
"doc",
"--workspace",
"--open",
"--no-deps",
"--all-features"
]
[tasks.unit]
command = "cargo"
args = ["test", "--all", "--lib", "--", "--nocapture"]
[tasks.test-cli]
command = "cargo"
args = ["test", "command_line", "--", "--nocapture"]
[tasks.integration]
command = "cargo"
args = ["test", "integration"]
[tasks.test-wasm]
command = "wasm-pack"
args = ["test", "--firefox"]
[tasks.test]
dependencies = ["unit", "integration"]
[tasks.dev]
dependencies = ["check-wasm", "test", "format"]
[tasks.check-wasm-node-client]
command = "cargo"
args = [
"check",
"--target",
"wasm32-unknown-unknown",
"-p",
"sos-net",
"--no-default-features",
"--features",
"client"
]
[tasks.check-wasm]
command = "cargo"
args = ["check", "--target", "wasm32-unknown-unknown", "-p", "sos-sdk"]
dependencies = ["check-wasm-node-client"]
[tasks.gen-server-key]
command = "cargo"
args = [
"run",
"--bin",
"sos-server",
"--",
"generate-keypair",
"sandbox/server_identity.pem",
]
[tasks.dev-server]
script = '''
cargo run --bin sos-server -- start -c sandbox/config.toml
'''
[tasks.dev-certs]
script = '''
command -v mkcert && cd sandbox &&
mkcert -key-file key.pem -cert-file cert.pem localhost 127.0.0.1 ::1
'''
[tasks.genhtml]
script = '''
grcov ${COVERAGE_PROF_OUTPUT} -s . --binary-path ./target/cover/debug -t html --branch --ignore-not-existing -o ./target/coverage/ --ignore 'workspace/*/build.rs' --ignore 'tests/*' --ignore 'target/*'
#genhtml -o ./target/debug/coverage/ --show-details --highlight --ignore-errors source --legend ./target/lcov.info
'''
[tasks.coverage]
alias = "coverage_grcov"
dependencies = ["clean-profraw"]
[tasks.clean-profraw]
script = '''
rm -f *.profraw
rm -f workspace/net/*.profraw
rm -f workspace/migrate/*.profraw
rm -f workspace/sdk/*.profraw
'''
[tasks.clean-coverage]
command = "cargo"
args = ["clean", "--target-dir", "target/coverage"]
[tasks.clean-cover]
command = "cargo"
args = ["clean", "--target-dir", "target/cover"]
[tasks.cover]
dependencies = [
"clean-cover",
"clean-coverage",
"coverage",
"genhtml",
"clean-profraw"
] This is the coverage one too in case it's relevant: # coverage_grcov.makefile.toml
#
# comes from https://github.com/kazuk/cargo-make-coverage-grcov
#
# The Unlicense
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# For more information, please refer to <https://unlicense.org>
#
[env]
COVERAGE_TARGET_DIRECTORY="${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/cover"
COVERAGE_BINARIES="${COVERAGE_TARGET_DIRECTORY}/debug"
COVERAGE_PROF_OUTPUT="${COVERAGE_BINARIES}/profraw"
COVERAGE_OUTPUT_LCOV="${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/lcov.info"
[tasks.coverage_grcov_build_stable]
condition = { rust_version = { min = "1.60.0" } }
private=true
command = "cargo"
args = ["build"]
[tasks.coverage_grcov_build_stable.env]
"CARGO_BUILD_TARGET_DIR"="${COVERAGE_TARGET_DIRECTORY}"
"RUSTFLAGS"= "-Cinstrument-coverage -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off"
"RUSTDOCFLAGS"="-Cpanic=abort"
[tasks.coverage_grcov_run_test_stable]
condition = { rust_version = { min = "1.60.0" } }
private=true
command = "cargo"
args = ["test", "--all", "--", "--nocapture"]
[tasks.coverage_grcov_run_test_stable.env]
"COVERAGE" = "1"
"CARGO_BUILD_TARGET_DIR"="${COVERAGE_TARGET_DIRECTORY}"
"LLVM_PROFILE_FILE"="${COVERAGE_PROF_OUTPUT}/coverage-%p-%m.profraw"
[tasks.coverage_grcov_prepare_outdir]
private=true
workspace=true
script='''
#!/usr/bin/env bash
set -eux
rm -rf ${COVERAGE_PROF_OUTPUT}
mkdir -p ${COVERAGE_PROF_OUTPUT}
'''
[tasks.coverage_grcov_stable]
condition = { rust_version = { min = "1.60.0" } }
workspace=true
script = '''
#!/usr/bin/env bash
set -eux
grcov ${COVERAGE_PROF_OUTPUT} \
-b ${COVERAGE_BINARIES} -s . \
-t lcov --llvm --branch --ignore-not-existing --ignore "*/src/build.rs" --ignore "/*" -o ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/lcov.info
'''
dependencies=["coverage_grcov_build_stable", "coverage_grcov_prepare_outdir", "coverage_grcov_run_test_stable"]
[tasks.coverage_grcov]
dependencies=["coverage_grcov_stable"] |
Beta Was this translation helpful? Give feedback.
-
@tmpfs i'm assuming few things to show you how it works, see example repo myproject - simple lib project with makefiles similar to yours. running test would do things as expected by you gitpod /workspace/misc-test/myproject (cargomake_986) $ cargo make test
[cargo-make] INFO - cargo make 0.37.4
[cargo-make] INFO - Calling cargo metadata to extract project info
[cargo-make] INFO - Cargo metadata done
[cargo-make] INFO - Project: myproject
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: test
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Execute Command: "cargo" "test" "--all" "--lib" "--" "--nocapture"
Finished test [unoptimized + debuginfo] target(s) in 0.00s
Running unittests src/lib.rs (target/debug/deps/myproject-57cf9616a7c6e6db)
running 1 test
test tests::it_works ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
[cargo-make] INFO - Execute Command: "cargo" "test" "integration"
Finished test [unoptimized + debuginfo] target(s) in 0.00s
Running unittests src/lib.rs (target/debug/deps/myproject-57cf9616a7c6e6db)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.00s
[cargo-make] INFO - Build Done in 0.29 seconds. myworkspace is a workspace with 2 libs and makefile in the root of the workspace based on yours (shorter of course). gitpod /workspace/misc-test/myworkspace (cargomake_986) $ cargo make test
[cargo-make] INFO - cargo make 0.37.4
[cargo-make] INFO - Calling cargo metadata to extract project info
[cargo-make] INFO - Cargo metadata done
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: test
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Execute Command: "cargo" "test" "--all" "--lib" "--" "--nocapture"
Finished test [unoptimized + debuginfo] target(s) in 0.00s
Running unittests src/lib.rs (target/debug/deps/mylib1-f14491950c8e1e3d)
running 1 test
test tests::it_works ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running unittests src/lib.rs (target/debug/deps/mylib2-70efe804061e6b4f)
running 1 test
test tests::it_works ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
[cargo-make] INFO - Execute Command: "cargo" "test" "integration"
Finished test [unoptimized + debuginfo] target(s) in 0.00s
Running unittests src/lib.rs (target/debug/deps/mylib1-f14491950c8e1e3d)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.00s
Running unittests src/lib.rs (target/debug/deps/mylib2-70efe804061e6b4f)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.00s
[cargo-make] INFO - Build Done in 0.30 seconds. now the interesting part. i go to each lib and run it from there. gitpod /workspace/misc-test/myworkspace/mylib1 (cargomake_986) $ cargo make test
[cargo-make] INFO - cargo make 0.37.4
[cargo-make] INFO - Calling cargo metadata to extract project info
[cargo-make] INFO - Cargo metadata done
[cargo-make] INFO - Project: mylib1
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: test
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration
[cargo-make] INFO - Execute Command: "cargo" "test" "--all-features"
Finished test [unoptimized + debuginfo] target(s) in 0.00s
Running unittests src/lib.rs (/workspace/misc-test/myworkspace/target/debug/deps/mylib1-f14491950c8e1e3d)
running 1 test
test tests::it_works ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Doc-tests mylib1
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
[cargo-make] INFO - Build Done in 0.21 seconds. however, in lib2 i have a member with makefile that just extends the workspace one so now it works as you assumed it would: gitpod /workspace/misc-test/myworkspace/mylib2 (cargomake_986) $ cargo make test
[cargo-make] INFO - cargo make 0.37.4
[cargo-make] INFO - Calling cargo metadata to extract project info
[cargo-make] INFO - Cargo metadata done
[cargo-make] INFO - Project: mylib2
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: test
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Execute Command: "cargo" "test" "--all" "--lib" "--" "--nocapture"
Finished test [unoptimized + debuginfo] target(s) in 0.00s
Running unittests src/lib.rs (/workspace/misc-test/myworkspace/target/debug/deps/mylib1-f14491950c8e1e3d)
running 1 test
test tests::it_works ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running unittests src/lib.rs (/workspace/misc-test/myworkspace/target/debug/deps/mylib2-70efe804061e6b4f)
running 1 test
test tests::it_works ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
[cargo-make] INFO - Execute Command: "cargo" "test" "integration"
Finished test [unoptimized + debuginfo] target(s) in 0.00s
Running unittests src/lib.rs (/workspace/misc-test/myworkspace/target/debug/deps/mylib2-70efe804061e6b4f)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.00s
[cargo-make] INFO - Build Done in 0.30 seconds. |
Beta Was this translation helpful? Give feedback.
@tmpfs i'm assuming few things to show you how it works, see example repo
https://github.com/sagiegurari/misc-test/tree/cargomake_986
myproject - simple lib project with makefiles similar to yours. running test would do things as expected by you