[libgee] Tests are not terminated when they fail in trap



commit fae11e4ac5f8c88066f3edc36e3a69384a03bff5
Author: Maciej Piechotka <uzytkownik2 gmail com>
Date:   Tue Sep 29 08:01:01 2009 +0200

    Tests are not terminated when they fail in trap
    
    When code in trap succeeds subprocess should be terminated - not only
    test case.
    
    Fixes bug 596703.

 tests/Makefile.am                 |    2 +-
 tests/testlist.vala               |   40 ++++++++++++++++++------------------
 tests/testmap.vala                |    6 ++--
 tests/testreadonlycollection.vala |   14 ++++++------
 tests/testreadonlylist.vala       |   18 ++++++++--------
 tests/testreadonlymap.vala        |   12 +++++-----
 tests/testsortedset.vala          |   12 ++++++----
 7 files changed, 53 insertions(+), 51 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 343859a..7976bb4 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -49,7 +49,7 @@ tests_DEPENDENCIES = $(top_srcdir)/gee/gee-1.0.vapi
 
 tests_SOURCES = tests.vala.stamp $(tests_VALASOURCES:.vala=.c)
 tests.vala.stamp: $(tests_VALASOURCES)
-	$(VALAC) -C --basedir $(top_srcdir) --vapidir $(top_srcdir)/gee --pkg gee-1.0 $^
+	$(VALAC) -C --basedir $(top_srcdir) --vapidir $(top_srcdir)/gee --pkg gee-1.0 --pkg posix $^
 	touch $@
 tests_LDADD = $(progs_ldadd)
 EXTRA_DIST += $(tests_VALASOURCES)
