Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/dub.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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].
Expand Down
7 changes: 6 additions & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
},
"undead": ">=1.1.1"
},
"buildTypes": {
"strict": {
"buildOptions": ["deprecationErrors", "warningsAsErrors"]
}
},
"configurations": [
{
"name": "library",
Expand All @@ -19,7 +24,7 @@
{
"name": "unittest",
"targetType": "executable",
"sourceFiles": ["test/main.d"]
"mainSourceFile": "test/main.d"
}
]
}
6 changes: 3 additions & 3 deletions src/dunit/assertion.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
27 changes: 14 additions & 13 deletions src/dunit/framework.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down Expand Up @@ -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");

Expand All @@ -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)
{
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down