Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore out own tests #63

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions yaml/testcase.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package yaml

import (
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -30,27 +31,34 @@ func ReadTestCases() ([]*TestCase, string) {
panic(err)
}

cases, err := collectTestCases(base, duration)
cases, err := collectTestCases(base, duration, true)
if err != nil {
panic(err)
}

return cases, base
}

func collectTestCases(base string, duration time.Duration) ([]*TestCase, error) {
func collectTestCases(base string, duration time.Duration, evaluateIgnoreFile bool) ([]*TestCase, error) {
var cases []*TestCase
err := filepath.WalkDir(base, func(p string, d os.DirEntry, err error) error {
if err != nil {
return err
}
if strings.HasPrefix(p, "oats/yaml") {
// skip the test framework which might be checked out in the same directory
return nil
}
if !oatsFileRegex.MatchString(d.Name()) || strings.Contains(d.Name(), "-template.yaml") {
return nil
}
if evaluateIgnoreFile {
if _, err := os.Stat(filepath.Join(p, ".oatsignore")); errors.Is(err, os.ErrNotExist) {
// ignore file does not exist
} else {
// ignore file exists
println("ignoring", p)
return nil
}
}

println("adding", p)
testCase, err := readTestCase(base, p, duration)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion yaml/testcase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestIncludePath(t *testing.T) {
}

func TestCollectTestCases(t *testing.T) {
cases, err := collectTestCases("testdata", 0)
cases, err := collectTestCases("testdata", 0, false)
require.NoError(t, err)
require.Len(t, cases, 2)
require.Equal(t, "runfoo-oats", cases[0].Name)
Expand Down
Empty file added yaml/testdata/.oatsignore
Empty file.