Просмотр исходного кода

Merge pull request #29662 from overleaf/ar-allow-esm-tests-to-be-grepped

[web] Split vitest tests and spread args

GitOrigin-RevId: d0e06836fc4f4b9de50def456aef7f0ecb6cb128
Andrew Rumble 9 месяцев назад
Родитель
Сommit
ccf1fb8fcb
1 измененных файлов с 19 добавлено и 13 удалено
  1. 19 13
      services/web/bin/test_unit_run_dir

+ 19 - 13
services/web/bin/test_unit_run_dir

@@ -3,15 +3,15 @@
 declare -a vitest_args=("$@")
 declare -a vitest_args=("$@")
 
 
 has_mocha_test=0
 has_mocha_test=0
-has_vitest_test=0
+has_sequential_test=0
 
 
 for dir_path in "$@"; do
 for dir_path in "$@"; do
   if [ -n "$(find "$dir_path" -name "*.js" -type f -print -quit 2>/dev/null)" ]; then
   if [ -n "$(find "$dir_path" -name "*.js" -type f -print -quit 2>/dev/null)" ]; then
     has_mocha_test=1
     has_mocha_test=1
   fi
   fi
 
 
-  if [ -n "$(find "$dir_path" -name "*.test.mjs" -type f -print -quit 2>/dev/null)" ]; then
-    has_vitest_test=1
+  if [ -n "$(find "$dir_path" -name "*.sequential.test.mjs" -type f -print -quit 2>/dev/null)" ]; then
+    has_sequential_test=1
   fi
   fi
 done
 done
 
 
@@ -26,24 +26,26 @@ fi
 
 
 echo "Running unit tests in directory: $*"
 echo "Running unit tests in directory: $*"
 
 
-# Remove this if/else when we have converted all module tests to vitest.
-if (( has_vitest_test == 1 )); then
-  npm run test:unit:esm -- "${vitest_args[@]}"
-  vitest_status=$?
+
+npm run test:unit:esm:parallel -- "${vitest_args[@]}"
+vitest_parallel_status=$?
+if (( has_sequential_test == 0 )); then
+  echo "No sequential vitest tests found, skipping sequential vitest step."
+  vitest_sequential_status=0
 else
 else
-  echo "No vitest tests found in $*, skipping vitest step."
-  vitest_status=0
+  npm run test:unit:esm:sequential -- "${vitest_args[@]}"
+  vitest_sequential_status=$?
 fi
 fi
 
 
 if (( has_mocha_test == 1 )); then
 if (( has_mocha_test == 1 )); then
   mocha --recursive --timeout 25000 --exit --grep="$MOCHA_GREP" --require test/unit/bootstrap.js --extension=js "$@"
   mocha --recursive --timeout 25000 --exit --grep="$MOCHA_GREP" --require test/unit/bootstrap.js --extension=js "$@"
   mocha_status=$?
   mocha_status=$?
 else
 else
-  echo "No mocha tests found in $TARGET_DIR, skipping mocha step."
+  echo "No mocha tests found, skipping mocha step."
   mocha_status=0
   mocha_status=0
 fi
 fi
 
 
-if [ "$mocha_status" -eq 0 ] && [ "$vitest_status" -eq 0 ]; then
+if [ "$mocha_status" -eq 0 ] && [ "$vitest_sequential_status" -eq 0 ] && [ "$vitest_parallel_status" -eq 0 ]; then
   exit 0
   exit 0
 fi
 fi
 
 
@@ -53,8 +55,12 @@ if [ "$mocha_status" -ne 0 ]; then
   echo "Mocha tests failed with status: $mocha_status"
   echo "Mocha tests failed with status: $mocha_status"
 fi
 fi
 
 
-if [ "$vitest_status" -ne 0 ]; then
-  echo "Vitest tests failed with status: $vitest_status"
+if [ "$vitest_parallel_status" -ne 0 ]; then
+  echo "Vitest parallel tests failed with status: $vitest_parallel_status"
+fi
+
+if [ "$vitest_sequential_status" -ne 0 ]; then
+  echo "Vitest sequential tests failed with status: $vitest_sequential_status"
 fi
 fi
 
 
 exit 1
 exit 1