~mcf/cproc#29: 
Add tests that must fail

There are many constraint errors specified by the standard, which require us to print a diagnostic.

We should extend runtests to support tests to check these errors, then start adding test C files that violate constraints.

Perhaps this could be done by adding a .err file instead of a .qbe file, and the test runner would check that cc-qbe failed and stderr matched the contents of the .err file.

Should these tests go alongside the others, or in a separate directory?

Status
REPORTED
Submitter
~mcf
Assigned to
No-one
Submitted
1 year, 3 months ago
Updated
1 year, 3 months ago
Labels
No labels applied.

~ach 1 year, 3 months ago

By coincidence, I have just been working on this, I have a working prototype.

Here is an example test case:

/*
PATTERN: incomplete
PATTERN: c:12
*/

int
main()
{
    {
        struct X {};
    }
    struct X x;
    return 0;
}

~ach 1 year, 3 months ago

I have improved on my idea quite a lot and it seems to work well here are some examples...

/*
t_output="hello world!"
*/

extern int printf(const char *, ...);
int main() { printf("hello world!"); }
/*
t_rc=2
t_output="hi!"
*/

extern int printf(const char *, ...);
int main() { printf("hi!"); return 2; }
/*
t_ccrc=1
t_ccouput () {
  exec grep "error" "$1"
}
*/

int main() { retu 2; }

The trick is just extracting sh hooks and evaling them, then you can do non trivial logic in your tests.

I have a parallel test running using redo, and it fall's back to a serial runner if redo is not installed.

Register here or Log in to comment, or comment via email.