www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - betterC, TestBetterC , betterCTest or ("betterC") to annotate

reply Seb <seb wilzba.ch> writes:
Phobos has recently gotten a primitive way to run betterC tests 
(https://github.com/dlang/phobos/pull/6640).

Now, it would be really cool if we can annotate existing tests 
with e.g. ` betterCTest` and thus ensure that those tests work 
with -betterC (i.e. extract them and run them with a minimal test 
runner.

a)  betterC

Probably too popular and would lead to too many conflicts.

b)  TestBetterC
c)  betterCTest ||  bettercTest

Would probably be defined a enum somewhere in `std.internal`

d)  ("betterC")

A bit ugly and harder to work with. If we ever want to name the 
unittests in Phobos, this will make it harder.

At some point we might also want to test whether something runs 
even without any runtime 
(https://github.com/dlang/phobos/pull/6641), so e.g. 
` baremetalTest` might be defined too.

My favorite is (c) - any objections?

See also: https://github.com/dlang/tools/pull/357 (implementation 
of the test extraction filter for UDAs)
Jul 29 2018
next sibling parent rikki cattermole <rikki cattermole.co.nz> writes:
On 30/07/2018 2:21 AM, Seb wrote:
 
 My favorite is (c) - any objections?
As long as its a enum/struct and is documented some place with DDOC, then none here :)
Jul 29 2018
prev sibling next sibling parent Mike Franklin <slavo5150 yahoo.com> writes:
On Sunday, 29 July 2018 at 14:21:20 UTC, Seb wrote:
 Phobos has recently gotten a primitive way to run betterC tests 
 (https://github.com/dlang/phobos/pull/6640).

 Now, it would be really cool if we can annotate existing tests 
 with e.g. ` betterCTest` and thus ensure that those tests work 
 with -betterC (i.e. extract them and run them with a minimal 
 test runner.
I don't really care as long is it contains the text "betterC" to ensure it's obvious at a glance what it's for. Does in need to be in the global namespace, or will it be in a private import?
 At some point we might also want to test whether something runs 
 even without any runtime 
 (https://github.com/dlang/phobos/pull/6641), so e.g. 
 ` baremetalTest` might be defined too.
I suggest the term "freestanding" over "baremetal", though, if it still requires the C standard library, it's not really freestanding, so hopefully this means without the druntime and without *any* other dependencies. Mike
Jul 29 2018
prev sibling next sibling parent RazvanN <razvan.nitu1305 gmail.com> writes:
On Sunday, 29 July 2018 at 14:21:20 UTC, Seb wrote:
 Phobos has recently gotten a primitive way to run betterC tests 
 (https://github.com/dlang/phobos/pull/6640).

 Now, it would be really cool if we can annotate existing tests 
 with e.g. ` betterCTest` and thus ensure that those tests work 
 with -betterC (i.e. extract them and run them with a minimal 
 test runner.

 a)  betterC

 Probably too popular and would lead to too many conflicts.
How about worksWithBetterC? This is specific enough
 b)  TestBetterC
This one is good too.
 c)  betterCTest ||  bettercTest

 Would probably be defined a enum somewhere in `std.internal`
Thumb up.
 d)  ("betterC")

 A bit ugly and harder to work with. If we ever want to name the 
 unittests in Phobos, this will make it harder.
Thumb down.
 At some point we might also want to test whether something runs 
 even without any runtime 
 (https://github.com/dlang/phobos/pull/6641), so e.g. 
 ` baremetalTest` might be defined too.
Why not noRuntime?
Jul 30 2018
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2018-07-29 16:21, Seb wrote:
 Phobos has recently gotten a primitive way to run betterC tests
 (https://github.com/dlang/phobos/pull/6640).

 Now, it would be really cool if we can annotate existing tests with e.g.
 ` betterCTest` and thus ensure that those tests work with -betterC (i.e.
 extract them and run them with a minimal test runner.

 a)  betterC

 Probably too popular and would lead to too many conflicts.
Shouldn't be any conflict because the "betterC" symbol would be in a different module.
 b)  TestBetterC
 c)  betterCTest ||  bettercTest

 Would probably be defined a enum somewhere in `std.internal`

 d)  ("betterC")

 A bit ugly and harder to work with. If we ever want to name the
 unittests in Phobos, this will make it harder.
I really hate that this is possible to do with UDAs. We should avoid this as much as possible.
 At some point we might also want to test whether something runs even
 without any runtime (https://github.com/dlang/phobos/pull/6641), so e.g.
 ` baremetalTest` might be defined too.

 My favorite is (c) - any objections?

 See also: https://github.com/dlang/tools/pull/357 (implementation of the
 test extraction filter for UDAs)
I would say, if it's only for internal use then it can be placed in `std.internal` with the `package` protection. If you want this to be used outside of Phobos then I recommend putting it in `core.attribute` in druntime, since that already exists. -- /Jacob Carlborg
Jul 31 2018
parent Seb <seb wilzba.ch> writes:
On Tuesday, 31 July 2018 at 10:09:08 UTC, Jacob Carlborg wrote:
 Shouldn't be any conflict because the "betterC" symbol would be 
 in a different module.
 ...
 I would say, if it's only for internal use then it can be 
 placed in `std.internal` with the `package` protection. If you 
 want this to be used outside of Phobos then I recommend putting 
 it in `core.attribute` in druntime, since that already exists.
Cool! std.internal.attributes and betterC it is then: https://github.com/dlang/phobos/pull/6645 This should allow to gradually annotate more unittests in Phobos with betterC (like we did with safe or nogc), and allow us to gradually increase the -betterC subset.
Jul 31 2018