Skip to content

Commit c65d9e4

Browse files
authored
Merge pull request #4943 from wilzbach/add-check-for-public-unittests
Add check for public unittests
2 parents 72af009 + fb6ce2e commit c65d9e4

File tree

18 files changed

+70
-9
lines changed

18 files changed

+70
-9
lines changed

circle.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ test:
88
override:
99
- ./circleci.sh style
1010
- ./circleci.sh setup-repos
11+
- ./circleci.sh publictests
1112
- ./circleci.sh coverage:
1213
parallel: true
1314

circleci.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -uexo pipefail
55
HOST_DMD_VER=2.068.2 # same as in dmd/src/posix.mak
66
DSCANNER_DMD_VER=2.071.2 # dscanner needs a more up-to-date version
77
CURL_USER_AGENT="CirleCI $(curl --version | head -n 1)"
8+
DUB=${DUB:-$HOME/dlang/dub/dub}
89
N=2
910

1011
case $CIRCLE_NODE_INDEX in
@@ -97,9 +98,19 @@ coverage()
9798
make -f posix.mak $(find std etc -name "*.d" | sed "s/[.]d$/.test/" | grep -vE '(std.algorithm.sorting|std.encoding|net.curl)' )
9899
}
99100

101+
# compile all public unittests separately
102+
publictests()
103+
{
104+
clone https://github.com/dlang/tools.git ../tools master
105+
# fix to a specific version of https://github.com/dlang/tools/blob/master/phobos_tests_extractor.d
106+
git -C ../tools checkout 184f5e60372d6dd36d3451b75fb6f21e23f7275b
107+
make -f posix.mak publictests DUB=$DUB
108+
}
109+
100110
case $1 in
101111
install-deps) install_deps ;;
102-
coverage) coverage ;;
103112
setup-repos) setup_repos ;;
113+
coverage) coverage ;;
104114
style) style ;;
115+
publictests) publictests ;;
105116
esac

posix.mak

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ DRUNTIME_PATH = ../druntime
5656
ZIPFILE = phobos.zip
5757
ROOT_OF_THEM_ALL = generated
5858
ROOT = $(ROOT_OF_THEM_ALL)/$(OS)/$(BUILD)/$(MODEL)
59+
DUB=dub
5960
# Documentation-related stuff
6061
DOCSRC = ../dlang.org
6162
WEBSITE_DIR = ../web
@@ -516,6 +517,13 @@ style: ../dscanner/dsc
516517
@echo "Running DScanner"
517518
../dscanner/dsc --config .dscanner.ini --styleCheck $$(find etc std -type f -name '*.d' | grep -vE 'std/traits.d|std/typecons.d') -I.
518519

520+
publictests: $(LIB)
521+
# parse all public unittests from Phobos, for now some modules are excluded
522+
rm -rf ./out
523+
DFLAGS="$(DFLAGS) $(LIB) -defaultlib= -debuglib= $(LINKDL)" $(DUB) --compiler=$${PWD}/$(DMD) --single ../tools/phobos_tests_extractor.d -- --inputdir . --ignore "allocator/allocator_list.d,allocator/building_blocks/allocator_list.d,allocator/building_blocks/free_list.d,allocator/building_blocks/quantizer,allocator/building_blocks/quantizer,allocator/building_blocks/stats_collector.d,base64.d,bitmanip.d,concurrency.d,conv.d,csv.d,datetime.d,digest/hmac.d,digest/sha.d,file.d,index.d,isemail.d,logger/core.d,logger/nulllogger.d,math.d,ndslice/selection.d,ndslice/slice.d,numeric.d,stdio.d,traits.d,typecons.d,uni.d,utf.d,uuid.d" --outputdir ./out
524+
# execute all parsed tests
525+
for file in $$(find out -name '*.d'); do echo "executing $${file}" && $(DMD) $(DFLAGS) -defaultlib= -debuglib= $(LIB) -main -unittest -run $$file || exit 1 ; done
526+
519527
.PHONY : auto-tester-build
520528
auto-tester-build: all checkwhitespace
521529

