T_old icon indicating copy to clipboard operation
T_old copied to clipboard

edit: pipe tests assume the availability of certain programs (echo, /bin/sh, etc.)

Open rogpeppe opened this issue 10 years ago • 5 comments

I use rc for a shell, and the Pipe tests fail like this, because they're using sh-specific syntax:

edit_test.go:514: ed.Do("$|echo -n stderr 1>&2\n", pr)=exit status 1, want <nil>

I'd suggest changing the shell to /bin/sh for the test (although that will still fail under windows)

rogpeppe avatar Jan 15 '16 17:01 rogpeppe

This is a known problem. I'm surprised that I didn't have an issue already open for it. Thanks for opening one.

eaburns avatar Jan 15 '16 17:01 eaburns

There are really two problems here:

  1. The tests assume a particular set of programs are available.
  2. We always use -c to pass commands to $SHELL, and that's not valid on Windows. I'm going to re-devote this to the first since that was the original intent.

There are various ways that we can fix the tests. For example, we can create programs that do what we want and include them in the distribution. That seems heavy-weight. It needs some thought.

eaburns avatar Jan 15 '16 18:01 eaburns

sed also behaves differently on OSX:

--- FAIL: TestEditPipe (0.07s)
    edit_test.go:2248: [.|sed 's/世界/World/'
        ]: "empty replaces" got "{.}Hello World\n{.}", want "{.}Hello World{.}"
--- FAIL: TestEditPipeFromString (0.06s)
    edit_test.go:2248: [.|sed 's/世界/World/'
        ]: "empty replaces" got "{.}Hello World\n{.}", want "{.}Hello World{.}"
--- FAIL: TestPipeDefaultShell (0.09s)
    edit_test.go:2251: print stderr: printed "-n stderr\n", want "stderr"
    edit_test.go:2248: [0,$|echo -n Hello 世界
        ]: "empty inserts" got "{.}-n Hello 世界\n{.}", want "{.}Hello 世界{.}"
    edit_test.go:2248: [.|sed 's/世界/World/'
        ]: "empty replaces" got "{.}Hello World\n{.}", want "{.}Hello World{.}"

eaburns avatar Apr 04 '16 14:04 eaburns

That is BSD sed and Plan 9 sed behavior. Maybe just toss a \n into the input here and expect it in the output; it doesn't look important to these tests to not have a newline. (At least until a proper fix is made.)

mccoyst avatar Apr 04 '16 14:04 mccoyst

That may be a workaround for the moment, but the underlying problem still exists. What I'd really like is to have some programs distributed with T to run for these tests. Then we will have total control.

eaburns avatar Apr 04 '16 14:04 eaburns