mirror of
https://github.com/go-task/task.git
synced 2025-11-25 22:32:55 +02:00
Fix summary test on Windows
This commit is contained in:
16
task_test.go
16
task_test.go
@@ -7,6 +7,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -608,13 +609,16 @@ func TestSummary(t *testing.T) {
|
|||||||
}
|
}
|
||||||
assert.NoError(t, e.Setup())
|
assert.NoError(t, e.Setup())
|
||||||
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-summary"}, taskfile.Call{Task: "other-task-with-summary"}))
|
assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-summary"}, taskfile.Call{Task: "other-task-with-summary"}))
|
||||||
assert.Equal(t, readTestFixture(t, dir, "task-with-summary.txt"), buff.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
func readTestFixture(t *testing.T, dir string, file string) string {
|
data, err := ioutil.ReadFile(filepath.Join(dir, "task-with-summary.txt"))
|
||||||
b, err := ioutil.ReadFile(dir + "/" + file)
|
assert.NoError(t, err)
|
||||||
assert.NoError(t, err, "error reading text fixture")
|
|
||||||
return string(b)
|
expectedOutput := string(data)
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
expectedOutput = strings.Replace(expectedOutput, "\r\n", "\n", -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Equal(t, expectedOutput, buff.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWhenNoDirAttributeItRunsInSameDirAsTaskfile(t *testing.T) {
|
func TestWhenNoDirAttributeItRunsInSameDirAsTaskfile(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user