diff --git a/.circleci/run.sh b/.circleci/run.sh index da7b7f8bf6..abfcfaa3af 100755 --- a/.circleci/run.sh +++ b/.circleci/run.sh @@ -90,7 +90,15 @@ setup_repos() { } style() { - make -f posix.mak style + source "$(CURL_USER_AGENT=\"$CURL_USER_AGENT\" bash ~/dlang/install.sh dmd-$HOST_DMD_VER --activate)" + + # checkout a specific version of https://github.com/dlang/tools + if [ ! -d ../tools ] ; then + clone https://github.com/dlang/tools.git ../tools master + fi + git -C ../tools checkout 6ad91215253b52e6ecfc39fe1854815867c66f23 + + make -f posix.mak -j$N style MODEL="$MODEL" } coverage() { @@ -114,7 +122,7 @@ codecov() case $1 in install-deps) install_deps ;; setup-repos) setup_repos ;; - style) style ;; + style) style;; coverage) coverage ;; codecov) codecov ;; esac diff --git a/posix.mak b/posix.mak index 901c810a35..42d3bb4ffe 100644 --- a/posix.mak +++ b/posix.mak @@ -6,6 +6,8 @@ QUIET:= DMD_DIR=../dmd +TOOLS_DIR=../tools +DUB=dub include $(DMD_DIR)/src/osmodel.mak @@ -90,7 +92,7 @@ endif PHOBOS_PATH=../phobos SHARED=$(if $(findstring $(OS),linux freebsd),1,) ROOT_DIR := $(shell pwd) -PHOBOS_DFLAGS=-conf= $(MODEL_FLAG) -I$(ROOT_DIR)/import -I$(PHOBOS_PATH) -L-L$(PHOBOS_PATH)/generated/$(OS)/$(BUILD)/$(MODEL) $(PIC) +PHOBOS_DFLAGS=-conf= $(MODEL_FLAG) -I$(ROOT_DIR)/import -I$(PHOBOS_PATH) -L-L$(PHOBOS_PATH)/generated/$(OS)/$(BUILD)/$(MODEL) $(PIC) -defaultlib= -debuglib= ifeq (1,$(SHARED)) PHOBOS_DFLAGS+=-defaultlib=libphobos2.so -L-rpath=$(PHOBOS_PATH)/generated/$(OS)/$(BUILD)/$(MODEL) endif @@ -362,12 +364,35 @@ test/%/.clean: test/%/Makefile # Submission to Druntime are required to conform to the DStyle # The tests below automate some, but not all parts of the DStyle guidelines. # See: http://dlang.org/dstyle.html -style: checkwhitespace style_lint +style: style_lint publictests style_lint: @echo "Check for trailing whitespace" $(GREP) -nr '[[:blank:]]$$' $(MANIFEST) ; test $$? -eq 1 +################################################################################ +# Check for missing imports in public unittest examples. +################################################################################ +TESTS_EXTRACTOR=$(ROOT)/tests_extractor +PUBLICTESTS_DIR=$(ROOT)/publictests + +publictests: $(addsuffix .publictests, $(basename $(SRCS))) + +$(TESTS_EXTRACTOR): $(TOOLS_DIR)/tests_extractor.d | $(LIB) + DFLAGS="$(PHOBOS_DFLAGS)" $(DUB) build --force --compiler=$${PWD}/$(DMD) --single $< + mv $(TOOLS_DIR)/tests_extractor $@ + +################################################################################ +# Extract public tests of a module and test them in an separate file (i.e. without its module) +# This is done to check for potentially missing imports in the examples, e.g. +# make -f posix.mak std/format.publictests +################################################################################ +%.publictests: %.d $(TESTS_EXTRACTOR) #| $(PUBLICTESTS_DIR)/.directory + @$(TESTS_EXTRACTOR) --inputdir $< --outputdir $(PUBLICTESTS_DIR) + @$(DMD) $(PHOBOS_DFLAGS) -main $(UDFLAGS) -run $(PUBLICTESTS_DIR)/$(subst /,_,$<) + +################################################################################ + .PHONY : auto-tester-build auto-tester-build: target checkwhitespace diff --git a/src/core/memory.d b/src/core/memory.d index 43403f4adf..3e2ef721ce 100644 --- a/src/core/memory.d +++ b/src/core/memory.d @@ -1138,7 +1138,6 @@ unittest // Deleting raw memory unittest { - import core.memory : GC; auto a = GC.malloc(5); assert(GC.addrOf(cast(void*) a) != null); __delete(a); diff --git a/src/object.d b/src/object.d index babda211d8..0da53ba73f 100644 --- a/src/object.d +++ b/src/object.d @@ -2168,12 +2168,12 @@ auto byKeyValue(T : V[K], K, V)(T aa) pure nothrow @nogc @safe { auto p = (() @trusted => cast(substInout!K*) keyp) (); return *p; - }; + } @property ref value() inout { auto p = (() @trusted => cast(substInout!V*) valp) (); return *p; - }; + } } return Pair(_aaRangeFrontKey(r), _aaRangeFrontValue(r));