Do it in the similar way compiler tests are written. You will have a bit of testing code in some scripting language (shell, perl, tcl etc.) that will run compiler on given snippets of code and check whether the right ones compiled and the right ones did not.
- gcc uses DejaGnu, which is built on top of expect, which is itself built on top of Tcl.
- If you use shell script (probably easier, DejaGnu is probably overkill), you might want to look at shUnit2.
- Perl's
Test::Harness
system should be mostly easy to use as is.
- After all, it's not that much more work to run process from C++, so writing a function to try to call compiler on a given string and check whether it outputs error for line where you expect it would not be that hard and than you can integrate it into the other boost.test-based tests.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…