| 1579 | } |
| 1580 | |
| 1581 | func TestIncludesInterpolation(t *testing.T) { // nolint:paralleltest // cannot run in parallel |
| 1582 | const dir = "testdata/includes_interpolation" |
| 1583 | tests := []struct { |
| 1584 | name string |
| 1585 | task string |
| 1586 | expectedErr bool |
| 1587 | expectedOutput string |
| 1588 | }{ |
| 1589 | {"include", "include", false, "include\n"}, |
| 1590 | {"include_with_env_variable", "include-with-env-variable", false, "include_with_env_variable\n"}, |
| 1591 | {"include_with_dir", "include-with-dir", false, "included\n"}, |
| 1592 | } |
| 1593 | t.Setenv("MODULE", "included") |
| 1594 | |
| 1595 | for _, test := range tests { // nolint:paralleltest // cannot run in parallel |
| 1596 | t.Run(test.name, func(t *testing.T) { |
| 1597 | var buff bytes.Buffer |
| 1598 | e := task.NewExecutor( |
| 1599 | task.WithDir(filepath.Join(dir, test.name)), |
| 1600 | task.WithStdout(&buff), |
| 1601 | task.WithStderr(&buff), |
| 1602 | task.WithSilent(true), |
| 1603 | ) |
| 1604 | require.NoError(t, e.Setup()) |
| 1605 | |
| 1606 | err := e.Run(t.Context(), &task.Call{Task: test.task}) |
| 1607 | if test.expectedErr { |
| 1608 | require.Error(t, err) |
| 1609 | } else { |
| 1610 | require.NoError(t, err) |
| 1611 | } |
| 1612 | assert.Equal(t, test.expectedOutput, buff.String()) |
| 1613 | }) |
| 1614 | } |
| 1615 | } |
| 1616 | |
| 1617 | func TestIncludesWithExclude(t *testing.T) { |
| 1618 | t.Parallel() |