trick to avoid limits on run.dlang.io all compilers

Steven Schveighoffer schveiguy at gmail.com
Wed Jan 31 19:54:24 UTC 2024


I use run.dlang.io often to test things, and then when I see they 
are broken, I change to "all compilers" to see when it might have 
broken/changed.

However, there are two limits that frustrate this process:

1. There is a limit to the amount of output that can be shown. If 
your test case spits out a bunch of text that changes from 
version to version (i.e. a big exception trace with differing 
line numbers), then it will truncate the result, potentially 
hiding the place where the issue lies.
2. There is a limit to the time your request can take. The 
reasons for this are obvious.

However, I have discovered a trick to avoid these limits while 
still testing multiple versions. D has a `__VERSION__` special 
token that identifies the version of the compiler. For 2.100, 
`__VERSION__ == 2100`.

Great, how can we use this?

```d
static if(__VERSION__ >= 2100) {
    // real test code
} else void main() {}
```

Now, the test code only builds on versions 2.100 and above, and a 
quick basic program which can build and run very quickly and 
outputs nothing will build on prior versions.

What if the change occurred before 2.100? Simply change the range:

```d
static if(__VERSION__ >= 2090 && __VERSION__ < 2100) {
    // real test code
} else void main() {}
```

Basically, this avoids the limitations, and still allows you to 
test simple problems with a range of D versions without having to 
download them locally.

-Steve


More information about the Digitalmars-d mailing list