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

Support go-mutesting on Windows #58

Open
ghost opened this issue Sep 11, 2017 · 9 comments
Open

Support go-mutesting on Windows #58

ghost opened this issue Sep 11, 2017 · 9 comments

Comments

@ghost
Copy link

ghost commented Sep 11, 2017

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
@zimmski
Copy link
Owner

zimmski commented Mar 2, 2018

Are you using windows?

@ghost
Copy link
Author

ghost commented Mar 2, 2018

Yes, that was run on a Windows Machine.

@zimmski
Copy link
Owner

zimmski commented Mar 2, 2018

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

@zimmski zimmski changed the title Go get fails ... Support go-mutestng on Windows Aug 4, 2018
@afraca
Copy link

afraca commented Oct 6, 2018

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 prestonvanloon@3a7f002 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
Copy link

afraca commented Oct 6, 2018

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

@afraca
Copy link

afraca commented Oct 6, 2018

(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/...

@zimmski zimmski changed the title Support go-mutestng on Windows Support go-mutesting on Windows Oct 31, 2018
@zimmski
Copy link
Owner

zimmski commented Oct 31, 2018

@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
Copy link
Owner

zimmski commented Oct 31, 2018

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

@zimmski
Copy link
Owner

zimmski commented Oct 31, 2018

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants