www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - writing DMD tests for inline assembly bugs

reply Cauterite <cauterite gmail.com> writes:
while working on issue 15235 I've been trying to add some new 
tests for DMD.

The tests I want to write involve checking that certain asm 
statements throw syntax errors instead of segfaults, but the fact 
that asmerr() ends compilation unconditionally is proving to be a 
problem. __traits(compiles, …) doesn't help (as discovered in 
issue 15257).

The only solution I can think of would be to have a separate test 
for each statement. Anyone got a better idea?
Oct 29 2015
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 10/29/2015 5:44 AM, Cauterite wrote:
 while working on issue 15235 I've been trying to add some new tests for DMD.

 The tests I want to write involve checking that certain asm statements throw
 syntax errors instead of segfaults, but the fact that asmerr() ends compilation
 unconditionally is proving to be a problem. __traits(compiles, …) doesn't
help
 (as discovered in issue 15257).

 The only solution I can think of would be to have a separate test for each
 statement. Anyone got a better idea?
The usual technique in the D test suite is to pipe the output to a file, and then diff against what it should be. Yes, you wind up with about one test file per error message. https://github.com/D-Programming-Language/dmd/tree/master/test/fail_compilation
Oct 29 2015
parent Jacob Carlborg <doob me.com> writes:
On 2015-10-29 18:58, Walter Bright wrote:

 The usual technique in the D test suite is to pipe the output to a file,
 and then diff against what it should be. Yes, you wind up with about one
 test file per error message.

 https://github.com/D-Programming-Language/dmd/tree/master/test/fail_compilation
An alternative would be to have multiple tests in the same file, but the actual source code for the tests in string literals. Then the testing framework can write temporary files with the content from the string literals and run the actual compilation on those temporary files. I think that will work pretty good as long as the code inside the string literals are fairly short. Another advantage would be that any specific compiler flags that are required for a given test can be passed as a separate argument instead of being inline in the source code as a comment. -- /Jacob Carlborg
Oct 30 2015
prev sibling parent Cauterite <cauterite gmail.com> writes:
This *seems* to fix it:
https://github.com/D-Programming-Language/dmd/pull/5244

On Thursday, 29 October 2015 at 12:44:51 UTC, Cauterite wrote:
 while working on issue 15235 I've been trying to add some new 
 tests for DMD.
Oct 30 2015