fq icon indicating copy to clipboard operation
fq copied to clipboard

Run expect script on windows CI

Open wader opened this issue 4 years ago • 17 comments

CI env is https://github.com/actions/virtual-environments/blob/main/images/win/Windows2022-Readme.md

The expect test is done from here https://github.com/wader/fq/blob/master/Makefile#L24 using https://github.com/wader/fq/blob/master/pkg/cli/test.sh and https://github.com/wader/fq/blob/master/pkg/cli/test.exp. The shell script is helper around the expect script to be able to pass a fq binary to test and also to be silent on success and print log if not.

The windows image has make and bash so hopefully it is mostly about installing expect and then checking if expect.exe is in path?

wader avatar Mar 14 '22 09:03 wader

@thushan

wader avatar Mar 14 '22 09:03 wader

FYI files got renamed and changed a bit in #198, also once again learned that it's tricky to have robust expect scripts hmm

wader avatar Mar 16 '22 09:03 wader

Sorry got distracted by other things. Didn't expect setting up expect on Windows to be non-trivial! Going to give it a crack tonight but the setup you've got seems quite straight forward.

thushan avatar Mar 19 '22 22:03 thushan

Hehe no worries, i did a quick check if expect is available in some nice package form for windows but no success. Yeap give it a try or if you know some other tool for testing feel free to use that, i just happened to have some previous experience with expect

wader avatar Mar 19 '22 23:03 wader

heh yeah, though I may have a solution via TCL (ActiveState's TCL)

$ choco install activetcl $ teapot install Expect

Will have to see how this goes.

thushan avatar Mar 20 '22 10:03 thushan

Oh yes that sounds promising. A bit worried about the expect script, i've already experienced it behaving differently between linux environtments so i guess we will see how it goes in windows :(

wader avatar Mar 20 '22 10:03 wader

yeah, i was going to suggest a move to a multi-platform expect like tool... but wasn't sure what The Great Expectation would be just yet.

thushan avatar Mar 20 '22 10:03 thushan

Short lived, choco was busted, ActiveState's TCL's expect isn't compatible with Windows.

image

Will look at alternatives.

thushan avatar Mar 20 '22 10:03 thushan

Hmm "Remove Windows"? that is a bold suggestion :)

wader avatar Mar 20 '22 13:03 wader

Hey, curious if you made any progress?

wader avatar Mar 30 '22 18:03 wader

Hey, missed this email. Went down a rabbit hole to find a portable expect that works on Unix and Windows, looked at some python alternatives (hangon, stay with me!) with wexpect and pexpect.

I've had some issues to overcome porting your stuff but will hopefully be able to get sometime this weekend to look into it. pexpect looks to be the winner at this stage.

Ideally, if I can prove it works with minimal maintenance across both platforms, would be good. Surprised that there's no native way in Windows. Expect more!

thushan avatar Apr 06 '22 10:04 thushan

No worries, nice! One test i would like to add for windows is file path handling, just check that path with driver name and backslash works as intended, maybe both absolute and relative. There was a regression breaking that once.

wader avatar Apr 06 '22 14:04 wader

Great use case. I'll add that to my list.

thushan avatar Apr 07 '22 11:04 thushan

Had sometime today to get this going properly. Ported the basic scripts over to pexpect (wexpect was not consistent). This is a WIP.

Started with the easiest...

test_cli_ctrlc.exp => test_cli_ctrlc.py

test_cli_ctrld.exp => test_cli_ctrld.py

Running these on Windows requires a bit of rework because they have a separate API (PopenSpawn).

Will hammer away at it, but I was thinking of moving these to isolate them from the rest of the go code (being purely CI activities) do you have a suggested location for these (+ the requirements.txt).

Maybe in a root under a folder meaningful for CI activities?

thushan avatar Apr 18 '22 02:04 thushan

Eek, the Windows support is quite flaky with pexpect too unfortunately. Will park this for the moment.

thushan avatar Apr 18 '22 04:04 thushan

Maybe in a root under a folder meaningful for CI activities?

No sure, i do use the expect tests outside CI also and i kind of like the go way of keeping tests close to the code it tests (same directory), but yeah maybe can get cluttered with python stuff... maybe could be in a subdirectory of pkg/cli?

wader avatar Apr 18 '22 17:04 wader

Eek, the Windows support is quite flaky with pexpect too unfortunately. Will park this for the moment.

Ok! thanks for giving it a try. Yeap, let it rest a bit and see if you come up with something

wader avatar Apr 18 '22 17:04 wader

@thushan close for now or you think you will have a go again soon? trying to clean up issues a bit

wader avatar Oct 03 '22 10:10 wader

Yeah I think so mate. Had Great Expectations but the tooling may not be ready for this yet and I haven't looked into it any further. If someone does come across this months & years from now, maybe something to try. A bit like The Hobbit - The Unexpected Journey.

thushan avatar Oct 05 '22 09:10 thushan

:) No worries and understood, thanks for taking some time to look into it

wader avatar Oct 05 '22 13:10 wader