diff --git a/tests/testlist.vala b/tests/testlist.vala
index 2d8d7a9..48ca387 100644
--- a/tests/testlist.vala
+++ b/tests/testlist.vala
@@ -188,7 +188,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.get (0);
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -200,7 +200,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.get (1);
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -208,7 +208,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.get (-1);
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -225,7 +225,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.get (0);
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 	}
@@ -241,7 +241,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.set (0, "zero");
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (test_list.size == 0);
@@ -260,7 +260,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.set (1, "zero");
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (test_list.size == 1);
@@ -277,7 +277,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.insert (1, "zero");
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -302,7 +302,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.insert (4, "four");
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -317,7 +317,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.insert (-1, "zero");
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 	}
@@ -332,14 +332,14 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.remove_at (0);
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.remove_at (1);
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -376,7 +376,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.remove_at (2);
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -384,7 +384,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.remove_at (-1);
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 	}
@@ -424,7 +424,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.first ();
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -445,7 +445,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.first ();
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 	}
@@ -460,7 +460,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.last ();
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -481,7 +481,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.last ();
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 	}
@@ -536,7 +536,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_list.insert_all (1, dummy);
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -635,7 +635,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			dummy = test_list.slice (1, 4);
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -660,7 +660,7 @@ public abstract class ListTests : CollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			dummy = test_list.slice (0, 9);
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 	}
diff --git a/tests/testmap.vala b/tests/testmap.vala
index 8a0a38b..65ac245 100644
--- a/tests/testmap.vala
+++ b/tests/testmap.vala
@@ -182,7 +182,7 @@ public abstract class MapTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			assert (! keys.add ("three"));
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		Test.trap_assert_stderr ("*code should not be reached*");
@@ -221,7 +221,7 @@ public abstract class MapTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			assert (! values.add ("two"));
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		Test.trap_assert_stderr ("*code should not be reached*");
@@ -260,7 +260,7 @@ public abstract class MapTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			assert (! entries.add (new TestEntry<string,string> ("two", "value_of_two")));
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		Test.trap_assert_stderr ("*code should not be reached*");
diff --git a/tests/testreadonlycollection.vala b/tests/testreadonlycollection.vala
index 7ee6417..510a925 100644
--- a/tests/testreadonlycollection.vala
+++ b/tests/testreadonlycollection.vala
@@ -100,7 +100,7 @@ public class ReadOnlyCollectionTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			iterator.remove ();
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -121,7 +121,7 @@ public class ReadOnlyCollectionTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			assert (ro_collection.add ("two"));
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_collection.size == 1);
@@ -130,7 +130,7 @@ public class ReadOnlyCollectionTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			ro_collection.clear ();
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_collection.size == 1);
@@ -139,7 +139,7 @@ public class ReadOnlyCollectionTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			assert (ro_collection.remove ("one"));
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_collection.size == 1);
@@ -148,7 +148,7 @@ public class ReadOnlyCollectionTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			assert (ro_collection.add_all (dummy));
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_collection.size == 1);
@@ -157,7 +157,7 @@ public class ReadOnlyCollectionTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			assert (ro_collection.remove_all (dummy));
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_collection.size == 1);
@@ -167,7 +167,7 @@ public class ReadOnlyCollectionTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			assert (ro_collection.retain_all (dummy));
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_collection.size == 1);
diff --git a/tests/testreadonlylist.vala b/tests/testreadonlylist.vala
index f10d0f6..d1b2220 100644
--- a/tests/testreadonlylist.vala
+++ b/tests/testreadonlylist.vala
@@ -90,7 +90,7 @@ public class ReadOnlyListTests : ReadOnlyCollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			iterator.remove ();
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_list.size == 2);
@@ -101,7 +101,7 @@ public class ReadOnlyListTests : ReadOnlyCollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			iterator.set ("three");
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_list.size == 2);
@@ -112,7 +112,7 @@ public class ReadOnlyListTests : ReadOnlyCollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			iterator.insert ("three");
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_list.size == 2);
@@ -123,7 +123,7 @@ public class ReadOnlyListTests : ReadOnlyCollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			iterator.add ("three");
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_list.size == 2);
@@ -147,7 +147,7 @@ public class ReadOnlyListTests : ReadOnlyCollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			ro_list.set (0, "two");
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_list.size == 1);
@@ -156,7 +156,7 @@ public class ReadOnlyListTests : ReadOnlyCollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			ro_list.insert (1, "two");
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_list.size == 1);
@@ -165,7 +165,7 @@ public class ReadOnlyListTests : ReadOnlyCollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			ro_list.remove_at (1);
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_list.size == 1);
@@ -174,7 +174,7 @@ public class ReadOnlyListTests : ReadOnlyCollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			ro_list.insert_all (1, dummy);
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_list.size == 1);
@@ -183,7 +183,7 @@ public class ReadOnlyListTests : ReadOnlyCollectionTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			ro_list.sort ();
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_list.size == 1);
diff --git a/tests/testreadonlymap.vala b/tests/testreadonlymap.vala
index e33b509..c32f763 100644
--- a/tests/testreadonlymap.vala
+++ b/tests/testreadonlymap.vala
@@ -93,7 +93,7 @@ public class ReadOnlyMapTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			iterator.remove ();
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -117,7 +117,7 @@ public class ReadOnlyMapTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			ro_map.set ("two", "two");
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_map.size == 1);
@@ -127,7 +127,7 @@ public class ReadOnlyMapTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			ro_map.clear ();
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_map.size == 1);
@@ -137,7 +137,7 @@ public class ReadOnlyMapTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			assert (ro_map.unset ("one"));
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_map.size == 1);
@@ -147,7 +147,7 @@ public class ReadOnlyMapTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			ro_map.set_all (dummy);
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_map.size == 1);
@@ -157,7 +157,7 @@ public class ReadOnlyMapTests : Gee.TestCase {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			assert (ro_map.unset_all (dummy));
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 		assert (ro_map.size == 1);
diff --git a/tests/testsortedset.vala b/tests/testsortedset.vala
index c13d9c2..a5172b4 100644
--- a/tests/testsortedset.vala
+++ b/tests/testsortedset.vala
@@ -100,7 +100,7 @@ public abstract class SortedSetTests : SetTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_set.first ();
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -120,7 +120,7 @@ public abstract class SortedSetTests : SetTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			test_set.last ();
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -337,7 +337,7 @@ public abstract class SortedSetTests : SetTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			iterator.remove ();
-			return;
+			Posix.exit (0);
 		}
 		Test.trap_assert_failed ();
 
@@ -350,7 +350,7 @@ public abstract class SortedSetTests : SetTests {
 		if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 		                       TestTrapFlags.SILENCE_STDERR)) {
 			iterator.get ();
-			return;
+			Posix.exit (0);
 		}
 		assert (!iterator.previous ());
 
@@ -645,7 +645,7 @@ public abstract class SortedSetTests : SetTests {
 				if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 				                       TestTrapFlags.SILENCE_STDERR)) {
 					iter.remove ();
-					return;
+					Posix.exit (0);
 				}
 				Test.trap_assert_failed ();
 			}
@@ -715,11 +715,13 @@ public abstract class SortedSetTests : SetTests {
 				if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 				                       TestTrapFlags.SILENCE_STDERR)) {
 					subset.first ();
+					Posix.exit (0);
 				}
 				Test.trap_assert_failed ();
 				if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
 				                       TestTrapFlags.SILENCE_STDERR)) {
 					subset.last ();
+					Posix.exit (0);
 				}
 				Test.trap_assert_failed ();
 				break;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]