Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run integration tests on Windows #3236

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

stefanhaller
Copy link
Collaborator

Fix running integration tests on Windows

At least they now work when using
go run cmd/integration_test/main.go cli
or
go run cmd/integration_test/main.go tui.

I haven't been able to get them to run headless (i.e. using go test pkg/integration/clients/*.go), which prevents us from running them on CI.

It is created on Windows when debugging lazygit using VS Code.
They use test/files/pre-push, which doesn't work on Windows.
The "touch" command isn't available on Windows, but "copy NUL file" seems to be
a good approximation.
Copy link

codacy-production bot commented Jan 19, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
0.00% (target: -2.00%) 64.71%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (221ebdc) 46428 38374 82.65%
Head commit (8311933) 46437 (+9) 38379 (+5) 82.65% (0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#3236) 17 11 64.71%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

@stefanhaller stefanhaller added the maintenance For refactorings, CI changes, tests, version bumping, etc label Jan 19, 2024
@stefanhaller stefanhaller force-pushed the run-integration-tests-on-windows branch from e2e2b10 to c39066e Compare January 19, 2024 22:19
@jesseduffield
Copy link
Owner

Nice work. Running integration tests on CI is dependent on creack/pty#155 which has been around for ages but may actually be close to merging

@jwhitley
Copy link
Contributor

Hi Stefan, I'm seeing a consistent failure on your branch (without the cherry pick from the rev-parse branch) with message:
unexpected number of lines in view 'files'. Expected equals 1, got 0 via:

go run cmd/integration_test/main.go cli pkg/integration/tests/custom_commands/form_prompts.go

This is run from cmd shell, with current Go for Windows and Git for Windows. Are you able to see this failure? If not, is there anything I should know about the Windows repro environment?

@stefanhaller
Copy link
Collaborator Author

Nice work. Running integration tests on CI is dependent on creack/pty#155 which has been around for ages but may actually be close to merging

Ah, I see. Too bad. Judging from how long this issue has already been going on, I wouldn't be so sure that it's close to merging. I wonder if it's worth switching to photostorm's fork in the meantime, which seems to have the fix already.

@stefanhaller
Copy link
Collaborator Author

Hi Stefan, I'm seeing a consistent failure on your branch

Yeah, sorry I lied when I said they succeed for me. :-/ I thought I had seen a successful run locally, but I must have dreamed that. I'll look into it in the afternoon, we might just have to skip that test too.

Unfortunately, using cli to run all tests stops at the first one that fails, so we don't know how many more there are...

stk and others added 2 commits January 20, 2024 18:32
It might be possible to make them work somehow, but for now I'm focusing on
getting things green as quickly as possible.
At least they now work when using
  go run cmd/integration_test/main.go cli
or
  go run cmd/integration_test/main.go tui

I haven't been able to get them to run headless (i.e. using
"go test pkg/integration/clients/*.go"), which prevents us from running them on
CI.
@stefanhaller stefanhaller force-pushed the run-integration-tests-on-windows branch from c39066e to 8311933 Compare January 20, 2024 17:32
@stefanhaller
Copy link
Collaborator Author

I'm giving up.

I disabled a few more tests on Windows in an attempt to make things green; but I can't get a complete run of go run cmd/integration_test/main.go cli. Some tests will either fail inconsistently, or hang (I had this several times, where a prompt was waiting for text input, and it didn't continue from there). This is too frustrating.

I also tried moving from creack/pty to photostorm's fork, as mentioned above, hoping that this will make it possible to run the integration tests in "go test" mode. Using photostorm's fork directly wasn't possible because its module declaration is wrong, so I had to make my own. It didn't help though; the code builds now, but running the tests didn't work (seemed to hang without doing anything).

My time budget is used up for this. If somebody else feels like picking this up, please do!

@jwhitley
Copy link
Contributor

Proposal: let's just disable EVERY remaining Windows test failure from the suite. Get the whole thing, even at reduced capacity, reliably passing via manual runs. That's a lot better than what we have now, and then it becomes possible to work incrementally towards a better future.

@stefanhaller
Copy link
Collaborator Author

Yes, that's what I tried to do. But I reached a point where tests were either failing or hanging inconsistently, i.e. different ones with every run. Feel free to give it a try too, maybe you have better luck.

@jwhitley
Copy link
Contributor

I was hoping to find one of those intermittent failure/hang cases and see if I can catch it in the debugger. That really smells like an integration test harness bug. But it's looking like that's just not going to happen on my Windows ARM VM. The VSCode Go debugger refuses to attach. I already had to swap out go windows arm64 for the Intel build, since one of the VSCode debugging dependencies (dlv) explicitly fails to install as unsupported on ARM. Switching to the Go amd64 build fixes that, but even so the debugger refuses to attach.

I'll try again on my Windows Intel VM, but it'll take a bit to set it up for dev work.

@jwhitley
Copy link
Contributor

As of this morning, I finally have my Intel Windows VM setup for lazygit work. I can successfully reproduce failures. 😅

I just had a go at attaching a debugger, and it nominally worked, except that the lazygit isDebuggerAttached() logic is broken on Windows and remains waiting forever because the parent executable name is not "debugserver" but rather "main.exe". I need to dig deeper to understand what's going on, and therefore identify what a fix might look like.

@jwhitley
Copy link
Contributor

OK, confirmed. The debug workflow in the comment on isDebuggerAttached() is completely wrong for Windows. The test_lazygit executable remains a child of the integration test runner's "main.exe" after the debugger has attached. Some research required to figure out the appropriate code here.

Ah, this SO answer suggests that the solution is to actually scrape all of the "dlv.exe" processes and check their arguments for a PID matching the waiting program's PID. But it's not clear that PID is actually included in the arguments to dlv, looking at an attached debug session with procmon. :-ppppp

@jwhitley
Copy link
Contributor

jwhitley commented Jan 24, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance For refactorings, CI changes, tests, version bumping, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants