Skip to content

Commit

Permalink
Add notes on adding failure test cases to CONTRIBUTING
Browse files Browse the repository at this point in the history
  • Loading branch information
200sc committed Mar 21, 2024
1 parent 942c291 commit a0b9faa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ Please raise issues for discussion before opening PRs (or ideally before startin
just to save time if its not the direction we want to take the project.

For small changes (anywhere from typos to non-breaking bug fixes) going straight to a PR is fine, but not required.

## Testing

This library is organized so `go test -v` will test tokenization, parsing, code generation, and the validity of the output generated code. Output code is validated via some integrated tests, and by relying on `go test` itself checking that output can be compiled.

If an example file fails tokenization, it can be added to `testTokenizeFiles` to track that failure and prevent regressions. Likewise for parsing, `TestReadFile` notes expected parsing output. Adding a variant that just ensures a file -can- be parsed, not ensuring a particular AST, is a welcome augmentation.

For generated code, add the example file to `generated/base` and add it's name, minus `.bop`, to `genTestFiles`.
6 changes: 3 additions & 3 deletions tokenize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
)

var testFiles = []string{
var testTokenizeFiles = []string{
"array_of_strings",
"all_consts",
"basic_arrays",
Expand All @@ -31,7 +31,7 @@ var testFiles = []string{

func TestTokenize(t *testing.T) {
t.Parallel()
for _, filename := range testFiles {
for _, filename := range testTokenizeFiles {
filename := filename
t.Run(filename, func(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -111,7 +111,7 @@ func TestTokenizeNoSemis(t *testing.T) {
"import": "import semis cannot be added",
"msgpack_comparison": "we are naively removing semis from within comments",
}
for _, filename := range testFiles {
for _, filename := range testTokenizeFiles {
filename := filename
t.Run(filename, func(t *testing.T) {
t.Parallel()
Expand Down

0 comments on commit a0b9faa

Please sign in to comment.