Skip to content

Commit

Permalink
Port cov-ctfe to a unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
Geod24 committed Mar 4, 2023
1 parent 0551727 commit 09deb72
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 28 deletions.
2 changes: 1 addition & 1 deletion source/dub/test/base.d
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class TestCLIApp
public ~this ()
{
// destroy dir
//std.file.rmdirRecurse(this.dir);
std.file.rmdirRecurse(this.dir);
this.dir = null;
}

Expand Down
52 changes: 52 additions & 0 deletions source/dub/test/build.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*******************************************************************************
Tests for `dub build`
*******************************************************************************/

module dub.test.build;

version (unittest):

import dub.test.base;

/// Test for cov-ctfe
unittest
{
scope dub = new TestCLIApp();

// Setup
const pkg_path = dub.path.buildPath("cov-ctfe");
std.file.mkdir(pkg_path);
std.file.write(pkg_path.buildPath("dub.sdl"),
`name "test"
version "1.0.0"
targetType "executable"
dflags "-cov=100"
mainSourceFile "test.d"
`);
std.file.write(pkg_path.buildPath("test.d"),
q{int f(int x)
{
return x + 1;
}

int g(int x)
{
return x * 2;
}

enum gResult = g(12); // execute g() at compile-time

int main(string[] args)
{
assert(f(11) + gResult == 36);
return 0;
}
});

// Run test
auto res = dub.run(["--root", "cov-ctfe", "--build=cov-ctfe"]);
assert(res.status == 0);
assert(res.stdout.canFind("Running cov-ctfe/test"));
}
5 changes: 0 additions & 5 deletions test/cov-ctfe.sh

This file was deleted.

Empty file removed test/cov-ctfe/.no_build
Empty file.
Empty file removed test/cov-ctfe/.no_run
Empty file.
Empty file removed test/cov-ctfe/.no_test
Empty file.
5 changes: 0 additions & 5 deletions test/cov-ctfe/dub.sdl

This file was deleted.

17 changes: 0 additions & 17 deletions test/cov-ctfe/test.d

This file was deleted.

0 comments on commit 09deb72

Please sign in to comment.