From 56e4290501b5141f09ec90234fb482463f56ae94 Mon Sep 17 00:00:00 2001 From: Don HO Date: Mon, 31 Aug 2020 04:21:32 +0200 Subject: [PATCH] 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. --- .../cpp/{unitTest2 => 1/unitTest} | 0 .../unitTest.expected.result} | 0 .../FunctionList/cpp/1/unitTest.result.json | 1 + .../FunctionList/cpp/{unitTest1 => unitTest} | 0 ...pected.result => unitTest.expected.result} | 2 +- PowerEditor/Test/FunctionList/unitTest.ps1 | 49 ++++++++++++------- .../Test/FunctionList/unitTestLauncher.ps1 | 46 ++++++++++++++++- 7 files changed, 77 insertions(+), 21 deletions(-) rename PowerEditor/Test/FunctionList/cpp/{unitTest2 => 1/unitTest} (100%) rename PowerEditor/Test/FunctionList/cpp/{unitTest2.expected.result => 1/unitTest.expected.result} (100%) create mode 100644 PowerEditor/Test/FunctionList/cpp/1/unitTest.result.json rename PowerEditor/Test/FunctionList/cpp/{unitTest1 => unitTest} (100%) rename PowerEditor/Test/FunctionList/cpp/{unitTest1.expected.result => unitTest.expected.result} (99%) diff --git a/PowerEditor/Test/FunctionList/cpp/unitTest2 b/PowerEditor/Test/FunctionList/cpp/1/unitTest similarity index 100% rename from PowerEditor/Test/FunctionList/cpp/unitTest2 rename to PowerEditor/Test/FunctionList/cpp/1/unitTest diff --git a/PowerEditor/Test/FunctionList/cpp/unitTest2.expected.result b/PowerEditor/Test/FunctionList/cpp/1/unitTest.expected.result similarity index 100% rename from PowerEditor/Test/FunctionList/cpp/unitTest2.expected.result rename to PowerEditor/Test/FunctionList/cpp/1/unitTest.expected.result diff --git a/PowerEditor/Test/FunctionList/cpp/1/unitTest.result.json b/PowerEditor/Test/FunctionList/cpp/1/unitTest.result.json new file mode 100644 index 000000000..bc22f701b --- /dev/null +++ b/PowerEditor/Test/FunctionList/cpp/1/unitTest.result.json @@ -0,0 +1 @@ +{"leaves":["test42","swap","operator+","operator-","operator!","operator~","operator+","operator-","operator*","operator%","operator^","operator&","operator|","operator<<","operator>>","operator&&","operator||","operator<=>","operator==","operator!=","operator<","operator<=","operator>","operator>=","operator<<","operator>>","swap","test_with_functor","main"],"nodes":[{"leaves":["test"],"name":"TestA1"},{"leaves":["test"],"name":"test::TestA2"},{"leaves":["test"],"name":"TestA3"},{"leaves":["test"],"name":"TestA4"},{"leaves":["test"],"name":"TestA5"},{"leaves":["test"],"name":"TestA6"},{"leaves":["test"],"name":"TestA7"},{"leaves":["test"],"name":"TestA8"},{"leaves":["test"],"name":"TestA9"},{"leaves":["test"],"name":"TestA10"},{"leaves":["test"],"name":"TestA11"},{"leaves":["test"],"name":"test::TestA12"},{"leaves":["test"],"name":"TestA13"},{"leaves":["test"],"name":"TestB1"},{"leaves":["test"],"name":"TestB2"},{"leaves":["test"],"name":"test::TestB3"},{"leaves":["test"],"name":"TestB4"},{"leaves":["test"],"name":"TestB5"},{"leaves":["test"],"name":"TestB6"},{"leaves":["test"],"name":"TestB7"},{"leaves":["test"],"name":"TestB8"},{"leaves":["test"],"name":"TestB9"},{"leaves":["test"],"name":"TestB10"},{"leaves":["test"],"name":"TestB11"},{"leaves":["test"],"name":"TestB12"},{"leaves":["test"],"name":"TestB13"},{"leaves":["test1","test2","test3"],"name":"TestC1"},{"leaves":["test1","test2","test3","test4"],"name":"TestC2"},{"leaves":["test1","test2"],"name":"TestC3"},{"leaves":["test"],"name":"TestD1"},{"leaves":["test"],"name":"TestD2"},{"leaves":["test"],"name":"test::TestD3"},{"leaves":["test"],"name":"TestD4"},{"leaves":["operator bool","operator double","operator unsigned int","swap","operator=","operator+=","operator-=","operator*=","operator%=","operator^=","operator&=","operator|=","operator<<=","operator>>=","operator++","operator++","operator--","operator--","operator+","operator-","operator!","operator~","operator+","operator-","operator*","operator%","operator^","operator&","operator|","operator<<","operator>>","operator&&","operator||","operator<=>","operator==","operator!=","operator<","operator<=","operator>","operator>=","operator<<","operator>>","operator[]","operator[]","operator()","operator*","operator->","test1","test2","test3","test4"],"name":"TestE1"},{"leaves":["test3"],"name":"TestE2"},{"leaves":["test"],"name":"TestH1"},{"leaves":["test"],"name":"TestH2"},{"leaves":["test"],"name":"test::TestH3"},{"leaves":["test"],"name":"TestH4"},{"leaves":["test"],"name":"TestH5"},{"leaves":["coalesce","coalesce","compare","divide","equals","cast","minus","modulus","multiply","negate","isnot","isnull","plus","print"],"name":"test"},{"leaves":["operator bool","operator double","operator unsigned int","operator=","operator+=","operator-=","operator*=","operator%=","operator^=","operator&=","operator|=","operator<<=","operator>>=","operator++","operator++","operator--","operator--","operator[]","operator[]","operator()","operator*","operator->","test1","test2","test3","test4"],"name":"TestF1"},{"leaves":["operator bool","operator unsigned int","operator Type","operator=","test1","test2","test3","test4"],"name":"TestG1"}],"root":"unitTest"} \ No newline at end of file diff --git a/PowerEditor/Test/FunctionList/cpp/unitTest1 b/PowerEditor/Test/FunctionList/cpp/unitTest similarity index 100% rename from PowerEditor/Test/FunctionList/cpp/unitTest1 rename to PowerEditor/Test/FunctionList/cpp/unitTest diff --git a/PowerEditor/Test/FunctionList/cpp/unitTest1.expected.result b/PowerEditor/Test/FunctionList/cpp/unitTest.expected.result similarity index 99% rename from PowerEditor/Test/FunctionList/cpp/unitTest1.expected.result rename to PowerEditor/Test/FunctionList/cpp/unitTest.expected.result index caa0acbb1..4f9b0d5fc 100644 --- a/PowerEditor/Test/FunctionList/cpp/unitTest1.expected.result +++ b/PowerEditor/Test/FunctionList/cpp/unitTest.expected.result @@ -1 +1 @@ -{"leaves":["strVal","decStrVal","hexStrVal","getKwClassFromName","getAsciiLenFromBase64Len","base64ToAscii","cutString","RGB2int","convertIntToFormatType"],"nodes":[{"leaves":["getLangFromXmlFileName","getXmlFilePathFromLangName","addLanguageFromXml","switchToLang"],"name":"LocalizationSwitcher"},{"leaves":["getThemeFromXmlFileName"],"name":"ThemeSwitcher"},{"leaves":["getWindowsVersion","reloadStylers","reloadLang","getSpecialFolderLocation","getSettingsFolder","load","destroyInstance","saveConfig_xml","setWorkSpaceFilePath","removeTransparent","SetTransparent","isExistingExternalLangName","getUserDefinedLangNameFromExt","getExternalLangIndexFromName","getULCFromName","getCurLineHilitingColour","setCurLineHilitingColour","setFontList","isInFontList","getLangKeywordsFromXmlTree","getExternalLexerFromXmlTree","addExternalLangToEnd","getUserStylersFromXmlTree","getUserParametersFromXmlTree","getUserDefineLangsFromXmlTree","getShortcutsFromXmlTree","getMacrosFromXmlTree","getUserCmdsFromXmlTree","getPluginCmdsFromXmlTree","getScintKeysFromXmlTree","getBlackListFromXmlTree","initMenuKeys","initScintillaKeys","reloadContextMenuFromXmlTree","getCmdIdFromMenuEntryItemName","getPluginCmdIdFromMenuEntryItemName","getContextMenuFromXmlTree","setWorkingDir","loadSession","getSessionFromXmlTree","feedFileListParameters","feedProjectPanelsParameters","feedFileBrowserParameters","feedFindHistoryParameters","feedShortcut","feedMacros","getActions","feedUserCmds","feedPluginCustomizedCmds","feedScintKeys","feedBlacklist","getShortcuts","feedUserLang","importUDLFromFile","exportUDLToFile","getLangFromExt","setCloudChoice","removeCloudChoice","isCloudPathChanged","writeSettingsFilesOnCloudForThe1stTime","writeUserDefinedLang","insertCmd","insertMacro","insertUserCmd","insertPluginCmd","insertScintKey","writeSession","writeShortcuts","addUserLangToEnd","removeUserLang","feedUserSettings","feedUserKeywordList","feedUserStyles","feedStylerArray","writeRecentFileHistorySettings","writeProjectPanelsSettings","writeFileBrowserSettings","writeHistory","getChildElementByAttribut","getLangIDFromStr","getLocPathFromStr","feedKeyWordsParameters","feedGUIParameters","feedScintillaParam","feedDockingManager","writeScintillaParams","createXmlTreeFromGUIParams","writeFindHistory","insertDockingParamNode","writePrintSetting","writeExcludedLangList","insertGUIConfigBoolNode","langTypeToCommandID","getWinVersionStr","getWinVerBitStr","writeStyles","insertTabInfo","writeStyle2Element","insertUserLang2Tree","stylerStrOp","addUserModifiedIndex","addPluginModifiedIndex","addScintillaModifiedIndex","safeWow64EnableWow64FsRedirection"],"name":"NppParameters"},{"leaves":["addLexerStyler","eraseAll"],"name":"LexerStylerArray"},{"leaves":["addStyler"],"name":"StyleArray"},{"leaves":["now"],"name":"Date"}],"root":"unitTest1"} \ No newline at end of file +{"leaves":["strVal","decStrVal","hexStrVal","getKwClassFromName","getAsciiLenFromBase64Len","base64ToAscii","cutString","RGB2int","convertIntToFormatType"],"nodes":[{"leaves":["getLangFromXmlFileName","getXmlFilePathFromLangName","addLanguageFromXml","switchToLang"],"name":"LocalizationSwitcher"},{"leaves":["getThemeFromXmlFileName"],"name":"ThemeSwitcher"},{"leaves":["getWindowsVersion","reloadStylers","reloadLang","getSpecialFolderLocation","getSettingsFolder","load","destroyInstance","saveConfig_xml","setWorkSpaceFilePath","removeTransparent","SetTransparent","isExistingExternalLangName","getUserDefinedLangNameFromExt","getExternalLangIndexFromName","getULCFromName","getCurLineHilitingColour","setCurLineHilitingColour","setFontList","isInFontList","getLangKeywordsFromXmlTree","getExternalLexerFromXmlTree","addExternalLangToEnd","getUserStylersFromXmlTree","getUserParametersFromXmlTree","getUserDefineLangsFromXmlTree","getShortcutsFromXmlTree","getMacrosFromXmlTree","getUserCmdsFromXmlTree","getPluginCmdsFromXmlTree","getScintKeysFromXmlTree","getBlackListFromXmlTree","initMenuKeys","initScintillaKeys","reloadContextMenuFromXmlTree","getCmdIdFromMenuEntryItemName","getPluginCmdIdFromMenuEntryItemName","getContextMenuFromXmlTree","setWorkingDir","loadSession","getSessionFromXmlTree","feedFileListParameters","feedProjectPanelsParameters","feedFileBrowserParameters","feedFindHistoryParameters","feedShortcut","feedMacros","getActions","feedUserCmds","feedPluginCustomizedCmds","feedScintKeys","feedBlacklist","getShortcuts","feedUserLang","importUDLFromFile","exportUDLToFile","getLangFromExt","setCloudChoice","removeCloudChoice","isCloudPathChanged","writeSettingsFilesOnCloudForThe1stTime","writeUserDefinedLang","insertCmd","insertMacro","insertUserCmd","insertPluginCmd","insertScintKey","writeSession","writeShortcuts","addUserLangToEnd","removeUserLang","feedUserSettings","feedUserKeywordList","feedUserStyles","feedStylerArray","writeRecentFileHistorySettings","writeProjectPanelsSettings","writeFileBrowserSettings","writeHistory","getChildElementByAttribut","getLangIDFromStr","getLocPathFromStr","feedKeyWordsParameters","feedGUIParameters","feedScintillaParam","feedDockingManager","writeScintillaParams","createXmlTreeFromGUIParams","writeFindHistory","insertDockingParamNode","writePrintSetting","writeExcludedLangList","insertGUIConfigBoolNode","langTypeToCommandID","getWinVersionStr","getWinVerBitStr","writeStyles","insertTabInfo","writeStyle2Element","insertUserLang2Tree","stylerStrOp","addUserModifiedIndex","addPluginModifiedIndex","addScintillaModifiedIndex","safeWow64EnableWow64FsRedirection"],"name":"NppParameters"},{"leaves":["addLexerStyler","eraseAll"],"name":"LexerStylerArray"},{"leaves":["addStyler"],"name":"StyleArray"},{"leaves":["now"],"name":"Date"}],"root":"unitTest"} \ No newline at end of file diff --git a/PowerEditor/Test/FunctionList/unitTest.ps1 b/PowerEditor/Test/FunctionList/unitTest.ps1 index 886eac36d..2de98e528 100644 --- a/PowerEditor/Test/FunctionList/unitTest.ps1 +++ b/PowerEditor/Test/FunctionList/unitTest.ps1 @@ -1,26 +1,39 @@ +# 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] - -if ((Get-Item $testRoot$dirName) -is [System.IO.DirectoryInfo]) -{ - ..\..\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) +Try { + if ((Get-Item $testRoot$dirName) -is [System.IO.DirectoryInfo]) { - Remove-Item $testRoot$dirName\unitTest.result.json - "$dirName ... OK" + 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 + } } - else - { - "$dirName ... KO" - "" - "There's a (some) problem(s) in your functionList.xml" - exit -1 - } } +Catch +{ + return -1 +} \ No newline at end of file diff --git a/PowerEditor/Test/FunctionList/unitTestLauncher.ps1 b/PowerEditor/Test/FunctionList/unitTestLauncher.ps1 index 4844c22f4..b20f4676b 100644 --- a/PowerEditor/Test/FunctionList/unitTestLauncher.ps1 +++ b/PowerEditor/Test/FunctionList/unitTestLauncher.ps1 @@ -5,8 +5,50 @@ Foreach-Object { if ((Get-Item $testRoot$_) -is [System.IO.DirectoryInfo]) { $dirName = (Get-Item $testRoot$_).Name - .\unitTest.ps1 $dirName $dirName - + $langName = $dirName + $result = &.\unitTest.ps1 $dirName $langName + + if ($result -eq 0) + { + "$dirName ... OK" + } + elseif ($result -eq 1) + { + "$dirName ... unitTest file not found. Test skipt." + } + else + { + "$dirName ... KO" + "" + "There are some problems in your functionList.xml" + exit -1 + } + + # Check all Sub-directories for other unit-tests + Get-ChildItem $testRoot$dirName -Filter *.* | + Foreach-Object { + if ((Get-Item $testRoot$dirName\$_) -is [System.IO.DirectoryInfo]) + { + $subDirName = (Get-Item $testRoot$dirName\$_).Name + $subResult = &.\unitTest.ps1 $langName\$subDirName $langName + + if ($subResult -eq 0) + { + "$dirName-$subDirName ... OK" + } + elseif ($subResult -eq 1) + { + "$dirName-$subDirName ... unitTest file not found. Test skipt." + } + else + { + "$dirName-$subDirName ... KO" + "" + "There are some problems in your functionList.xml" + exit -1 + } + } + } } } ""