From 4c51437199b542f21f8c618e803e3ddaca565aac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Sun, 17 Feb 2019 13:31:44 +0000 Subject: [PATCH] all: make remaining tests pass on Wine sed, cat, and diff may not be installed. Rewrite two tests to not use the first two, and skip the third if diff is not installed. --- cmd/gosh/main_test.go | 2 +- cmd/shfmt/main_test.go | 4 ++++ shell/source_test.go | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/gosh/main_test.go b/cmd/gosh/main_test.go index 66f1db166..d151df424 100644 --- a/cmd/gosh/main_test.go +++ b/cmd/gosh/main_test.go @@ -81,7 +81,7 @@ var interactiveTests = [][]string{ { "echo foo |\n", "> ", - "cat\n", + "read var; echo $var\n", "foo\n", }, { diff --git a/cmd/shfmt/main_test.go b/cmd/shfmt/main_test.go index 108b05e8c..4d76ac04b 100644 --- a/cmd/shfmt/main_test.go +++ b/cmd/shfmt/main_test.go @@ -8,6 +8,7 @@ import ( "bytes" "io/ioutil" "os" + "os/exec" "path/filepath" "regexp" "strings" @@ -49,6 +50,9 @@ func TestStdin(t *testing.T) { }) t.Run("Diff", func(t *testing.T) { + if _, err := exec.LookPath("diff"); err != nil { + t.Skip("skipping as the diff tool is not available") + } *diff = true defer func() { *diff = false }() in = strings.NewReader(" foo\nbar\n\n") diff --git a/shell/source_test.go b/shell/source_test.go index befb1aeec..cc4ae7e91 100644 --- a/shell/source_test.go +++ b/shell/source_test.go @@ -37,9 +37,9 @@ var mapTests = []struct { }, }, { - "a=$(echo foo | sed 's/o/a/g')", + "a=$(echo foo && echo bar)", map[string]expand.Variable{ - "a": {Kind: expand.String, Str: "faa"}, + "a": {Kind: expand.String, Str: "foo\nbar"}, }, }, }