Skip to content

Commit 05d8f0b

Browse files
committed
Merge pull request #650 from dawgfoto/stderrStacktrace
stacktraces need to be written to stderr
2 parents 691097f + 8a573d2 commit 05d8f0b

File tree

5 files changed

+57
-3
lines changed

5 files changed

+57
-3
lines changed

posix.mak

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ $(DRUNTIME): $(OBJS) $(SRCS)
169169
$(DMD) -lib -of$(DRUNTIME) -Xfdruntime.json $(DFLAGS) $(SRCS) $(OBJS)
170170

171171
UT_MODULES:=$(patsubst src/%.d,$(OBJDIR)/%,$(SRCS))
172-
ADDITIONAL_TESTS:=test/init_fini
172+
ADDITIONAL_TESTS:=test/init_fini test/exceptions
173173
ADDITIONAL_TESTS+=$(if $(findstring $(OS),linux),test/shared,)
174174

175175
unittest : $(UT_MODULES) $(addsuffix /.run,$(ADDITIONAL_TESTS))
@@ -215,7 +215,7 @@ $(OBJDIR)/% : $(OBJDIR)/test_runner
215215
# succeeded, render the file new again
216216
@touch $@
217217

218-
test/init_fini/.run: $(DRUNTIME)
218+
test/init_fini/.run test/exceptions/.run: $(DRUNTIME)
219219
test/shared/.run: $(DRUNTIMESO)
220220

221221
test/%/.run: test/%/Makefile

src/rt/dmain2.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ private void printThrowable(Throwable t)
433433
{
434434
void sink(const(char)[] buf) nothrow
435435
{
436-
printf("%.*s", cast(int)buf.length, buf.ptr);
436+
fprintf(stderr, "%.*s", cast(int)buf.length, buf.ptr);
437437
}
438438

439439
for (; t; t = t.next)

test/exceptions/Makefile

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# set from top makefile
2+
OS:=
3+
MODEL:=
4+
DMD:=
5+
DRUNTIME:=
6+
DRUNTIMESO:=
7+
QUIET:=
8+
9+
SRC:=src
10+
ROOT:=obj/$(OS)/$(MODEL)
11+
TESTS:=stderr_msg unittest_assert
12+
13+
ifneq (default,$(MODEL))
14+
MODEL_FLAG:=-m$(MODEL)
15+
endif
16+
CFLAGS:=$(MODEL_FLAG) -Wall
17+
DFLAGS:=$(MODEL_FLAG) -w -I../../src -I../../import -I$(SRC) -L$(DRUNTIME) -defaultlib= -debuglib=
18+
19+
.PHONY: all clean
20+
all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS)))
21+
22+
$(ROOT)/%.done: $(ROOT)/%
23+
@echo Testing $*
24+
$(QUIET)./$(ROOT)/$* $(RUN_ARGS)
25+
@touch $@
26+
27+
$(ROOT)/stderr_msg.done: $(ROOT)/stderr_msg
28+
@echo Testing stderr_msg
29+
$(QUIET)./$(ROOT)/stderr_msg $(RUN_ARGS) 2>&1 1>/dev/null | grep -qF "stderr_msg msg"
30+
@touch $@
31+
32+
$(ROOT)/unittest_assert.done: $(ROOT)/unittest_assert
33+
@echo Testing unittest_assert
34+
$(QUIET)./$(ROOT)/unittest_assert $(RUN_ARGS) 2>&1 1>/dev/null | grep -qF "unittest_assert msg"
35+
@touch $@
36+
37+
$(ROOT)/unittest_assert: DFLAGS+=-unittest
38+
$(ROOT)/%: $(SRC)/%.d
39+
$(QUIET)$(DMD) $(DFLAGS) -of$@ $<
40+
41+
clean:
42+
rm -rf obj

test/exceptions/src/stderr_msg.d

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
void main()
2+
{
3+
throw new Exception("stderr_msg msg");
4+
}

test/exceptions/src/unittest_assert.d

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
unittest
2+
{
3+
assert(0, "unittest_assert msg");
4+
}
5+
6+
void main()
7+
{
8+
}

0 commit comments

Comments
 (0)