Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests with DMD / LDC master #87

Closed
wants to merge 3 commits into from
Closed
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
40 changes: 40 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Github action to test localrest
#
# Also upload the documentation to Github pages
#
name: CI

on: [push, pull_request]

jobs:
main:
name: Run
# Matrix configuration
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macOS-latest, windows-latest ]
dc: [ ldc-master, dmd-master, ldc-latest, dmd-latest, ldc-1.20.0, dmd-2.090.1 ]

runs-on: ${{ matrix.os }}
timeout-minutes: 15

# The actual work being performed
steps:
- uses: actions/checkout@v2

- name: Prepare compiler
uses: dlang-community/setup-dlang@v1
with:
compiler: ${{ matrix.dc }}

- name: Test
shell: bash
run: dub test -b unittest-cov --compiler=${DC}

- uses: codecov/codecov-action@v1
with:
name: localrest-${{ matrix.os }}-${{ matrix.dc }}
flags: unittest
# false until we can re-trigger a single test in Github
fail_ci_if_error: false
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

100 changes: 57 additions & 43 deletions source/geod24/LocalRest.d
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ module geod24.LocalRest;

static import C = geod24.concurrency;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our of spawn => out of spawn

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What ? Where is this written ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the commit message. Sorry github makes it not easy to comment on the actual commit message.

import geod24.Serialization;
import std.datetime.systime : Clock, SysTime;
import std.format;
import std.meta : AliasSeq;
import std.traits : fullyQualifiedName, Parameters, ReturnType;
Expand Down Expand Up @@ -203,6 +204,58 @@ public class ClientException : Exception
}
}

/// Simple exception unwind the stack when we need to terminate/restart,
/// used by `spawn` but kept here as it doesn't depend on template parameters.
private final class ExitException : Exception
{
public bool restart;

this () @safe pure nothrow @nogc
{
super("You should never see this exception - please report a bug");
}
}

/// Wrapper for data inside of `spawn`, kept here as it doesn't
/// depend on template parameters
private struct Variant
{
pure nothrow @nogc:

public this (Response res) @trusted
{
this.res = res;
this.tag = 0;
}
public this (Command cmd) @trusted
{
this.cmd = cmd;
this.tag = 1;
}

union
{
Response res;
Command cmd;
}

public ubyte tag;
}

/// Used by `spawn` for recording current filtering / sleeping setting
private struct Control
{
public FilterAPI filter; // filter specific messages
public SysTime sleep_until; // sleep until this time
public bool drop; // drop messages if sleeping

public bool isSleeping() const @safe /* nothrow: Not on Windows (currTime) */
{
return this.sleep_until != SysTime.init
&& Clock.currTime < this.sleep_until;
}
}

/// Simple wrapper to deal with tuples
/// Vibe.d might emit a pragma(msg) when T.length == 0
private struct ArgWrapper (T...)
Expand Down Expand Up @@ -536,51 +589,9 @@ public final class RemoteAPI (API, alias S = VibeJSONSerializer!()) : API
C.Tid self, string file, int line, CtorParams!Implementation cargs)
nothrow
{
import std.datetime.systime : Clock, SysTime;
import std.algorithm : each;
import std.range;

/// Simple exception unwind the stack when we need to terminate/restart
static final class ExitException : Exception
{
bool restart;

this () @safe pure nothrow @nogc
{
super("You should never see this exception - please report a bug");
}
}

// very simple & limited variant, to keep it performant.
// should be replaced by a real Variant later
static struct Variant
{
this (Response res) { this.res = res; this.tag = 0; }
this (Command cmd) { this.cmd = cmd; this.tag = 1; }

union
{
Response res;
Command cmd;
}

ubyte tag;
}

// used for controling filtering / sleep
static struct Control
{
FilterAPI filter; // filter specific messages
SysTime sleep_until; // sleep until this time
bool drop; // drop messages if sleeping

bool isSleeping() const
{
return this.sleep_until != SysTime.init
&& Clock.currTime < this.sleep_until;
}
}

scope exc = new ExitException();

void runNode ()
Expand Down Expand Up @@ -1428,7 +1439,10 @@ unittest

// Now drop many messages
n1.sleep(1.seconds, true);
for (size_t i = 0; i < 500; i++)
// Github Action runs out of memory with MessageCount == 500
version (Windows) enum MessageCount = 100;
else enum MessageCount = 500;
for (size_t i = 0; i < MessageCount; i++)
n2.asyncCall();
// Make sure we don't end up blocked forever
n1.sleep(0.seconds, false);
Expand Down