From 14a0a43b16cc809d1e67b083f8873d114a1aa7e6 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 5 Jul 2021 15:49:48 +0200 Subject: [PATCH] Add global regex unitTest via UDL way Use User Defined Language to have function list on Unit-tests. It could reduce regression happening while the code of boost regex or the related code is changed. And also make build system be aware of unit-test result. Close #10108 --- .../FunctionList/udl-regexGlobalTest/unitTest | 28 ++++ .../unitTest.expected.result | 1 + .../udl-regexGlobalTest/unitTest.result.json | 1 + PowerEditor/Test/FunctionList/unitTest.ps1 | 10 +- PowerEditor/bin/userDefineLang.xml | 65 --------- .../installer/filesForTesting/overrideMap.xml | 133 ++++++++++++++++++ .../filesForTesting/regexGlobalTest.xml | 23 +++ appveyor.yml | 6 + 8 files changed, 201 insertions(+), 66 deletions(-) create mode 100644 PowerEditor/Test/FunctionList/udl-regexGlobalTest/unitTest create mode 100644 PowerEditor/Test/FunctionList/udl-regexGlobalTest/unitTest.expected.result create mode 100644 PowerEditor/Test/FunctionList/udl-regexGlobalTest/unitTest.result.json delete mode 100644 PowerEditor/bin/userDefineLang.xml create mode 100644 PowerEditor/installer/filesForTesting/overrideMap.xml create mode 100644 PowerEditor/installer/filesForTesting/regexGlobalTest.xml diff --git a/PowerEditor/Test/FunctionList/udl-regexGlobalTest/unitTest b/PowerEditor/Test/FunctionList/udl-regexGlobalTest/unitTest new file mode 100644 index 000000000..f39bb04b7 --- /dev/null +++ b/PowerEditor/Test/FunctionList/udl-regexGlobalTest/unitTest @@ -0,0 +1,28 @@ ++++ +title = "Make Your Business Card with Notepad++" +description = "" +date = "2011-12-25" +menu = "main" ++++ + +2011-12-25 + +Notepad++ is not just a text/code editor, you can use it to make your business card: + + +![Business Card](/news/images/npp.businessCard.jpg) + +Here are some tips/instructions to help you make your original business card with Notepad++: + +1. Hide menu, tab bar and status bar (you probably want to hide tool bar if you have more content to show) via the General tab of Preferences dialog. +2. Hide folder margin, bookmark margin, line number margin and current line highlighting via the Editing tab of Preference dialog. +3. Check "Show only filename in title bar" via "MISC." tab of Preference Dialog, this removes the full path and keep only the file name on the caption bar. +4. Resize Notepad++ to fit the size of your empty business card to print. (I made the Notepad++ size on screen just fit my card) +5.Type the content of your business card with your favorite programming language (html, xml, php, c, c++, etc...) then set the language's syntax highlighting via menu Language (type "Alt" to show menu). +6. Launch "Style Configurator" Dialog (via menu "Settings") to tune up the syntax highlighting of your language of choice (for the bg/fg colour, font style and font size). You can choose the theme (on the top) as well to have the different look & feel. Save & close it. +7. Print your card - Do the screen capture by "Alt + Print Screen", Then paste it into Word to print. +8. That's it. Enjoy making your geek business card! + +The original idea came from [Albert Hwang's Notepad Business Card](https://www.albert-hwang.com/blog/2011/12/re-my-business-card). + +Happy Isaac Newton's Birthday! diff --git a/PowerEditor/Test/FunctionList/udl-regexGlobalTest/unitTest.expected.result b/PowerEditor/Test/FunctionList/udl-regexGlobalTest/unitTest.expected.result new file mode 100644 index 000000000..e156dddd5 --- /dev/null +++ b/PowerEditor/Test/FunctionList/udl-regexGlobalTest/unitTest.expected.result @@ -0,0 +1 @@ +{"leaves":["(/news/images/npp.businessCard.jpg)","(you probably want to hide tool bar if you have more content to show)","(I made the Notepad++ size on screen just fit my card)","(html, xml, php, c, c++, etc...)","(type \"Alt\" to show menu)","(via menu \"Settings\")","(for the bg/fg colour, font style and font size)","(on the top)","(https://www.albert-hwang.com/blog/2011/12/re-my-business-card)"],"root":"unitTest"} \ No newline at end of file diff --git a/PowerEditor/Test/FunctionList/udl-regexGlobalTest/unitTest.result.json b/PowerEditor/Test/FunctionList/udl-regexGlobalTest/unitTest.result.json new file mode 100644 index 000000000..e156dddd5 --- /dev/null +++ b/PowerEditor/Test/FunctionList/udl-regexGlobalTest/unitTest.result.json @@ -0,0 +1 @@ +{"leaves":["(/news/images/npp.businessCard.jpg)","(you probably want to hide tool bar if you have more content to show)","(I made the Notepad++ size on screen just fit my card)","(html, xml, php, c, c++, etc...)","(type \"Alt\" to show menu)","(via menu \"Settings\")","(for the bg/fg colour, font style and font size)","(on the top)","(https://www.albert-hwang.com/blog/2011/12/re-my-business-card)"],"root":"unitTest"} \ No newline at end of file diff --git a/PowerEditor/Test/FunctionList/unitTest.ps1 b/PowerEditor/Test/FunctionList/unitTest.ps1 index f7eb53abf..760e10a4d 100644 --- a/PowerEditor/Test/FunctionList/unitTest.ps1 +++ b/PowerEditor/Test/FunctionList/unitTest.ps1 @@ -19,7 +19,15 @@ Try { { return 1 } - ..\..\bin\notepad++.exe -export=functionList -l"$langName" $testRoot$dirName\unitTest | Out-Null + if ($langName.StartsWith("udl-")) + { + $langName = $langName.Replace("udl-", "") + ..\..\bin\notepad++.exe -export=functionList -udl="`"$langName"`" $testRoot$dirName\unitTest | Out-Null + } + else + { + ..\..\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 diff --git a/PowerEditor/bin/userDefineLang.xml b/PowerEditor/bin/userDefineLang.xml deleted file mode 100644 index d89feb6f7..000000000 --- a/PowerEditor/bin/userDefineLang.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/PowerEditor/installer/filesForTesting/overrideMap.xml b/PowerEditor/installer/filesForTesting/overrideMap.xml new file mode 100644 index 000000000..5aa36ae11 --- /dev/null +++ b/PowerEditor/installer/filesForTesting/overrideMap.xml @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/PowerEditor/installer/filesForTesting/regexGlobalTest.xml b/PowerEditor/installer/filesForTesting/regexGlobalTest.xml new file mode 100644 index 000000000..94bd3e7d8 --- /dev/null +++ b/PowerEditor/installer/filesForTesting/regexGlobalTest.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 56feb76ad..eac0ffc6f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -82,8 +82,14 @@ after_build: Copy-Item "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\src\shortcuts.xml" -Destination "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\bin" Copy-Item "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\src\contextMenu.xml" -Destination "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\bin" Copy-Item "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\installer\functionList" -Destination "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\bin" -Recurse + + Copy-Item "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\installer\filesForTesting\regexGlobalTest.xml" -Destination "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\bin\functionList" + Copy-Item "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\installer\filesForTesting\overrideMap.xml" -Destination "$env:APPVEYOR_BUILD_FOLDER\PowerEditor\bin\functionList" + cd .\PowerEditor\Test\FunctionList\ .\unitTestLauncher.ps1 + if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) } + #ATTENTION: current working dir is no longer at APPVEYOR_BUILD_FOLDER cd ..\UrlDetection .\verifyUrlDetection.ps1