Skip to content

Commit efaad13

Browse files
authored
Merge pull request #288 from Zardoz89/examples
Examples uses dub
2 parents c560215 + ff0991b commit efaad13

File tree

58 files changed

+773
-160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+773
-160
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ dub.selections.json
4343
build/*
4444
.directory
4545

46+
.vscode/
47+

.travis.yml

+18-12
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
os: linux
2-
#Latest Ubuntu LTS
2+
# Latest Ubuntu LTS
33
dist: bionic
44
language: d
55

6+
addons:
7+
apt:
8+
update: true
9+
packages:
10+
- gdb
11+
612
# Enable core dumps
713
before_script:
8-
- ulimit -c unlimited -S
9-
- sudo mkdir /cores/ && sudo chmod 777 /cores/
10-
- echo "/cores/%E.%p" | sudo tee /proc/sys/kernel/core_pattern
14+
- ulimit -c unlimited -S
15+
- sudo mkdir /cores/ && sudo chmod 777 /cores/
16+
- echo "/cores/%E.%p" | sudo tee /proc/sys/kernel/core_pattern
1117

1218
after_failure:
13-
- ./scripts/core-dump.sh
19+
- ./scripts/core-dump.sh
1420

1521
jobs:
16-
include:
17-
- d: dmd-nightly
18-
- d: dmd
19-
- d: ldc
20-
allow_failures:
21-
- d: dmd-nightly
22-
22+
include:
23+
- d: dmd-nightly
24+
- d: dmd
25+
- d: ldc
26+
allow_failures:
27+
- d: dmd-nightly
2328

2429
script: ./ci.sh
30+

appveyor.yml

+24-28
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
platform: x64
22
environment:
3-
matrix:
4-
- DC: dmd
5-
DVersion: stable
6-
arch: x64
7-
- DC: dmd
8-
DVersion: stable
9-
arch: x86
10-
- DC: dmd
11-
DVersion: 2.090.1
12-
arch: x86
13-
- DC: dmd
14-
DVersion: 2.087.1
15-
arch: x86
16-
- DC: ldc
17-
DVersion: stable
18-
arch: x86
19-
- DC: ldc
20-
DVersion: stable
21-
arch: x64
3+
matrix:
4+
- DC: dmd
5+
DVersion: stable
6+
arch: x64
7+
- DC: dmd
8+
DVersion: stable
9+
arch: x86
10+
- DC: dmd
11+
DVersion: 2.090.1
12+
arch: x86
13+
- DC: dmd
14+
DVersion: 2.087.1
15+
arch: x86
16+
- DC: ldc
17+
DVersion: stable
18+
arch: x86
19+
- DC: ldc
20+
DVersion: stable
21+
arch: x64
2222

2323
matrix:
2424
allow_failures:
@@ -27,7 +27,7 @@ matrix:
2727
skip_tags: true
2828

2929
install:
30-
- ps: function ResolveLatestDMD
30+
- ps: function ResolveLatestDMD
3131
{
3232
$version = $env:DVersion;
3333
if($version -eq "stable") {
@@ -44,12 +44,11 @@ install:
4444
}
4545
if($env:arch -eq "x64"){
4646
$env:PATH += ";C:\dmd2\windows\bin64;";
47-
} else {
48-
$env:PATH += ";C:\dmd2\windows\bin;";
4947
}
48+
$env:PATH += ";C:\dmd2\windows\bin;";
5049
return $url;
5150
}
52-
- ps: function ResolveLatestLDC
51+
- ps: function ResolveLatestLDC
5352
{
5453
$version = $env:DVersion;
5554
$arch = $env:arch;
@@ -67,7 +66,7 @@ install:
6766
$env:DC = "ldc2";
6867
return $url;
6968
}
70-
- ps: function SetUpDCompiler
69+
- ps: function SetUpDCompiler
7170
{
7271
$env:toolchain = "msvc";
7372
if($env:DC -eq "dmd"){
@@ -91,10 +90,7 @@ install:
9190
popd;
9291
}
9392
}
94-
- ps: SetUpDCompiler
95-
- powershell -Command Invoke-WebRequest http://code.dlang.org/files/dub-1.11.0-windows-x86.zip -OutFile dub.zip
96-
- 7z x dub.zip -odub > nul
97-
- set PATH=%CD%\%binpath%;%CD%\dub;%PATH%
93+
- ps: SetUpDCompiler
9894

9995
before_build:
10096
- ps: if($env:arch -eq "x86"){

ci.bat

+67-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,67 @@
1-
@echo off
2-
@setlocal
3-
setlocal EnableDelayedExpansion
4-
5-
echo Unit Tests
6-
REM cd %~dp0\..
7-
8-
echo "Test for successful release build"
9-
dub build -b release --compiler=%DC%
10-
dub clean --all-packages
11-
12-
echo "Runnin tests"
13-
dub test --compiler=%DC% -v
14-
REM --build=unittest-cov
1+
@echo off
2+
@setlocal
3+
setlocal EnableDelayedExpansion
4+
5+
echo Unit Tests
6+
7+
echo "Test for successful release build"
8+
dub build -b release --compiler=%DC%
9+
dub clean --all-packages -q
10+
11+
echo "Running tests"
12+
dub test --compiler=%DC% -v
13+
14+
echo "Running example tests"
15+
16+
pushd examples\simple_arithmetic
17+
dub test --compiler=%DC% -q
18+
popd
19+
20+
dub test :numbers --compiler=%DC% -q
21+
dub test :arithmetic --compiler=%DC% -q
22+
dub test :strings --compiler=%DC% -q
23+
dub test :csv --compiler=%DC% -q
24+
dub test :json --compiler=%DC% -q
25+
26+
pushd examples\composition
27+
dub test --compiler=%DC% -q
28+
popd
29+
30+
rem TODO Actually doesn't compiles
31+
rem pushd examples\c
32+
rem dub test --compiler=%DC% -q
33+
rem popd
34+
35+
pushd examples\dgrammar
36+
dub test --compiler=%DC% -q
37+
popd
38+
39+
pushd examples\markdown
40+
dub test --compiler=%DC% -q
41+
popd
42+
43+
pushd examples\oberon2
44+
dub test --compiler=%DC% -q
45+
popd
46+
47+
pushd examples\parameterized
48+
dub test --compiler=%DC% -q
49+
popd
50+
51+
pushd examples\PEG
52+
dub test --compiler=%DC% -q
53+
popd
54+
55+
pushd examples\peggedgrammar
56+
dub test --compiler=%DC% -q
57+
popd
58+
59+
pushd examples\xml
60+
dub test --compiler=%DC% -q
61+
popd
62+
63+
echo Execute extended_pascal build
64+
pushd examples\extended_pascal
65+
rem Hack to workaround dub bug with preGenerateCommands
66+
dub build -b release --compiler=%DC% || dub build -b release --compiler=%DC%
67+
popd

ci.sh

+52-3
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,69 @@ DC=${DC:-dmd}
66

77
# test for successful release build
88
dub build -b release --compiler=$DC
9-
dub clean --all-packages
9+
dub clean --all-packages -q
1010

1111
# test for successful 32-bit build
1212
if [ "$DC" == "dmd" ]; then
1313
dub build -b release --compiler=$DC --arch=x86
14-
dub clean --all-packages
14+
dub clean --all-packages -q
1515
fi
1616

1717
# Run unit tests
1818
dub test --compiler=$DC
1919

20+
# Run examples tests
21+
pushd examples/simple_arithmetic
22+
dub test --compiler=$DC -q
23+
popd
24+
25+
dub test :arithmetic --compiler=$DC -q
26+
dub test :numbers --compiler=$DC -q
27+
dub test :strings --compiler=$DC -q
28+
dub test :csv --compiler=$DC -q
29+
dub test :json --compiler=$DC -q
30+
31+
pushd examples/composition
32+
dub test --compiler=$DC -q
33+
popd
34+
35+
# TODO Actually doesn't compiles
36+
# pushd examples/c
37+
# dub test --compiler=$DC -q
38+
# popd
39+
40+
pushd examples/dgrammar
41+
dub test --compiler=$DC -q
42+
popd
43+
44+
pushd examples/markdown
45+
dub test --compiler=$DC -q
46+
popd
47+
48+
pushd examples/oberon2
49+
dub test --compiler=$DC -q
50+
popd
51+
52+
pushd examples/parameterized
53+
dub test --compiler=$DC -q
54+
popd
55+
56+
pushd examples/PEG
57+
dub test --compiler=$DC -q
58+
popd
59+
60+
pushd examples/peggedgrammar
61+
dub test --compiler=$DC -q
62+
popd
63+
64+
pushd examples/xml
65+
dub test --compiler=$DC -q
66+
popd
67+
2068
# Execute extended_pascal build with time -v
21-
cd pegged/examples/extended_pascal
69+
pushd examples/extended_pascal
2270
# Hack to workaround dub bug with preGenerateCommands
2371
dub build -b release --compiler=$DC || true
2472
/usr/bin/time -v dub build -b release --compiler=$DC
73+
popd
2574

dub.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,18 @@
2121
"dflags-ldc": ["-check-printf-calls"],
2222
"configurations": [
2323
{
24-
"name": "default",
24+
"name": "default"
2525
},
2626
{
2727
"name": "tracer",
28-
"versions": ["tracer"],
28+
"versions": ["tracer"]
2929
}
30+
],
31+
"subPackages": [
32+
"examples/arithmetic",
33+
"examples/numbers",
34+
"examples/strings",
35+
"examples/csv",
36+
"examples/json"
3037
]
3138
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/PEG/dub.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "PEG",
3+
"description": "The basic PEG grammar, as described by Ford.",
4+
"license": "Boost",
5+
"targetType": "library",
6+
"dependencies": {
7+
"pegged": {
8+
"version": "*",
9+
"path": "../.."
10+
}
11+
}
12+
}
File renamed without changes.
File renamed without changes.

examples/arithmetic/dub.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "arithmetic",
3+
"description": "Example arithmetic PEG grammar. Parses arithmetic expression, like 1*(2+ x/3) - ( x * y * y -4).",
4+
"license": "Boost",
5+
"targetType": "library",
6+
"dependencies": {
7+
"pegged": {
8+
"version": "*",
9+
"path": "../.."
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)