26 changes: 26 additions & 0 deletions test/cycles/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
include ../common.mak

TESTS:=cycle_ignore cycle_abort cycle_print

DIFF:=diff
SED:=sed

.PHONY: all clean
all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS)))

$(ROOT)/cycle_ignore.done: RETCODE=0
$(ROOT)/cycle_ignore.done: LINES=0
$(ROOT)/cycle_abort.done: RETCODE=1
$(ROOT)/cycle_abort.done: LINES=5
$(ROOT)/cycle_print.done: RETCODE=0
$(ROOT)/cycle_print.done: LINES=8
$(ROOT)/%.done: $(ROOT)/test_cycles
@echo Testing $*
$(QUIET)$(TIMELIMIT)$(ROOT)/test_cycles --DRT-oncycle=$(patsubst cycle_%.done,%, $(notdir $@)) > $@ 2>&1; test $$? -eq $(RETCODE)
test `cat $@ | wc -l` -eq $(LINES)

$(ROOT)/test_cycles: $(SRC)/*.d
$(QUIET)$(DMD) $(DFLAGS) -of$@ $^

clean:
rm -rf $(GENERATED)
8 changes: 8 additions & 0 deletions test/cycles/src/mod1.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module mod1;
import mod2;

shared int x;
shared static this()
{
x = 1;
}
14 changes: 14 additions & 0 deletions test/cycles/src/mod2.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module mod2;
import mod1;
import mod3;

shared int x;
shared static this()
{
x = 2;
}

void main()
{
// do nothing
}
8 changes: 8 additions & 0 deletions test/cycles/src/mod3.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module mod3;
import mod2;

shared int x;
shared static this()
{
x = 3;
}
6 changes: 4 additions & 2 deletions test/exceptions/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include ../common.mak

TESTS:=stderr_msg unittest_assert invalid_memory_operation unknown_gc
TESTS:=stderr_msg unittest_assert invalid_memory_operation unknown_gc static_dtor
ifeq ($(OS)-$(BUILD),linux-debug)
TESTS:=$(TESTS) line_trace
endif
Expand All @@ -25,9 +25,11 @@ $(ROOT)/stderr_msg.done: STDERR_EXP="stderr_msg msg"
$(ROOT)/unittest_assert.done: STDERR_EXP="unittest_assert msg"
$(ROOT)/invalid_memory_operation.done: STDERR_EXP="InvalidMemoryOperationError"
$(ROOT)/unknown_gc.done: STDERR_EXP="'unknowngc'"
$(ROOT)/static_dtor.done: STDERR_EXP="dtor_called_more_than_once"
$(ROOT)/static_dtor.done: NEGATE=!
$(ROOT)/%.done: $(ROOT)/%
@echo Testing $*
$(QUIET)$(TIMELIMIT)$(ROOT)/$* $(RUN_ARGS) 2>&1 1>/dev/null | grep -qF $(STDERR_EXP)
$(NEGATE) $(QUIET)$(TIMELIMIT)$(ROOT)/$* $(RUN_ARGS) 2>&1 1>/dev/null | grep -qF $(STDERR_EXP)
@touch $@

$(ROOT)/unittest_assert: DFLAGS+=-unittest
Expand Down
14 changes: 14 additions & 0 deletions test/exceptions/src/static_dtor.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Issue 16594
import core.stdc.stdio;

shared static ~this()
{
__gshared int count;

if (count++) fprintf(stderr, "dtor_called_more_than_once");
else throw new Exception("static_dtor_exception");
}

void main()
{
}