Fix TestExternalShellEscaping and TestExternalShellEscapeIncludingSpaces on darwin
TestExternalShellEscaping and TestExternalShellEscapeIncludingSpaces use "echo -n", which fails on darwin. These tests weren't running on darwin because they were only run in Soong, which always limits to only short tests. The test are now run in aosp-build-tools, which doesn't limit to short tests. Remove the unsupported -n argument from echo and trim the added newline instead. Test: TestExternalShellEscaping and TestExternalShellEscapeIncludingSpaces Change-Id: I3d8ff1c0db0af386e1dc13cb6c2dabe561c1c89e
This commit is contained in:
parent
516ef4f48e
commit
0bb75189da
1 changed files with 5 additions and 2 deletions
|
@ -15,6 +15,7 @@
|
||||||
package proptools
|
package proptools
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -143,8 +144,9 @@ func TestExternalShellEscaping(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, testCase := range shellEscapeTestCase {
|
for _, testCase := range shellEscapeTestCase {
|
||||||
cmd := "echo -n " + ShellEscape(testCase.in)
|
cmd := "echo " + ShellEscape(testCase.in)
|
||||||
got, err := exec.Command("/bin/sh", "-c", cmd).Output()
|
got, err := exec.Command("/bin/sh", "-c", cmd).Output()
|
||||||
|
got = bytes.TrimSuffix(got, []byte("\n"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
@ -159,8 +161,9 @@ func TestExternalShellEscapeIncludingSpaces(t *testing.T) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, testCase := range shellEscapeIncludingSpacesTestCase {
|
for _, testCase := range shellEscapeIncludingSpacesTestCase {
|
||||||
cmd := "echo -n " + ShellEscapeIncludingSpaces(testCase.in)
|
cmd := "echo " + ShellEscapeIncludingSpaces(testCase.in)
|
||||||
got, err := exec.Command("/bin/sh", "-c", cmd).Output()
|
got, err := exec.Command("/bin/sh", "-c", cmd).Output()
|
||||||
|
got = bytes.TrimSuffix(got, []byte("\n"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue