jostyee / gomock

Automatically exported from code.google.com/p/gomock
Apache License 2.0
0 stars 0 forks source link

Loading input failed: : exec: "C:\\[...]\\Temp\\gomock_reflect_569018487\\prog.bin": file does not exist #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
C:\Users\Bruno>mockgen net/http Client
2013/04/01 16:35:05 Loading input failed: exec: 
"C:\\Users\\Bruno\\AppData\\Local\\Temp\\gomock_reflect_674068563\\prog.bin": 
file does not exist

What steps will reproduce the problem?
1. mockgen net/http Client

What is the expected output? What do you see instead?
I have no idea since I'm using this tool for the first time. I wish to mock 
http.PostForm(). I saw the syntax with mockgen -h

What version of the product are you using? On what operating system?
go version go1.0.3
Windows 8 (64 bits)
Latest version of both gomock and mockgen

Original issue reported on code.google.com by bigras.b...@gmail.com on 1 Apr 2013 at 8:35

GoogleCodeExporter commented 9 years ago
Hmm. I suspect that's a Windows problem.

Can you see what other files are created in that directory?

Original comment by dsymo...@golang.org on 1 Apr 2013 at 9:52

GoogleCodeExporter commented 9 years ago
The directory doesn't seems to exist after mockgen exits.

C:\Users\Bruno>mockgen net/http Client
2013/04/01 17:54:55 Loading input failed: exec: 
"C:\\Users\\Bruno\\AppData\\Local\\Temp\\gomock_reflect_736510951\\prog.bin": 
file does not exist

C:\Users\Bruno>dir 
C:\\Users\\Bruno\\AppData\\Local\\Temp\\gomock_reflect_736510951
Le chemin d’accès spécifié n'est pas valide.

(the last line mean the directory doesn't exists)

Original comment by bigras.b...@gmail.com on 1 Apr 2013 at 9:58

GoogleCodeExporter commented 9 years ago
Can you try one more thing for me? (sorry, I don't have easy access to a 
Windows machine)

Wherever gomock has been installed (probably 
$GOPATH/src/code.google.com/p/gomock), edit mockgen/reflect.go, find the line 
that says
  defer func() { os.RemoveAll(tmpDir) }()
and delete or comment it out. Then run
  go install code.google.com/p/gomock/mockgen
and try again? The temporary directory should be left behind so we can see 
what's going wrong.

Original comment by dsymo...@golang.org on 1 Apr 2013 at 10:03

GoogleCodeExporter commented 9 years ago
Without the defer, I got 'prog.bin' and 'prog.go' in the directory.

I played a bit with the code and I was able to temporary fix it by changing :
const progBinary = "prog.bin"
to:
const progBinary = "prog.bin.exe"

It seems Run() whine if it doesn't think the file is an executable.

Now I got :
C:\Users\Bruno>mockgen net/http Client
Reflection: http.Client is not an interface
2013/04/01 18:28:48 Loading input failed: exit status 1

C:\Users\Bruno>C:\Users\Bruno\AppData\Local\Temp\gomock_reflect_132250887\prog.b
in.exe
Reflection: http.Client is not an interface

How can I mock http.Client (without using httptest)?

Original comment by bigras.b...@gmail.com on 1 Apr 2013 at 10:32

GoogleCodeExporter commented 9 years ago
I've got a fix on the way for the filename extension muck. Thanks for helping 
debug that.

mockgen only produces mocks for interfaces. http.Client isn't an interface. 
Depending on what you are trying to test, you might want to mock 
http.RoundTripper instead, and plug that into a real http.Client.

Original comment by dsymo...@golang.org on 2 Apr 2013 at 2:53

GoogleCodeExporter commented 9 years ago
Ok, thanks!

Original comment by bigras.b...@gmail.com on 2 Apr 2013 at 2:57

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 25dd25bab010.

Original comment by dsymo...@golang.org on 2 Apr 2013 at 10:55

GoogleCodeExporter commented 9 years ago
Thanks!

Original comment by bigras.b...@gmail.com on 2 Apr 2013 at 10:58