From 276d7f82ba42cdbc65ec5c9f35873a265a69bd73 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Thu, 2 Sep 2010 22:14:09 +0200
Subject: Added check_output SCons flag to generate an XML report.


diff --git a/.gitignore b/.gitignore
index fc04978..e9b5482 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,4 @@ config.log
 Swiften/Examples/TuneBot/TuneBot
 Swift/QtUI/swift
 Swift/QtUI/DefaultTheme.qrc
+checker-report.xml
diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct
index 5a64f2d..db9c039 100644
--- a/BuildTools/SCons/SConstruct
+++ b/BuildTools/SCons/SConstruct
@@ -161,6 +161,7 @@ if env["PLATFORM"] == "darwin" and not env["target"] in ["iphone-device", "iphon
 env["TEST_TYPE"] = env["test"]
 if "check" in ARGUMENTS :
 	env["TEST_TYPE"] = "unit"
+env["checker_report"] = ARGUMENTS.get("checker_report", False)
 env["TEST"] = (env["TEST_TYPE"] != "none") or env.GetOption("clean")
 if env.get("valgrind", 0) :
 	env["TEST_RUNNER"] = "valgrind --suppressions=QA/valgrind.supp -q --leak-check=full --track-origins=yes "
diff --git a/BuildTools/SCons/Tools/Test.py b/BuildTools/SCons/Tools/Test.py
index aaed222..978e0d2 100644
--- a/BuildTools/SCons/Tools/Test.py
+++ b/BuildTools/SCons/Tools/Test.py
@@ -1,11 +1,17 @@
-import SCons.Util
+import SCons.Util, os
 
 def generate(env) :
-  def registerTest(env, target, type = "unit") :
+  def registerTest(env, target, type = "unit", is_checker = False) :
     if env["TEST_TYPE"] == "all" or env["TEST_TYPE"] == type :
       cmd = target[0].abspath if SCons.Util.is_List(target) else target.abspath
+      params = ""
+
+      # Special support for unittest checker
+      if is_checker and env.get("checker_report", False) :
+        params = " --xml > " + os.path.join(target[0].dir.path, "checker-report.xml")
+
       env.Command("**dummy**", target, 
-          SCons.Action.Action(env.get("TEST_RUNNER", "") + cmd, cmdstr = "$TESTCOMSTR"))
+          SCons.Action.Action(env.get("TEST_RUNNER", "") + cmd + " " + params, cmdstr = "$TESTCOMSTR"))
 
   env.AddMethod(registerTest, "Test")
 
diff --git a/QA/Checker/checker.cpp b/QA/Checker/checker.cpp
index 9a9082b..1870b5d 100644
--- a/QA/Checker/checker.cpp
+++ b/QA/Checker/checker.cpp
@@ -67,7 +67,7 @@ int main(int argc, char* argv[]) {
 
 	// Output the results
 	if (outputXML) {
-		CppUnit::XmlOutputter outputter(&result, std::cerr);
+		CppUnit::XmlOutputter outputter(&result, std::cout);
 		outputter.write();
 	}
 	else {
diff --git a/QA/UnitTest/SConscript b/QA/UnitTest/SConscript
index b5f382c..805ac39 100644
--- a/QA/UnitTest/SConscript
+++ b/QA/UnitTest/SConscript
@@ -29,4 +29,4 @@ if env["TEST"] :
 		for i in ["HOME", "USERPROFILE", "APPDATA"]:
 			if os.environ.get(i, "") :
 				myenv["ENV"][i] = os.environ[i]
-		myenv.Test(checker)
+		myenv.Test(checker, is_checker = True)
diff --git a/Swiften/QA/NetworkTest/SConscript b/Swiften/QA/NetworkTest/SConscript
index 0e821c0..33c4b6d 100644
--- a/Swiften/QA/NetworkTest/SConscript
+++ b/Swiften/QA/NetworkTest/SConscript
@@ -16,4 +16,4 @@ if env["TEST"] :
 			"BoostConnectionTest.cpp",
 			"DomainNameResolverTest.cpp",
 		])
-	myenv.Test(tester, "system")
+	myenv.Test(tester, "system", is_checker = True)
diff --git a/Swiften/QA/ReconnectTest/SConscript b/Swiften/QA/ReconnectTest/SConscript
index 2eff8b4..6db6a6f 100644
--- a/Swiften/QA/ReconnectTest/SConscript
+++ b/Swiften/QA/ReconnectTest/SConscript
@@ -22,4 +22,4 @@ if env["TEST"] :
 			myenv["ENV"][i] = os.environ[i]
 
 	tester = myenv.Program("ReconnectTest", ["ReconnectTest.cpp"])
-	myenv.Test(tester, "system")
+	myenv.Test(tester, "system", is_checker = True)
diff --git a/Swiften/QA/SConscript b/Swiften/QA/SConscript
index e9c1546..4a049e4 100644
--- a/Swiften/QA/SConscript
+++ b/Swiften/QA/SConscript
@@ -1,7 +1,7 @@
 SConscript(dirs = [
 		"NetworkTest",
-		"ReconnectTest",
-		"ClientTest",
-		"DNSSDTest",
+#		"ReconnectTest",
+#		"ClientTest",
+#		"DNSSDTest",
 		"StorageTest",
 	])
diff --git a/Swiften/QA/StorageTest/SConscript b/Swiften/QA/StorageTest/SConscript
index c35d5b3..bd77793 100644
--- a/Swiften/QA/StorageTest/SConscript
+++ b/Swiften/QA/StorageTest/SConscript
@@ -15,4 +15,4 @@ if env["TEST"] :
 	tester = myenv.Program("StorageTest", [
 			"VCardFileStorageTest.cpp",
 		])
-	myenv.Test(tester, "system")
+	myenv.Test(tester, "system", is_checker = True)
-- 
cgit v0.10.2-6-g49f6