| 1 | package t2 |
| 2 | |
| 3 | import ( |
| 4 | "os/exec" |
| 5 | "strings" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func TestEmptyKeyword(t *testing.T) { |
| 10 | var buf = new(strings.Builder) |
| 11 | cmd := exec.Command("gocc", "t2.bnf") |
| 12 | cmd.Stdout = buf |
| 13 | err := cmd.Run() |
| 14 | |
| 15 | e, ok := err.(*exec.ExitError) |
| 16 | if !ok || e.Success() { |
| 17 | t.Fatalf("gocc t2.bnf should return with exit error, but get %v.", err) |
| 18 | } |
| 19 | expectedStderr := `empty production alternative: Maybe you are missing the "empty" keyword in "B : \t<< >>"` |
| 20 | actual := buf.String() |
| 21 | if !strings.Contains(actual, expectedStderr) { |
| 22 | t.Fatalf("%q should contains %q, but not", actual, expectedStderr) |
| 23 | } |
| 24 | } |