Skip to content

Commit

Permalink
stdinservice_test: Simplify platform differences
Browse files Browse the repository at this point in the history
Python auto-converts newlines into the platform-dependent form, which trips up
our equality check.  Make sure that we don't have newlines in the output.

PiperOrigin-RevId: 704729437
  • Loading branch information
gnoack authored and copybara-github committed Dec 10, 2024
1 parent ceb2de0 commit 8c06395
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions fleetspeak/src/client/stdinservice/stdinservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestStdinServiceWithEcho(t *testing.T) {
&fspb.Message{
MessageType: "StdinServiceInputMessage",
Data: anypbtest.New(t, &sspb.InputMessage{
Args: []string{"-c", `print("foo bar")`},
Args: []string{"-c", `print("foo bar", end="")`},
}),
})
if err != nil {
Expand All @@ -70,10 +70,8 @@ func TestStdinServiceWithEcho(t *testing.T) {
t.Fatal(err)
}

wantStdout := []byte("foo bar\n")
wantStdoutWin := []byte("foo bar\r\n")
if !bytes.Equal(om.Stdout, wantStdout) &&
!bytes.Equal(om.Stdout, wantStdoutWin) {
wantStdout := []byte("foo bar")
if !bytes.Equal(om.Stdout, wantStdout) {
t.Fatalf("unexpected output; got %q, want %q", om.Stdout, wantStdout)
}
}
Expand Down Expand Up @@ -109,7 +107,7 @@ except NameError:
try:
while True:
print(my_input())
print(my_input(), end="")
except EOFError:
pass
`},
Expand All @@ -132,10 +130,8 @@ except EOFError:
t.Fatal(err)
}

wantStdout := []byte("foo bar\n")
wantStdoutWin := []byte("foo bar\r\n")
if !bytes.Equal(om.Stdout, wantStdout) &&
!bytes.Equal(om.Stdout, wantStdoutWin) {
wantStdout := []byte("foo bar")
if !bytes.Equal(om.Stdout, wantStdout) {
t.Fatalf("unexpected output; got %q, want %q", om.Stdout, wantStdout)
}
}
Expand Down

0 comments on commit 8c06395

Please sign in to comment.