AppFlowy/frontend/scripts/makefile/tests.toml

348 lines
9.5 KiB
TOML
Raw Normal View History

# If you want to test a single file with single case, you can try this command:
# RUST_LOG="debug" flutter test -d macOS -j, 'path to the file' --name 'test case name'
[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
flutter test -j, --concurrency=1 "${@}"
'''
script_runner = "@shell"
[tasks.dart_unit_test]
script = '''
cargo make --profile test-macos-$(uname -m) run_dart_unit_test
'''
script_runner = "@shell"
[tasks.dart_unit_test.windows]
script = '''
2023-03-04 00:59:40 +00:00
cargo make --profile test-windows run_dart_unit_test
'''
script_runner = "@shell"
[tasks.dart_unit_test.linux]
script = '''
2023-03-04 00:59:40 +00:00
cargo make --profile test-linux run_dart_unit_test
'''
script_runner = "@shell"
2023-03-04 00:59:40 +00:00
[tasks.run_dart_unit_test]
env = { RUST_LOG = "info" }
dependencies = ["inner_build_test_backend"]
2022-10-26 14:36:34 +00:00
description = "Run flutter unit tests"
script = '''
cd appflowy_flutter
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
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]
run_task = { name = ["rust_lib_unit_test"] }
2022-05-27 12:26:33 +00:00
feat: migrate user data to cloud (#3078) * refactor: weak passed-in params in handler * refactor: rename struct * chore: update tables * chore: update schema * chore: add permission * chore: update tables * chore: support transaction mode * chore: workspace database id * chore: add user workspace * feat: return list of workspaces * chore: add user to workspace * feat: separate database row table * refactor: update schema * chore: partition table * chore: use transaction * refactor: dir * refactor: collab db ref * fix: collab db lock * chore: rename files * chore: add tables descriptions * chore: update readme * docs: update documentation * chore: rename crate * chore: update ref * chore: update tests * chore: update tests * refactor: crate deps * chore: update crate ref * chore: remove unused deps * chore: remove unused deps * chore: update collab crate refs * chore: replace client with transaction in pooler * refactor: return error type * refactor: use anyhow error in deps * feat: supabase postgrest user signin (wip) * fix: Cargo.toml source git deps, changed Error to anyhow::Error * fix: uuid serialization * chore: fix conflict * chore: extend the response * feat: add implementation place holders * feat: impl get_user_workspaces * feat: impl get_user_profile * test: create workspace * fix: postgrest: field names and alias * chore: implement folder restful api * chore: implement collab storate with restful api * feat: added placeholders for impl: update_user_profile, check_user * feat: impl: update_user_profile * feat: impl: check_user * fix: use UidResponse, add more debug info for serde serialization error * fix: get_user_profile: use Optional<UserProfileResponse> * chore: imple init sync * chore: support soft delete * feat: postgresql: add migration test * feat: postgresql migration test: added UID display and colored output * feat: postgresql migration test: workspace role * feat: postgresql migration test: create shared common utils * feat: postgresql migration test: fixed shebang * chore: add flush_collab_update pg function * chore: implement datbaase and document restful api * chore: migrate to use restful api * chore: update table schema * chore: fix tests * chore: remove unused code * chore: format code * chore: remove unused env * fix: tauri build * fix: tauri build --------- Co-authored-by: Fu Zi Xiang <speed2exe@live.com.sg>
2023-07-29 01:46:24 +00:00
[tasks.supabase_unit_test]
env = { RUST_LOG = "info" }
description = "Run cloud unit tests"
script = '''
cd rust-lib/event-integration
feat: migrate user data to cloud (#3078) * refactor: weak passed-in params in handler * refactor: rename struct * chore: update tables * chore: update schema * chore: add permission * chore: update tables * chore: support transaction mode * chore: workspace database id * chore: add user workspace * feat: return list of workspaces * chore: add user to workspace * feat: separate database row table * refactor: update schema * chore: partition table * chore: use transaction * refactor: dir * refactor: collab db ref * fix: collab db lock * chore: rename files * chore: add tables descriptions * chore: update readme * docs: update documentation * chore: rename crate * chore: update ref * chore: update tests * chore: update tests * refactor: crate deps * chore: update crate ref * chore: remove unused deps * chore: remove unused deps * chore: update collab crate refs * chore: replace client with transaction in pooler * refactor: return error type * refactor: use anyhow error in deps * feat: supabase postgrest user signin (wip) * fix: Cargo.toml source git deps, changed Error to anyhow::Error * fix: uuid serialization * chore: fix conflict * chore: extend the response * feat: add implementation place holders * feat: impl get_user_workspaces * feat: impl get_user_profile * test: create workspace * fix: postgrest: field names and alias * chore: implement folder restful api * chore: implement collab storate with restful api * feat: added placeholders for impl: update_user_profile, check_user * feat: impl: update_user_profile * feat: impl: check_user * fix: use UidResponse, add more debug info for serde serialization error * fix: get_user_profile: use Optional<UserProfileResponse> * chore: imple init sync * chore: support soft delete * feat: postgresql: add migration test * feat: postgresql migration test: added UID display and colored output * feat: postgresql migration test: workspace role * feat: postgresql migration test: create shared common utils * feat: postgresql migration test: fixed shebang * chore: add flush_collab_update pg function * chore: implement datbaase and document restful api * chore: migrate to use restful api * chore: update table schema * chore: fix tests * chore: remove unused code * chore: format code * chore: remove unused env * fix: tauri build * fix: tauri build --------- Co-authored-by: Fu Zi Xiang <speed2exe@live.com.sg>
2023-07-29 01:46:24 +00:00
RUST_BACKTRACE=1 cargo test supabase_ --features "cloud_test"
'''
2022-05-27 12:26:33 +00:00
[tasks.rust_lib_unit_test]
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
RUST_LOG=info DISABLE_CI_TEST_LOG="true" RUST_BACKTRACE=1 cargo test --no-default-features
2021-09-04 01:00:15 +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 ./rust-lib/build-tool/**/*.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' \
cargo test --no-default-features
"""]
[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' \
cargo test --no-default-features
"""]
[tasks.get_rustlib_grcov_report]
description = "Get `grcov` HTML report for test coverage for rust-lib"
script_runner = "@shell"
script = [
"""
echo --- Getting 'grcov' results for 'rust-lib' ---
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_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"
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_rustlib_lcov_report",
], parallel = true }
[tasks.rust_unit_test_with_coverage]
description = "Run rust unit test with code coverage"
run_task = { name = [
"check_grcov",
'appflowy-flutter-deps-tools',
"run_rustlib_coverage_tests",
"run_sharedlib_coverage_tests",
"get_lcov_report",
"clean_profraw_files",
] }
[tasks.build_test_backend]
env = { RUST_LOG = "trace" }
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]
env = { RUST_LOG = "trace" }
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}
""",
2023-10-23 14:17:11 +00:00
]
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
""",
2023-10-23 14:17:11 +00:00
]
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}
""",
2023-10-23 14:17:11 +00:00
]
script_runner = "@duckscript"