Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test:
override:
- ./circleci.sh style
- ./circleci.sh setup-repos
- ./circleci.sh publictests
- ./circleci.sh coverage:
parallel: true

Expand Down
13 changes: 12 additions & 1 deletion circleci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set -uexo pipefail
HOST_DMD_VER=2.068.2 # same as in dmd/src/posix.mak
DSCANNER_DMD_VER=2.071.2 # dscanner needs a more up-to-date version
CURL_USER_AGENT="CirleCI $(curl --version | head -n 1)"
DUB=${DUB:-$HOME/dlang/dub/dub}
N=2

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

# compile all public unittests separately
publictests()
{
clone https://github.com/dlang/tools.git ../tools master
Copy link
Member

@MartinNowak MartinNowak Dec 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why master instead of $base_branch? I'd argue that unconditionally using master is almost always wrong, b/c it's not tied to the phobos version.
In fact we were only able to resolve most of our testing issues, after scrutinizingly pinning all our dmd, dub, et.al. versions.
Master also means that repeating builds might not be reproducible, that's just asking for troubles (e.g. I spend about 1 week on Issue 16574 b/c the reporter only provided a moving target).
That clone does print the exact commit version, right? So at least it's reproducible.

Possible ways to avoid future issues:

  • checkout a specific version (v2.072.2) or commit of that file in the tools repo
  • maintain that tool in phobos if it's merely designed for phobos
  • do dmd independent releases of that script and pin those

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why master instead of $base_branch? I'd argue that unconditionally using master is almost always wrong, b/c it's not tied to the phobos version.

Thanks for the advice! :)

Possible ways to avoid future issues:
checkout a specific version (v2.072.2) or commit of that file in the tools repo

Okay I have done that.

maintain that tool in phobos if it's merely designed for phobos

Well it's general in the sense that the script has nothing about Phobos hard-coded (except for the script's name), but I think that would have been the best option.

# fix to a specific version of https://github.com/dlang/tools/blob/master/phobos_tests_extractor.d
git -C ../tools checkout 184f5e60372d6dd36d3451b75fb6f21e23f7275b
make -f posix.mak publictests DUB=$DUB
}

case $1 in
install-deps) install_deps ;;
coverage) coverage ;;
setup-repos) setup_repos ;;
coverage) coverage ;;
style) style ;;
publictests) publictests ;;
esac
8 changes: 8 additions & 0 deletions posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ DRUNTIME_PATH = ../druntime
ZIPFILE = phobos.zip
ROOT_OF_THEM_ALL = generated
ROOT = $(ROOT_OF_THEM_ALL)/$(OS)/$(BUILD)/$(MODEL)
DUB=dub
# Documentation-related stuff
DOCSRC = ../dlang.org
WEBSITE_DIR = ../web
Expand Down Expand Up @@ -516,6 +517,13 @@ style: ../dscanner/dsc
@echo "Running DScanner"
../dscanner/dsc --config .dscanner.ini --styleCheck $$(find etc std -type f -name '*.d' | grep -vE 'std/traits.d|std/typecons.d') -I.

publictests: $(LIB)
# parse all public unittests from Phobos, for now some modules are excluded
rm -rf ./out
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
# execute all parsed tests
for file in $$(find out -name '*.d'); do echo "executing $${file}" && $(DMD) $(DFLAGS) -defaultlib= -debuglib= $(LIB) -main -unittest -run $$file || exit 1 ; done

.PHONY : auto-tester-build
auto-tester-build: all checkwhitespace

