2020-08-31 02:21:32 +00:00
|
|
|
# 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
|
2020-10-11 00:24:15 +00:00
|
|
|
# -2 if exception
|
2020-08-31 02:21:32 +00:00
|
|
|
# 1 if unitTest file not found
|
|
|
|
|
2020-10-11 00:24:15 +00:00
|
|
|
|
2018-12-29 17:58:00 +00:00
|
|
|
$testRoot = ".\"
|
|
|
|
|
|
|
|
$dirName=$args[0]
|
|
|
|
$langName=$args[1]
|
|
|
|
|
2020-08-31 02:21:32 +00:00
|
|
|
Try {
|
|
|
|
if ((Get-Item $testRoot$dirName) -is [System.IO.DirectoryInfo])
|
2018-12-29 17:58:00 +00:00
|
|
|
{
|
2020-08-31 02:21:32 +00:00
|
|
|
if (-Not (Test-Path $testRoot$dirName\unitTest))
|
|
|
|
{
|
|
|
|
return 1
|
|
|
|
}
|
2021-07-05 13:49:48 +00:00
|
|
|
if ($langName.StartsWith("udl-"))
|
|
|
|
{
|
|
|
|
$langName = $langName.Replace("udl-", "")
|
2023-10-29 07:04:22 +00:00
|
|
|
..\..\bin\notepad++.exe -export=functionList -udl="$langName" $testRoot$dirName\unitTest | Out-Null
|
2021-07-05 13:49:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
..\..\bin\notepad++.exe -export=functionList -l"$langName" $testRoot$dirName\unitTest | Out-Null
|
|
|
|
}
|
2020-08-31 02:21:32 +00:00
|
|
|
|
|
|
|
$expectedRes = Get-Content $testRoot$dirName\unitTest.expected.result
|
|
|
|
$generatedRes = Get-Content $testRoot$dirName\unitTest.result.json
|
2023-10-29 07:04:22 +00:00
|
|
|
|
2022-12-12 01:18:11 +00:00
|
|
|
# Some parser results contain CRLF or LF (\r\n or \n) dependent of file EOL format
|
2023-10-29 07:04:22 +00:00
|
|
|
# In order to make tests pass in any environment, all the CRLF turning into LF (if any) in both strings
|
2022-12-12 01:18:11 +00:00
|
|
|
$expectedRes = $expectedRes.replace('\r\n','\n')
|
|
|
|
$generatedRes = $generatedRes.replace('\r\n','\n')
|
2023-10-29 07:04:22 +00:00
|
|
|
|
2020-08-31 02:21:32 +00:00
|
|
|
if ($generatedRes -eq $expectedRes)
|
|
|
|
{
|
2023-10-29 07:04:22 +00:00
|
|
|
Remove-Item $testRoot$dirName\unitTest.result.json
|
|
|
|
return 0
|
2020-08-31 02:21:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-12-12 01:18:11 +00:00
|
|
|
$expectedRes
|
|
|
|
"`nvs`n"
|
|
|
|
$generatedRes
|
2020-08-31 02:21:32 +00:00
|
|
|
return -1
|
2023-10-29 07:04:22 +00:00
|
|
|
}
|
2018-12-29 17:58:00 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-31 02:21:32 +00:00
|
|
|
Catch
|
|
|
|
{
|
2020-10-11 00:24:15 +00:00
|
|
|
return -2
|
|
|
|
}
|