Rewrite translations tests scripts to python

This commit is contained in:
Alexey Safronov 2023-11-17 13:30:58 +04:00
parent 403fb2f4f3
commit cc2ae0f319
4 changed files with 62 additions and 25 deletions

View File

@ -1,17 +0,0 @@
rd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo "Run script directory:" $dir
dir=$(builtin cd $rd/../; pwd)
save=false
while getopts s: flag
do
case "${flag}" in
s) save=${OPTARG};;
esac
done
echo "Root directory:" $dir
dotnet test $dir/client/common/Tests/Frontend.Translations.Tests/Frontend.Translations.Tests.csproj --filter Name~SpellCheckTest -l:html --results-directory "$dir/TestsResults" --environment "BASE_DIR=$dir" --environment "SAVE=$save"

View File

@ -0,0 +1,46 @@
import os
import subprocess
import sys
import getopt
def help():
# Display Help
print("Run spellcheck tests.")
print()
print("Syntax: available params [-h|s")
print("options:")
print("h Print this Help.")
print("s Force save.")
print()
force = False
# Get the options
opts, args = getopt.getopt(sys.argv[1:], "hf")
for opt, arg in opts:
if opt == "-h":
help()
sys.exit()
elif opt == "-f":
force = arg if arg else True
else:
print("Error: Invalid '-" + opt + "' option")
sys.exit()
sd = os.path.dirname(os.path.abspath(__file__))
dir = os.path.abspath(os.path.join(sd, ".."))
clientDir = os.path.abspath(os.path.join(dir, "client"))
projFile = os.path.abspath(os.path.join(clientDir, "common", "Tests",
"Frontend.Translations.Tests", "Frontend.Translations.Tests.csproj"))
resultDir = os.path.abspath(os.path.join(dir, "TestsResults"))
print("Script directory:", sd)
print("Root directory:", dir)
print("FORCE SAFE:", force) # --environment "SAVE=$save"
print(f"== Run {projFile} ==")
subprocess.run(["dotnet", "test", projFile, "--filter", "Name~SpellCheckTest",
"-l:html", "--results-directory", resultDir, "--environment", f"BASE_DIR={clientDir}", "--environment", f"SAVE={force}"])

16
run.translations.tests.py Executable file
View File

@ -0,0 +1,16 @@
import os
import subprocess
sd = os.path.dirname(os.path.abspath(__file__))
dir = os.path.abspath(os.path.join(sd, ".."))
clientDir = os.path.abspath(os.path.join(dir, "client"))
projFile = os.path.abspath(os.path.join(clientDir, "common", "Tests",
"Frontend.Translations.Tests", "Frontend.Translations.Tests.csproj"))
resultDir = os.path.abspath(os.path.join(dir, "TestsResults"))
print("Script directory:", sd)
print("Root directory:", dir)
print(f"== Run {projFile} ==")
subprocess.run(["dotnet", "test", projFile, "--filter", "TestCategory=Locales",
"-l:html", "--results-directory", resultDir, "--environment", f"BASE_DIR={clientDir}"])

View File

@ -1,8 +0,0 @@
rd="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo "Run script directory:" $dir
dir=$(builtin cd $rd/../; pwd)
echo "Root directory:" $dir
dotnet test $dir/client/common/Tests/Frontend.Translations.Tests/Frontend.Translations.Tests.csproj --filter "TestCategory=Locales" -l:html --results-directory "$dir/TestsResults" --environment "BASE_DIR=$dir/client"