go-mutesting icon indicating copy to clipboard operation
go-mutesting copied to clipboard

Support go-mutesting on Windows

Open ghost opened this issue 8 years ago • 9 comments

Go get fails for me:

$ go get -t -v github.com/zimmski/go-mutesting/...
github.com/zimmski/go-mutesting (download)
github.com/jessevdk/go-flags (download)
github.com/zimmski/go-tool (download)
github.com/zimmski/osutil (download)
github.com/stretchr/testify/vendor/github.com/pmezard/go-difflib/difflib
github.com/zimmski/go-mutesting/mutator
github.com/jessevdk/go-flags
golang.org/x/tools/go/buildutil
github.com/zimmski/go-mutesting/astutil
github.com/zimmski/go-tool/importing
golang.org/x/tools/go/ast/astutil
github.com/stretchr/testify/vendor/github.com/davecgh/go-spew/spew
github.com/zimmski/go-mutesting/mutator/expression
github.com/zimmski/go-mutesting/mutator/branch
github.com/zimmski/go-mutesting/mutator/statement
github.com/zimmski/go-mutesting/example
github.com/zimmski/go-mutesting/example/sub
github.com/stretchr/testify/assert
golang.org/x/tools/go/loader
github.com/zimmski/go-mutesting
github.com/zimmski/osutil
github.com/zimmski/go-mutesting/test
# github.com/zimmski/osutil
\Local\Temp\go-build052092062\github.com\zimmski\osutil\_obj\_cgo_main.o:_cgo_main.c:(.data+0x0): undefined reference to `stdout'
\Local\Temp\go-build052092062\github.com\zimmski\osutil\_obj\_cgo_main.o:_cgo_main.c:(.data+0x8): undefined reference to `stderr'
collect2.exe: error: ld returned 1 exit status

ghost avatar Sep 11 '17 21:09 ghost

Are you using windows?

zimmski avatar Mar 02 '18 21:03 zimmski

Yes, that was run on a Windows Machine.

ghost avatar Mar 02 '18 21:03 ghost

I am really sorry but I do not have a Windows machine to try to solve this. Can you help me?

zimmski avatar Mar 02 '18 21:03 zimmski

Got it working! :)

I was trying to reach your tool for some research, but am using Windows, and more importantly, I'm clueless about Go tooling.... So I set out on a small journey to get this working.

Compiling on Windows itself is annoying, but luckily Go supports easy cross-compilation. So I could compile in a docker container for Windows. Unfortunately, when trying that, you get errors about osutil having undefined things (https://github.com/zimmski/osutil/blob/master/limits.go#L9 specifically) . So that's a problem.

But..... I noticed https://github.com/prestonvanloon/go-mutesting/commit/3a7f002d781bd15553a48edd88918df95dd3a33c in a fork, that seems interesting! So I applied it locally, but Go will in some places just pull in github.com/zimmski/go-mutesting, and not use the "in-repo" osutil , that's annoying.....

Then I took a very blunt approach, and I'm want to hear if this overkill or wrong @zimmski !, I just replaced your username with mine everywhere, pushed my changes to my fork and it worked.

So, at the root of the repo (my fork), run: docker run --rm -v ${PWD}:/usr/src/myapp -w /usr/src/myapp -e GOOS=windows -e GOARCH=amd64 golang:1.8 /bin/bash -c "make install-dependencies install-tools install && cp /go/bin/windows_amd64/go-mutesting.exe /usr/src/myapp/bin"

afraca avatar Oct 06 '18 12:10 afraca

(Actually I know it's overkill to replace everywhere (especially README), but it was easiest and I'm out of time for today....)

afraca avatar Oct 06 '18 12:10 afraca

(Sorry for the spam)

It doesn't really seem to work 👎 There doesn't have to be any compilation of the mutated source code if I specify --no-exec right? I'm trying to mutate the docker/engine source but gets hundreds of errors like

PS C:\go\src\github.com\docker\docker> .\go-mutesting.exe /no-exec ./...       

C:\go\src\github.com\docker\docker\vendor\github.com\moby\buildkit\util\apicaps\caps.go:12:12: expected type, found '=' (and 1 more errors)                                                                                                     C:\go\src\internal\cpu\cpu_x86.go:9:7: CacheLineSize redeclared in this block             

C:\go\src\github.com\docker\docker\vendor\github.com\moby\buildkit\solver\llbsolver\bridge.go:99:24: 
invalid operation: req (variable of type github.com/docker/docker/vendor/github.com/moby/buildkit/frontend.SolveRequest) has no field or method Frontend 

Will now move to just doing things completely in a container, bit clumsy but ok.


edit: Switched to Go 1.11.1 , then something like this seems to work for some part:

docker run -it --rm -v ${PWD}:/usr/src/myapp -w /usr/src/myapp -v C:\go\src\github.com\docker\docker:/go/src/github.com/docker/docker golang:1.11.1
make install-dependencies install-tools install
/go/bin/go-mutesting --debug --no-exec /go/src/github.com/docker/docker/...

afraca avatar Oct 06 '18 17:10 afraca

@afraca: The usual workflow I use when I fork a project for doing a PR to said project is: Checkout the project in the correct subdirectory (e.g. ~/go/src/github.com/zimmski/go-mutesting on my computer), then add a "fork" git "remote" to the repository, and then work with branches pushed to the fork repository. This makes it possible to use the correct namespace/path even though it is not a repository you have write access to.

zimmski avatar Oct 31 '18 19:10 zimmski

@afraca: The osutil problem should be already solved. So please give it another whirl!

zimmski avatar Oct 31 '18 19:10 zimmski

@afraca: The "no-exec" option should generate all mutations for the given package(s) but should not execute any test suite. I tried the "no-exec" option with go-mutesting --verbose --no-exec github.com/zimmski/osutil/... I had no problems. Can you test again with the latest version?

zimmski avatar Oct 31 '18 19:10 zimmski