mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-11 21:03:05 +08:00
fix: update smoke-test to AHK V2
This commit is contained in:
parent
57fe82df14
commit
9dda1c7dd7
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -105,7 +105,7 @@ jobs:
|
||||
|
||||
msbuild Notepad3.sln /m /p:Configuration=$config /p:Platform=$platform /v:minimal
|
||||
|
||||
- name: Install AutoHotkey
|
||||
- name: Install AutoHotkey V2
|
||||
if: matrix.platform == 'Win32' || matrix.platform == 'x64'
|
||||
run: choco install autohotkey.install --no-progress -y
|
||||
|
||||
|
||||
@ -2,145 +2,132 @@
|
||||
; Regression Tests Notepad3 Gui
|
||||
; Needs files in a Test Directory:
|
||||
; Notepad3.exe and Notepad3.ini (from distrib)
|
||||
; Execute: AutoHotkeyU32.exe "TestAhkNotepad3.ahk"
|
||||
; Execute: AutoHotkey64.exe "TestAhkNotepad3.ahk"
|
||||
; =============================================================================
|
||||
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
|
||||
; #Warn ; Enable warnings to assist with detecting common errors.
|
||||
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||
SetBatchLines, -1
|
||||
StringCaseSense, Off
|
||||
CoordMode, Pixel, Screen
|
||||
#Requires AutoHotkey v2.0
|
||||
SendMode("Input")
|
||||
SetWorkingDir(A_ScriptDir)
|
||||
CoordMode("Pixel", "Screen")
|
||||
; =============================================================================
|
||||
|
||||
v_NP3Name = Notepad3
|
||||
v_NP3TestDir = %A_WorkingDir%\_TESTDIR
|
||||
v_NP3IniFile = %v_NP3Name%.ini
|
||||
; All globals declared and initialised up front so functions always find them set.
|
||||
global v_NP3Name := "Notepad3"
|
||||
global v_NP3TestDir := A_WorkingDir . "\_TESTDIR"
|
||||
global v_NP3IniFile := v_NP3Name . ".ini"
|
||||
global v_ExitCode := 0
|
||||
global v_Notepad3_PID := 0
|
||||
global stdout := ""
|
||||
|
||||
stdout := FileOpen("*", "w")
|
||||
v_ExitCode := 0
|
||||
try {
|
||||
stdout := FileOpen("*", "w")
|
||||
} catch OSError {
|
||||
; stdout not available - script must be run from CMD with output redirection:
|
||||
; "%AHK_EXE%" /ErrorStdOut TestAhkNotepad3.ahk >> test.log 2>&1
|
||||
MsgBox("stdout not available.`nRun via: TestAhkNotepad3.cmd", "TestAhkNotepad3", "Iconx")
|
||||
ExitApp(1)
|
||||
}
|
||||
|
||||
; =============================================================================
|
||||
|
||||
stdout.WriteLine("Run " . v_NP3Name . ": " . v_NP3TestDir . "\" . v_NP3Name . ".exe '" . v_NP3TestDir . "\" . v_NP3IniFile . ".")
|
||||
|
||||
Run, %v_NP3TestDir%\%v_NP3Name%.exe "%v_NP3TestDir%\%v_NP3IniFile%", , UseErrorLevel, v_Notepad3_PID
|
||||
v_ErrLevel = %ErrorLevel%
|
||||
|
||||
if (v_ErrLevel != 0)
|
||||
{
|
||||
stdout.WriteLine("*** ERROR: " . v_NP3Name . "could not be launched.")
|
||||
try {
|
||||
Run(v_NP3TestDir . "\" . v_NP3Name . ".exe `"" . v_NP3TestDir . "\" . v_NP3IniFile . "`"", , , &v_Notepad3_PID)
|
||||
} catch Error {
|
||||
v_Notepad3_PID := 0 ; Run() unsets &OutputVarPID on throw — restore it
|
||||
stdout.WriteLine("*** ERROR: " . v_NP3Name . " could not be launched.")
|
||||
v_ExitCode := 1
|
||||
Goto LABEL_END
|
||||
Cleanup()
|
||||
ExitApp(v_ExitCode)
|
||||
}
|
||||
; -----------------------------------------------------------------------------
|
||||
|
||||
GoSub CHECK_NP3_STARTS
|
||||
Sleep, 1000
|
||||
GoSub CHECK_WIN_TITLE
|
||||
Sleep, 1000
|
||||
GoSub CHECK_ABOUT_BOX
|
||||
CHECK_NP3_STARTS()
|
||||
Sleep(1000)
|
||||
CHECK_WIN_TITLE()
|
||||
Sleep(1000)
|
||||
CHECK_ABOUT_BOX()
|
||||
|
||||
|
||||
Goto LABEL_END
|
||||
Cleanup()
|
||||
ExitApp(0)
|
||||
; =============================================================================
|
||||
|
||||
; =============================================================================
|
||||
CHECK_NP3_STARTS:
|
||||
; check that NP3 starts up
|
||||
WinWait ahk_pid %v_Notepad3_PID%, , 10
|
||||
v_ErrLevel = %ErrorLevel%
|
||||
if (v_ErrLevel != 0)
|
||||
{
|
||||
stdout.WriteLine("*** ERROR: " . v_NP3Name . "'s seems not to start in time ???")
|
||||
v_ExitCode := 2
|
||||
Goto LABEL_END
|
||||
CHECK_NP3_STARTS() {
|
||||
global v_Notepad3_PID, v_NP3Name, stdout, v_ExitCode
|
||||
; check that NP3 starts up
|
||||
if !WinWait("ahk_pid " . v_Notepad3_PID, , 10) {
|
||||
stdout.WriteLine("*** ERROR: " . v_NP3Name . "'s seems not to start in time ???")
|
||||
v_ExitCode := 2
|
||||
Cleanup()
|
||||
ExitApp(v_ExitCode)
|
||||
}
|
||||
}
|
||||
Return
|
||||
; =============================================================================
|
||||
|
||||
; =============================================================================
|
||||
CHECK_WIN_TITLE:
|
||||
; check Main Window Title
|
||||
WinGetTitle, v_NP3Title, ahk_pid %v_Notepad3_PID%
|
||||
stdout.WriteLine(v_NP3Name . "'s Title is: " . v_NP3Title)
|
||||
CHECK_WIN_TITLE() {
|
||||
global v_Notepad3_PID, v_NP3Name, v_NP3IniFile, v_NP3TestDir, stdout, v_ExitCode
|
||||
; check Main Window Title
|
||||
local v_NP3Title := WinGetTitle("ahk_pid " . v_Notepad3_PID)
|
||||
stdout.WriteLine(v_NP3Name . "'s Title is: " . v_NP3Title)
|
||||
|
||||
IfNotInString, v_NP3Title, %v_NP3Name%
|
||||
{
|
||||
v_ExitCode := 3
|
||||
stdout.WriteLine("*** ERROR: " . v_NP3Name . " missing in Title: ")
|
||||
if !InStr(v_NP3Title, v_NP3Name) {
|
||||
v_ExitCode := 3
|
||||
stdout.WriteLine("*** ERROR: " . v_NP3Name . " missing in Title: ")
|
||||
}
|
||||
if !InStr(v_NP3Title, v_NP3IniFile) {
|
||||
v_ExitCode := 3
|
||||
stdout.WriteLine("*** ERROR: " . v_NP3IniFile . " missing in Title: ")
|
||||
}
|
||||
if !InStr(v_NP3Title, v_NP3TestDir) {
|
||||
v_ExitCode := 3
|
||||
stdout.WriteLine("*** ERROR: " . v_NP3TestDir . " missing in Title: ")
|
||||
}
|
||||
if (v_ExitCode != 0) {
|
||||
Cleanup()
|
||||
ExitApp(v_ExitCode)
|
||||
}
|
||||
}
|
||||
IfNotInString, v_NP3Title, %v_NP3IniFile%
|
||||
{
|
||||
v_ExitCode := 3
|
||||
stdout.WriteLine("*** ERROR: " . v_NP3IniFile . " missing in Title: ")
|
||||
}
|
||||
IfNotInString, v_NP3Title, %v_NP3TestDir%
|
||||
{
|
||||
v_ExitCode := 3
|
||||
stdout.WriteLine("*** ERROR: " . v_NP3TestDir . " missing in Title: ")
|
||||
}
|
||||
If (v_ExitCode != 0)
|
||||
{
|
||||
Goto LABEL_END
|
||||
}
|
||||
Return
|
||||
; =============================================================================
|
||||
|
||||
; =============================================================================
|
||||
CHECK_ABOUT_BOX:
|
||||
; check About DlgBox
|
||||
WinActivate, ahk_pid %v_Notepad3_PID%
|
||||
CHECK_ABOUT_BOX() {
|
||||
global v_Notepad3_PID, v_NP3Name, stdout, v_ExitCode
|
||||
; check About DlgBox
|
||||
WinActivate("ahk_pid " . v_Notepad3_PID)
|
||||
|
||||
; This will select File->Open in Notepad:
|
||||
WinMenuSelectItem, ahk_pid %v_Notepad3_PID%, , Help, About...
|
||||
; Open Help -> About... via its keyboard shortcut (Shift+F1):
|
||||
Send("+{F1}")
|
||||
|
||||
WinWait, About %v_NP3Name%, , 3
|
||||
v_ErrLevel = %ErrorLevel%
|
||||
if (v_ErrLevel != 0)
|
||||
{
|
||||
v_ExitCode := 4
|
||||
stdout.WriteLine("*** ERROR: " . v_NP3Name . "'s About Box is not displayed!")
|
||||
Goto LABEL_END
|
||||
if !WinWait("About " . v_NP3Name, , 3) {
|
||||
stdout.WriteLine("*** ERROR: " . v_NP3Name . "'s About Box is not displayed!")
|
||||
v_ExitCode := 4
|
||||
Cleanup()
|
||||
ExitApp(v_ExitCode)
|
||||
}
|
||||
WinActivate("About " . v_NP3Name)
|
||||
ControlClick("OK", "About " . v_NP3Name)
|
||||
if !WinWaitClose("About " . v_NP3Name, , 2) {
|
||||
stdout.WriteLine("*** ERROR: " . v_NP3Name . "'s About Box can not be closed!")
|
||||
v_ExitCode := 5
|
||||
Cleanup()
|
||||
ExitApp(v_ExitCode)
|
||||
}
|
||||
}
|
||||
WinActivate ; About Box
|
||||
;ControlFocus, OK, About %v_NP3Name%
|
||||
ControlClick, OK, About %v_NP3Name%
|
||||
;Send {Enter}
|
||||
WinWaitClose, About %v_NP3Name%, , 2
|
||||
v_ErrLevel = %ErrorLevel%
|
||||
if (v_ErrLevel != 0)
|
||||
{
|
||||
v_ExitCode := 5
|
||||
stdout.WriteLine("*** ERROR: " . v_NP3Name . "'s About Box can not be closed!")
|
||||
Goto LABEL_END
|
||||
}
|
||||
Return
|
||||
; =============================================================================
|
||||
|
||||
|
||||
; =============================================================================
|
||||
LABEL_END:
|
||||
WinClose ahk_pid %v_Notepad3_PID%, , 2
|
||||
v_ErrLevel = %ErrorLevel%
|
||||
if (v_ErrLevel != 0)
|
||||
{
|
||||
v_ExitCode := 99
|
||||
stdout.WriteLine("*** ERROR: " . v_NP3Name . "can not be closed!")
|
||||
Cleanup() {
|
||||
global v_Notepad3_PID, v_NP3Name, stdout, v_ExitCode
|
||||
if (v_Notepad3_PID > 0) {
|
||||
WinClose("ahk_pid " . v_Notepad3_PID, , 2)
|
||||
if WinExist("ahk_pid " . v_Notepad3_PID)
|
||||
WinWaitClose("ahk_pid " . v_Notepad3_PID, , 10)
|
||||
}
|
||||
if (v_ExitCode != 0)
|
||||
stdout.WriteLine("*** ERROR: Testing " . v_NP3Name . " exit with: " . v_ExitCode)
|
||||
else
|
||||
stdout.WriteLine("Testing " . v_NP3Name . ": All tests PASSED.")
|
||||
}
|
||||
; -------------------------------------
|
||||
WinWaitClose ahk_pid %v_Notepad3_PID%
|
||||
v_ErrLevel = %ErrorLevel%
|
||||
if (v_ErrLevel != 0)
|
||||
{
|
||||
v_ExitCode := 111
|
||||
; FORCED Kill / HANGUP
|
||||
}
|
||||
; -------------------------------------
|
||||
if (v_ExitCode != 0)
|
||||
{
|
||||
stdout.WriteLine("*** ERROR: Testing " . v_NP3Name . " exit with: " . v_ExitCode)
|
||||
ExitApp, %v_ExitCode%
|
||||
}
|
||||
stdout.WriteLine("Testing " . v_NP3Name . ": All tests PASSED.")
|
||||
ExitApp, 0
|
||||
; =============================================================================
|
||||
|
||||
@ -9,12 +9,12 @@ set TEST_LOG=test.log
|
||||
set NP3_CONFIG_DIR=%SCRIPT_DIR%config\
|
||||
set NP3_WIN32_DIR=%SCRIPT_DIR%..\Bin\Release_x86_v143\
|
||||
set NP3_X64_DIR=%SCRIPT_DIR%..\Bin\Release_x64_v143\
|
||||
::set NP3_WIN32_DIR=%SCRIPT_DIR%..\Bin\Release_x86_v145\
|
||||
::set NP3_X64_DIR=%SCRIPT_DIR%..\Bin\Release_x64_v145\
|
||||
|
||||
set AHK_EXE=%ProgramW6432%/AutoHotkey/AutoHotkeyU32.exe
|
||||
set AHK_EXE32=%ProgramFiles(x86)%/AutoHotkey/AutoHotkeyU32.exe
|
||||
set AHK_EXE64=%ProgramFiles%/AutoHotkey/AutoHotkeyU32.exe
|
||||
if not exist "%AHK_EXE%" set AHK_EXE=%AHK_EXE32%
|
||||
if not exist "%AHK_EXE%" set AHK_EXE=%AHK_EXE64%
|
||||
set AHK_EXE=%ProgramFiles%\AutoHotkey\v2\AutoHotkey64.exe
|
||||
if not exist "%AHK_EXE%" set AHK_EXE=%ProgramFiles%\AutoHotkey\AutoHotkey64.exe
|
||||
if not exist "%AHK_EXE%" set AHK_EXE=%ProgramFiles%\AutoHotkey\AutoHotkey.exe
|
||||
|
||||
:: --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -29,10 +29,10 @@ if exist "%NP3_X64_DIR%Notepad3.exe" copy /B "%NP3_X64_DIR%Notepad3.exe" /B "%TE
|
||||
echo. > "%TEST_LOG%"
|
||||
set EXITCODE=0
|
||||
::for /r %%i in (*.ahk) do (
|
||||
for %%i in (*.ahk) do (
|
||||
for %%i in (Test*.ahk) do (
|
||||
echo - Run Testsuite %%~nxi
|
||||
echo +++ Run Testsuite %%~nxi +++ >> "%TEST_LOG%"
|
||||
start "testing" /B /Wait "%AHK_EXE%" /ErrorStdOut "%%~nxi" >> "%TEST_LOG%" 2>&1
|
||||
"%AHK_EXE%" /ErrorStdOut "%%~nxi" >> "%TEST_LOG%" 2>&1
|
||||
if errorlevel 1 (
|
||||
set EXITCODE=1
|
||||
echo *** Testsuite %%~nxi failed! ***
|
||||
|
||||
Loading…
Reference in New Issue
Block a user