+2008-11-22 Jürg Billeter <j@bitron.ch>
+
+ * tests/:
+
+ Prepare support for more complex test cases
+
2008-11-22 Jürg Billeter <j@bitron.ch>
* gobject/valaccodemethodmodule.vala:
TESTS_ENVIRONMENT = EXEEXT=$(EXEEXT) $(srcdir)/testrunner.sh
TESTS = \
- hello.vala \
- basic-types/floats.vala \
- basic-types/integers.vala \
- basic-types/strings.vala \
- basic-types/test-027.vala \
- namespaces.vala \
- methods/lambda.vala \
- control-flow/break.vala \
- control-flow/expressions-conditional.vala \
- control-flow/for.vala \
- control-flow/switch.vala \
- arrays.vala \
- enums.vala \
- structs.vala \
- delegates.vala \
- objects/classes.vala \
- objects/fields.vala \
- objects/interfaces.vala \
- objects/methods.vala \
- objects/properties.vala \
- objects/signals.vala \
- objects/test-025.vala \
- objects/test-026.vala \
- objects/test-029.vala \
- objects/test-034.vala \
- exceptions.vala \
- pointers.vala \
- test-023.vala \
+ basic-types/floats.test \
+ basic-types/integers.test \
+ basic-types/strings.test \
+ basic-types/test-027.test \
+ namespaces.test \
+ methods/lambda.test \
+ control-flow/break.test \
+ control-flow/expressions-conditional.test \
+ control-flow/for.test \
+ control-flow/switch.test \
+ arrays.test \
+ enums.test \
+ structs.test \
+ delegates.test \
+ objects/classes.test \
+ objects/fields.test \
+ objects/interfaces.test \
+ objects/methods.test \
+ objects/properties.test \
+ objects/signals.test \
+ objects/test-025.test \
+ objects/test-026.test \
+ objects/test-029.test \
+ objects/test-034.test \
+ exceptions.test \
+ pointers.test \
+ test-023.test \
$(NULL)
EXTRA_DIST = \
testrunner.sh \
$(TESTS) \
- \
- hello.exp \
- basic-types/floats.exp \
- basic-types/integers.exp \
- basic-types/strings.exp \
- basic-types/test-027.exp \
- namespaces.exp \
- methods/lambda.exp \
- control-flow/break.exp \
- control-flow/expressions-conditional.exp \
- control-flow/for.exp \
- control-flow/switch.exp \
- arrays.exp \
- enums.exp \
- structs.exp \
- delegates.exp \
- objects/classes.exp \
- objects/fields.exp \
- objects/interfaces.exp \
- objects/methods.exp \
- objects/properties.exp \
- objects/signals.exp \
- objects/test-025.exp \
- objects/test-026.exp \
- objects/test-029.exp \
- objects/test-034.exp \
- exceptions.exp \
- pointers.exp \
- test-023.exp \
$(NULL)
+++ /dev/null
-One dimensional array creation and assignment: 1 2 3 4 5 6 7 8 9 10 11
-String array creation and assignment: 1 2 3 4 5 6 7 8 9 10 11
-Object array creation and assignment: 1 2 3 4 5 6 7 8 9 10 11
-Array Test: 1 2 3 4 5
-testing switch on strings: 1 2 3 4 5 6 7
-Element access: 1 2 3 4 5 6 7 8 9 10 11 12 13
+
+Program: test
+
using GLib;
class Maman.Foo : Object {
+++ /dev/null
-float: range=1.17549e-38...3.40282e+38
- digits=24(6), exp=-125..128(-37..38)
- epsilon=1.19209e-07, infinity=inf/-inf, nan=nan
-float(1.19209e-07): nan=false, finite=true, normal=true, infinity=none
-float(0): nan=false, finite=true, normal=false, infinity=none
-float(1): nan=false, finite=true, normal=true, infinity=none
-float(-inf): nan=false, finite=false, normal=false, infinity=negative
-float(inf): nan=false, finite=false, normal=false, infinity=positive
-float(nan): nan=true, finite=false, normal=false, infinity=none
-double: range=2.22507e-308...1.79769e+308
- digits=53(15), exp=-1021..1024(-307..308)
- epsilon=2.22045e-16, infinity=inf/-inf, nan=nan
-double(2.22045e-16): nan=false, finite=true, normal=true, infinity=none
-double(0): nan=false, finite=true, normal=false, infinity=none
-double(1): nan=false, finite=true, normal=true, infinity=none
-double(-inf): nan=false, finite=false, normal=false, infinity=negative
-double(inf): nan=false, finite=false, normal=false, infinity=positive
-double(nan): nan=true, finite=false, normal=false, infinity=none
+
+Program: test
+
using GLib;
class Maman.Foo : Object {
+++ /dev/null
-Binary Expression Test: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
-Assignment Test: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
-int8: -128...127
-int16: -32768...32767
-int32: -2147483648...2147483647
-int64: -9223372036854775808...9223372036854775807
-uint8: 0...255
-uint16: 0...65535
-uint32: 0...4294967295
-uint64: 0...18446744073709551615
+
+Program: test
+
using GLib;
class Maman.Bar : Object {
+++ /dev/null
-String Test: 1 2 3 4 5 6 7 8
+
+Program: test
+
using GLib;
class Maman.Foo : Object {
+++ /dev/null
-Postfix and Prefix Expression Test: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
-Prefix Increment in Loop Test: 0 1 2 3 4 5 6 7 8 9 10
+
+Program: test
+
using GLib;
class Maman.Bar : Object {
+++ /dev/null
-Break Test: 1 2 3
+
+Program: test
+
using GLib;
class Maman.Bar : Object {
+++ /dev/null
-Conditional Expression Test: 1 2 3 4 5
+
+Program: test
+
using GLib;
class Maman.Bar : Object {
+
+Program: test
+
void void_method () {
}
+++ /dev/null
-For Test: 1 2 3 4 5 6 7
-Switch statement: 1 2 3 4 5 6 7
+
+Program: test
+
using GLib;
class Maman.Bar : Object {
+++ /dev/null
-Delegate Test: 1 2 3 4 5 6 7
-testing function pointers: 1 2 3
+
+Program: test
+
using GLib;
public static delegate void Maman.VoidCallback ();
+++ /dev/null
-Enum Test: 1 2 3 4 5 6
+
+Program: test
+
using GLib;
enum Maman.Foo {
+++ /dev/null
-Exception Test: 1 2 3 4 5 6 7 8 9 10 11
+
+Program: test
+
using GLib;
errordomain Maman.BarError {
+++ /dev/null
-Hello, world!
+++ /dev/null
-using GLib;
-
-public class Sample : Object {
- public Sample () {
- }
-
- public void run () {
- stdout.printf ("Hello, world!\n");
- }
-
- static int main (string[] args) {
- var sample = new Sample ();
- sample.run ();
- return 0;
- }
-}
-
+++ /dev/null
-Lambda Test: 1 2 3 4
+
+Program: test
+
using GLib;
static delegate int Maman.ActionCallback (int i);
+++ /dev/null
-Namespace Test
-Class in Namespace Test
+
+Program: test
+
using Foo.Sub;
public class GlobalTestClass {
+++ /dev/null
-Classes Test:
-new CompactClass ()
-new DerivedClass ()
-new PublicClass ()
-new ClassWithCreationMethod ()
-ClassWithCreationMethod
-new ClassWithNamedCreationMethod ()
-ClassWithNamedCreationMethod
-new CompactClassWithDestructor ()
-~CompactClassWithDestructor
-new SimpleGTypeInstanceClass ()
-new DerivedGTypeInstanceClass ()
-new PublicGTypeInstanceClass ()
-new GTypeInstanceClassWithCreationMethod ()
-GTypeInstanceClassWithCreationMethod
-new GTypeInstanceClassWithNamedCreationMethod ()
-GTypeInstanceClassWithNamedCreationMethod
-new SimpleGObjectClass ()
-new DerivedGObjectClass ()
-new PublicGObjectClass ()
-new GObjectClassWithCreationMethod ()
-new GObjectClassWithNamedCreationMethod ()
-new CompactClass () { field = 1 }
-compact_class.field = 1
-.
+
+Program: test
+
using GLib;
[Compact]
+++ /dev/null
-Field Test: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
+
+Program: test
+
using GLib;
[Compact]
+++ /dev/null
-Interface Test: 1 2 3 4 5 6 7
+
+Program: test
+
using GLib;
interface Maman.Ibaz : Object {
+++ /dev/null
-Inheritance Test: 1 2 3
-Static Inheritance Test: 1 2 3
-Virtual Method Test: 1 2 3
-Interface Inheritance Test: 1 2 3
-Access class method in class constructor: OK
-Access class method in static constructor: OK
-Access class method by member access: OK
-Access class method in instance method: OK
+
+Program: test
+
using GLib;
class Maman.Bar : Object {
+++ /dev/null
-property `name' has changed!
-automatic: TheNewAutomatic
-name: TheNewName
-read_only: InitialReadOnly
-automatic: TheNewAutomatic
-Property Test: 1 2 3 4 5 6 7
-Interface Properties Test: 1 2 3
+
+Program: test
+
using GLib;
public class Sample : Object {
+++ /dev/null
-Signal Test: 1 2 3 4 5 6 7 8 9 10
-User Signal Test: 1 2 3 4 5 6
-Signal Return Test: 1 2 3 4 5 6 7 8
+
+Program: test
+
using GLib;
class Maman.Foo : Object {
+++ /dev/null
-Base Access Test: 1 2 3 4 5
+
+Program: test
+
using GLib;
class Maman.Bar : Object {
+++ /dev/null
-Hidden Base Method Access Test: 1 2 3 4 5
+
+Program: test
+
using GLib;
class Maman.Bar : Object {
+++ /dev/null
-Construct Formal Parameter Test: 1 2 3 4 5
+
+Program: test
+
using GLib;
class Maman.Foo : Object {
+++ /dev/null
-init: 1 1 1
-is A: 1 1 0
-is B: 0 1 0
-is C: 0 0 1
-as A: 1 1 0
-as B: 0 1 0
-as C: 0 0 1
+
+Program: test
+
using GLib;
class Maman.A : Object {
+
+Program: test
+
using GLib;
struct SimpleStruct {
+++ /dev/null
-Structs Test:
-new SimpleStruct ()
-new PublicStruct ()
-new StructWithCreationMethod ()
-StructWithCreationMethod
-new StructWithNamedCreationMethod ()
-StructWithNamedCreationMethod
-new SimpleStruct () { field = 1 }
-simple_struct.field = 1
-test_in_parameter: st.field = 1
-test_ref_parameter: st.field = 1
-after test_ref_parameter: st.field = 2
-after test_out_parameter: st.field = 3
-StructWithPrivateField: field = 1
-.
+
+Program: test
+
using GLib;
struct SimpleStruct {
+++ /dev/null
-List construction: 1 2 3 4
+
+Program: test
+
using GLib;
class Maman.Foo : Object {
srcdir=`dirname $0`
topsrcdir=$srcdir/..
vapidir=$topsrcdir/vapi
-exe=$EXEEXT
-
-# make sure we detect failed test cases
-set -o pipefail
export G_DEBUG=fatal_warnings
CODE=0
-for testcasesource in "$@"
-do
- testsrc=${testcasesource/.vala/}
- if ! $VALAC -C --vapidir "$vapidir" --basedir $topsrcdir -d $topbuilddir $testsrc.vala > $testsrc.err 2>&1
- then
- echo "ERROR: Compiling" $testcasesource
- cat $testsrc.err
- CODE=1
- continue
+function testheader() {
+ if [ "$1" = "Packages:" ]; then
+ shift
+ PACKAGES="$@"
+ for pkg in $PACKAGES; do
+ if [ "$pkg" = "dbus-glib-1" ]; then
+ echo 'eval `dbus-launch --sh-syntax`' >> prepare
+ echo 'trap "kill $DBUS_SESSION_BUS_PID" INT TERM EXIT' >> prepare
+ fi
+ done
fi
- if ! $CC $CFLAGS $testsrc.c $(pkg-config --cflags --libs gobject-2.0) -o $testsrc $LDLIBS > $testsrc.err 2>&1
- then
- echo "ERROR: Compiling" $testsrc.c
- cat $testsrc.err
- CODE=1
- continue
+}
+
+function sourceheader() {
+ if [ "$1" = "Program:" ]; then
+ PROGRAM=$2
+ SOURCEFILE=$PROGRAM.vala
fi
- if ./$testsrc 2>&1 | tee $testsrc.err | cmp -s $testsrc.exp
- then
- rm $testsrc.c $testsrc.h $testsrc$exe $testsrc.err
- else
- echo "ERROR: test failed. This is the difference between" $testsrc.exp "and" $testsrc.err
- diff -u $testsrc.exp $testsrc.err
+}
+
+function sourceend() {
+ if [ -n "$PROGRAM" ]; then
+ echo "$VALAC $(echo $PACKAGES | xargs -n 1 -r echo --pkg) -C $SOURCEFILE" >> build
+ echo "$CC $CFLAGS $LDLIBS \$(pkg-config --cflags --libs glib-2.0 gobject-2.0 $PACKAGES) -o $PROGRAM$EXEEXT $PROGRAM.c" >> build
+ echo "./$PROGRAM$EXEEXT" > check
+ fi
+}
+
+for testfile in "$@"; do
+ testname=$(basename $testfile)
+ testdir=${testname/.test/.d}
+ rm -rf $testdir
+ mkdir $testdir
+ cd $testdir
+
+ touch prepare build check cleanup
+
+ echo 'set -e' >> prepare
+
+ PART=0
+ INHEADER=1
+ PACKAGES=
+ PROGRAM=
+ cat "$builddir/$testfile" | while true; do
+ if IFS="" read -r line; then
+ if [ $PART -eq 0 ]; then
+ if [ -n "$line" ]; then
+ testheader $line
+ else
+ PART=1
+ fi
+ else
+ if [ $INHEADER -eq 1 ]; then
+ if [ -n "$line" ]; then
+ sourceheader $line
+ else
+ INHEADER=0
+ fi
+ else
+ if echo "$line" | grep -q "^[A-Za-z]\+:"; then
+ sourceend
+ PART=$(($PART + 1))
+ INHEADER=1
+ PROGRAM=
+ sourceheader $line
+ else
+ echo "$line" >> $SOURCEFILE
+ fi
+ fi
+ fi
+ else
+ sourceend
+ break
+ fi
+ done
+
+ cat prepare build check cleanup > script
+ if ! bash script >log 2>&1; then
+ cat log
CODE=1
fi
+
+ cd $builddir
+
+ if [ $CODE -eq 0 ]; then
+ rm -rf $testdir
+ fi
done
exit $CODE
+