move code from main into app package to allow test to be injected
This commit is contained in:
Binary file not shown.
@@ -1 +1 @@
|
||||
0000000000000000000000000000000000000000 460150760ff1f381c3f5769b919cb73107c5871a CI <CI@example.com> 1659863059 +1000 commit (initial): my commit message
|
||||
0000000000000000000000000000000000000000 944b9ea58bef8f6352c3a081a1d0037125bcaabc CI <CI@example.com> 1660133266 +1000 commit (initial): my commit message
|
||||
|
||||
@@ -1 +1 @@
|
||||
0000000000000000000000000000000000000000 460150760ff1f381c3f5769b919cb73107c5871a CI <CI@example.com> 1659863059 +1000 commit (initial): my commit message
|
||||
0000000000000000000000000000000000000000 944b9ea58bef8f6352c3a081a1d0037125bcaabc CI <CI@example.com> 1660133266 +1000 commit (initial): my commit message
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
460150760ff1f381c3f5769b919cb73107c5871a
|
||||
944b9ea58bef8f6352c3a081a1d0037125bcaabc
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
0000000000000000000000000000000000000000 470038e1336649b2965305f9f6a82501a836810e CI <CI@example.com> 1659865912 +1000 commit (initial): commit 1
|
||||
470038e1336649b2965305f9f6a82501a836810e c8bec8f2b323cbb476e708bd10c145ea7cc9f726 CI <CI@example.com> 1659865912 +1000 commit: commit 2
|
||||
c8bec8f2b323cbb476e708bd10c145ea7cc9f726 62a60693a2e154e745ee353f67a05156d0532c23 CI <CI@example.com> 1659865912 +1000 commit: commit 3
|
||||
62a60693a2e154e745ee353f67a05156d0532c23 c8bec8f2b323cbb476e708bd10c145ea7cc9f726 CI <CI@example.com> 1659865912 +1000 checkout: moving from master to my-branch-name
|
||||
0000000000000000000000000000000000000000 4e72cd440eec154569568bff8d4c955052ae246c CI <CI@example.com> 1660125381 +1000 commit (initial): commit 1
|
||||
4e72cd440eec154569568bff8d4c955052ae246c 563414ba32c967cfbe21a17fe892d6118c1c58e8 CI <CI@example.com> 1660125381 +1000 commit: commit 2
|
||||
563414ba32c967cfbe21a17fe892d6118c1c58e8 0af36e404e6fec1c3a4d887e30622238e5ea0b2b CI <CI@example.com> 1660125381 +1000 commit: commit 3
|
||||
0af36e404e6fec1c3a4d887e30622238e5ea0b2b 563414ba32c967cfbe21a17fe892d6118c1c58e8 CI <CI@example.com> 1660125382 +1000 checkout: moving from master to my-branch-name
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
0000000000000000000000000000000000000000 470038e1336649b2965305f9f6a82501a836810e CI <CI@example.com> 1659865912 +1000 commit (initial): commit 1
|
||||
470038e1336649b2965305f9f6a82501a836810e c8bec8f2b323cbb476e708bd10c145ea7cc9f726 CI <CI@example.com> 1659865912 +1000 commit: commit 2
|
||||
c8bec8f2b323cbb476e708bd10c145ea7cc9f726 62a60693a2e154e745ee353f67a05156d0532c23 CI <CI@example.com> 1659865912 +1000 commit: commit 3
|
||||
0000000000000000000000000000000000000000 4e72cd440eec154569568bff8d4c955052ae246c CI <CI@example.com> 1660125381 +1000 commit (initial): commit 1
|
||||
4e72cd440eec154569568bff8d4c955052ae246c 563414ba32c967cfbe21a17fe892d6118c1c58e8 CI <CI@example.com> 1660125381 +1000 commit: commit 2
|
||||
563414ba32c967cfbe21a17fe892d6118c1c58e8 0af36e404e6fec1c3a4d887e30622238e5ea0b2b CI <CI@example.com> 1660125381 +1000 commit: commit 3
|
||||
|
||||
@@ -1 +1 @@
|
||||
0000000000000000000000000000000000000000 c8bec8f2b323cbb476e708bd10c145ea7cc9f726 CI <CI@example.com> 1659865912 +1000 branch: Created from c8bec8f2b323cbb476e708bd10c145ea7cc9f726
|
||||
0000000000000000000000000000000000000000 563414ba32c967cfbe21a17fe892d6118c1c58e8 CI <CI@example.com> 1660125382 +1000 branch: Created from 563414ba32c967cfbe21a17fe892d6118c1c58e8
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
xŤÎA
|
||||
1@Q×=Eö‚¤1‰-<2D>®ćm&<26>‚u†ˇ‚ÇwŔíç-ľÍ=:Ä,»ľş×D2š2YUŻą ˘×)Ťš)Ą©şsFKYýŐ<C3BD>ýD62Ł»EaŃ,šę´q¶,‚BʼnŐBy÷űĽÂm€óm¸ú§´ĺé›Ű˘*F’cаŹ<C2B0>¶şMu˙“˙<Př)R:p
|
||||
Binary file not shown.
@@ -1,2 +0,0 @@
|
||||
x<01>ŽK
|
||||
1]罤ók»AD˜Õ#ÉtP0Î0Dðøfá\ÔæQ<ª¬=:X‰‡¾«BÈìâR(¸’I³$$Ôrå…Ä1׬ƒÙÒ®¯áŒèY÷DA²Šc•Ji¡Mì‰-ªIï~_w˜f¸LóM?©mO=•µ]ÁRXG‹ˆf¬#ªëŸúÏg¾…_9>
|
||||
@@ -1 +1 @@
|
||||
62a60693a2e154e745ee353f67a05156d0532c23
|
||||
0af36e404e6fec1c3a4d887e30622238e5ea0b2b
|
||||
|
||||
@@ -1 +1 @@
|
||||
c8bec8f2b323cbb476e708bd10c145ea7cc9f726
|
||||
563414ba32c967cfbe21a17fe892d6118c1c58e8
|
||||
|
||||
@@ -14,14 +14,14 @@ commit 05
|
||||
# Please enter the commit message for your changes. Lines starting
|
||||
# with '#' will be ignored, and an empty message aborts the commit.
|
||||
#
|
||||
# Date: Mon Aug 8 21:32:34 2022 +1000
|
||||
# Date: Wed Aug 10 19:26:28 2022 +1000
|
||||
#
|
||||
# interactive rebase in progress; onto a1a6f7b
|
||||
# interactive rebase in progress; onto cc9defb
|
||||
# Last commands done (4 commands done):
|
||||
# drop 84b1ae9 commit 04
|
||||
# squash aa2585a commit 05
|
||||
# drop da71be1 commit 04
|
||||
# squash 8a38398 commit 05
|
||||
# No commands remaining.
|
||||
# You are currently rebasing branch 'master' on 'a1a6f7b'.
|
||||
# You are currently rebasing branch 'master' on 'cc9defb'.
|
||||
#
|
||||
# Changes to be committed:
|
||||
# new file: file02.txt
|
||||
|
||||
@@ -1 +1 @@
|
||||
aa2585aff7d2278341ca816f187e623503d7c4fb
|
||||
8a3839811a7a9f4c678090c9def892d1e7ad7e54
|
||||
|
||||
@@ -1 +1 @@
|
||||
aa2585aff7d2278341ca816f187e623503d7c4fb
|
||||
8a3839811a7a9f4c678090c9def892d1e7ad7e54
|
||||
|
||||
Binary file not shown.
@@ -1,10 +1,10 @@
|
||||
0000000000000000000000000000000000000000 a1a6f7bda6aeaa08ec75f590845780fde90d901c CI <CI@example.com> 1659958354 +1000 commit (initial): commit 01
|
||||
a1a6f7bda6aeaa08ec75f590845780fde90d901c cb7e56856ecee89fa44c613e094fcf962fe18cf1 CI <CI@example.com> 1659958354 +1000 commit: commit 02
|
||||
cb7e56856ecee89fa44c613e094fcf962fe18cf1 6741ab4fe22a3d36b6c64397fc4295dbae1ba71d CI <CI@example.com> 1659958354 +1000 commit: commit 03
|
||||
6741ab4fe22a3d36b6c64397fc4295dbae1ba71d 84b1ae9d83049341897c9388afffdc9049c3317f CI <CI@example.com> 1659958354 +1000 commit: commit 04
|
||||
84b1ae9d83049341897c9388afffdc9049c3317f aa2585aff7d2278341ca816f187e623503d7c4fb CI <CI@example.com> 1659958354 +1000 commit: commit 05
|
||||
aa2585aff7d2278341ca816f187e623503d7c4fb a1a6f7bda6aeaa08ec75f590845780fde90d901c CI <CI@example.com> 1659958355 +1000 rebase (start): checkout a1a6f7bda6aeaa08ec75f590845780fde90d901c
|
||||
a1a6f7bda6aeaa08ec75f590845780fde90d901c cb7e56856ecee89fa44c613e094fcf962fe18cf1 CI <CI@example.com> 1659958355 +1000 rebase: fast-forward
|
||||
cb7e56856ecee89fa44c613e094fcf962fe18cf1 9c68b57ac7b652fbebc5e93a9a1b72014400c269 CI <CI@example.com> 1659958355 +1000 rebase (continue) (fixup): # This is a combination of 2 commits.
|
||||
9c68b57ac7b652fbebc5e93a9a1b72014400c269 f4316f7a6df3fe5b7e8da1b2c8767ed1e825dc05 CI <CI@example.com> 1659958355 +1000 rebase (continue) (squash): commit 02
|
||||
f4316f7a6df3fe5b7e8da1b2c8767ed1e825dc05 f4316f7a6df3fe5b7e8da1b2c8767ed1e825dc05 CI <CI@example.com> 1659958355 +1000 rebase (continue) (finish): returning to refs/heads/master
|
||||
0000000000000000000000000000000000000000 cc9defb8ae9134f1a9a6c28a0006dc8c8cd78347 CI <CI@example.com> 1660123588 +1000 commit (initial): commit 01
|
||||
cc9defb8ae9134f1a9a6c28a0006dc8c8cd78347 2e2cd25ffdec58d32b5d549f8402bd054e22cc2a CI <CI@example.com> 1660123588 +1000 commit: commit 02
|
||||
2e2cd25ffdec58d32b5d549f8402bd054e22cc2a 90fda12ce101e7d0d4594a879e5bbd1be3c857a8 CI <CI@example.com> 1660123588 +1000 commit: commit 03
|
||||
90fda12ce101e7d0d4594a879e5bbd1be3c857a8 da71be1afbb03f46e91ab5de17d69f148bb009f3 CI <CI@example.com> 1660123588 +1000 commit: commit 04
|
||||
da71be1afbb03f46e91ab5de17d69f148bb009f3 8a3839811a7a9f4c678090c9def892d1e7ad7e54 CI <CI@example.com> 1660123589 +1000 commit: commit 05
|
||||
8a3839811a7a9f4c678090c9def892d1e7ad7e54 cc9defb8ae9134f1a9a6c28a0006dc8c8cd78347 CI <CI@example.com> 1660123589 +1000 rebase (start): checkout cc9defb8ae9134f1a9a6c28a0006dc8c8cd78347
|
||||
cc9defb8ae9134f1a9a6c28a0006dc8c8cd78347 2e2cd25ffdec58d32b5d549f8402bd054e22cc2a CI <CI@example.com> 1660123589 +1000 rebase: fast-forward
|
||||
2e2cd25ffdec58d32b5d549f8402bd054e22cc2a b85535ebf12659044c33386376121d76756ceb59 CI <CI@example.com> 1660123590 +1000 rebase (continue) (fixup): # This is a combination of 2 commits.
|
||||
b85535ebf12659044c33386376121d76756ceb59 aba3469fd6fc584a6af9c0073873005ffaaea56c CI <CI@example.com> 1660123590 +1000 rebase (continue) (squash): commit 02
|
||||
aba3469fd6fc584a6af9c0073873005ffaaea56c aba3469fd6fc584a6af9c0073873005ffaaea56c CI <CI@example.com> 1660123590 +1000 rebase (continue) (finish): returning to refs/heads/master
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
0000000000000000000000000000000000000000 a1a6f7bda6aeaa08ec75f590845780fde90d901c CI <CI@example.com> 1659958354 +1000 commit (initial): commit 01
|
||||
a1a6f7bda6aeaa08ec75f590845780fde90d901c cb7e56856ecee89fa44c613e094fcf962fe18cf1 CI <CI@example.com> 1659958354 +1000 commit: commit 02
|
||||
cb7e56856ecee89fa44c613e094fcf962fe18cf1 6741ab4fe22a3d36b6c64397fc4295dbae1ba71d CI <CI@example.com> 1659958354 +1000 commit: commit 03
|
||||
6741ab4fe22a3d36b6c64397fc4295dbae1ba71d 84b1ae9d83049341897c9388afffdc9049c3317f CI <CI@example.com> 1659958354 +1000 commit: commit 04
|
||||
84b1ae9d83049341897c9388afffdc9049c3317f aa2585aff7d2278341ca816f187e623503d7c4fb CI <CI@example.com> 1659958354 +1000 commit: commit 05
|
||||
aa2585aff7d2278341ca816f187e623503d7c4fb f4316f7a6df3fe5b7e8da1b2c8767ed1e825dc05 CI <CI@example.com> 1659958355 +1000 rebase (continue) (finish): refs/heads/master onto a1a6f7bda6aeaa08ec75f590845780fde90d901c
|
||||
0000000000000000000000000000000000000000 cc9defb8ae9134f1a9a6c28a0006dc8c8cd78347 CI <CI@example.com> 1660123588 +1000 commit (initial): commit 01
|
||||
cc9defb8ae9134f1a9a6c28a0006dc8c8cd78347 2e2cd25ffdec58d32b5d549f8402bd054e22cc2a CI <CI@example.com> 1660123588 +1000 commit: commit 02
|
||||
2e2cd25ffdec58d32b5d549f8402bd054e22cc2a 90fda12ce101e7d0d4594a879e5bbd1be3c857a8 CI <CI@example.com> 1660123588 +1000 commit: commit 03
|
||||
90fda12ce101e7d0d4594a879e5bbd1be3c857a8 da71be1afbb03f46e91ab5de17d69f148bb009f3 CI <CI@example.com> 1660123588 +1000 commit: commit 04
|
||||
da71be1afbb03f46e91ab5de17d69f148bb009f3 8a3839811a7a9f4c678090c9def892d1e7ad7e54 CI <CI@example.com> 1660123589 +1000 commit: commit 05
|
||||
8a3839811a7a9f4c678090c9def892d1e7ad7e54 aba3469fd6fc584a6af9c0073873005ffaaea56c CI <CI@example.com> 1660123590 +1000 rebase (continue) (finish): refs/heads/master onto cc9defb8ae9134f1a9a6c28a0006dc8c8cd78347
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
x█нA
|
||||
б0Pв9еЛи$1≥─┬пU▐1≥LQ0╤■ъ,<─ЭщГ}Ь╡╤ЖХ─9З╝
|
||||
l²└Бc┴T≈d ЯЛ9Y░╧≈T\п≤▀ыxвW▒\u)д я┤║2GqджзX┘Fj"▓Аw©╞;L3\╕Ы╕nшSO╡╤+`▄²?агп▄v°ЙЗ'Ъy╟н|л╠;u
|
||||
@@ -1,3 +0,0 @@
|
||||
x<01>ÎM
|
||||
Â0†a×9Åì™ÉŸºê1’ô
|
||||
Ö–ÁãÛ…pûò,ÞºÌó£“h<ô
|
||||
@@ -1,3 +0,0 @@
|
||||
xŤÎM
|
||||
Â0@a×9ĹěI2?m@DčĘcL’
|
||||
Ö–ÁăŰ…pűřŻ,óüč’úfČU…[LąřLŁęčsEő±´&K#dnÝŞ›˝:Č@A35‹Q±˘d)B<>†V(&®Y-dBuúî÷e<C3B7>éçévµŹÎëÓNe™/„Sâ™ŕĽ÷nŻűT·?ůĎ<C5AF>'÷Ěu;Ť
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,2 +0,0 @@
|
||||
x…ŽÁJÄ0†=ç)z–IÚ´‰Č˛°§˝ű“fbĂ6mi"úřF© ^„9}óý3˙¸¦´Ş{(;3pďťÚŚĘ9Íä;‰ť%áµŰą2%Y‰Ťv^
|
||||
<EFBFBD>¤>ÎSOL„†ÇAmŃtz0<[ôĺ(čLë×<_oţ ´Í|×tŮkkµiuŹEĄµTát}č˘<C48D>—)f¨CPł..TâşŔ@}<7D>z,ź~Yeb<65>ą+Hś3˝ň“8*ńmóďqžÁ1ä{Ü6ö5ÔüXŘŠOz d×
|
||||
Binary file not shown.
@@ -1,4 +0,0 @@
|
||||
x<01>ÎA
|
||||
1…a×=E÷‚4“¦m@D˜•Çh3)
|
||||
Ö†
|
||||
ß.<€Û<E282AC>ÿÁ“µµG·ÀáÐwU«pLJ9׊‘¦²¨–€$BT!*ÃÀly×W·ÉÈÊKBç=$ŽÂ˜Ò˜×Ex B¬&¿û}Ýí|³çùvÕOnÛSO²¶‹…@Ì”<C38C>¼=‚sΧºþ™ÿzëÈ|²);=
|
||||
@@ -0,0 +1,3 @@
|
||||
x}ŽÍ
|
||||
Â0„=ç)ö.Èæwzêc¬Û-
|
||||
Æ–ÁÇ7‡âQfÃð
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
x<01>ΞA
|
||||
1@QΧ=Eφ‚$mΣiAD<41>•ΗHΫλC<05>ο,<€ΫΟ[ό²τώ@)Ζ¦
|
||||
<EFBFBD>«n6ε‚ΩG‘<47>Ή:A[ZΦ•ζs«Ξ¬²ιk@ΒV…lQB<51>©bυ<62>ΌΔ))η\)«+‘'‰FήγΎl0ίΰ<ί®ϊ‘Ύ>υT–~
|
||||
Ι:<3A><11>„<EFBFBD>f―ϋΤΠ?ωΟzσΟ£;v
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
f4316f7a6df3fe5b7e8da1b2c8767ed1e825dc05
|
||||
aba3469fd6fc584a6af9c0073873005ffaaea56c
|
||||
|
||||
@@ -1,419 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration"
|
||||
"github.com/jesseduffield/lazygit/pkg/secureexec"
|
||||
)
|
||||
|
||||
// this program lets you manage integration tests in a TUI. See docs/Integration_Tests.md for more info.
|
||||
|
||||
type App struct {
|
||||
tests []*integration.Test
|
||||
itemIdx int
|
||||
testDir string
|
||||
editing bool
|
||||
g *gocui.Gui
|
||||
}
|
||||
|
||||
func (app *App) getCurrentTest() *integration.Test {
|
||||
if len(app.tests) > 0 {
|
||||
return app.tests[app.itemIdx]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (app *App) refreshTests() {
|
||||
app.loadTests()
|
||||
app.g.Update(func(*gocui.Gui) error {
|
||||
listView, err := app.g.View("list")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
listView.Clear()
|
||||
for _, test := range app.tests {
|
||||
fmt.Fprintln(listView, test.Name)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (app *App) loadTests() {
|
||||
tests, err := integration.LoadTests(app.testDir)
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
app.tests = tests
|
||||
if app.itemIdx > len(app.tests)-1 {
|
||||
app.itemIdx = len(app.tests) - 1
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
rootDir := integration.GetRootDirectory()
|
||||
testDir := filepath.Join(rootDir, "test", "integration")
|
||||
|
||||
app := &App{testDir: testDir}
|
||||
app.loadTests()
|
||||
|
||||
g, err := gocui.NewGui(gocui.OutputTrue, false, gocui.NORMAL, false, gui.RuneReplacements)
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
g.Cursor = false
|
||||
|
||||
app.g = g
|
||||
|
||||
g.SetManagerFunc(app.layout)
|
||||
|
||||
if err := g.SetKeybinding("list", gocui.KeyArrowUp, gocui.ModNone, func(*gocui.Gui, *gocui.View) error {
|
||||
if app.itemIdx > 0 {
|
||||
app.itemIdx--
|
||||
}
|
||||
listView, err := g.View("list")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
listView.FocusPoint(0, app.itemIdx)
|
||||
return nil
|
||||
}); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
if err := g.SetKeybinding("list", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
if err := g.SetKeybinding("list", 'q', gocui.ModNone, quit); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
if err := g.SetKeybinding("list", 'r', gocui.ModNone, func(*gocui.Gui, *gocui.View) error {
|
||||
currentTest := app.getCurrentTest()
|
||||
if currentTest == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
cmd := secureexec.Command("sh", "-c", fmt.Sprintf("INCLUDE_SKIPPED=true MODE=record go run test/runner/main.go %s", currentTest.Name))
|
||||
app.runSubprocess(cmd)
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
if err := g.SetKeybinding("list", 's', gocui.ModNone, func(*gocui.Gui, *gocui.View) error {
|
||||
currentTest := app.getCurrentTest()
|
||||
if currentTest == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
cmd := secureexec.Command("sh", "-c", fmt.Sprintf("INCLUDE_SKIPPED=true MODE=sandbox go run test/runner/main.go %s", currentTest.Name))
|
||||
app.runSubprocess(cmd)
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
if err := g.SetKeybinding("list", gocui.KeyEnter, gocui.ModNone, func(*gocui.Gui, *gocui.View) error {
|
||||
currentTest := app.getCurrentTest()
|
||||
if currentTest == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
cmd := secureexec.Command("sh", "-c", fmt.Sprintf("INCLUDE_SKIPPED=true go run test/runner/main.go %s", currentTest.Name))
|
||||
app.runSubprocess(cmd)
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
if err := g.SetKeybinding("list", 'u', gocui.ModNone, func(*gocui.Gui, *gocui.View) error {
|
||||
currentTest := app.getCurrentTest()
|
||||
if currentTest == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
cmd := secureexec.Command("sh", "-c", fmt.Sprintf("INCLUDE_SKIPPED=true MODE=updateSnapshot go run test/runner/main.go %s", currentTest.Name))
|
||||
app.runSubprocess(cmd)
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
if err := g.SetKeybinding("list", 't', gocui.ModNone, func(*gocui.Gui, *gocui.View) error {
|
||||
currentTest := app.getCurrentTest()
|
||||
if currentTest == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
cmd := secureexec.Command("sh", "-c", fmt.Sprintf("INCLUDE_SKIPPED=true SPEED=1 go run test/runner/main.go %s", currentTest.Name))
|
||||
app.runSubprocess(cmd)
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
if err := g.SetKeybinding("list", 'o', gocui.ModNone, func(*gocui.Gui, *gocui.View) error {
|
||||
currentTest := app.getCurrentTest()
|
||||
if currentTest == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
cmd := secureexec.Command("sh", "-c", fmt.Sprintf("code -r %s/%s/test.json", app.testDir, currentTest.Name))
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
if err := g.SetKeybinding("list", 'n', gocui.ModNone, func(*gocui.Gui, *gocui.View) error {
|
||||
currentTest := app.getCurrentTest()
|
||||
if currentTest == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// need to duplicate that folder and then re-fetch our tests.
|
||||
dir := app.testDir + "/" + app.getCurrentTest().Name
|
||||
newDir := dir + "_Copy"
|
||||
|
||||
cmd := secureexec.Command("sh", "-c", fmt.Sprintf("cp -r %s %s", dir, newDir))
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
app.loadTests()
|
||||
|
||||
app.refreshTests()
|
||||
return nil
|
||||
}); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
if err := g.SetKeybinding("list", 'm', gocui.ModNone, func(*gocui.Gui, *gocui.View) error {
|
||||
currentTest := app.getCurrentTest()
|
||||
if currentTest == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
app.editing = true
|
||||
if _, err := g.SetCurrentView("editor"); err != nil {
|
||||
return err
|
||||
}
|
||||
editorView, err := g.View("editor")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
editorView.Clear()
|
||||
fmt.Fprint(editorView, currentTest.Name)
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
if err := g.SetKeybinding("list", 'd', gocui.ModNone, func(*gocui.Gui, *gocui.View) error {
|
||||
currentTest := app.getCurrentTest()
|
||||
if currentTest == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
dir := app.testDir + "/" + app.getCurrentTest().Name
|
||||
|
||||
cmd := secureexec.Command("sh", "-c", fmt.Sprintf("rm -rf %s", dir))
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
app.refreshTests()
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
if err := g.SetKeybinding("editor", gocui.KeyEnter, gocui.ModNone, func(*gocui.Gui, *gocui.View) error {
|
||||
currentTest := app.getCurrentTest()
|
||||
if currentTest == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
app.editing = false
|
||||
if _, err := g.SetCurrentView("list"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
editorView, err := g.View("editor")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dir := app.testDir + "/" + app.getCurrentTest().Name
|
||||
newDir := app.testDir + "/" + editorView.Buffer()
|
||||
|
||||
cmd := secureexec.Command("sh", "-c", fmt.Sprintf("mv %s %s", dir, newDir))
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
editorView.Clear()
|
||||
|
||||
app.refreshTests()
|
||||
return nil
|
||||
}); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
if err := g.SetKeybinding("editor", gocui.KeyEsc, gocui.ModNone, func(*gocui.Gui, *gocui.View) error {
|
||||
app.editing = false
|
||||
if _, err := g.SetCurrentView("list"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
err = g.MainLoop()
|
||||
g.Close()
|
||||
switch err {
|
||||
case gocui.ErrQuit:
|
||||
return
|
||||
default:
|
||||
log.Panicln(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (app *App) runSubprocess(cmd *exec.Cmd) {
|
||||
if err := gocui.Screen.Suspend(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.Stdout = os.Stdout
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Println(err.Error())
|
||||
}
|
||||
cmd.Stdin = nil
|
||||
cmd.Stderr = nil
|
||||
cmd.Stdout = nil
|
||||
|
||||
fmt.Fprintf(os.Stdout, "\n%s", style.FgGreen.Sprint("press enter to return"))
|
||||
fmt.Scanln() // wait for enter press
|
||||
|
||||
if err := gocui.Screen.Resume(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (app *App) layout(g *gocui.Gui) error {
|
||||
maxX, maxY := g.Size()
|
||||
descriptionViewHeight := 7
|
||||
keybindingsViewHeight := 3
|
||||
editorViewHeight := 3
|
||||
if !app.editing {
|
||||
editorViewHeight = 0
|
||||
} else {
|
||||
descriptionViewHeight = 0
|
||||
keybindingsViewHeight = 0
|
||||
}
|
||||
g.Cursor = app.editing
|
||||
g.FgColor = gocui.ColorGreen
|
||||
listView, err := g.SetView("list", 0, 0, maxX-1, maxY-descriptionViewHeight-keybindingsViewHeight-editorViewHeight-1, 0)
|
||||
if err != nil {
|
||||
if err.Error() != "unknown view" {
|
||||
return err
|
||||
}
|
||||
listView.Highlight = true
|
||||
listView.Clear()
|
||||
for _, test := range app.tests {
|
||||
fmt.Fprintln(listView, test.Name)
|
||||
}
|
||||
listView.Title = "Tests"
|
||||
listView.FgColor = gocui.ColorDefault
|
||||
if _, err := g.SetCurrentView("list"); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
descriptionView, err := g.SetViewBeneath("description", "list", descriptionViewHeight)
|
||||
if err != nil {
|
||||
if err.Error() != "unknown view" {
|
||||
return err
|
||||
}
|
||||
descriptionView.Title = "Test description"
|
||||
descriptionView.Wrap = true
|
||||
descriptionView.FgColor = gocui.ColorDefault
|
||||
}
|
||||
|
||||
keybindingsView, err := g.SetViewBeneath("keybindings", "description", keybindingsViewHeight)
|
||||
if err != nil {
|
||||
if err.Error() != "unknown view" {
|
||||
return err
|
||||
}
|
||||
keybindingsView.Title = "Keybindings"
|
||||
keybindingsView.Wrap = true
|
||||
keybindingsView.FgColor = gocui.ColorDefault
|
||||
fmt.Fprintln(keybindingsView, "up/down: navigate, enter: run test, u: run test and update snapshots, r: record test, s: sandbox, o: open test config, n: duplicate test, m: rename test, d: delete test, t: run test at original speed")
|
||||
}
|
||||
|
||||
editorView, err := g.SetViewBeneath("editor", "keybindings", editorViewHeight)
|
||||
if err != nil {
|
||||
if err.Error() != "unknown view" {
|
||||
return err
|
||||
}
|
||||
editorView.Title = "Enter Name"
|
||||
editorView.FgColor = gocui.ColorDefault
|
||||
editorView.Editable = true
|
||||
}
|
||||
|
||||
currentTest := app.getCurrentTest()
|
||||
if currentTest == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
descriptionView.Clear()
|
||||
fmt.Fprintf(descriptionView, "Speed: %f. %s", currentTest.Speed, currentTest.Description)
|
||||
|
||||
if err := g.SetKeybinding("list", gocui.KeyArrowDown, gocui.ModNone, func(*gocui.Gui, *gocui.View) error {
|
||||
if app.itemIdx < len(app.tests)-1 {
|
||||
app.itemIdx++
|
||||
}
|
||||
|
||||
listView, err := g.View("list")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
listView.FocusPoint(0, app.itemIdx)
|
||||
return nil
|
||||
}); err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func quit(g *gocui.Gui, v *gocui.View) error {
|
||||
return gocui.ErrQuit
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/integration"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/integration_tests"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// see docs/Integration_Tests.md
|
||||
// This file can be invoked directly, but you might find it easier to go through
|
||||
// test/lazyintegration/main.go, which provides a convenient gui wrapper to integration tests.
|
||||
//
|
||||
// If invoked directly, you can specify a test by passing it as the first argument.
|
||||
// You can also specify that you want to record a test by passing MODE=record
|
||||
// as an env var.
|
||||
|
||||
func main() {
|
||||
mode := integration.GetModeFromEnv()
|
||||
includeSkipped := os.Getenv("INCLUDE_SKIPPED") == "true"
|
||||
selectedTestName := os.Args[1]
|
||||
|
||||
// check if our given test name actually exists
|
||||
if selectedTestName != "" {
|
||||
found := false
|
||||
for _, test := range integration_tests.Tests {
|
||||
if test.Name() == selectedTestName {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
log.Fatalf("test %s not found. Perhaps you forgot to add it to `pkg/integration/integration_tests/tests.go`?", selectedTestName)
|
||||
}
|
||||
}
|
||||
|
||||
err := integration.RunTestsNew(
|
||||
log.Printf,
|
||||
runCmdInTerminal,
|
||||
func(test types.Test, f func() error) {
|
||||
if selectedTestName != "" && test.Name() != selectedTestName {
|
||||
return
|
||||
}
|
||||
if err := f(); err != nil {
|
||||
log.Print(err.Error())
|
||||
}
|
||||
},
|
||||
mode,
|
||||
func(expected string, actual string, prefix string) { //nolint:thelper
|
||||
assert.Equal(MockTestingT{}, expected, actual, fmt.Sprintf("Unexpected %s. Expected:\n%s\nActual:\n%s\n", prefix, expected, actual))
|
||||
},
|
||||
includeSkipped,
|
||||
)
|
||||
if err != nil {
|
||||
log.Print(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
type MockTestingT struct{}
|
||||
|
||||
func (t MockTestingT) Errorf(format string, args ...interface{}) {
|
||||
fmt.Printf(format, args...)
|
||||
}
|
||||
|
||||
func runCmdInTerminal(cmd *exec.Cmd) error {
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
return cmd.Run()
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/integration"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// Deprecated: This file is part of the old way of doing things. See test/runner_new/main.go for the new way
|
||||
|
||||
// see docs/Integration_Tests.md
|
||||
// This file can be invoked directly, but you might find it easier to go through
|
||||
// test/lazyintegration/main.go, which provides a convenient gui wrapper to integration tests.
|
||||
//
|
||||
// If invoked directly, you can specify a test by passing it as the first argument.
|
||||
// You can also specify that you want to record a test by passing MODE=record
|
||||
// as an env var.
|
||||
|
||||
func main() {
|
||||
mode := integration.GetModeFromEnv()
|
||||
speedEnv := os.Getenv("SPEED")
|
||||
includeSkipped := os.Getenv("INCLUDE_SKIPPED") == "true"
|
||||
selectedTestName := os.Args[1]
|
||||
|
||||
err := integration.RunTests(
|
||||
log.Printf,
|
||||
runCmdInTerminal,
|
||||
func(test *integration.Test, f func(*testing.T) error) {
|
||||
if selectedTestName != "" && test.Name != selectedTestName {
|
||||
return
|
||||
}
|
||||
if err := f(nil); err != nil {
|
||||
log.Print(err.Error())
|
||||
}
|
||||
},
|
||||
mode,
|
||||
speedEnv,
|
||||
func(_t *testing.T, expected string, actual string, prefix string) { //nolint:thelper
|
||||
assert.Equal(MockTestingT{}, expected, actual, fmt.Sprintf("Unexpected %s. Expected:\n%s\nActual:\n%s\n", prefix, expected, actual))
|
||||
},
|
||||
includeSkipped,
|
||||
)
|
||||
if err != nil {
|
||||
log.Print(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
type MockTestingT struct{}
|
||||
|
||||
func (t MockTestingT) Errorf(format string, args ...interface{}) {
|
||||
fmt.Printf(format, args...)
|
||||
}
|
||||
|
||||
func runCmdInTerminal(cmd *exec.Cmd) error {
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
return cmd.Run()
|
||||
}
|
||||
Reference in New Issue
Block a user