notepad-plus-plus-legacy/PowerEditor/Test/FunctionList/unitTest.ps1
Don HO 56e4290501 Add the ability to have more than 1 unit-test per language
For function list, each language can have 2 or mor unit-test files.
The 2nd added unit-test file should be added in a sub-directory, the 3rd added unit-test file should be added into anather sub-directory, and so on.
2020-08-31 04:21:32 +02:00

39 lines
856 B
PowerShell

# This script does 1 unit-test on given relative dir path and on given language.
# Here's its syntax:
# .\unit-test.ps1 RELATIVE_PATH LANG
# It return 0 if result is OK
# -1 if result is KO
# 1 if unitTest file not found
$testRoot = ".\"
$dirName=$args[0]
$langName=$args[1]
Try {
if ((Get-Item $testRoot$dirName) -is [System.IO.DirectoryInfo])
{
if (-Not (Test-Path $testRoot$dirName\unitTest))
{
return 1
}
..\..\bin\notepad++.exe -export=functionList -l"$langName" $testRoot$dirName\unitTest | Out-Null
$expectedRes = Get-Content $testRoot$dirName\unitTest.expected.result
$generatedRes = Get-Content $testRoot$dirName\unitTest.result.json
if ($generatedRes -eq $expectedRes)
{
Remove-Item $testRoot$dirName\unitTest.result.json
return 0
}
else
{
return -1
}
}
}
Catch
{
return -1
}