The updated test runner builds all tests at once to speed up testing.
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = vala-1.0.pc
+.PHONY: test
+test:
+ cd tests && $(MAKE) $(AM_MAKEFLAGS) check
+
dist-hook: gen-ChangeLog
gen_start_date = 2009-02-25
TESTS_ENVIRONMENT = EXEEXT=$(EXEEXT) $(srcdir)/testrunner.sh
TESTS = \
- basic-types/integers.test \
- basic-types/floats.test \
- basic-types/strings.test \
- basic-types/arrays.test \
- basic-types/pointers.test \
- namespaces.test \
- methods/lambda.test \
- methods/closures.test \
- control-flow/break.test \
- control-flow/expressions-conditional.test \
- control-flow/for.test \
- control-flow/foreach.test \
- control-flow/switch.test \
- control-flow/sideeffects.test \
- enums/enums.test \
- structs/structs.test \
- structs/gvalue.test \
- delegates/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 \
- errors/errors.test \
+ basic-types/integers.vala \
+ basic-types/floats.vala \
+ basic-types/strings.vala \
+ basic-types/arrays.vala \
+ basic-types/pointers.vala \
+ namespaces.vala \
+ methods/lambda.vala \
+ methods/closures.vala \
+ control-flow/break.vala \
+ control-flow/expressions-conditional.vala \
+ control-flow/for.vala \
+ control-flow/foreach.vala \
+ control-flow/switch.vala \
+ control-flow/sideeffects.vala \
+ enums/enums.vala \
+ structs/structs.vala \
+ structs/gvalue.vala \
+ delegates/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 \
+ errors/errors.vala \
dbus/basic-types.test \
dbus/arrays.test \
dbus/async.test \
$(NULL)
+check-TESTS: $(TESTS)
+ @EXEEXT=$(EXEEXT) $(srcdir)/testrunner.sh $(TESTS)
+
EXTRA_DIST = \
testrunner.sh \
$(TESTS) \
-
-Program: test
-
void test_integer_array () {
// declaration and initialization
int[] a = { 42 };
assert (b[0] == 42);
}
-void main (string[] args) {
+void main () {
test_integer_array ();
test_string_array ();
test_array_pass ();
-
-Program: test
-
void test_double () {
// declaration and initialization
double d = 42d;
-
-Program: test
-
void test_int () {
// declaration and initialization
int i = 42;
-
-Program: test
-
using GLib;
struct SimpleStruct {
return field;
}
- static void main () {
+ public static void main () {
SimpleStruct* st = new SimpleStruct[1];
st->field = 1;
assert (st->field == st->test ());
}
}
+void main () {
+ SimpleStruct.main ();
+}
+
-
-Program: test
-
void test_string () {
// declaration and initialization
string s = "hello";
-
-Program: test
-
using GLib;
class Maman.Bar : Object {
- static int main (string[] args) {
+ public static int main () {
stdout.printf ("Break Test: 1");
int i;
return 0;
}
}
+
+void main () {
+ Maman.Bar.main ();
+}
-
-Program: test
-
using GLib;
class Maman.Bar : Object {
return false ? "BAD" : "4";
}
- static int main (string[] args) {
+ public static int main () {
stdout.printf ("Conditional Expression Test: 1");
stdout.printf (" %d", false ? -1 : 2);
return 0;
}
}
+
+void main () {
+ Maman.Bar.main ();
+}
-
-Program: test
-
void void_method () {
}
-
-Program: test
-
-
void test_owned (ValueArray array) {
uint i = 0;
-
-Program: test
-
class Maman.Foo : Object {
public int i = 1;
}
class Maman.Bar : Object {
- static int main (string[] args) {
+ public static int main () {
var foo = new Foo ();
foo.sideeffect ().data = "foo";
assert (foo.i == 0);
return 0;
}
}
+
+void main () {
+ Maman.Bar.main ();
+}
-
-Program: test
-
using GLib;
class Maman.Bar : Object {
}
}
- static int main (string[] args) {
+ public static int main () {
stdout.printf ("For Test: 1");
int i;
private int counter = 0;
}
+
+void main () {
+ Maman.Bar.main ();
+}
+
}
MainLoop main_loop;
-int exit_status;
void client_exit (Pid pid, int status) {
// client finished, terminate server
- if (status != 0) {
- exit_status = 1;
- }
+ assert (status == 0);
main_loop.quit ();
}
-int main () {
+void main () {
var conn = DBus.Bus.get (DBus.BusType.SESSION);
dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
// try to register service in session bus
uint request_name_result = bus.request_name ("org.example.Test", (uint) 0);
- if (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER) {
- // start server
- var server = new Test ();
- conn.register_object ("/org/example/test", server);
-
- // server ready, spawn client
- Pid client_pid;
- Process.spawn_async (null, { "client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
- ChildWatch.add (client_pid, client_exit);
-
- main_loop = new MainLoop (null, false);
- main_loop.run ();
- } else {
- exit_status = 1;
- }
- return exit_status;
+ assert (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER);
+
+ // start server
+ var server = new Test ();
+ conn.register_object ("/org/example/test", server);
+
+ // server ready, spawn client
+ Pid client_pid;
+ Process.spawn_async (null, { "test", "/dbus/arrays/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
+ ChildWatch.add (client_pid, client_exit);
+
+ main_loop = new MainLoop (null, false);
+ main_loop.run ();
}
}
MainLoop main_loop;
-int exit_status;
void client_exit (Pid pid, int status) {
// client finished, terminate server
- if (status != 0) {
- exit_status = 1;
- }
+ assert (status == 0);
main_loop.quit ();
}
-int main () {
+void main () {
var conn = DBus.Bus.get (DBus.BusType.SESSION);
dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
// try to register service in session bus
uint request_name_result = bus.request_name ("org.example.Test", (uint) 0);
- if (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER) {
- // start server
- var server = new Test ();
- conn.register_object ("/org/example/test", server);
-
- // server ready, spawn client
- Pid client_pid;
- Process.spawn_async (null, { "client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
- ChildWatch.add (client_pid, client_exit);
-
- main_loop = new MainLoop (null, false);
- main_loop.run ();
- } else {
- exit_status = 1;
- }
- return exit_status;
+ assert (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER);
+
+ // start server
+ var server = new Test ();
+ conn.register_object ("/org/example/test", server);
+
+ // server ready, spawn client
+ Pid client_pid;
+ Process.spawn_async (null, { "test", "/dbus/async/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
+ ChildWatch.add (client_pid, client_exit);
+
+ main_loop = new MainLoop (null, false);
+ main_loop.run ();
}
}
MainLoop main_loop;
-int exit_status;
void client_exit (Pid pid, int status) {
// client finished, terminate server
- if (status != 0) {
- exit_status = 1;
- }
+ assert (status == 0);
main_loop.quit ();
}
-int main () {
+void main () {
var conn = DBus.Bus.get (DBus.BusType.SESSION);
dynamic DBus.Object bus = conn.get_object ("org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus");
// try to register service in session bus
uint request_name_result = bus.request_name ("org.example.Test", (uint) 0);
- if (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER) {
- // start server
- var server = new Test ();
- conn.register_object ("/org/example/test", server);
-
- // server ready, spawn client
- Pid client_pid;
- Process.spawn_async (null, { "client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
- ChildWatch.add (client_pid, client_exit);
-
- main_loop = new MainLoop (null, false);
- main_loop.run ();
- } else {
- exit_status = 1;
- }
- return exit_status;
+ assert (request_name_result == DBus.RequestNameReply.PRIMARY_OWNER);
+
+ // start server
+ var server = new Test ();
+ conn.register_object ("/org/example/test", server);
+
+ // server ready, spawn client
+ Pid client_pid;
+ Process.spawn_async (null, { "test", "/dbus/basic-types/client" }, null, SpawnFlags.DO_NOT_REAP_CHILD, null, out client_pid);
+ ChildWatch.add (client_pid, client_exit);
+
+ main_loop = new MainLoop (null, false);
+ main_loop.run ();
}
-
-Program: test
-
using GLib;
public enum ParameterEnum { FOO, BAR }
call_instance_delegate (bar.foo_method);
}
- static int main (string[] args) {
+ public static int main () {
stdout.printf ("Delegate Test: 1");
VoidCallback void_cb = do_void_action;
return 0;
}
}
+
+void main () {
+ Maman.Bar.main ();
+}
+
-
-Program: test
-
using GLib;
enum Maman.Foo {
Foo foo = 0;
}
- static int main (string[] args) {
+ public static int main () {
stdout.printf ("Enum Test: 1");
var bar = new Bar ();
return 0;
}
}
+
+void main () {
+ Maman.Bar.main ();
+}
+
-
-Program: test
-
using GLib;
errordomain Maman.BarError {
}
}
- static int main (string[] args) {
+ public static int main () {
stdout.printf ("Exception Test: 1");
var bar = new Bar ();
return 0;
}
}
+
+void main () {
+ Maman.Bar.main ();
+}
+
-
-Program: test
-
delegate int Func ();
int A (int k, Func x1, Func x2, Func x3, Func x4, Func x5) {
-
-Program: test
-
using GLib;
static delegate int Maman.ActionCallback (int i);
return cb (1);
}
- static int main (string[] args) {
+ public static int main () {
stdout.printf ("Lambda Test: 1");
stdout.printf (" %d", do_action (i => i * 2));
return 0;
}
}
+
+void main () {
+ Maman.Bar.main ();
+}
+
-
-Program: test
-
using Foo.Sub;
public class GlobalTestClass {
}
namespace Maman {
- public class GlobalTestClass {
- public GlobalTestClass() {
- stdout.printf("Incorrect class constructed");
- }
- }
-
- static int main (string[] args) {
+ static int main () {
stdout.printf ("Namespace Test\n");
Bar.run ();
- new global::GlobalTestClass();
+ new GlobalTestClass();
var obj = new ClassInNestedNamespace ();
public class Foo.Sub.ClassInNestedNamespace {
}
+
+void main () {
+ Maman.main ();
+}
+
-
-Program: test
-
using GLib;
[Compact]
-
-Program: test
-
using GLib;
[Compact]
private_class_field, public_class_field);
}
- static int main (string[] args) {
+ public static int main () {
stdout.printf ("Field Test: 1");
var bar = new Bar ();
return 0;
}
}
+
+void main () {
+ Maman.Bar.main ();
+}
+
-
-Program: test
-
using GLib;
interface Maman.Ibaz : Object {
stdout.printf (" 6");
}
- static int main (string[] args) {
+ public static int main () {
stdout.printf ("Interface Test: 1");
Ibaz ibaz = new Baz ();
return 0;
}
}
+
+void main () {
+ Maman.SubBaz.main ();
+}
+
-
-Program: test
-
using GLib;
class Maman.Bar : Object {
accept_ref_string (ref str);
}
- static int main (string[] args) {
+ public static int main () {
stdout.printf ("Inheritance Test: 1");
var bar = new SubBar ();
}
}
+void main () {
+ Maman.SubBar.main ();
+}
+
-
-Program: test
-
using GLib;
public class Sample : Object {
stdout.printf("automatic: %s\n", automatic);
}
- static int main (string[] args) {
+ public static int main () {
var test = new Sample("InitialName");
test.run();
get { return 2; }
}
}
+
+void main () {
+ Sample.main ();
+}
+
-
-Program: test
-
using GLib;
class Maman.Foo : Object {
stdout.printf (" 9");
}
- static int main (string[] args) {
+ public static int main () {
stdout.printf ("Signal Test: 1");
var bar = new Bar ();
stdout.printf (" 7");
}
}
+
+void main () {
+ Maman.Bar.main ();
+}
+
-
-Program: test
-
using GLib;
class Maman.Bar : Object {
stdout.printf (" 4");
}
- static int main (string[] args) {
+ public static int main () {
stdout.printf ("Base Access Test: 1");
var bar = new SubBar ();
return 0;
}
}
+
+void main () {
+ Maman.SubBar.main ();
+}
+
-
-Program: test
-
using GLib;
class Maman.Bar : Object {
stdout.printf (" 4");
}
- static int main (string[] args) {
+ public static int main () {
stdout.printf ("Hidden Base Method Access Test: 1");
var bar = new SubBar ();
return 0;
}
}
+
+void main () {
+ Maman.SubBar.main ();
+}
+
-
-Program: test
-
using GLib;
class Maman.Foo : Object {
this.p2 = p2;
}
- public static int main (string[] args) {
+ public static int main () {
stdout.printf ("Construct Formal Parameter Test: 1");
var foo = new Foo (2, 3);
return 0;
}
}
+
+void main () {
+ Maman.Foo.main ();
+}
+
-
-Program: test
-
using GLib;
class Maman.A : Object {
}
class Maman.Bar : Object {
- static void main () {
+ public static void main () {
var a = new A ();
var b = new B ();
var c = new C ();
stdout.printf ("as C: %d %d %d\n", null != (a as C) ? 1 : 0, null != (b as C) ? 1 : 0, null != (c as C) ? 1 : 0);
}
}
+
+void main () {
+ Maman.Bar.main ();
+}
+
-
-Program: test
-
void test_value () {
Value v1 = 1;
assert (v1.get_int() == 1);
-
-Program: test
-
using GLib;
struct SimpleStruct {
export G_DEBUG=fatal_warnings
VALAC=$topbuilddir/compiler/valac
-VALAFLAGS="--vapidir $vapidir"
-CC="gcc -std=c99"
-CFLAGS="-O0 -g3"
-LDLIBS="-lm"
-
-CODE=0
+VALAFLAGS="--vapidir $vapidir --disable-warnings --main main --save-temps -X -O0 -X -pipe -X -lm"
function testheader() {
if [ "$1" = "Packages:" ]; then
shift
- PACKAGES="$@"
- for pkg in $PACKAGES; do
+ PACKAGES="$PACKAGES $@"
+ for pkg in "$@"; 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
function sourceheader() {
if [ "$1" = "Program:" ]; then
- PROGRAM=$2
- SOURCEFILE=$PROGRAM.vala
+ testpath=${testfile/.test/}/$2
+ ns=${testpath//\//.}
+ ns=${ns//-/_}
+ SOURCEFILE=$ns.vala
+ SOURCEFILES="$SOURCEFILES $SOURCEFILE"
+ echo " case \"/$testpath\": $ns.main (); break;" >> main.vala
+ echo "namespace $ns {" > $SOURCEFILE
fi
}
function sourceend() {
- if [ -n "$PROGRAM" ]; then
- echo "$VALAC $VALAFLAGS $(echo $PACKAGES | xargs -n 1 -r echo -n " --pkg") -C $SOURCEFILE" >> build
- echo "$CC $CFLAGS -o $PROGRAM$EXEEXT $PROGRAM.c \$(pkg-config --cflags --libs glib-2.0 gobject-2.0 $PACKAGES) $LDLIBS" >> build
- echo "./$PROGRAM$EXEEXT" > check
+ if [ -n "$testpath" ]; then
+ echo "}" >> $SOURCEFILE
+ echo "./test$EXEEXT /$testpath" > check
fi
}
-for testfile in "$@"; do
- testname=$(basename $testfile)
- testdir=${testname/.test/.d}
- rm -rf $testdir
- mkdir $testdir
- cd $testdir
+testdir=_test
+rm -rf $testdir
+mkdir $testdir
+cd $testdir
+
+echo -n -e "TEST: Building...\033[72G"
+
+cat << "EOF" > checkall
+all=0
+fail=0
+EOF
- touch prepare build check cleanup
+cat << "EOF" > main.vala
+void main (string[] args) {
+ switch (args[1]) {
+EOF
+PACKAGES=
+SOURCEFILES=
+for testfile in "$@"; do
+ rm -f prepare check
echo 'set -e' >> prepare
- PART=0
- INHEADER=1
- PACKAGES=
- PROGRAM=
- cat "$builddir/$testfile" | while true; do
- if IFS="" read -r line; then
+ case "$testfile" in
+ *.vala)
+ testpath=${testfile/.vala/}
+ ns=${testpath//\//.}
+ ns=${ns//-/_}
+ SOURCEFILE=$ns.vala
+ SOURCEFILES="$SOURCEFILES $SOURCEFILE"
+
+ echo " case \"/$testpath\": $ns.main (); break;" >> main.vala
+ echo "namespace $ns {" > $SOURCEFILE
+ cat "$srcdir/$testfile" >> $SOURCEFILE
+ echo "}" >> $SOURCEFILE
+
+ echo "./test$EXEEXT /$testpath" > check
+ ;;
+ *.test)
+ PART=0
+ INHEADER=1
+ testpath=
+ while IFS="" read -r line; do
if [ $PART -eq 0 ]; then
if [ -n "$line" ]; then
testheader $line
sourceend
PART=$(($PART + 1))
INHEADER=1
- PROGRAM=
+ testpath=
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
+ done < "$srcdir/$testfile"
+ sourceend
+ ;;
+ esac
+
+ cat prepare check > $ns.check
+ cat << EOF >> checkall
+echo -n -e " /$testpath: \033[72G"
+((all++))
+if bash $ns.check &>log; then
+ echo -e "\033[0;32mOK\033[m"
+else
+ ((fail++))
+ echo -e "\033[0;31mFAIL\033[m"
+ cat log
+fi
+EOF
+done
- cd $builddir
+cat << "EOF" >> checkall
+if [ $fail -eq 0 ]; then
+ echo "All $all tests passed"
+else
+ echo "$fail of $all tests failed"
+ exit 1
+fi
+EOF
+
+cat << "EOF" >> main.vala
+ default: assert_not_reached ();
+ }
+}
+EOF
- if [ $CODE -eq 0 ]; then
- rm -rf $testdir
- fi
-done
+cat $SOURCEFILES >> main.vala
-exit $CODE
+if $VALAC $VALAFLAGS -o test$EXEEXT $(echo $PACKAGES | xargs -n 1 -r echo -n " --pkg") main.vala &>log; then
+ echo -e "\033[0;32mOK\033[m"
+else
+ echo -e "\033[0;31mFAIL\033[m"
+ cat log
+
+ cd $builddir
+ exit 1
+fi
+
+if bash checkall; then
+ cd $builddir
+ rm -rf $testdir
+else
+ cd $builddir
+ exit 1
+fi