tests.toml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. [tasks.dart_unit_test]
  2. script = '''
  3. cargo make dart_unit_test_inner
  4. '''
  5. script_runner = "@shell"
  6. [tasks.dart_unit_test.windows]
  7. script = '''
  8. cargo make --profile test-windows dart_unit_test_inner
  9. '''
  10. script_runner = "@shell"
  11. [tasks.dart_unit_test_inner]
  12. dependencies = ["build-test-lib"]
  13. description = "Run flutter unit tests"
  14. script = '''
  15. cd app_flowy
  16. flutter test --dart-define=RUST_LOG=${TEST_RUST_LOG} --concurrency=1
  17. '''
  18. [tasks.rust_unit_test]
  19. run_task = { name = ["rust_lib_unit_test", "shared_lib_unit_test"] }
  20. [tasks.rust_lib_unit_test]
  21. description = "Run rust-lib unit tests"
  22. script = '''
  23. cd rust-lib
  24. cargo test --no-default-features --features="sync"
  25. '''
  26. [tasks.shared_lib_unit_test]
  27. description = "Run shared-lib unit test"
  28. script = '''
  29. cd ../shared-lib
  30. cargo test --no-default-features
  31. '''
  32. [tasks.check_grcov]
  33. description = "Check if `grcov` is installled"
  34. script_runner = "@shell"
  35. script = '''
  36. export PATH=$PATH:"$HOME/.cargo/bin/"
  37. if command -v grcov > /dev/null; then
  38. echo "Found 'grcov' executable."
  39. else
  40. echo "[!] Could not find 'grcov' executable."
  41. echo "[!] Please install 'grcov' by running 'cargo install grcov'."
  42. echo "[!] You may also need to install 'llvm-tools-preview' using 'rustup component add llvm-tools-preview'."
  43. echo "[!] If installed, check if 'grcov' is in PATH."
  44. echo "[!] Exiting..."
  45. exit -1
  46. fi
  47. '''
  48. [tasks.clean_profraw_files]
  49. description = "Cleans profraw files that are created by `cargo test`"
  50. script_runner = "@duckscript"
  51. script = [
  52. """
  53. rust_lib_profs = glob_array ./rust-lib/**/*.profraw
  54. for prof in ${rust_lib_profs}
  55. full_path = canonicalize ${prof}
  56. rm ${full_path}
  57. end
  58. shared_lib_profs = glob_array ../shared-lib/**/*.profraw
  59. for prof in ${shared_lib_profs}
  60. full_path = canonicalize ${prof}
  61. rm ${full_path}
  62. end
  63. """
  64. ]
  65. [tasks.run_rustlib_coverage_tests]
  66. description = "Run tests with coverage instrumentation"
  67. script_runner = "@shell"
  68. script = [
  69. """
  70. echo --- Running coverage tests ---
  71. cd rust-lib/
  72. CARGO_INCREMENTAL=0 \
  73. RUSTFLAGS='-C instrument-coverage' \
  74. LLVM_PROFILE_FILE='prof-%p-%m.profraw' \
  75. cargo test --no-default-features --features="sync"
  76. """
  77. ]
  78. [tasks.run_sharedlib_coverage_tests]
  79. description = "Run tests with coverage instrumentation"
  80. script_runner = "@shell"
  81. script = [
  82. """
  83. echo --- Running coverage tests ---
  84. cd ../shared-lib
  85. CARGO_INCREMENTAL=0 \
  86. RUSTFLAGS='-C instrument-coverage' \
  87. LLVM_PROFILE_FILE='prof-%p-%m.profraw' \
  88. cargo test --no-default-features
  89. """
  90. ]
  91. [tasks.get_rustlib_grcov_report]
  92. description = "Get `grcov` HTML report for test coverage for rust-lib"
  93. script_runner = "@shell"
  94. script = [
  95. """
  96. echo --- Getting 'grcov' results for 'rust-lib' ---
  97. cd rust-lib/
  98. grcov . \
  99. --binary-path target/debug/deps \
  100. --source-dir . \
  101. --output-type html \
  102. --branch \
  103. --ignore-not-existing \
  104. --log-level WARN \
  105. --output-path target/coverage-html
  106. echo "--- Done! Generated HTML report under 'target/coverage-html' for rustlib."
  107. """
  108. ]
  109. [tasks.get_sharedlib_grcov_report]
  110. description = "Get `grcov` HTML report for test coverage shared-lib"
  111. script_runner = "@shell"
  112. script = [
  113. """
  114. echo --- Getting 'grcov' results 'shared-lib' ---
  115. cd ../shared-lib
  116. grcov . \
  117. --binary-path target/debug/deps \
  118. --source-dir . \
  119. --output-type html \
  120. --branch \
  121. --ignore-not-existing \
  122. --log-level WARN \
  123. --output-path target/coverage-html
  124. echo "--- Done! Generated HTML report under 'target/coverage-html' for sharedlib."
  125. """
  126. ]
  127. [tasks.get_grcov_report]
  128. description = "Get `grcov` HTML report for test coverage"
  129. run_task = { name = [
  130. "get_rustlib_grcov_report",
  131. "get_sharedlib_grcov_report"
  132. ], parallel = true }
  133. [tasks.get_sharedlib_lcov_report]
  134. description = "Generates `lcov` report for `shared-lib`"
  135. script_runner = "@shell"
  136. script = [
  137. """
  138. echo Getting 'lcov' results for 'shared-lib'
  139. cd ../shared-lib
  140. grcov . \
  141. --binary-path target/debug/deps \
  142. --source-dir . \
  143. --output-type lcov \
  144. --branch \
  145. --ignore-not-existing \
  146. --log-level WARN \
  147. --output-path target/coverage.lcov
  148. echo "--- Done! Generated 'target/coverage.lcov' sharedlib."
  149. """
  150. ]
  151. [tasks.get_rustlib_lcov_report]
  152. description = "Generates `lcov` report for `rust-lib`"
  153. script_runner = "@shell"
  154. script = [
  155. """
  156. echo Getting 'lcov' results for 'rust-lib'
  157. cd rust-lib/
  158. grcov . \
  159. --binary-path target/debug/deps \
  160. --source-dir . \
  161. --output-type lcov \
  162. --branch \
  163. --ignore-not-existing \
  164. --log-level WARN \
  165. --output-path target/coverage.lcov
  166. echo "--- Done! Generated 'target/coverage.lcov' for rustlib."
  167. """
  168. ]
  169. [tasks.get_lcov_report]
  170. description = "Get `lcov` reports for test coverage"
  171. run_task = { name = [
  172. "get_sharedlib_lcov_report",
  173. "get_rustlib_lcov_report"
  174. ], parallel = true }
  175. [tasks.rust_unit_test_with_coverage]
  176. description = "Run rust unit test with code coverage"
  177. run_task = { name = [
  178. "check_grcov",
  179. 'appflowy-deps-tools',
  180. "run_rustlib_coverage_tests",
  181. "run_sharedlib_coverage_tests",
  182. "get_lcov_report",
  183. "clean_profraw_files"
  184. ]}