diff --git a/.github/workflows/dub.yml b/.github/workflows/dub.yml new file mode 100644 index 0000000..14a6276 --- /dev/null +++ b/.github/workflows/dub.yml @@ -0,0 +1,63 @@ +name: dub + +on: + push: + pull_request: + branches: + - master + +## A wide range of dmd versions on Linux are used to ensure compatibility. On Windows & macOS only the latest DMD and LDC are used +jobs: + test: + name: ${{ matrix.compiler }} on ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] # see include section for Windows & macOS builds + compiler: + - dmd-latest + - ldc-latest + - dmd-2.105.3 # (released in 2023) + - dmd-2.104.2 # (released in 2023) + - dmd-2.103.1 # (released in 2023) + - dmd-2.102.2 # (released in 2023) + - dmd-2.101.2 # (released in 2023) + - dmd-2.100.2 # (released in 2022) ## GDC 12 can support 2.100 + - dmd-2.099.1 # (released in 2022) + - dmd-2.098.1 # (released in 2021) + - dmd-2.097.2 # (released in 2021) + - dmd-2.096.1 # (released in 2021) + - dmd-2.095.1 # (released in 2021) + - dmd-2.094.2 # (released in 2020) + - ldc-1.35.0 # eq to dmd v2.105.2 + - ldc-1.34.0 # eq to dmd v2.104.2 + - ldc-1.33.0 # eq to dmd v2.103.1 + - ldc-1.28.1 # eq to dmd v2.098.1 + - ldc-1.27.1 # eq to dmd v2.097.2 + + include: + - { os: windows-latest, compiler: dmd-latest } # Windows Server 2022 + - { os: windows-latest, compiler: ldc-latest } # Windows Server 2022 + - { os: macos-latest, compiler: dmd-latest } # macOS 12 + - { os: macos-latest, compiler: ldc-latest } # macOS 12 + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + + - name: Install D ${{ matrix.compiler }} + uses: dlang-community/setup-dlang@v1 + with: + compiler: ${{ matrix.compiler }} + + - name: Show version + if: runner.os != 'Windows' + run: | + $DC --version + dub --version + + - name: run unit tests with coverage + run: dub test --coverage + + - name: build library (strict build) + run: dub build --config=library --build=strict diff --git a/.gitignore b/.gitignore index e0dc92d..d6226cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,13 @@ +# Ignore Intellij IDEA folder: +.idea +*.iml + +# Ignore Sublime Text workspace (project file is ok): +*.sublime-workspace + *.a *.o +*.lst *.swp *.exe .dub diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 62d0c9e..0000000 --- a/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -language: d diff --git a/README.md b/README.md index 5820f7c..69b01cf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # xUnit Testing Framework for D -[![Build Status](https://travis-ci.org/linkrope/dunit.svg?branch=master)](https://travis-ci.org/linkrope/dunit) +[![DUB Package](https://img.shields.io/dub/v/d-unit.svg)](https://code.dlang.org/packages/d-unit) [![CI](https://github.com/linkrope/dunit/actions/workflows/dub.yml/badge.svg)](https://github.com/linkrope/dunit/actions/workflows/dub.yml) This is a simple implementation of the xUnit Testing Framework for the [D Programming Language]. diff --git a/dub.json b/dub.json index c5a4ac2..030ed47 100644 --- a/dub.json +++ b/dub.json @@ -11,6 +11,11 @@ }, "undead": ">=1.1.1" }, + "buildTypes": { + "strict": { + "buildOptions": ["deprecationErrors", "warningsAsErrors"] + } + }, "configurations": [ { "name": "library", @@ -19,7 +24,7 @@ { "name": "unittest", "targetType": "executable", - "sourceFiles": ["test/main.d"] + "mainSourceFile": "test/main.d" } ] } diff --git a/src/dunit/assertion.d b/src/dunit/assertion.d index 8bb60e1..1025d7f 100644 --- a/src/dunit/assertion.d +++ b/src/dunit/assertion.d @@ -7,7 +7,7 @@ module dunit.assertion; import core.thread; -import core.time; +import core.time : MonoTime; import std.algorithm; import std.array; import std.conv; @@ -669,11 +669,11 @@ public static void assertEventually(bool delegate() probe, string file = __FILE__, size_t line = __LINE__) { - const startTime = TickDuration.currSystemTick(); + const startTime = MonoTime.currTime; while (!probe()) { - const elapsedTime = cast(Duration)(TickDuration.currSystemTick() - startTime); + const elapsedTime = cast(Duration)(MonoTime.currTime - startTime); if (elapsedTime >= timeout) fail(msg.empty ? "timed out" : msg, file, line); diff --git a/src/dunit/framework.d b/src/dunit/framework.d index d75594c..289000a 100644 --- a/src/dunit/framework.d +++ b/src/dunit/framework.d @@ -11,7 +11,8 @@ import dunit.attributes; import dunit.color; import core.runtime; -import core.time; +// import core.time : TickDuration; +import core.time : Duration, MonoTime; import std.algorithm; import std.array; import std.conv; @@ -559,7 +560,7 @@ class IssueReporter : TestListener class DetailReporter : TestListener { private string test; - private TickDuration startTime; + private MonoTime startTime; public override void enterClass(string className) { @@ -569,7 +570,7 @@ class DetailReporter : TestListener public override void enterTest(string test) { this.test = test; - this.startTime = TickDuration.currSystemTick(); + this.startTime = MonoTime.currTime; } public override void skip(string reason) @@ -599,10 +600,10 @@ class DetailReporter : TestListener { if (success) { - const elapsed = (TickDuration.currSystemTick() - this.startTime).usecs() / 1_000.0; + Duration elapsed = MonoTime.currTime() - this.startTime; writec(Color.green, " OK: "); - writefln("%6.2f ms %s", elapsed, this.test); + writefln("%6.2f ms %s", elapsed.total!"msecs", this.test); } } @@ -690,7 +691,7 @@ class XmlReporter : TestListener private Document testCase; private string className; - private TickDuration startTime; + private MonoTime startTime; public override void enterClass(string className) { @@ -702,7 +703,7 @@ class XmlReporter : TestListener this.testCase = new Document(new Tag("testcase")); this.testCase.tag.attr["classname"] = this.className; this.testCase.tag.attr["name"] = test; - this.startTime = TickDuration.currSystemTick(); + this.startTime = MonoTime.currTime; } public override void skip(string reason) @@ -733,9 +734,9 @@ class XmlReporter : TestListener public override void exitTest(bool success) { - const elapsed = (TickDuration.currSystemTick() - this.startTime).msecs() / 1_000.0; + Duration elapsed = MonoTime.currTime() - this.startTime; - this.testCase.tag.attr["time"] = format("%.3f", elapsed); + this.testCase.tag.attr["time"] = format("%.3f", elapsed.total!"msecs"); const report = join(this.testCase.pretty(4), "\n"); @@ -760,7 +761,7 @@ class ReportReporter : TestListener private Element testSuite; private Element testCase; private string className; - private TickDuration startTime; + private MonoTime startTime; public this(string fileName, string testSuiteName) { @@ -782,7 +783,7 @@ class ReportReporter : TestListener this.testCase.tag.attr["classname"] = this.className; this.testCase.tag.attr["name"] = test; this.testSuite ~= this.testCase; - this.startTime = TickDuration.currSystemTick(); + this.startTime = MonoTime.currTime; } public override void skip(string reason) @@ -825,9 +826,9 @@ class ReportReporter : TestListener public override void exitTest(bool success) { - const elapsed = (TickDuration.currSystemTick() - this.startTime).msecs() / 1_000.0; + Duration elapsed = MonoTime.currTime - this.startTime; - this.testCase.tag.attr["time"] = format("%.3f", elapsed); + this.testCase.tag.attr["time"] = format("%.3f", elapsed.total!"msecs"); } public override void exit()