Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Fix Issue 19433 - Don't consume --DRT-* options if rt_cmdline_enabled…
Browse files Browse the repository at this point in the history
… is false
  • Loading branch information
CyberShadow committed Nov 25, 2018
1 parent 072b7a4 commit ae9581c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion posix.mak
Expand Up @@ -253,7 +253,7 @@ HAS_ADDITIONAL_TESTS:=$(shell test -d test && echo 1)
ifeq ($(HAS_ADDITIONAL_TESTS),1)
ADDITIONAL_TESTS:=test/init_fini test/exceptions test/coverage test/profile test/cycles test/allocations test/typeinfo \
test/aa test/hash \
test/thread test/unittest test/imports test/betterc test/stdcpp
test/thread test/unittest test/imports test/betterc test/stdcpp test/config
ADDITIONAL_TESTS+=$(if $(SHARED),test/shared,)
endif

Expand Down
4 changes: 3 additions & 1 deletion src/rt/dmain2.d
Expand Up @@ -443,7 +443,9 @@ extern (C) int _d_run_main(int argc, char **argv, MainFunc mainFunc)
size_t j = 0;
foreach (arg; args)
{
if (arg.length < 6 || arg[0..6] != "--DRT-") // skip D runtime options
import rt.config : rt_cmdline_enabled;

if (!rt_cmdline_enabled!() || arg.length < 6 || arg[0..6] != "--DRT-") // skip D runtime options
{
argsCopy[j++] = (argBuff[0 .. arg.length] = arg[]);
argBuff += arg.length;
Expand Down
17 changes: 17 additions & 0 deletions test/config/Makefile
@@ -0,0 +1,17 @@
include ../common.mak

TESTS:=test19433

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

$(ROOT)/%: $(SRC)/%.d
$(QUIET)$(DMD) $(DFLAGS) -of$@ $<

$(ROOT)/test19433.done: $(ROOT)/test19433
@echo Testing test19433
$(QUIET)$(ROOT)/test19433 --DRT-dont-eat-me
@touch $@

clean:
rm -rf $(ROOT)
7 changes: 7 additions & 0 deletions test/config/src/test19433.d
@@ -0,0 +1,7 @@
extern(C) __gshared bool rt_cmdline_enabled = false;

void main(string[] args)
{
assert(args.length == 2);
assert(args[1] == "--DRT-dont-eat-me");
}

0 comments on commit ae9581c

Please sign in to comment.