(t *testing.T)
| 1277 | } |
| 1278 | |
| 1279 | func TestIncludesHttp(t *testing.T) { |
| 1280 | enableExperimentForTest(t, &experiments.RemoteTaskfiles, 1) |
| 1281 | |
| 1282 | dir, err := filepath.Abs("testdata/includes_http") |
| 1283 | require.NoError(t, err) |
| 1284 | |
| 1285 | srv := httptest.NewServer(http.FileServer(http.Dir(dir))) |
| 1286 | defer srv.Close() |
| 1287 | |
| 1288 | t.Cleanup(func() { |
| 1289 | // This test fills the .task/remote directory with cache entries because the include URL |
| 1290 | // is different on every test due to the dynamic nature of the TCP port in srv.URL |
| 1291 | if err := os.RemoveAll(filepath.Join(dir, ".task")); err != nil { |
| 1292 | t.Logf("error cleaning up: %s", err) |
| 1293 | } |
| 1294 | }) |
| 1295 | |
| 1296 | taskfiles, err := fs.Glob(os.DirFS(dir), "root-taskfile-*.yml") |
| 1297 | require.NoError(t, err) |
| 1298 | |
| 1299 | remotes := []struct { |
| 1300 | name string |
| 1301 | root string |
| 1302 | }{ |
| 1303 | { |
| 1304 | name: "local", |
| 1305 | root: ".", |
| 1306 | }, |
| 1307 | { |
| 1308 | name: "http-remote", |
| 1309 | root: srv.URL, |
| 1310 | }, |
| 1311 | } |
| 1312 | |
| 1313 | for _, taskfile := range taskfiles { |
| 1314 | t.Run(taskfile, func(t *testing.T) { |
| 1315 | for _, remote := range remotes { |
| 1316 | t.Run(remote.name, func(t *testing.T) { |
| 1317 | t.Setenv("INCLUDE_ROOT", remote.root) |
| 1318 | entrypoint := filepath.Join(dir, taskfile) |
| 1319 | |
| 1320 | var buff SyncBuffer |
| 1321 | e := task.NewExecutor( |
| 1322 | task.WithEntrypoint(entrypoint), |
| 1323 | task.WithDir(dir), |
| 1324 | task.WithStdout(&buff), |
| 1325 | task.WithStderr(&buff), |
| 1326 | task.WithInsecure(true), |
| 1327 | task.WithDownload(true), |
| 1328 | task.WithAssumeYes(true), |
| 1329 | task.WithStdout(&buff), |
| 1330 | task.WithStderr(&buff), |
| 1331 | task.WithVerbose(true), |
| 1332 | task.WithTimeout(time.Minute), |
| 1333 | ) |
| 1334 | require.NoError(t, e.Setup()) |
| 1335 | defer func() { t.Log("output:", buff.buf.String()) }() |
| 1336 |
nothing calls this directly
no test coverage detected
searching dependent graphs…