Jump to page: 1 2 3
Thread overview
Is it acceptable to not parse unittest blocks when unittests are disabled ?
Mar 29, 2017
deadalnix
Mar 29, 2017
rikki cattermole
Mar 29, 2017
deadalnix
Mar 29, 2017
rikki cattermole
Mar 29, 2017
Stefan Koch
Mar 29, 2017
Vladimir Panteleev
Mar 29, 2017
Stefan Koch
Mar 29, 2017
Vladimir Panteleev
Mar 30, 2017
Claude
Mar 30, 2017
deadalnix
Mar 30, 2017
Stefan Koch
Mar 30, 2017
Dukc
Mar 31, 2017
deadalnix
Mar 30, 2017
XavierAP
Mar 30, 2017
ixid
Mar 30, 2017
rjframe
Mar 30, 2017
drug
Mar 30, 2017
XavierAP
Mar 31, 2017
Jacob Carlborg
Apr 01, 2017
Walter Bright
Apr 01, 2017
Jonathan M Davis
Apr 01, 2017
Walter Bright
Apr 01, 2017
Stefan Koch
Apr 01, 2017
Walter Bright
Apr 01, 2017
Patrick Schluter
Apr 01, 2017
rjframe
Apr 02, 2017
H. S. Teoh
March 29, 2017
I was wondering. When uniitests aren't going to run, it may be desirable to skip parsing altogether, just lexing and counting braces until the matching closing brace is found.

Obviously, this means that no error will be found in unittests blocks. That can contain pretty much anything that lex, so it's even more lax than what's allowed inside a static if.

Is that an acceptable tradeof ?

March 29, 2017
On 29/03/2017 12:16 PM, deadalnix wrote:
> I was wondering. When uniitests aren't going to run, it may be desirable
> to skip parsing altogether, just lexing and counting braces until the
> matching closing brace is found.
>
> Obviously, this means that no error will be found in unittests blocks.
> That can contain pretty much anything that lex, so it's even more lax
> than what's allowed inside a static if.
>
> Is that an acceptable tradeof ?

I see no reason to not to treat it as:

version(unittest) {
	void func_xxxx() {
		...
	}
}

Which is basically what you said.
March 29, 2017
On Wednesday, 29 March 2017 at 11:22:59 UTC, rikki cattermole wrote:
> Which is basically what you said.

It isn't. version needs to be parsed and thus, grammatically valid.
March 29, 2017
On 29/03/2017 1:16 PM, deadalnix wrote:
> On Wednesday, 29 March 2017 at 11:22:59 UTC, rikki cattermole wrote:
>> Which is basically what you said.
>
> It isn't. version needs to be parsed and thus, grammatically valid.

Hmm, well that is another thing that could be disabled to shave some time off the build times I suppose.
March 29, 2017
On Wednesday, 29 March 2017 at 11:16:28 UTC, deadalnix wrote:
> I was wondering. When uniitests aren't going to run, it may be desirable to skip parsing altogether, just lexing and counting braces until the matching closing brace is found.
>
> Obviously, this means that no error will be found in unittests blocks. That can contain pretty much anything that lex, so it's even more lax than what's allowed inside a static if.
>
> Is that an acceptable tradeof ?

I would not do this trade off,
It's highly surprising since no other language feature works that way.
Also parsing is rather cheap.

March 29, 2017
On Wednesday, 29 March 2017 at 11:16:28 UTC, deadalnix wrote:
> I was wondering. When uniitests aren't going to run, it may be desirable to skip parsing altogether, just lexing and counting braces until the matching closing brace is found.

Sorry, is this not already the case?

$ dmd test.d
$ cat test.d
void main()
{
	import std.stdio;
	writeln("Hello, world!");
}


unittest
{
	foo bar {} baz more-syntax!errors)blah
}
$ dmd test.d
$ ./test
Hello, world!

March 29, 2017
On Wednesday, 29 March 2017 at 19:32:50 UTC, Vladimir Panteleev wrote:
> On Wednesday, 29 March 2017 at 11:16:28 UTC, deadalnix wrote:
>> I was wondering. When uniitests aren't going to run, it may be desirable to skip parsing altogether, just lexing and counting braces until the matching closing brace is found.
>
> Sorry, is this not already the case?
>
> $ dmd test.d
> $ cat test.d
> void main()
> {
> 	import std.stdio;
> 	writeln("Hello, world!");
> }
>
>
> unittest
> {
> 	foo bar {} baz more-syntax!errors)blah
> }
> $ dmd test.d
> $ ./test
> Hello, world!

Surprise!
March 29, 2017
On Wednesday, 29 March 2017 at 19:32:50 UTC, Vladimir Panteleev wrote:
> On Wednesday, 29 March 2017 at 11:16:28 UTC, deadalnix wrote:
>> I was wondering. When uniitests aren't going to run, it may be desirable to skip parsing altogether, just lexing and counting braces until the matching closing brace is found.
>
> Sorry, is this not already the case?

https://github.com/dlang/dmd/pull/4704
March 30, 2017
On Wednesday, 29 March 2017 at 11:16:28 UTC, deadalnix wrote:
>
> Is that an acceptable tradeof ?

I would consider this harmful... The spec already states this about unit tests, so I'd guess the decision was taken in the past conscientiously.

If you're worried about compilation time, you can always define your unit tests in separate files that are included for compilation only when needed.
March 30, 2017
On Thursday, 30 March 2017 at 06:53:47 UTC, XavierAP wrote:
> On Wednesday, 29 March 2017 at 11:16:28 UTC, deadalnix wrote:
>>
>> Is that an acceptable tradeof ?
>
> I would consider this harmful... The spec already states this about unit tests, so I'd guess the decision was taken in the past conscientiously.
>
> If you're worried about compilation time, you can always define your unit tests in separate files that are included for compilation only when needed.

Why is it harmful (actually asking, not telling you you're wrong)? I thought we were going to use a pay for what you use philosophy, if a unit test is not run then why is it paid for?
« First   ‹ Prev
1 2 3