Browse Source

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
pull/10125/head
Don Ho 3 years ago
parent
commit
14a0a43b16
  1. 28
      PowerEditor/Test/FunctionList/udl-regexGlobalTest/unitTest
  2. 1
      PowerEditor/Test/FunctionList/udl-regexGlobalTest/unitTest.expected.result
  3. 1
      PowerEditor/Test/FunctionList/udl-regexGlobalTest/unitTest.result.json
  4. 10
      PowerEditor/Test/FunctionList/unitTest.ps1
  5. 65
      PowerEditor/bin/userDefineLang.xml
  6. 133
      PowerEditor/installer/filesForTesting/overrideMap.xml
  7. 23
      PowerEditor/installer/filesForTesting/regexGlobalTest.xml
  8. 6
      appveyor.yml

28
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!

1
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"}

1
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"}

10
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

65
PowerEditor/bin/userDefineLang.xml

@ -1,65 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<NotepadPlus>
<UserLang name="ggg" ext="" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments"></Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
<Keywords name="Numbers, extras1"></Keywords>
<Keywords name="Numbers, extras2"></Keywords>
<Keywords name="Numbers, suffix1"></Keywords>
<Keywords name="Numbers, suffix2"></Keywords>
<Keywords name="Numbers, range"></Keywords>
<Keywords name="Operators1"></Keywords>
<Keywords name="Operators2"></Keywords>
<Keywords name="Folders in code1, open"></Keywords>
<Keywords name="Folders in code1, middle"></Keywords>
<Keywords name="Folders in code1, close"></Keywords>
<Keywords name="Folders in code2, open"></Keywords>
<Keywords name="Folders in code2, middle"></Keywords>
<Keywords name="Folders in code2, close"></Keywords>
<Keywords name="Folders in comment, open"></Keywords>
<Keywords name="Folders in comment, middle"></Keywords>
<Keywords name="Folders in comment, close"></Keywords>
<Keywords name="Keywords1"></Keywords>
<Keywords name="Keywords2"></Keywords>
<Keywords name="Keywords3"></Keywords>
<Keywords name="Keywords4"></Keywords>
<Keywords name="Keywords5"></Keywords>
<Keywords name="Keywords6"></Keywords>
<Keywords name="Keywords7"></Keywords>
<Keywords name="Keywords8"></Keywords>
<Keywords name="Delimiters"></Keywords>
</KeywordLists>
<Styles>
<WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="COMMENTS" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="LINE COMMENTS" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="NUMBERS" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS1" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS2" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS3" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="OPERATORS" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="FOLDER IN CODE1" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS1" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS2" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS3" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
<WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
</Styles>
</UserLang>
</NotepadPlus>

