Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

root/tags/releases/0.99.8/lib/unittest.sh

Revision 4409, 3.8 kB (checked in by fawzi, 3 years ago)

improving hashing, typeinfo further refs #988
better runtime support for stacktracing refs #1368
allow overriding of exception info in constructor closes #1308
using non allocating void writeOut(void delegate(char[])sink) for exception messages closes #508
WARNING: this checkin changes object.di, you will need to rebuild the runtime

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1 #!/usr/bin/env bash
2
3 # A simple script to build unittests for on posix for dmd/gdc
4 # Copyright (C) 2007  Lars Ivar Igesund
5 # Permission is granted to do anything you please with this software.
6 # This software is provided with no warranty, express or implied, within the
7 # bounds of applicable law.
8
9
10 die() {
11     echo "$1"
12     exit $2
13 }
14
15 usage() {
16     echo 'Usage: ./unittest.sh [otions ...]
17 Options:
18   --help: This message
19   --run-all: Reports result instead of breaking. Do not use this if you want to
20          run unittest runner through a debugger.
21   dmd:    Builds unittests for dmd
22   gdc:    Builds unittests for gdc
23   ldc: Builds unittests for ldc
24
25   <none>: Builds unittests for all known compilers.'
26   exit 0
27 }
28
29 DC=
30 LIB=
31 RUNALL=
32
33 compile() {
34
35     DC=$1
36     EXE=$2
37
38     rebuild --help >& /dev/null || die "rebuild required, aborting" 1
39
40     if ! which $DC >& /dev/null
41     then
42         echo "$DC not found on your \$PATH!"
43     else
44         cd ..
45
46         cat > $EXE.d <<EOF
47 module ${EXE};
48
49 import tango.io.Stdout;
50 import tango.core.Runtime;
51
52 bool tangoUnitTester()
53 {
54     uint countFailed = 0;
55     uint countTotal = 1;
56     Stdout ("NOTE: This is still fairly rudimentary, and will only report the").newline;
57     Stdout ("    first error per module.").newline;
58     foreach ( m; ModuleInfo )  // _moduleinfo_array )
59     {
60         if ( m.unitTest) {
61             Stdout.format ("{}. Executing unittests in '{}' ", countTotal, m.name).flush;
62             countTotal++;
63             try {
64                m.unitTest();
65             }
66             catch (Exception e) {
67                 countFailed++;
68                 Stdout(" - Unittest failed.").newline;
69                 e.writeOut(delegate void(char[]s){ Stdout(s); });
70                 continue;
71             }
72             Stdout(" - Success.").newline;
73         }
74     }
75
76     Stdout.format ("{} out of {} tests failed.", countFailed, countTotal - 1).newline;
77     return true;
78 }
79
80 static this() {
81     $RUNALL   
82 }
83
84 void main() {}
85 EOF
86
87         rebuild -w -d -g -L-ldl -L-lz -L-lbz2 -debug=UnitTest -debug -full -clean -unittest \
88         -version=UnitTest $EXE.d tango/core/*.d tango/core/sync/*.d tango/io/digest/*.d \
89         tango/io/model/*.d tango/io/protocol/*.d tango/io/selector/*.d tango/io/*.d \
90         tango/io/vfs/*.d tango/io/vfs/model/*.d \
91         tango/io/stream/*.d tango/math/*.d tango/math/random/*.d \
92         tango/io/compress/*.d tango/net/ftp/*.d tango/net/http/*.d tango/net/*.d \
93         tango/net/model/*.d tango/stdc/stringz.d tango/sys/*.d tango/text/convert/*.d \
94         tango/text/locale/Collation.d tango/text/locale/Convert.d tango/text/locale/Core.d \
95         tango/text/locale/Data.d tango/text/locale/Locale.d tango/text/locale/Parse.d \
96         tango/text/xml/*.d \
97         tango/text/locale/Posix.d tango/text/stream/*.d tango/text/*.d tango/util/*.d \
98         tango/util/collection/model/*.d tango/util/collection/*.d tango/util/collection/iterator/*.d \
99         tango/util/collection/impl/*.d tango/util/log/model/*.d tango/util/log/*.d \
100         tango/util/container/*.d tango/util/container/model/*.d tango/util/container/more/*.d \
101         tango/time/chrono/*.d tango/time/*.d -dc=$DC-posix-tango
102
103         mv $EXE lib/$EXE
104         rm $EXE.d
105
106         cd lib/
107     fi
108
109 }
110
111 while [ "$#" != "0" ]
112 do
113     case "$1" in
114         --help)
115             usage
116             ;;
117         --run-all)
118             RUNALL="Runtime.moduleUnitTester( &tangoUnitTester );"
119             ;;
120         dmd)
121             DMD=1
122             ;;
123         gdc)
124             GDC=1
125             ;;
126         ldc)
127             LDC=1
128             ;;
129         *)
130             usage
131             ;;
132     esac
133     shift
134 done
135
136 if [ ! "$DMD" -a ! "$GDC" -a ! "$LDC" ]
137 then
138     DMD=1
139     GDC=1
140     LDC=1
141 fi
142
143 if [ "$DMD" = "1" ]
144 then
145     compile dmd runUnitTest_dmd
146 fi
147 if [ "$GDC" = "1" ]
148 then
149     compile gdc runUnitTest_gdc
150 fi
151 if [ "$LDC" = "1" ]
152 then
153     compile ldc runUnitTest_ldc
154 fi
Note: See TracBrowser for help on using the browser.