1
0
mirror of https://github.com/ONLYOFFICE/DocSpace-buildtools.git synced 2025-04-18 13:44:02 +03:00

Tests: Frontend: re-written runners after tests changes

This commit is contained in:
Alexey Safronov 2024-09-16 12:46:11 +04:00
parent 19615c7912
commit d8b74544a5
4 changed files with 80 additions and 70 deletions

View File

@ -1,10 +0,0 @@
PUSHD %~dp0..
set dir=%~dp0..
echo %dir%
set save=false
if /I "%1" == "-s" set save=%2 & shift
shift
dotnet test client\common\Tests\Frontend.Translations.Tests\Frontend.Translations.Tests.csproj --filter Name~SpellCheckTest -l:html --environment "BASE_DIR=%dir%" --environment "SAVE=%save%" --results-directory "%dir%/TestsResults"

View File

@ -1,46 +0,0 @@
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}"])

View File

@ -1,5 +1,32 @@
@echo OFF
REM Check if node is installed
node -v 2> Nul 2>&1
if "%errorlevel%" == "9009" (
echo Node.js could not be found.
start https://nodejs.org/en/download/package-manager
exit /b
)
@echo ON
PUSHD %~dp0\..
set dir=%cd%
echo %dir%
dotnet test %dir%\client\common\Tests\Frontend.Translations.Tests\Frontend.Translations.Tests.csproj --filter "TestCategory=Locales" -l:html --environment "BASE_DIR=%dir%\client" --results-directory "%dir%\TestsResults"
set root=%cd%
PUSHD %root%\client\common\tests
set tests=%cd%
call npm install
call npm run test:locales
set OUTPUT=%root%\TestsResults\TestResult__%date:/=%_%time:~0,2%%time:~3,2%%time:~6,2%.html
echo f | xcopy %tests%\reports\tests-results.html %OUTPUT% /F /E /R /Y
echo Results saved to: %OUTPUT%
start %OUTPUT%
pause

View File

@ -1,16 +1,55 @@
import os
import subprocess
import shutil
from datetime import datetime
import webbrowser
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)
def check_node_installed():
try:
subprocess.run(["node", "--version"], check=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print("Node.js is installed.")
except subprocess.CalledProcessError:
print("Node.js could not be found.")
webbrowser.open("https://nodejs.org/en/download/package-manager")
exit(1)
print(f"== Run {projFile} ==")
subprocess.run(["dotnet", "test", projFile, "--filter", "TestCategory=Locales",
"-l:html", "--results-directory", resultDir, "--environment", f"BASE_DIR={clientDir}"])
def main():
check_node_installed()
# Get the root directory
script_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.abspath(os.path.join(script_dir, ".."))
# Change to the tests directory
tests_dir = os.path.join(root_dir, "client", "common", "tests")
os.chdir(tests_dir)
# Run npm install
subprocess.run(["npm", "install"], check=True)
# Run npm test:locales
subprocess.run(["npm", "run", "test:locales"], check=False)
# Generate the output file name
now = datetime.now()
output_file = os.path.join(root_dir, "TestsResults", f"TestResult__{
now.strftime('%Y%m%d_%H%M%S')}.html")
# Copy the test results to the output file
shutil.copyfile(os.path.join(tests_dir, "reports",
"tests-results.html"), output_file)
print("Results saved to:", output_file)
# Open the output file in the default web browser
webbrowser.open(output_file)
# Pause the script
input("Press Enter to continue...")
if __name__ == "__main__":
main()