2021-09-04 01:00:15 +00:00
|
|
|
|
2023-05-02 09:10:35 +00:00
|
|
|
# If you want to test a single file with single case, you can try this command:
|
2023-12-25 18:03:42 +00:00
|
|
|
# RUST_LOG="debug" flutter test -d macOS -j, 'path to the file' --name 'test case name'
|
2023-04-04 00:41:16 +00:00
|
|
|
[tasks.flutter_test]
|
|
|
|
description = "Run flutter test with single case in single file. Input: cargo make flutter_test 'path to the file' --name 'test case name'"
|
|
|
|
script = '''
|
|
|
|
cd appflowy_flutter
|
2023-12-25 18:03:42 +00:00
|
|
|
flutter test -j, --concurrency=1 "${@}"
|
2023-04-04 00:41:16 +00:00
|
|
|
'''
|
|
|
|
script_runner = "@shell"
|
|
|
|
|
2023-01-02 04:31:31 +00:00
|
|
|
[tasks.dart_unit_test]
|
2023-01-01 15:26:27 +00:00
|
|
|
script = '''
|
2023-04-17 01:19:55 +00:00
|
|
|
cargo make --profile test-macos-$(uname -m) run_dart_unit_test
|
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 = '''
|
2023-03-04 00:59:40 +00:00
|
|
|
cargo make --profile test-windows run_dart_unit_test
|
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
|
|
|
|
2023-01-05 07:25:30 +00:00
|
|
|
[tasks.dart_unit_test.linux]
|
|
|
|
script = '''
|
2023-03-04 00:59:40 +00:00
|
|
|
cargo make --profile test-linux run_dart_unit_test
|
2023-01-05 07:25:30 +00:00
|
|
|
'''
|
|
|
|
script_runner = "@shell"
|
|
|
|
|
2023-03-04 00:59:40 +00:00
|
|
|
[tasks.run_dart_unit_test]
|
2023-02-27 11:00:00 +00:00
|
|
|
env = { RUST_LOG = "info" }
|
2023-05-02 09:10:35 +00:00
|
|
|
dependencies = ["inner_build_test_backend"]
|
2022-10-26 14:36:34 +00:00
|
|
|
description = "Run flutter unit tests"
|
|
|
|
script = '''
|
2023-02-26 08:27:17 +00:00
|
|
|
cd appflowy_flutter
|
2023-11-28 02:54:31 +00:00
|
|
|
flutter test -j, --concurrency=1 --coverage
|
2022-10-26 14:36:34 +00:00
|
|
|
'''
|
|
|
|
|
2023-10-23 14:17:11 +00:00
|
|
|
[tasks.dart_unit_test_no_build]
|
|
|
|
script = '''
|
|
|
|
cargo make --profile test-macos-$(uname -m) run_dart_unit_test_no_build
|
|
|
|
'''
|
|
|
|
|
|
|
|
[tasks.dart_unit_test_no_build.windows]
|
|
|
|
script = '''
|
|
|
|
cargo make --profile test-windows run_dart_unit_test_no_build
|
|
|
|
'''
|
|
|
|
|
|
|
|
[tasks.dart_unit_test_no_build.linux]
|
|
|
|
script = '''
|
|
|
|
cargo make --profile test-linux run_dart_unit_test_no_build
|
|
|
|
'''
|
|
|
|
|
|
|
|
[tasks.run_dart_unit_test_no_build]
|
|
|
|
env = { RUST_LOG = "info" }
|
|
|
|
dependencies = ["copy-from-build-to-sandbox-folder"]
|
|
|
|
description = "Run flutter unit tests"
|
|
|
|
script = '''
|
|
|
|
cd appflowy_flutter
|
2023-11-28 02:54:31 +00:00
|
|
|
flutter test -j, --concurrency=1 --coverage
|
2023-10-23 14:17:11 +00:00
|
|
|
'''
|
|
|
|
script_runner = "@shell"
|
|
|
|
|
2022-05-27 12:26:33 +00:00
|
|
|
[tasks.rust_unit_test]
|
2023-10-24 12:11:06 +00:00
|
|
|
run_task = { name = ["rust_lib_unit_test"] }
|
2022-05-27 12:26:33 +00:00
|
|
|
|
2023-07-29 01:46:24 +00:00
|
|
|
[tasks.supabase_unit_test]
|
|
|
|
env = { RUST_LOG = "info" }
|
2023-07-05 12:57:09 +00:00
|
|
|
description = "Run cloud unit tests"
|
|
|
|
script = '''
|
2023-10-11 12:02:09 +00:00
|
|
|
cd rust-lib/event-integration
|
2023-07-29 01:46:24 +00:00
|
|
|
RUST_BACKTRACE=1 cargo test supabase_ --features "cloud_test"
|
2023-07-05 12:57:09 +00:00
|
|
|
'''
|
|
|
|
|
2022-05-27 12:26:33 +00:00
|
|
|
[tasks.rust_lib_unit_test]
|
2023-02-02 15:02:49 +00:00
|
|
|
env = { RUST_LOG = "info" }
|
2022-05-27 12:26:33 +00:00
|
|
|
description = "Run rust-lib unit tests"
|
2021-09-04 01:00:15 +00:00
|
|
|
script = '''
|
|
|
|
cd rust-lib
|
2024-03-30 08:28:24 +00:00
|
|
|
RUST_LOG=info DISABLE_CI_TEST_LOG="true" RUST_BACKTRACE=1 cargo test --no-default-features --features "rev-sqlite"
|
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"
|
2023-02-02 15:02:49 +00:00
|
|
|
script = ["""
|
2022-10-11 11:54:31 +00:00
|
|
|
rust_lib_profs = glob_array ./rust-lib/**/*.profraw
|
|
|
|
for prof in ${rust_lib_profs}
|
|
|
|
full_path = canonicalize ${prof}
|
|
|
|
rm ${full_path}
|
|
|
|
end
|
|
|
|
|
2023-12-30 23:29:40 +00:00
|
|
|
shared_lib_profs = glob_array ./rust-lib/build-tool/**/*.profraw
|
2022-10-11 11:54:31 +00:00
|
|
|
for prof in ${shared_lib_profs}
|
|
|
|
full_path = canonicalize ${prof}
|
|
|
|
rm ${full_path}
|
|
|
|
end
|
|
|
|
|
2023-02-02 15:02:49 +00:00
|
|
|
"""]
|
2022-10-11 11:54:31 +00:00
|
|
|
|
|
|
|
[tasks.run_rustlib_coverage_tests]
|
|
|
|
description = "Run tests with coverage instrumentation"
|
|
|
|
script_runner = "@shell"
|
2023-02-02 15:02:49 +00:00
|
|
|
script = ["""
|
2022-10-11 11:54:31 +00:00
|
|
|
echo --- Running coverage tests ---
|
|
|
|
cd rust-lib/
|
|
|
|
|
|
|
|
CARGO_INCREMENTAL=0 \
|
|
|
|
RUSTFLAGS='-C instrument-coverage' \
|
|
|
|
LLVM_PROFILE_FILE='prof-%p-%m.profraw' \
|
2023-05-17 01:49:39 +00:00
|
|
|
cargo test --no-default-features --features="rev-sqlite"
|
2023-02-02 15:02:49 +00:00
|
|
|
"""]
|
2022-10-11 11:54:31 +00:00
|
|
|
|
|
|
|
[tasks.run_sharedlib_coverage_tests]
|
|
|
|
description = "Run tests with coverage instrumentation"
|
|
|
|
script_runner = "@shell"
|
2023-02-02 15:02:49 +00:00
|
|
|
script = ["""
|
2022-10-11 11:54:31 +00:00
|
|
|
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
|
|
|
|
2023-02-02 15:02:49 +00:00
|
|
|
"""]
|
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."
|
2023-02-02 15:02:49 +00:00
|
|
|
""",
|
2022-10-11 11:54:31 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
[tasks.get_grcov_report]
|
|
|
|
description = "Get `grcov` HTML report for test coverage"
|
|
|
|
run_task = { name = [
|
|
|
|
"get_rustlib_grcov_report",
|
|
|
|
], parallel = true }
|
|
|
|
|
|
|
|
[tasks.get_rustlib_lcov_report]
|
|
|
|
description = "Generates `lcov` report for `rust-lib`"
|
|
|
|
script_runner = "@shell"
|
2023-02-02 15:02:49 +00:00
|
|
|
script = ["""
|
2022-10-11 11:54:31 +00:00
|
|
|
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."
|
2023-02-02 15:02:49 +00:00
|
|
|
"""]
|
2022-10-11 11:54:31 +00:00
|
|
|
|
|
|
|
[tasks.get_lcov_report]
|
|
|
|
description = "Get `lcov` reports for test coverage"
|
|
|
|
run_task = { name = [
|
2023-02-02 15:02:49 +00:00
|
|
|
"get_rustlib_lcov_report",
|
2022-10-11 11:54:31 +00:00
|
|
|
], 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 = [
|
2023-02-02 15:02:49 +00:00
|
|
|
"check_grcov",
|
|
|
|
'appflowy-flutter-deps-tools',
|
|
|
|
"run_rustlib_coverage_tests",
|
|
|
|
"run_sharedlib_coverage_tests",
|
|
|
|
"get_lcov_report",
|
|
|
|
"clean_profraw_files",
|
|
|
|
] }
|
2023-05-02 09:10:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
[tasks.build_test_backend]
|
2023-11-28 02:54:31 +00:00
|
|
|
env = { RUST_LOG = "trace" }
|
2023-05-02 09:10:35 +00:00
|
|
|
script = '''
|
|
|
|
cargo make --profile test-macos-$(uname -m) inner_build_test_backend
|
|
|
|
'''
|
|
|
|
script_runner = "@shell"
|
|
|
|
|
|
|
|
[tasks.build_test_backend.windows]
|
|
|
|
script = '''
|
|
|
|
cargo make --profile test-windows inner_build_test_backend
|
|
|
|
'''
|
|
|
|
script_runner = "@shell"
|
|
|
|
|
|
|
|
[tasks.build_test_backend.linux]
|
|
|
|
script = '''
|
|
|
|
cargo make --profile test-linux inner_build_test_backend
|
|
|
|
'''
|
|
|
|
script_runner = "@shell"
|
|
|
|
|
|
|
|
[tasks.inner_build_test_backend]
|
|
|
|
category = "Build"
|
|
|
|
dependencies = ["env_check"]
|
|
|
|
run_task = { name = [
|
|
|
|
"setup-test-crate-type",
|
|
|
|
"compile_test_backend",
|
|
|
|
"copy-to-sandbox-folder",
|
|
|
|
"restore-test-crate-type",
|
|
|
|
] }
|
|
|
|
|
|
|
|
[tasks.compile_test_backend]
|
|
|
|
mac_alias = "compile_test_backend_default"
|
|
|
|
windows_alias = "compile_test_backend_windows"
|
|
|
|
linux_alias = "compile_test_backend_default"
|
|
|
|
|
|
|
|
[tasks.compile_test_backend_default]
|
2023-11-28 02:54:31 +00:00
|
|
|
env = { RUST_LOG = "trace" }
|
2023-05-02 09:10:35 +00:00
|
|
|
private = true
|
|
|
|
script = [
|
|
|
|
"""
|
|
|
|
cd rust-lib/
|
|
|
|
rustup show
|
|
|
|
echo RUST_LOG=${RUST_LOG} cargo build --package=dart-ffi --target ${TEST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}"
|
|
|
|
RUST_LOG=${RUST_LOG} cargo build --package=dart-ffi --target ${TEST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}"
|
|
|
|
cd ../
|
|
|
|
""",
|
|
|
|
]
|
|
|
|
script_runner = "@shell"
|
|
|
|
|
|
|
|
[tasks.compile_test_backend_windows]
|
|
|
|
private = true
|
|
|
|
script = [
|
|
|
|
"""
|
|
|
|
cd rust-lib/
|
|
|
|
rustup show
|
|
|
|
echo cargo build --package=dart-ffi --target ${TEST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}"
|
|
|
|
RUST_LOG=${RUST_LOG} cargo build --package=dart-ffi --target ${TEST_COMPILE_TARGET} --features "${FLUTTER_DESKTOP_FEATURES}"
|
|
|
|
cd ../
|
|
|
|
""",
|
|
|
|
]
|
|
|
|
script_runner = "@shell"
|
|
|
|
|
|
|
|
[tasks.copy-to-sandbox-folder]
|
|
|
|
mac_alias = "copy-to-sandbox-folder-default"
|
|
|
|
windows_alias = "copy-to-sandbox-folder-windows"
|
|
|
|
linux_alias = "copy-to-sandbox-folder-default"
|
|
|
|
|
|
|
|
[tasks.copy-to-sandbox-folder-windows]
|
|
|
|
private = true
|
|
|
|
script = [
|
|
|
|
"""
|
|
|
|
# Copy the appflowy_backend lib to system temp directory for flutter unit test.
|
|
|
|
lib = set ${LIB_NAME}.${TEST_LIB_EXT}
|
|
|
|
dest = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/appflowy_flutter/.sandbox/${lib}
|
|
|
|
rm ${dest}
|
|
|
|
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${TEST_COMPILE_TARGET}/${TEST_BUILD_FLAG}/${lib} \
|
|
|
|
${dest}
|
|
|
|
""",
|
|
|
|
]
|
|
|
|
script_runner = "@duckscript"
|
|
|
|
|
|
|
|
[tasks.copy-to-sandbox-folder-default]
|
|
|
|
private = true
|
|
|
|
script = [
|
|
|
|
"""
|
|
|
|
# Copy the appflowy_backend lib to system temp directory for flutter unit test.
|
|
|
|
lib = set lib${LIB_NAME}.${TEST_LIB_EXT}
|
|
|
|
dest = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/appflowy_flutter/.sandbox/${lib}
|
|
|
|
rm ${dest}
|
|
|
|
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${TEST_COMPILE_TARGET}/${TEST_BUILD_FLAG}/${lib} \
|
|
|
|
${dest}
|
|
|
|
""",
|
|
|
|
]
|
2023-10-23 14:17:11 +00:00
|
|
|
script_runner = "@duckscript"
|
|
|
|
|
|
|
|
[tasks.copy-from-build-to-sandbox-folder]
|
|
|
|
mac_alias = "copy-from-build-to-sandbox-folder-macos"
|
|
|
|
windows_alias = "copy-from-build-to-sandbox-folder-windows"
|
|
|
|
linux_alias = "copy-from-build-to-sandbox-folder-linux"
|
|
|
|
|
|
|
|
[tasks.copy-from-build-to-sandbox-folder-windows]
|
|
|
|
private = true
|
|
|
|
script = [
|
|
|
|
"""
|
|
|
|
# Copy the appflowy_backend lib to system temp directory for flutter unit test.
|
|
|
|
lib = set ${LIB_NAME}.${TEST_LIB_EXT}
|
|
|
|
dest = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/appflowy_flutter/.sandbox/${lib}
|
|
|
|
dart_ffi_dir= set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/appflowy_flutter/windows/flutter/dart_ffi
|
|
|
|
rm ${dest}
|
|
|
|
|
|
|
|
cp ${dart_ffi_dir}/${lib} ${dest}
|
|
|
|
""",
|
|
|
|
]
|
|
|
|
script_runner = "@duckscript"
|
|
|
|
|
|
|
|
[tasks.copy-from-build-to-sandbox-folder-macos]
|
|
|
|
private = true
|
|
|
|
script = [
|
|
|
|
"""
|
|
|
|
echo "This is not possible for mac because the tests wont work with .a lib"
|
|
|
|
exit 127
|
|
|
|
""",
|
|
|
|
]
|
|
|
|
script_runner = "@duckscript"
|
|
|
|
|
|
|
|
[tasks.copy-from-build-to-sandbox-folder-linux]
|
|
|
|
private = true
|
|
|
|
script = [
|
|
|
|
"""
|
|
|
|
# Copy the appflowy_backend lib to system temp directory for flutter unit test.
|
|
|
|
lib = set lib${LIB_NAME}.${TEST_LIB_EXT}
|
|
|
|
dest = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/appflowy_flutter/.sandbox/${lib}
|
|
|
|
dart_ffi_dir= set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/appflowy_flutter/linux/flutter/dart_ffi
|
|
|
|
rm ${dest}
|
|
|
|
|
|
|
|
cp ${dart_ffi_dir}/${lib} ${dest}
|
|
|
|
""",
|
|
|
|
]
|
|
|
|
script_runner = "@duckscript"
|