Expand Down
2 changes: 2 additions & 0 deletions std/algorithm/comparison.d
Original file line number Diff line number Diff line change
Expand Up @@ -1991,6 +1991,8 @@ bool isPermutation(alias pred = "a == b", Range1, Range2)
///
@safe pure unittest
{
import std.typecons : Yes;

assert(isPermutation([1, 2, 3], [3, 2, 1]));
assert(isPermutation([1.1, 2.3, 3.5], [2.3, 3.5, 1.1]));
assert(isPermutation("abc", "bca"));
Expand Down
1 change: 1 addition & 0 deletions std/algorithm/iteration.d
Original file line number Diff line number Diff line change
Expand Up @@ -4086,6 +4086,7 @@ if (isForwardRange!Range && is(typeof(unaryFun!isTerminator(input.front))))
@safe unittest
{
import std.algorithm.comparison : equal;
import std.range.primitives : front;

assert(equal(splitter!(a => a == ' ')("hello world"), [ "hello", "", "world" ]));
int[] a = [ 1, 2, 0, 0, 3, 0, 4, 5, 0 ];
Expand Down
1 change: 1 addition & 0 deletions std/algorithm/mutation.d
Original file line number Diff line number Diff line change
Expand Up @@ -2588,6 +2588,7 @@ swapRanges(InputRange1, InputRange2)(InputRange1 r1, InputRange2 r2)
///
@safe unittest
{
import std.range : empty;
int[] a = [ 100, 101, 102, 103 ];
int[] b = [ 0, 1, 2, 3 ];
auto c = swapRanges(a[1 .. 3], b[2 .. 4]);
Expand Down
1 change: 1 addition & 0 deletions std/algorithm/searching.d
Original file line number Diff line number Diff line change
Expand Up @@ -4177,6 +4177,7 @@ struct Until(alias pred, Range, Sentinel) if (isInputRange!Range)
@safe unittest
{
import std.algorithm.comparison : equal;
import std.typecons : No;
int[] a = [ 1, 2, 4, 7, 7, 2, 4, 7, 3, 5];
assert(equal(a.until(7), [1, 2, 4][]));
assert(equal(a.until(7, No.openRight), [1, 2, 4, 7][]));
Expand Down
6 changes: 5 additions & 1 deletion std/algorithm/sorting.d
Original file line number Diff line number Diff line change
Expand Up @@ -3558,6 +3558,8 @@ TRange topNCopy(alias less = "a < b", SRange, TRange)
///
unittest
{
import std.typecons : Yes;

int[] a = [ 10, 16, 2, 3, 1, 5, 0 ];
int[] b = new int[3];
topNCopy(a, b, Yes.sortOutput);
Expand All @@ -3567,6 +3569,7 @@ unittest
unittest
{
import std.random : Random, unpredictableSeed, uniform, randomShuffle;
import std.typecons : Yes;

debug(std_algorithm) scope(success)
writeln("unittest @", __FILE__, ":", __LINE__, " done.");
Expand Down Expand Up @@ -3679,6 +3682,8 @@ void topNIndex(alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable,
///
unittest
{
import std.typecons : Yes;

// Construct index to top 3 elements using numerical indices:
int[] a = [ 10, 2, 7, 5, 8, 1 ];
int[] index = new int[3];
Expand Down Expand Up @@ -3862,7 +3867,6 @@ if (isRandomAccessRange!Range && hasLength!Range &&
}
}

///
unittest
{
// Verify medianOf for all permutations of [1, 2, 2, 3, 4].
Expand Down
2 changes: 2 additions & 0 deletions std/exception.d
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,8 @@ bool mayPointTo(S, T)(auto ref const shared S source, ref const shared T target)
//To check the class payload itself, iterate on its members:
()
{
import std.traits : Fields;

foreach (index, _; Fields!C)
if (doesPointTo(a.tupleof[index], i))
return;
Expand Down
4 changes: 4 additions & 0 deletions std/experimental/ndslice/slice.d
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,8 @@ pure nothrow unittest
import std.algorithm.iteration : map, sum, reduce;
import std.algorithm.comparison : max;
import std.experimental.ndslice.iteration : transposed;
import std.typecons : No;

/// Returns maximal column average.
auto maxAvg(S)(S matrix) {
return matrix.transposed.map!sum.reduce!max
Expand All @@ -515,6 +517,8 @@ pure nothrow unittest
import std.algorithm.iteration : map, sum, reduce;
import std.algorithm.comparison : max;
import std.experimental.ndslice.iteration : transposed;
import std.typecons : No;

/// Returns maximal column average.
auto maxAvg(S)(S matrix) {
return matrix.transposed.map!sum.reduce!max
Expand Down
1 change: 1 addition & 0 deletions std/experimental/typecons.d
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ unittest
///
unittest
{
import std.traits : functionAttributes, FunctionAttribute;
interface A { int run(); }
interface B { int stop(); @property int status(); }
class X
Expand Down
1 change: 1 addition & 0 deletions std/format.d
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,7 @@ FormatSpec!Char singleSpec(Char)(Char[] fmt)
///
@safe unittest
{
import std.exception : assertThrown;
auto spec = singleSpec("%2.3e");

assert(spec.trailing == "");
Expand Down
2 changes: 2 additions & 0 deletions std/json.d
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import std.traits;
///
@system unittest
{
import std.conv : to;

// parse a file or string of json into a usable structure
string s = `{ "language": "D", "rating": 3.5, "code": "42" }`;
JSONValue j = parseJSON(s);
Expand Down
2 changes: 2 additions & 0 deletions std/path.d
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ auto driveName(R)(R path)
///
@safe unittest
{
import std.range : empty;
version (Posix) assert (driveName("c:/foo").empty);
version (Windows)
{
Expand Down Expand Up @@ -929,6 +930,7 @@ auto extension(R)(R path)
///
@safe unittest
{
import std.range : empty;
assert (extension("file").empty);
assert (extension("file.") == ".");
assert (extension("file.ext"w) == ".ext");
Expand Down
3 changes: 2 additions & 1 deletion std/range/primitives.d
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,6 @@ package(std) template isNativeOutputRange(R, E)
}));
}

///
@safe unittest
{
int[] r = new int[](4);
Expand Down Expand Up @@ -935,6 +934,8 @@ template isRandomAccessRange(R)
///
unittest
{
import std.traits : isNarrowString;

alias R = int[];

// range is finite and bidirectional or infinite and forward.
Expand Down
14 changes: 8 additions & 6 deletions std/regex/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -594,10 +594,9 @@ public:
assert(matchFirst("abc", "[0-9]+", "[a-z]+").whichPattern == 2);
}

/++
Lookup named submatch.

---
/// Lookup named submatch.
unittest
{
import std.regex;
import std.range;

Expand All @@ -608,8 +607,8 @@ public:
//named groups are unaffected by range primitives
assert(c["var"] =="a");
assert(c.front == "42");
----
+/
}

R opIndex(String)(String i) /*const*/ //@@@BUG@@@
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, this was not even a unittest...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I accidentally saw this and thus "ddocified" the example to a unittest

if (isSomeString!String)
{
Expand All @@ -627,6 +626,8 @@ public:
///
unittest
{
import std.range : popFrontN;

auto c = matchFirst("@abc#", regex(`(\w)(\w)(\w)`));
assert(c.pre == "@"); // Part of input preceding match
assert(c.post == "#"); // Immediately after match
Expand Down Expand Up @@ -1592,6 +1593,7 @@ unittest
unittest
{
import std.algorithm.comparison : equal;
import std.typecons : Yes;

const pattern = regex(`([\.,])`);

Expand Down
16 changes: 16 additions & 0 deletions std/string.d
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,8 @@ ptrdiff_t indexOf(Range)(Range s, in dchar c, in size_t startIdx,
///
@safe pure unittest
{
import std.typecons : No;

string s = "Hello World";
assert(indexOf(s, 'W') == 6);
assert(indexOf(s, 'Z') == -1);
Expand All @@ -554,6 +556,8 @@ ptrdiff_t indexOf(Range)(Range s, in dchar c, in size_t startIdx,
///
@safe pure unittest
{
import std.typecons : No;

string s = "Hello World";
assert(indexOf(s, 'W', 4) == 6);
assert(indexOf(s, 'Z', 100) == -1);
Expand Down Expand Up @@ -801,6 +805,8 @@ ptrdiff_t indexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
///
@safe pure unittest
{
import std.typecons : No;

string s = "Hello World";
assert(indexOf(s, "Wo", 4) == 6);
assert(indexOf(s, "Zo", 100) == -1);
Expand All @@ -810,6 +816,8 @@ ptrdiff_t indexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
///
@safe pure unittest
{
import std.typecons : No;

string s = "Hello World";
assert(indexOf(s, "Wo") == 6);
assert(indexOf(s, "Zo") == -1);
Expand Down Expand Up @@ -1059,6 +1067,8 @@ ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, in size_t startIdx,
///
@safe pure unittest
{
import std.typecons : No;

string s = "Hello World";
assert(lastIndexOf(s, 'l') == 9);
assert(lastIndexOf(s, 'Z') == -1);
Expand All @@ -1068,6 +1078,8 @@ ptrdiff_t lastIndexOf(Char)(const(Char)[] s, in dchar c, in size_t startIdx,
///
@safe pure unittest
{
import std.typecons : No;

string s = "Hello World";
assert(lastIndexOf(s, 'l', 4) == 3);
assert(lastIndexOf(s, 'Z', 1337) == -1);
Expand Down Expand Up @@ -1264,6 +1276,8 @@ ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
///
@safe pure unittest
{
import std.typecons : No;

string s = "Hello World";
assert(lastIndexOf(s, "ll") == 2);
assert(lastIndexOf(s, "Zo") == -1);
Expand All @@ -1273,6 +1287,8 @@ ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub,
///
@safe pure unittest
{
import std.typecons : No;

string s = "Hello World";
assert(lastIndexOf(s, "ll", 4) == 2);
assert(lastIndexOf(s, "Zo", 128) == -1);
Expand Down
1 change: 1 addition & 0 deletions std/uni.d
Original file line number Diff line number Diff line change
Expand Up @@ -6851,6 +6851,7 @@ static assert(Grapheme.sizeof == size_t.sizeof*4);
{
import std.algorithm.comparison : equal;
import std.algorithm.iteration : filter;
import std.range : isRandomAccessRange;

string bold = "ku\u0308hn";

Expand Down