-
Notifications
You must be signed in to change notification settings - Fork 11
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
Port to Windows #216
Port to Windows #216
Conversation
it keeps the naming consistent and makes it easier to figure out what the difference between e.g. the test and test_windows targets are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great, thanks a lot for the PR
"testing" | ||
) | ||
|
||
func TestEchoStdout(t *testing.T) { | ||
const echoStr = "hello world!" | ||
|
||
res, err := Command("echo", "-n", echoStr).Run() | ||
// Windows returns StrOutput with surrounding quotation marks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The windows echo command prints the string quoted?
Or all output that is returned from running commands via the stdlib exec
package is quoted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have investigated this further and the results are quite interesting.
I created a simple app that runs a few different commands with a couple of different inputs, I then ran this on Windows and Linux.
Here are the results:
Running on Windows
Running on Linux
Summary:
- cmd adds quotation marks around the string if it contains spaces
- PowerShell wraps the output onto a new line at the space if it contains spaces
- more on Linux outputs headers and footers, Windows doesn't
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so the echo
command is probably also a shell builtin command like for bash and the implementation of it in cmd and PowerShell differ.
When commands are invoked without a shell, the output that is returned by the exec
package should not be quoted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is my understanding.
Windows doesn't have an echo executable so it must be invoked from a shell. However it does have a more executable and when it is invoked the file contents are not quoted.
I noticed that the test results were not being reported in CircleCI. After a bit of investigation I found that the go-test-report.xml file was being generated with Unicode encoding which was causing the problem. |
This change set addresses #94 and ports baur to Windows. The
make release
command will create a baur.exe file.Things to note:
cmd /C
on Windows.-race
flag has been removed from the Windowsgo test
command as a gcc compiler is not installed. I figured this wasn't a problem as it is used in the existing test job. This could be addressed later if necessary.