diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ef3e9fd..2cb2fcb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,4 +43,4 @@ jobs: run: | zip -r MDX.zip MDX -x "*.DS_Store" cd testdata && ../bin/vale sync && cd - - go test -v ./... + go run main.go diff --git a/.gitignore b/.gitignore index ab05532..d84379d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ MDX.zip /testdata/styles +/testdata/out.md # Binaries for programs and plugins *.exe diff --git a/MDX/.vale.ini b/MDX/.vale.ini index 58c31fb..d1f1a54 100644 --- a/MDX/.vale.ini +++ b/MDX/.vale.ini @@ -11,11 +11,11 @@ CommentDelimiters = {/*, */} # `...` # `{ ... }` TokenIgnores = (?sm)((?:import|export) .+?$), \ -(<[A-Z]+ ?.+ ?\/>), \ +(?)(?!`), \ (<[A-Z]\w+>.+?<\/[A-Z]\w+>) # Exclude: # # `` BlockIgnores = (?sm)^(<\w+\n .*\s\/>)$, \ -(?sm)^({.+\n.*}) +(?sm)^({.+.*}) diff --git a/Makefile b/Makefile index 7a05cb1..33e7b4e 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,6 @@ zip: zip -r MDX.zip MDX -x "*.DS_Store" sync: - cd testdata && vale sync && vale transform test.mdx > test.md && cd - + cd testdata && vale sync && vale transform test.mdx > out.md && cd - test: zip sync diff --git a/go.mod b/go.mod index ade82c3..8c294fa 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,3 @@ -module github.com/errata-ai/Hugo +module github.com/errata-ai/MDX go 1.17 - -require github.com/google/go-cmdtest v0.4.0 - -require ( - github.com/google/go-cmp v0.3.1 // indirect - github.com/google/renameio v0.1.0 // indirect -) diff --git a/go.sum b/go.sum deleted file mode 100644 index 57cabf1..0000000 --- a/go.sum +++ /dev/null @@ -1,6 +0,0 @@ -github.com/google/go-cmdtest v0.4.0 h1:ToXh6W5spLp3npJV92tk6d5hIpUPYEzHLkD+rncbyhI= -github.com/google/go-cmdtest v0.4.0/go.mod h1:apVn/GCasLZUVpAJ6oWAuyP7Ne7CEsQbTnc0plM3m+o= -github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= diff --git a/main.go b/main.go index 2ce8d07..d2d6887 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,28 @@ package main -import "os" +import ( + "errors" + "os" + "path/filepath" +) -func cdf() int { - os.Chdir(os.Args[1]) - return 0 +func main() { + expected := filepath.Join("testdata", "in.md") + observed := filepath.Join("testdata", "out.md") + + // Read the expected and observed files + expectedContent, err := os.ReadFile(expected) + if err != nil { + panic(err) + } + + observedContent, err := os.ReadFile(observed) + if err != nil { + panic(err) + } + + // Compare the contents of the files + if string(expectedContent) != string(observedContent) { + panic(errors.New("expected and observed files do not match")) + } } diff --git a/main_test.go b/main_test.go deleted file mode 100644 index 3b04cbb..0000000 --- a/main_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "os" - "os/exec" - "path/filepath" - "runtime" - "testing" - - "github.com/google/go-cmdtest" -) - -var update = flag.Bool("update", false, "replace test file contents with output") - -func Test(t *testing.T) { - ts, err := cmdtest.Read("testdata") - if err != nil { - t.Fatal(err) - } - - ts.Setup = func(_ string) error { - _, testFileName, _, ok := runtime.Caller(0) - if !ok { - return fmt.Errorf("failed get real working directory from caller") - } - - projectRootDir := filepath.Join(filepath.Dir(testFileName), "testdata") - if err := os.Setenv("ROOTDIR", projectRootDir); err != nil { - return fmt.Errorf("failed change 'ROOTDIR' to caller working directory: %v", err) - } - - return nil - } - - path, err := exec.LookPath("vale") - if err != nil { - path = "./bin/vale" - } - - ts.Commands["vale"] = cmdtest.Program(path) - ts.Commands["cdf"] = cmdtest.InProcessProgram("cdf", cdf) - - ts.Run(t, *update) -} diff --git a/testdata/test.md b/testdata/in.md similarity index 95% rename from testdata/test.md rename to testdata/in.md index 3c0fc60..effd447 100644 --- a/testdata/test.md +++ b/testdata/in.md @@ -21,7 +21,7 @@ An `external` component and a `local one`. `` You can also use objects with components, such as the `thisOne` component on -the `myComponents` object: +the `myComponents` object: `` ```