digitalmars.D.announce - unit-threaded v0.5.7 - advanced multi-threaded unit testing library
- Atila Neves (36/36) Feb 08 2016 What's new:
- earthfront (2/6) Feb 09 2016 Thanks! What is the relevant link?
- earthfront (2/10) Feb 09 2016 First link on DuckGo: https://github.com/atilaneves/unit-threaded
- Daniel Murphy (3/7) Feb 13 2016 I feel obliged to point out that this is going to be a disaster as soon
- Atila Neves (6/17) Feb 14 2016 The @Name UDA still exists, and I think it's unlikely another
- Sebastiaan Koppe (33/37) Feb 16 2016 I just started using unit-threaded and I like it so far,
- Sebastiaan Koppe (1/1) Feb 16 2016 Oh, kuddos for the nice library.
- Jacob Carlborg (5/11) Feb 16 2016 "dub test" will generate a program that discovers all modules. Not sure
- Sebastiaan Koppe (8/22) Feb 17 2016 It isn't, but I found a workaround. Dub has the preBuildCommands
- Atila Neves (13/53) Feb 17 2016 I'm on a tablet on holiday so sorry in advance for the short
- Sebastiaan Koppe (39/50) Feb 17 2016 Nice. What about @ShoudFail though?
- Atila Neves (7/17) Feb 18 2016 Well, then there are no miracles ;) I suggest this:
- Atila Neves (5/10) Feb 29 2016 You don't need a testrunner generator anymore:
What's new: Built-in unittest blocks can now have a name with just a string UDA: -------------------------------------------------------------------- ("test that does stuff") unittest {... } Why is this important? If you just want to run unit tests in threads and have them named, you don't need to import unit_threaded in your source code anymore. I'm going to build on this later with a tool to make it so that existing codebases can benefit from unit_threaded without using it directly. Value-parametrized tests ------------------------ Have you ever written a test that looks like this? unittest { foreach(v; [...]) { //test code } } I have, and when it fails you have no idea which of the values caused the failure. Now, you can do this: (42, 2, 3) void testValues(int i) { (i % 2 == 0).shouldBeTrue; } testValues will be run once for each value UDA with the same type in its declaration (in this case, int). Each run will be considered a different test and reported as such with the value that was used. In the above case, the output will contain this: tests.pass.attributes.testValues.42: tests.pass.attributes.testValues.2: tests.pass.attributes.testValues.3: tests/pass/attributes.d:76 - Expected: true tests/pass/attributes.d:76 - Got: false Test tests.pass.attributes.testValues.3 failed. Enjoy! Atila
Feb 08 2016
On Monday, 8 February 2016 at 13:23:40 UTC, Atila Neves wrote:What's new: <snip> Enjoy! AtilaThanks! What is the relevant link?
Feb 09 2016
On Tuesday, 9 February 2016 at 17:07:15 UTC, earthfront wrote:On Monday, 8 February 2016 at 13:23:40 UTC, Atila Neves wrote:First link on DuckGo: https://github.com/atilaneves/unit-threadedWhat's new: <snip> Enjoy! AtilaThanks! What is the relevant link?
Feb 09 2016
On 9/02/2016 12:23 AM, Atila Neves wrote:What's new: Built-in unittest blocks can now have a name with just a string UDA: -------------------------------------------------------------------- ("test that does stuff") unittest {... }I feel obliged to point out that this is going to be a disaster as soon as any other library decides that means something else.
Feb 13 2016
On Saturday, 13 February 2016 at 12:41:35 UTC, Daniel Murphy wrote:On 9/02/2016 12:23 AM, Atila Neves wrote:The Name UDA still exists, and I think it's unlikely another library will be looking for string UDAs on unittest blocks that isn't itself a testing library. AtilaWhat's new: Built-in unittest blocks can now have a name with just a string UDA: -------------------------------------------------------------------- ("test that does stuff") unittest {... }I feel obliged to point out that this is going to be a disaster as soon as any other library decides that means something else.
Feb 14 2016
On Monday, 8 February 2016 at 13:23:40 UTC, Atila Neves wrote:What's new: [...] Enjoy! AtilaI just started using unit-threaded and I like it so far, specially the parallel runner. Just had some speed-bumps that might be worth noting. Before going into details I want to mention that I am not using it the way it is supposed to be used, which voids me from warranty I suppose. From what I gather the normal way would be to create separate test-files with test-cases and unittest blocks inside them, completely separate from normal code. Two things that made me go in the opposite direction was dub and code coverage. So I don't have separate test files; I have the unittest blocks interspersed with code. Because I don't want to include unit_threaded in production code I ended up doing this: version (unittest) { include unit_threaded; Name("Test test") unittest { ... } } Which is redundant, but I need the import outside the unittest for the UDA, and I don't want the import to show up in production code. Then to get `dub test` to run unit_threaded I had to create a small program that discovers all modules and generates a testrunner.d file in the source directory, which gets picked up by dub. So now instead of `dub test` I call `rdmd test.d`, which generates the testrunner.d and calls dub test. I feel I am going against the grain here.
Feb 16 2016
On 2016-02-16 23:13, Sebastiaan Koppe wrote:Then to get `dub test` to run unit_threaded I had to create a small program that discovers all modules and generates a testrunner.d file in the source directory, which gets picked up by dub. So now instead of `dub test` I call `rdmd test.d`, which generates the testrunner.d and calls dub test. I feel I am going against the grain here."dub test" will generate a program that discovers all modules. Not sure if it's compatible with unit-threaded. -- /Jacob Carlborg
Feb 16 2016
On Wednesday, 17 February 2016 at 07:46:51 UTC, Jacob Carlborg wrote:On 2016-02-16 23:13, Sebastiaan Koppe wrote:It isn't, but I found a workaround. Dub has the preBuildCommands which allows you to run shell commands,. It now runs my small util that generates a testrunner compatible with unit-threaded. So now its just `dub test` again. Plus I can add modules as arguments so only those will be tested. (e.g. dub test -- my.module). This is a godsend.Then to get `dub test` to run unit_threaded I had to create a small program that discovers all modules and generates a testrunner.d file in the source directory, which gets picked up by dub. So now instead of `dub test` I call `rdmd test.d`, which generates the testrunner.d and calls dub test. I feel I am going against the grain here."dub test" will generate a program that discovers all modules. Not sure if it's compatible with unit-threaded.
Feb 17 2016
On Tuesday, 16 February 2016 at 22:13:15 UTC, Sebastiaan Koppe wrote:On Monday, 8 February 2016 at 13:23:40 UTC, Atila Neves wrote:I'm on a tablet on holiday so sorry in advance for the short answer. Your versioned import is the reason why I made it so a plain string UDA is just as good as Name. That way you only need to import unit_threaded once in a version block, and only if you want to use the shouldXXX assertions. The test runner you mentioned can be generated by using my dtest tool, also on dub. The next thing on my TODO list is to make it even easier to opt-in to using unit-threaded without having to change existing project code AtilaWhat's new: [...] Enjoy! AtilaI just started using unit-threaded and I like it so far, specially the parallel runner. Just had some speed-bumps that might be worth noting. Before going into details I want to mention that I am not using it the way it is supposed to be used, which voids me from warranty I suppose. From what I gather the normal way would be to create separate test-files with test-cases and unittest blocks inside them, completely separate from normal code. Two things that made me go in the opposite direction was dub and code coverage. So I don't have separate test files; I have the unittest blocks interspersed with code. Because I don't want to include unit_threaded in production code I ended up doing this: version (unittest) { include unit_threaded; Name("Test test") unittest { ... } } Which is redundant, but I need the import outside the unittest for the UDA, and I don't want the import to show up in production code. Then to get `dub test` to run unit_threaded I had to create a small program that discovers all modules and generates a testrunner.d file in the source directory, which gets picked up by dub. So now instead of `dub test` I call `rdmd test.d`, which generates the testrunner.d and calls dub test. I feel I am going against the grain here.
Feb 17 2016
On Wednesday, 17 February 2016 at 09:05:34 UTC, Atila Neves wrote:I'm on a tablet on holiday so sorry in advance for the short answer.You're on a holiday, I appreciate anything you write :)Your versioned import is the reason why I made it so a plain string UDA is just as good as Name. That way you only need to import unit_threaded once in a version block, and only if you want to use the shouldXXX assertions.Nice. What about ShoudFail though?The test runner you mentioned can be generated by using my dtest tool, also on dub.I saw it, does it integrate well with `dub test` and -cov?The next thing on my TODO list is to make it even easier to opt-in to using unit-threaded without having to change existing project codeI feel you are almost there. For completeness, here is my testrunner generator that dub's preBuildCommands calls: void main(string[] args) { import std.file; import std.algorithm : endsWith, startsWith, filter, map, joiner; import std.array : replace; import std.range : array; bool onlyDFiles(DirEntry e) { return !e.isDir() && e.name.endsWith(".d"); } auto files = dirEntries("source/es5", SpanMode.depth).filter!onlyDFiles.map!("a.name").map!(`"\""~a~"\""`).joiner(",").array().replace("/",".").replace("\\",".").replace("source.","").replace(".d",""); import std.stdio; writeln("Generating TestRunner"); auto f = File("source/testrunner.d","w"); f.write(`version (unittest) { bool runner() { import testhelpers; import core.runtime; return runTests!(`~files~`)(Runtime.args) == 0; } static this() { import core.runtime; Runtime.moduleUnitTester = &runner; } }`); f.close(); }
Feb 17 2016
On Wednesday, 17 February 2016 at 09:16:02 UTC, Sebastiaan Koppe wrote:On Wednesday, 17 February 2016 at 09:05:34 UTC, Atila Neves wrote:Well, then there are no miracles ;) I suggest this: version(unittest) import unit_threaded; else enum ShouldFail; // or import unit_threaded.attrsI'm on a tablet on holiday so sorry in advance for the short answer.You're on a holiday, I appreciate anything you write :)Your versioned import is the reason why I made it so a plain string UDA is just as good as Name. That way you only need to import unit_threaded once in a version block, and only if you want to use the shouldXXX assertions.Nice. What about ShoudFail though?
Feb 18 2016
On Wednesday, 17 February 2016 at 09:16:02 UTC, Sebastiaan Koppe wrote:On Wednesday, 17 February 2016 at 09:05:34 UTC, Atila Neves wrote:You don't need a testrunner generator anymore: http://forum.dlang.org/post/tgbfkazeuqrcjctyemqz forum.dlang.org Atila[...]You're on a holiday, I appreciate anything you write :) [...]
Feb 29 2016