std/algorithm/comparison.d

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,6 +1991,8 @@ bool isPermutation(alias pred = "a == b", Range1, Range2)
19911991
///
19921992
@safe pure unittest
19931993
{
1994+
import std.typecons : Yes;
1995+
19941996
assert(isPermutation([1, 2, 3], [3, 2, 1]));
19951997
assert(isPermutation([1.1, 2.3, 3.5], [2.3, 3.5, 1.1]));
19961998
assert(isPermutation("abc", "bca"));

std/algorithm/iteration.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4086,6 +4086,7 @@ if (isForwardRange!Range && is(typeof(unaryFun!isTerminator(input.front))))
40864086
@safe unittest
40874087
{
40884088
import std.algorithm.comparison : equal;
4089+
import std.range.primitives : front;
40894090

40904091
assert(equal(splitter!(a => a == ' ')("hello world"), [ "hello", "", "world" ]));
40914092
int[] a = [ 1, 2, 0, 0, 3, 0, 4, 5, 0 ];

std/algorithm/mutation.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2588,6 +2588,7 @@ swapRanges(InputRange1, InputRange2)(InputRange1 r1, InputRange2 r2)
25882588
///
25892589
@safe unittest
25902590
{
2591+
import std.range : empty;
25912592
int[] a = [ 100, 101, 102, 103 ];
25922593
int[] b = [ 0, 1, 2, 3 ];
25932594
auto c = swapRanges(a[1 .. 3], b[2 .. 4]);

std/algorithm/searching.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4177,6 +4177,7 @@ struct Until(alias pred, Range, Sentinel) if (isInputRange!Range)
41774177
@safe unittest
41784178
{
41794179
import std.algorithm.comparison : equal;
4180+
import std.typecons : No;
41804181
int[] a = [ 1, 2, 4, 7, 7, 2, 4, 7, 3, 5];
41814182
assert(equal(a.until(7), [1, 2, 4][]));
41824183
assert(equal(a.until(7, No.openRight), [1, 2, 4, 7][]));

std/algorithm/sorting.d

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3558,6 +3558,8 @@ TRange topNCopy(alias less = "a < b", SRange, TRange)
35583558
///
35593559
unittest
35603560
{
3561+
import std.typecons : Yes;
3562+
35613563
int[] a = [ 10, 16, 2, 3, 1, 5, 0 ];
35623564
int[] b = new int[3];
35633565
topNCopy(a, b, Yes.sortOutput);
@@ -3567,6 +3569,7 @@ unittest
35673569
unittest
35683570
{
35693571
import std.random : Random, unpredictableSeed, uniform, randomShuffle;
3572+
import std.typecons : Yes;
35703573

35713574
debug(std_algorithm) scope(success)
35723575
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
@@ -3679,6 +3682,8 @@ void topNIndex(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable,
36793682
///
36803683
unittest
36813684
{
3685+
import std.typecons : Yes;
3686+
36823687
// Construct index to top 3 elements using numerical indices:
36833688
int[] a = [ 10, 2, 7, 5, 8, 1 ];
36843689
int[] index = new int[3];
@@ -3862,7 +3867,6 @@ if (isRandomAccessRange!Range && hasLength!Range &&
38623867
}
38633868
}
38643869

3865-
///
38663870
unittest
38673871
{
38683872
// Verify medianOf for all permutations of [1, 2, 2, 3, 4].

std/exception.d

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,8 @@ bool mayPointTo(S, T)(auto ref const shared S source, ref const shared T target)
11961196
//To check the class payload itself, iterate on its members:
11971197
()
11981198
{
1199+
import std.traits : Fields;
1200+
11991201
foreach (index, _; Fields!C)
12001202
if (doesPointTo(a.tupleof[index], i))
12011203
return;

std/experimental/ndslice/slice.d

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,8 @@ pure nothrow unittest
498498
import std.algorithm.iteration : map, sum, reduce;
499499
import std.algorithm.comparison : max;
500500
import std.experimental.ndslice.iteration : transposed;
501+
import std.typecons : No;
502+
501503
/// Returns maximal column average.
502504
auto maxAvg(S)(S matrix) {
503505
return matrix.transposed.map!sum.reduce!max
@@ -515,6 +517,8 @@ pure nothrow unittest
515517
import std.algorithm.iteration : map, sum, reduce;
516518
import std.algorithm.comparison : max;
517519
import std.experimental.ndslice.iteration : transposed;
520+
import std.typecons : No;
521+
518522
/// Returns maximal column average.
519523
auto maxAvg(S)(S matrix) {
520524
return matrix.transposed.map!sum.reduce!max

0 commit comments

Comments
 (0)