133
PowerEditor/installer/filesForTesting/overrideMap.xml

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- ==========================================================================\
|
| To learn how to make your own language parser, please check the following
| link:
| https://npp-user-manual.org/docs/function-list/
|
\=========================================================================== -->
<NotepadPlus>
<functionList>
<associationMap>
<!--
This file is optional (can be removed).
Each functionlist parse rule links to a language ID ("langID").
The "id" is the parse rule's default file name, but users can override it.
Here are the default value they are using:
<association id= "php.xml" langID= "1" />
<association id= "c.xml" langID= "2" />
<association id= "cpp.xml" langID= "3" /> (C++)
<association id= "cs.xml" langID= "4" /> (C#)
<association id= "objc.xml" langID= "5" /> (Obective-C)
<association id= "java.xml" langID= "6" />
<association id= "rc.xml" langID= "7" /> (Windows Resource file)
<association id= "html.xml" langID= "8" />
<association id= "xml.xml" langID= "9" />
<association id= "makefile.xml" langID= "10"/>
<association id= "pascal.xml" langID= "11"/>
<association id= "batch.xml" langID= "12"/>
<association id= "ini.xml" langID= "13"/>
<association id= "asp.xml" langID= "16"/>
<association id= "sql.xml" langID= "17"/>
<association id= "vb.xml" langID= "18"/>
<association id= "css.xml" langID= "20"/>
<association id= "perl.xml" langID= "21"/>
<association id= "python.xml" langID= "22"/>
<association id= "lua.xml" langID= "23"/>
<association id= "tex.xml" langID= "24"/> (TeX)
<association id= "fortran.xml" langID= "25"/>
<association id= "bash.xml" langID= "26"/>
<association id= "actionscript.xml" langID= "27"/>
<association id= "nsis.xml" langID= "28"/>
<association id= "tcl.xml" langID= "29"/>
<association id= "lisp.xml" langID= "30"/>
<association id= "scheme.xml" langID= "31"/>
<association id= "asm.xml" langID= "32"/> (Assembly)
<association id= "diff.xml" langID= "33"/>
<association id= "props.xml" langID= "34"/>
<association id= "postscript.xml" langID= "35"/>
<association id= "ruby.xml" langID= "36"/>
<association id= "smalltalk.xml" langID= "37"/>
<association id= "vhdl.xml" langID= "38"/>
<association id= "kix.xml" langID= "39"/> (KiXtart)
<association id= "autoit.xml" langID= "40"/>
<association id= "caml.xml" langID= "41"/>
<association id= "ada.xml" langID= "42"/>
<association id= "verilog.xml" langID= "43"/>
<association id= "matlab.xml" langID= "44"/>
<association id= "haskell.xml" langID= "45"/>
<association id= "inno.xml" langID= "46"/> (Inno Setup)
<association id= "cmake.xml" langID= "48"/>
<association id= "yaml.xml" langID= "49"/>
<association id= "cobol.xml" langID= "50"/>
<association id= "gui4cli.xml" langID= "51"/>
<association id= "d.xml" langID= "52"/>
<association id= "powershell.xml" langID= "53"/>
<association id= "r.xml" langID= "54"/>
<association id= "jsp.xml" langID= "55"/>
<association id= "coffeescript.xml" langID= "56"/>
<association id= "json.xml" langID= "57"/>
<association id= "javascript.js.xml" langID= "58"/>
<association id= "fortran77.xml" langID= "59"/>
<association id= "baanc.xml" langID= "60"/> (BaanC)
<association id= "srec.xml" langID= "61"/> (Motorola S-Record binary data)
<association id= "ihex.xml" langID= "62"/> (Intel HEX binary data)
<association id= "tehex.xml" langID= "63"/> (Tektronix extended HEX binary data)
<association id= "swift.xml" langID= "64"/>
<association id= "asn1.xml" langID= "65"/> (Abstract Syntax Notation One)
<association id= "avs.xml" langID= "66"/> (AviSynth)
<association id= "blitzbasic.xml" langID= "67"/> (BlitzBasic)
<association id= "purebasic.xml" langID= "68"/>
<association id= "freebasic.xml" langID= "69"/>
<association id= "csound.xml" langID= "70"/>
<association id= "erlang.xml" langID= "71"/>
<association id= "escript.xml" langID= "72"/>
<association id= "forth.xml" langID= "73"/>
<association id= "latex.xml" langID= "74"/>
<association id= "mmixal.xml" langID= "75"/>
<association id= "nimrod.xml" langID= "76"/>
<association id= "nncrontab.xml" langID= "77"/> (extended crontab)
<association id= "oscript.xml" langID= "78"/>
<association id= "rebol.xml" langID= "79"/>
<association id= "registry.xml" langID= "80"/>
<association id= "rust.xml" langID= "81"/>
<association id= "spice.xml" langID= "82"/>
<association id= "txt2tags.xml" langID= "83"/>
<association id= "visualprolog.xml" langID= "84"/>
If you create your own parse rule of supported languages (above) for your specific need,
you can copy it without modifying the original one, and make it point to your rule.
For example, you have created your php parse rule, named "myphp2.xml". You add the rule file
into the functionlist directory and add the following line in this file:
<association id= "myphp2.xml" langID= "1" />
and that's it.
-->
<!--
As there is currently only one langID for COBOL:
uncomment the following line to change to cobol-free.xml (cobol section free)
if this is your favourite format
-->
<!--
<association id= "cobol-free.xml" langID= "50"/>
-->
<!--
For User Defined Languages (UDL's) use:
<association id="my_parser.xml" userDefinedLangName="My UDL Name" />
If "My UDL Name" doesn't exist yet, you can create it via UDL dialog.
-->
<!-- ==================== User Defined Languages ============================ -->
<association id= "krl.xml" userDefinedLangName="KRL"/>
<association id= "sinumerik.xml" userDefinedLangName="Sinumerik"/>
<association id= "universe_basic.xml" userDefinedLangName="UniVerse BASIC"/>
<association id= "regexGlobalTest.xml" userDefinedLangName="regexGlobalTest"/>
<!-- ======================================================================== -->
</associationMap>
</functionList>
</NotepadPlus>

23
PowerEditor/installer/filesForTesting/regexGlobalTest.xml

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- ==========================================================================\
|
| To learn how to make your own language parser, please check the following
| link:
| https://npp-user-manual.org/docs/function-list/
|
\=========================================================================== -->
<NotepadPlus>
<functionList>
<!-- =========================================== [ regexGlobalTest ] -->
<!-- Regular Expression Global Test -->
<parser
displayName="RegexGlobalTest"
id ="regexGlobalTest"
>
<function
mainExpr="\((?>[^()]|(?R))*\)"
/>
</parser>
</functionList>
</NotepadPlus>

6
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

Loading…
Cancel
Save