| 1776 | } |
| 1777 | |
| 1778 | func TestSummary(t *testing.T) { |
| 1779 | t.Parallel() |
| 1780 | |
| 1781 | const dir = "testdata/summary" |
| 1782 | |
| 1783 | var buff bytes.Buffer |
| 1784 | e := task.NewExecutor( |
| 1785 | task.WithDir(dir), |
| 1786 | task.WithStdout(&buff), |
| 1787 | task.WithStderr(&buff), |
| 1788 | task.WithSummary(true), |
| 1789 | task.WithSilent(true), |
| 1790 | ) |
| 1791 | require.NoError(t, e.Setup()) |
| 1792 | require.NoError(t, e.Run(t.Context(), &task.Call{Task: "task-with-summary"}, &task.Call{Task: "other-task-with-summary"})) |
| 1793 | |
| 1794 | data, err := os.ReadFile(filepathext.SmartJoin(dir, "task-with-summary.txt")) |
| 1795 | require.NoError(t, err) |
| 1796 | |
| 1797 | expectedOutput := string(data) |
| 1798 | if runtime.GOOS == "windows" { |
| 1799 | expectedOutput = strings.ReplaceAll(expectedOutput, "\r\n", "\n") |
| 1800 | } |
| 1801 | |
| 1802 | assert.Equal(t, expectedOutput, buff.String()) |
| 1803 | } |
| 1804 | |
| 1805 | func TestWhenNoDirAttributeItRunsInSameDirAsTaskfile(t *testing.T) { |
| 1806 | t.Parallel() |