
* proc: add tests for command-line arguments adds tests to make sure command-line arguments are passed to Launch() properly * proc_windows: pass command-line arguments to CreateProcess() build command-line arguments according to how the standard library does it and pass the command line along to the actual syscall on Windows. see discussion in #479 * proc: better testing of cmd-line arguments * proc_windows: fix a possible error-case with passing just 1 argument previously, the command line pointer passed to sys.CreateProcess was empty, if we had 0 parameters (len(cmd) == 1, as cmd[0] is the executable, so no cmdlineGo would be created, while with any argument it would as len(cmd) > 1). This might cause problems down the road, so make sure we include the command line every time, even if it seems to work without. * proc: improve testing of command-line arguments test that arguments with spaces are passed on correctly and DRY failure/success condition checking in the args test
21 lines
471 B
Go
21 lines
471 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
// this test expects AT LEAST 1 argument, and the first one needs to be "test".
|
|
// second one is optional but if given, it should be "-passFlag"
|
|
fmt.Printf("received args %#v\n", os.Args)
|
|
if len(os.Args) < 2 {
|
|
panic("os.args too short!")
|
|
} else if os.Args[1] != "test" {
|
|
panic("os.args[1] is not test!")
|
|
}
|
|
if len(os.Args) >= 3 && os.Args[2] != "pass flag" {
|
|
panic("os.args[2] is not \"pass flag\"!")
|
|
}
|
|
}
|