Skip to content

Commit f8caee9

Browse files
committed
ui-tests: create the Git worktree as part of SetWorkTree()
And likewise, have a tear-down function (CleanUpWorkTree()). Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 6ab0807 commit f8caee9

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

ui-tests/background-hook.ahk

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@
1313

1414
SetWorkTree('git-test-background-hook')
1515

16-
SetWorkingDir(EnvGet('TEMP'))
17-
Info 'uname: ' RunWaitOne('uname -a')
18-
Info RunWaitOne('git version --build-options')
19-
20-
RunWait('git init "' workTree '"', '', 'Hide')
21-
if A_LastError
22-
ExitWithError 'Could not initialize Git worktree at: ' workTree
23-
24-
SetWorkingDir(workTree)
25-
if A_LastError
26-
ExitWithError 'Could not set working directory to: ' workTree
27-
2816
if not FileExist('.git/hooks') and not DirCreate('.git/hooks')
2917
ExitWithError 'Could not create hooks directory: ' workTree
3018

@@ -70,5 +58,4 @@ Info('Match!')
7058
Send('^C')
7159
Send('exit{Enter}')
7260
Sleep 50
73-
SetWorkingDir(EnvGet('TEMP'))
74-
DirDelete(workTree, true)
61+
CleanUpWorkTree()

ui-tests/ui-test-library.ahk

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@ SetWorkTree(defaultName) {
1818
workTree := workTree '-' counter
1919
}
2020
}
21+
22+
SetWorkingDir(EnvGet('TEMP'))
23+
Info 'uname: ' RunWaitOne('uname -a')
24+
Info RunWaitOne('git version --build-options')
25+
26+
RunWait('git init "' workTree '"', '', 'Hide')
27+
if A_LastError
28+
ExitWithError 'Could not initialize Git worktree at: ' workTree
29+
30+
SetWorkingDir(workTree)
31+
if A_LastError
32+
ExitWithError 'Could not set working directory to: ' workTree
33+
}
34+
35+
CleanUpWorkTree() {
36+
global workTree
37+
SetWorkingDir(EnvGet('TEMP'))
38+
Info 'Cleaning up worktree: ' workTree
39+
DirDelete(workTree, true)
2140
}
2241

2342
Info(text) {

0 commit comments

Comments
 (0)