Skip to content
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ bin/
.DS_Store
.idea/
*.iml

# TCK tests configs
/tests/tck/TestCases/
24 changes: 13 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
RESOURCES_DIR=resources
TCK_DIR=$(RESOURCES_DIR)/tck
TCK_REPO=https://github.com/dmn-tck/tck.git
TEST_CONFIG_FILE=./test-cases_feel.yaml

GO_FILES := $(shell find . -name '*.go')
GO_FLAGS :=

all: build

test:
go test -v ./...
go test $$(go list ./... | grep -v /tests/tck)

cover:
go test -coverprofile=coverage.out ./...
Expand All @@ -28,14 +23,21 @@ bin/feel: ${GO_FILES}

clean:
rm -rf build dist bin/*
rm -rf $(TCK_DIR)
rm -rf resources/
rm -rf tests/tck/TestCases/

.PHONY: test gofmt build-cli clean
.SECONDARY: $(buildarchdirs)

.PHONY: extract-testcases
extract-testcases:
mkdir -p $(RESOURCES_DIR)
git clone --depth 1 $(TCK_REPO) $(TCK_DIR)
go run ./cmd/testcase-extractor --dir $(TCK_DIR) --output-file $(TEST_CONFIG_FILE)
rm -rf $(TCK_DIR)
mkdir -p resources/
git clone --depth 1 https://github.com/dmn-tck/tck.git resources/tck/
go run ./cmd/testcase-extractor --dir resources/tck --output-dir tests/tck/
rm -rf resources/


.PHONY: test-tck
test-tck:
go test ./tests/tck

59 changes: 59 additions & 0 deletions cmd/testcase-extractor/fs/fs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package fs

import (
"fmt"
"os"
"path/filepath"
)

// EnsureDir make sure the dir exists - checks that dir exists,
// if not creates it, including parent dirs.
func EnsureDir(outputDirPath string) {
err := os.MkdirAll(outputDirPath, 0755)
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Error creating directory: %v\n", err)
return
}
}

// FindFiles traverses the directory tree starting at dir and returns files
// matching the wildcard pattern
func FindFiles(dir, wildcard string, inSubDirs bool) []string {
var filePaths []string

if _, err := os.Stat(dir); os.IsNotExist(err) {
_, _ = fmt.Fprintf(os.Stderr, "Error: Directory '%s' does not exist\n", dir)
os.Exit(1)
}

var err error
if inSubDirs {
err = filepath.WalkDir(dir, func(path string, d os.DirEntry, err error) error {
if err != nil {
return err
}
if !d.IsDir() {
matched, err := filepath.Match(wildcard, d.Name())
if err != nil {
return err
}
if matched {
filePaths = append(filePaths, path)
}
}
return nil
})
} else {
var matches []string
matches, err = filepath.Glob(wildcard)

filePaths = append(filePaths, matches...)
}

if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}

return filePaths
}
Loading