Skip to content

endtoend: Add per-test configuration files #521

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

Merged
merged 1 commit into from
May 24, 2020
Merged
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: 20 additions & 0 deletions internal/endtoend/endtoend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"bufio"
"bytes"
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
Expand Down Expand Up @@ -45,6 +46,10 @@ func TestExamples(t *testing.T) {
}
}

type testConfig struct {
ExperimentalParserOnly bool `json:"experimental_parser_only"`
}

func TestReplay(t *testing.T) {
t.Parallel()
files, err := ioutil.ReadDir("testdata")
Expand Down Expand Up @@ -73,6 +78,21 @@ func TestReplay(t *testing.T) {
t.Run(tc+"/deprecated-parser", func(t *testing.T) {
t.Parallel()
path, _ := filepath.Abs(filepath.Join("testdata", tc))
// TODO: Extract test configuration into a method
confPath := filepath.Join(path, "endtoend.json")
if _, err := os.Stat(confPath); !os.IsNotExist(err) {
blob, err := ioutil.ReadFile(confPath)
if err != nil {
t.Fatal(err)
}
var conf testConfig
if err := json.Unmarshal(blob, &conf); err != nil {
t.Fatal(err)
}
if conf.ExperimentalParserOnly {
t.Skip("experimental parser only")
}
}
var stderr bytes.Buffer
expected := expectedStderr(t, path)
output, err := cmd.Generate(cmd.Env{ExperimentalParser: false}, path, &stderr)
Expand Down