commit - d728769d30366f48bd81c28233bd89c1b8f306b0
commit + 0b453b63092adb976784e2e908bed7618100dfc3
blob - 5b307502c6eac3f8790de1e1f6f485613daad9f7
blob + 6c5de914e4816aeddea7633deef21e3b8b3455d1
--- np.y
+++ np.y
void lungetc(int);
int findeol(void);
+static int shouldfail;
+
typedef struct {
union {
struct op *op;
%token INCLUDE
%token PROC
%token REPEAT
-%token STR
+%token SHOULD_FAIL STR
%token TESTING
%token U8 U16 U32
test : TESTING STRING DIR STRING {
prepare_test();
- } '{' optnl block '}' {
- test_done($2, $4);
+ } testopt '{' optnl block '}' {
+ test_done(shouldfail, $2, $4);
+ shouldfail = 0;
}
+ ;
+
+testopt : /* empty */
+ | SHOULD_FAIL { shouldfail = 1; }
;
%%
{"include", INCLUDE},
{"proc", PROC},
{"repeat", REPEAT},
+ {"should-fail", SHOULD_FAIL},
{"str", STR},
{"testing", TESTING},
{"u16", U16},
blob - 5251641aa7b2b4facb6ef1e2bd999ebc4add67f8
blob + 9511faba88384dc377c67c82817d1fa8a44ce49e
--- script.c
+++ script.c
}
void
-test_done(char *name, char *dir)
+test_done(int shouldfail, char *name, char *dir)
{
struct test *test;
test = xcalloc(1, sizeof(*test));
+ test->shouldfail = shouldfail;
test->name = name;
test->dir = dir;
test->body = finalize(&blocks, NULL);
while (waitpid(pid, NULL, 0) != pid)
; /* nop */
+
+ if (t->shouldfail) {
+ if (ret == EVAL_OK) {
+ before_printing();
+ printf("test was expected to fail\n");
+ return EVAL_ERR;
+ } else if (ret == EVAL_ERR)
+ return EVAL_OK;
+ }
return ret;
}
blob - ad15a7b8674cc8967bcb70b55cd19345f30ac9f7
blob + 3331b113f627d5fb4b3f87b1c0867389857e75aa
--- script.h
+++ script.h
TAILQ_HEAD(tests, test);
struct test {
TAILQ_ENTRY(test) entry;
+ int shouldfail;
char *name;
char *dir;
struct op *body;
/* testing */
void prepare_test(void);
-void test_done(char *, char *);
+void test_done(int, char *, char *);
/* np.y */
void loadfile(const char *);