2021-09-04 01:00:15 +00:00
|
|
|
|
2023-01-02 04:31:31 +00:00
|
|
|
[tasks.dart_unit_test]
|
2023-01-01 15:26:27 +00:00
|
|
|
script = '''
|
2023-01-05 07:25:30 +00:00
|
|
|
cargo make --profile test-macos dart_unit_test_inner
|
2023-01-01 15:26:27 +00:00
|
|
|
'''
|
2023-01-02 04:31:31 +00:00
|
|
|
script_runner = "@shell"
|
2023-01-01 15:26:27 +00:00
|
|
|
|
|
|
|
[tasks.dart_unit_test.windows]
|
|
|
|
script = '''
|
|
|
|
cargo make --profile test-windows dart_unit_test_inner
|
|
|
|
'''
|
2023-01-02 04:31:31 +00:00
|
|
|
script_runner = "@shell"
|
2023-01-01 15:26:27 +00:00
|
|
|
|
2023-01-05 07:25:30 +00:00
|
|
|
[tasks.dart_unit_test.linux]
|
|
|
|
script = '''
|
|
|
|
cargo make --profile test-linux dart_unit_test_inner
|
|
|
|
'''
|
|
|
|
script_runner = "@shell"
|
|
|
|
|
2023-01-01 15:26:27 +00:00
|
|
|
[tasks.dart_unit_test_inner]
|
2022-10-26 14:36:34 +00:00
|
|
|
dependencies = ["build-test-lib"]
|
|
|
|
description = "Run flutter unit tests"
|
|
|
|
script = '''
|
|
|
|
cd app_flowy
|
2022-11-17 08:44:17 +00:00
|
|
|
flutter test --dart-define=RUST_LOG=${TEST_RUST_LOG} --concurrency=1
|
2022-10-26 14:36:34 +00:00
|
|
|
'''
|
|
|
|
|
2022-05-27 12:26:33 +00:00
|
|
|
[tasks.rust_unit_test]
|
|
|
|
run_task = { name = ["rust_lib_unit_test", "shared_lib_unit_test"] }
|
|
|
|
|
|
|
|
[tasks.rust_lib_unit_test]
|
|
|
|
description = "Run rust-lib unit tests"
|
2021-09-04 01:00:15 +00:00
|
|
|
script = '''
|
|
|
|
cd rust-lib
|
2023-01-12 05:09:08 +00:00
|
|
|
cargo test --no-default-features --features="sync, rev-sqlite"
|
2021-09-04 01:00:15 +00:00
|
|
|
'''
|
|
|
|
|
2022-05-27 12:26:33 +00:00
|
|
|
[tasks.shared_lib_unit_test]
|
|
|
|
description = "Run shared-lib unit test"
|
|
|
|
script = '''
|
|
|
|
cd ../shared-lib
|
2023-01-02 04:31:31 +00:00
|
|
|
cargo test --no-default-features
|
2022-05-27 12:26:33 +00:00
|
|
|
'''
|
2021-09-04 01:00:15 +00:00
|
|
|
|
2022-10-11 11:54:31 +00:00
|
|
|
[tasks.check_grcov]
|
|
|
|
description = "Check if `grcov` is installled"
|
|
|
|
script_runner = "@shell"
|
|
|
|
script = '''
|
|
|
|
export PATH=$PATH:"$HOME/.cargo/bin/"
|
|
|
|
if command -v grcov > /dev/null; then
|
|
|
|
echo "Found 'grcov' executable."
|
|
|
|
else
|
|
|
|
echo "[!] Could not find 'grcov' executable."
|
|
|
|
echo "[!] Please install 'grcov' by running 'cargo install grcov'."
|
|
|
|
echo "[!] You may also need to install 'llvm-tools-preview' using 'rustup component add llvm-tools-preview'."
|
|
|
|
echo "[!] If installed, check if 'grcov' is in PATH."
|
|
|
|
echo "[!] Exiting..."
|
|
|
|
exit -1
|
|
|
|
fi
|
|
|
|
'''
|
|
|
|
|
|
|
|
[tasks.clean_profraw_files]
|
|
|
|
description = "Cleans profraw files that are created by `cargo test`"
|
|
|
|
script_runner = "@duckscript"
|
|
|
|
script = [
|
|
|
|
"""
|
|
|
|
rust_lib_profs = glob_array ./rust-lib/**/*.profraw
|
|
|
|
for prof in ${rust_lib_profs}
|
|
|
|
full_path = canonicalize ${prof}
|
|
|
|
rm ${full_path}
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_lib_profs = glob_array ../shared-lib/**/*.profraw
|
|
|
|
for prof in ${shared_lib_profs}
|
|
|
|
full_path = canonicalize ${prof}
|
|
|
|
rm ${full_path}
|
|
|
|
end
|
|
|
|
|
|
|
|
"""
|
|
|
|
]
|
|
|
|
|
|
|
|
[tasks.run_rustlib_coverage_tests]
|
|
|
|
description = "Run tests with coverage instrumentation"
|
|
|
|
script_runner = "@shell"
|
|
|
|
script = [
|
|
|
|
"""
|
|
|
|
echo --- Running coverage tests ---
|
|
|
|
cd rust-lib/
|
|
|
|
|
|
|
|
CARGO_INCREMENTAL=0 \
|
|
|
|
RUSTFLAGS='-C instrument-coverage' \
|
|
|
|
LLVM_PROFILE_FILE='prof-%p-%m.profraw' \
|
2023-01-26 07:40:23 +00:00
|
|
|
cargo test --no-default-features --features="sync,rev-sqlite"
|
2022-10-11 11:54:31 +00:00
|
|
|
"""
|
|
|
|
]
|
|
|
|
|
|
|
|
[tasks.run_sharedlib_coverage_tests]
|
|
|
|
description = "Run tests with coverage instrumentation"
|
|
|
|
script_runner = "@shell"
|
|
|
|
script = [
|
|
|
|
"""
|
|
|
|
echo --- Running coverage tests ---
|
|
|
|
cd ../shared-lib
|
|
|
|
|
|
|
|
CARGO_INCREMENTAL=0 \
|
|
|
|
RUSTFLAGS='-C instrument-coverage' \
|
|
|
|
LLVM_PROFILE_FILE='prof-%p-%m.profraw' \
|
2022-12-19 02:47:40 +00:00
|
|
|
cargo test --no-default-features
|
2022-10-11 11:54:31 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
]
|
|
|
|
|
|
|
|
[tasks.get_rustlib_grcov_report]
|
|
|
|
description = "Get `grcov` HTML report for test coverage for rust-lib"
|
|
|
|
script_runner = "@shell"
|
|
|
|
script = [
|
|
|
|
"""
|
2022-12-19 02:47:40 +00:00
|
|
|
echo --- Getting 'grcov' results for 'rust-lib' ---
|
2022-10-11 11:54:31 +00:00
|
|
|
cd rust-lib/
|
|
|
|
|
|
|
|
grcov . \
|
|
|
|
--binary-path target/debug/deps \
|
|
|
|
--source-dir . \
|
|
|
|
--output-type html \
|
|
|
|
--branch \
|
|
|
|
--ignore-not-existing \
|
|
|
|
--log-level WARN \
|
|
|
|
--output-path target/coverage-html
|
|
|
|
|
|
|
|
echo "--- Done! Generated HTML report under 'target/coverage-html' for rustlib."
|
|
|
|
"""
|
|
|
|
]
|
|
|
|
|
|
|
|
[tasks.get_sharedlib_grcov_report]
|
|
|
|
description = "Get `grcov` HTML report for test coverage shared-lib"
|
|
|
|
script_runner = "@shell"
|
|
|
|
script = [
|
|
|
|
"""
|
2022-12-19 02:47:40 +00:00
|
|
|
echo --- Getting 'grcov' results 'shared-lib' ---
|
2022-10-11 11:54:31 +00:00
|
|
|
cd ../shared-lib
|
|
|
|
|
|
|
|
grcov . \
|
|
|
|
--binary-path target/debug/deps \
|
|
|
|
--source-dir . \
|
|
|
|
--output-type html \
|
|
|
|
--branch \
|
|
|
|
--ignore-not-existing \
|
|
|
|
--log-level WARN \
|
|
|
|
--output-path target/coverage-html
|
|
|
|
|
|
|
|
echo "--- Done! Generated HTML report under 'target/coverage-html' for sharedlib."
|
|
|
|
"""
|
|
|
|
]
|
|
|
|
|
|
|
|
[tasks.get_grcov_report]
|
|
|
|
description = "Get `grcov` HTML report for test coverage"
|
|
|
|
run_task = { name = [
|
|
|
|
"get_rustlib_grcov_report",
|
|
|
|
"get_sharedlib_grcov_report"
|
|
|
|
], parallel = true }
|
|
|
|
|
|
|
|
[tasks.get_sharedlib_lcov_report]
|
|
|
|
description = "Generates `lcov` report for `shared-lib`"
|
|
|
|
script_runner = "@shell"
|
|
|
|
script = [
|
|
|
|
"""
|
|
|
|
echo Getting 'lcov' results for 'shared-lib'
|
|
|
|
|
|
|
|
cd ../shared-lib
|
|
|
|
|
|
|
|
grcov . \
|
|
|
|
--binary-path target/debug/deps \
|
|
|
|
--source-dir . \
|
|
|
|
--output-type lcov \
|
|
|
|
--branch \
|
|
|
|
--ignore-not-existing \
|
|
|
|
--log-level WARN \
|
|
|
|
--output-path target/coverage.lcov
|
|
|
|
|
|
|
|
echo "--- Done! Generated 'target/coverage.lcov' sharedlib."
|
|
|
|
"""
|
|
|
|
]
|
|
|
|
|
|
|
|
[tasks.get_rustlib_lcov_report]
|
|
|
|
description = "Generates `lcov` report for `rust-lib`"
|
|
|
|
script_runner = "@shell"
|
|
|
|
script = [
|
|
|
|
"""
|
|
|
|
echo Getting 'lcov' results for 'rust-lib'
|
|
|
|
|
|
|
|
cd rust-lib/
|
|
|
|
|
|
|
|
grcov . \
|
|
|
|
--binary-path target/debug/deps \
|
|
|
|
--source-dir . \
|
|
|
|
--output-type lcov \
|
|
|
|
--branch \
|
|
|
|
--ignore-not-existing \
|
|
|
|
--log-level WARN \
|
|
|
|
--output-path target/coverage.lcov
|
|
|
|
|
|
|
|
echo "--- Done! Generated 'target/coverage.lcov' for rustlib."
|
|
|
|
"""
|
|
|
|
]
|
|
|
|
|
|
|
|
[tasks.get_lcov_report]
|
|
|
|
description = "Get `lcov` reports for test coverage"
|
|
|
|
run_task = { name = [
|
|
|
|
"get_sharedlib_lcov_report",
|
|
|
|
"get_rustlib_lcov_report"
|
|
|
|
], parallel = true }
|
|
|
|
|
2022-12-19 02:47:40 +00:00
|
|
|
[tasks.rust_unit_test_with_coverage]
|
|
|
|
description = "Run rust unit test with code coverage"
|
2022-10-11 11:54:31 +00:00
|
|
|
run_task = { name = [
|
|
|
|
"check_grcov",
|
2023-01-17 08:27:17 +00:00
|
|
|
'appflowy-flutter-deps-tools',
|
2022-10-11 11:54:31 +00:00
|
|
|
"run_rustlib_coverage_tests",
|
|
|
|
"run_sharedlib_coverage_tests",
|
|
|
|
"get_lcov_report",
|
|
|
|
"clean_profraw_files"
|
|
|
|
]}
|