TODO: mock fs
(t *testing.T)
| 524 | |
| 525 | // TODO: mock fs |
| 526 | func TestStatus(t *testing.T) { |
| 527 | t.Parallel() |
| 528 | |
| 529 | const dir = "testdata/status" |
| 530 | |
| 531 | files := []string{ |
| 532 | "foo.txt", |
| 533 | "bar.txt", |
| 534 | "baz.txt", |
| 535 | } |
| 536 | |
| 537 | for _, f := range files { |
| 538 | path := filepathext.SmartJoin(dir, f) |
| 539 | _ = os.Remove(path) |
| 540 | if _, err := os.Stat(path); err == nil { |
| 541 | t.Errorf("File should not exist: %v", err) |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | // gen-foo creates foo.txt, and will always fail it's status check. |
| 546 | NewExecutorTest(t, |
| 547 | WithName("run gen-foo 1 silent"), |
| 548 | WithExecutorOptions( |
| 549 | task.WithDir(dir), |
| 550 | task.WithSilent(true), |
| 551 | ), |
| 552 | WithTask("gen-foo"), |
| 553 | ) |
| 554 | // gen-foo creates bar.txt, and will pass its status-check the 3. time it |
| 555 | // is run. It creates bar.txt, but also lists it as its source. So, the checksum |
| 556 | // for the file won't match before after the second run as we the file |
| 557 | // only exists after the first run. |
| 558 | NewExecutorTest(t, |
| 559 | WithName("run gen-bar 1 silent"), |
| 560 | WithExecutorOptions( |
| 561 | task.WithDir(dir), |
| 562 | task.WithSilent(true), |
| 563 | ), |
| 564 | WithTask("gen-bar"), |
| 565 | ) |
| 566 | // gen-silent-baz is marked as being silent, and should only produce output |
| 567 | // if e.Verbose is set to true. |
| 568 | NewExecutorTest(t, |
| 569 | WithName("run gen-baz silent"), |
| 570 | WithExecutorOptions( |
| 571 | task.WithDir(dir), |
| 572 | task.WithSilent(true), |
| 573 | ), |
| 574 | WithTask("gen-silent-baz"), |
| 575 | ) |
| 576 | |
| 577 | for _, f := range files { |
| 578 | if _, err := os.Stat(filepathext.SmartJoin(dir, f)); err != nil { |
| 579 | t.Errorf("File should exist: %v", err) |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | // Run gen-bar a second time to produce a checksum file that matches bar.txt |
nothing calls this directly
no test coverage detected
searching dependent graphs…