summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--BuildTools/SCons/Tools/Test.py13
-rw-r--r--QA/Swiften/ClientTest/.gitignore1
-rw-r--r--QA/Swiften/ClientTest/SConscript32
-rw-r--r--QA/Swiften/NetworkTest/SConscript26
-rw-r--r--QA/Swiften/SConscript14
-rw-r--r--QA/UnitTest/SConscript5
-rw-r--r--SConstruct14
7 files changed, 60 insertions, 45 deletions
diff --git a/BuildTools/SCons/Tools/Test.py b/BuildTools/SCons/Tools/Test.py
new file mode 100644
index 0000000..aaed222
--- /dev/null
+++ b/BuildTools/SCons/Tools/Test.py
@@ -0,0 +1,13 @@
+import SCons.Util
+
+def generate(env) :
+ def registerTest(env, target, type = "unit") :
+ if env["TEST_TYPE"] == "all" or env["TEST_TYPE"] == type :
+ cmd = target[0].abspath if SCons.Util.is_List(target) else target.abspath
+ env.Command("**dummy**", target,
+ SCons.Action.Action(env.get("TEST_RUNNER", "") + cmd, cmdstr = "$TESTCOMSTR"))
+
+ env.AddMethod(registerTest, "Test")
+
+def exists(env) :
+ return True
diff --git a/QA/Swiften/ClientTest/.gitignore b/QA/Swiften/ClientTest/.gitignore
new file mode 100644
index 0000000..9fb3e67
--- /dev/null
+++ b/QA/Swiften/ClientTest/.gitignore
@@ -0,0 +1 @@
+ClientTest
diff --git a/QA/Swiften/ClientTest/SConscript b/QA/Swiften/ClientTest/SConscript
index 164de57..a9d9a19 100644
--- a/QA/Swiften/ClientTest/SConscript
+++ b/QA/Swiften/ClientTest/SConscript
@@ -2,21 +2,21 @@ import os
Import("env")
-myenv = env.Clone()
-myenv.MergeFlags(env["SWIFTEN_FLAGS"])
-myenv.MergeFlags(env["CPPUNIT_FLAGS"])
-myenv.MergeFlags(env["LIBIDN_FLAGS"])
-myenv.MergeFlags(env["BOOST_FLAGS"])
-myenv.MergeFlags(env["SQLITE_FLAGS"])
-myenv.MergeFlags(env["ZLIB_FLAGS"])
-myenv.MergeFlags(env["OPENSSL_FLAGS"])
-myenv.MergeFlags(env.get("LIBXML_FLAGS", ""))
-myenv.MergeFlags(env.get("EXPAT_FLAGS", ""))
+if env["TEST"] :
+ myenv = env.Clone()
+ myenv.MergeFlags(env["SWIFTEN_FLAGS"])
+ myenv.MergeFlags(env["CPPUNIT_FLAGS"])
+ myenv.MergeFlags(env["LIBIDN_FLAGS"])
+ myenv.MergeFlags(env["BOOST_FLAGS"])
+ myenv.MergeFlags(env["SQLITE_FLAGS"])
+ myenv.MergeFlags(env["ZLIB_FLAGS"])
+ myenv.MergeFlags(env["OPENSSL_FLAGS"])
+ myenv.MergeFlags(env.get("LIBXML_FLAGS", ""))
+ myenv.MergeFlags(env.get("EXPAT_FLAGS", ""))
-for i in ["SWIFT_CLIENTTEST_JID", "SWIFT_CLIENTTEST_PASS"]:
- if os.environ.get(i, "") :
- myenv["ENV"][i] = os.environ[i]
+ for i in ["SWIFT_CLIENTTEST_JID", "SWIFT_CLIENTTEST_PASS"]:
+ if os.environ.get(i, "") :
+ myenv["ENV"][i] = os.environ[i]
-tester = myenv.Program("ClientTest", ["ClientTest.cpp"])
-clientTest = myenv.Alias("ClientTest", tester, env.get("TEST_RUNNER", "") + tester[0].abspath)
-env.AlwaysBuild(clientTest)
+ tester = myenv.Program("ClientTest", ["ClientTest.cpp"])
+ myenv.Test(tester, "system")
diff --git a/QA/Swiften/NetworkTest/SConscript b/QA/Swiften/NetworkTest/SConscript
index fa5122b..cf66a68 100644
--- a/QA/Swiften/NetworkTest/SConscript
+++ b/QA/Swiften/NetworkTest/SConscript
@@ -2,17 +2,17 @@ import os
Import("env")
-myenv = env.Clone()
-myenv.MergeFlags(env["CHECKER_FLAGS"])
-myenv.MergeFlags(env["SWIFTEN_FLAGS"])
-myenv.MergeFlags(env["CPPUNIT_FLAGS"])
-myenv.MergeFlags(env["BOOST_FLAGS"])
-myenv.MergeFlags(env["LIBIDN_FLAGS"])
+if env["TEST"] :
+ myenv = env.Clone()
+ myenv.MergeFlags(env["CHECKER_FLAGS"])
+ myenv.MergeFlags(env["SWIFTEN_FLAGS"])
+ myenv.MergeFlags(env["CPPUNIT_FLAGS"])
+ myenv.MergeFlags(env["BOOST_FLAGS"])
+ myenv.MergeFlags(env["LIBIDN_FLAGS"])
-tester = myenv.Program("NetworkTest", [
- "BoostConnectionServerTest.cpp",
- "BoostConnectionTest.cpp",
- "DomainNameResolverTest.cpp",
- ])
-clientTest = myenv.Alias("NetworkTest", tester, env.get("TEST_RUNNER", "") + tester[0].abspath)
-env.AlwaysBuild(clientTest)
+ tester = myenv.Program("NetworkTest", [
+ "BoostConnectionServerTest.cpp",
+ "BoostConnectionTest.cpp",
+ "DomainNameResolverTest.cpp",
+ ])
+ myenv.Test(tester, "system")
diff --git a/QA/Swiften/SConscript b/QA/Swiften/SConscript
index 6ee7365..ede7b39 100644
--- a/QA/Swiften/SConscript
+++ b/QA/Swiften/SConscript
@@ -1,10 +1,4 @@
-Import("env")
-
-tests = ["NetworkTest", "ClientTest"]
-if "test" in COMMAND_LINE_TARGETS or env.GetOption("clean") or len(set(tests) & set(COMMAND_LINE_TARGETS)):
- SConscript([
- "NetworkTest/SConscript",
- "ClientTest/SConscript",
- ])
-
- test = env.Alias("test", tests)
+SConscript([
+ "NetworkTest/SConscript",
+ "ClientTest/SConscript",
+ ])
diff --git a/QA/UnitTest/SConscript b/QA/UnitTest/SConscript
index 4911018..f93cdc2 100644
--- a/QA/UnitTest/SConscript
+++ b/QA/UnitTest/SConscript
@@ -12,7 +12,7 @@ env["CHECKER_FLAGS"] = {
"LINKFLAGS": ["/SUBSYSTEM:CONSOLE"] if env["PLATFORM"] == "win32" else []
}
-if "check" in COMMAND_LINE_TARGETS or env.GetOption("clean") :
+if env["TEST"] :
myenv = env.Clone()
myenv.MergeFlags(env["CHECKER_FLAGS"])
myenv.MergeFlags(env["SLIMBER_FLAGS"])
@@ -33,5 +33,4 @@ if "check" in COMMAND_LINE_TARGETS or env.GetOption("clean") :
for i in ["HOME", "USERPROFILE", "APPDATA"]:
if os.environ.get(i, "") :
myenv["ENV"][i] = os.environ[i]
- check = myenv.Alias("check", checker, env.get("TEST_RUNNER", "") + checker[0].abspath)
- myenv.AlwaysBuild(check)
+ myenv.Test(checker)
diff --git a/SConstruct b/SConstruct
index 1a737ed..6ee509a 100644
--- a/SConstruct
+++ b/SConstruct
@@ -6,6 +6,7 @@ sys.path.append(Dir("BuildTools/SCons").abspath)
################################################################################
vars = Variables("config.py")
+vars.Add(EnumVariable("test", "Compile and run tests", "none", ["none", "all", "unit", "system"]))
vars.Add(BoolVariable("optimize", "Compile with optimizations turned on", "no"))
vars.Add(BoolVariable("debug", "Compile with debug information", "yes" if os.name != "nt" else "no"))
vars.Add(BoolVariable("warnings", "Compile with warnings turned on",
@@ -34,6 +35,7 @@ Help(vars.GenerateHelpText(env))
env.Alias("dist", ["."])
# Default custom tools
+env.Tool("Test", toolpath = ["#/BuildTools/SCons/Tools"])
env.Tool("WriteVal", toolpath = ["#/BuildTools/SCons/Tools"])
env.Tool("BuildVersion", toolpath = ["#/BuildTools/SCons/Tools"])
if env["PLATFORM"] == "darwin" :
@@ -82,9 +84,6 @@ if env.get("coverage", 0) :
env.Append(CCFLAGS = ["-fprofile-arcs", "-ftest-coverage"])
env.Append(LINKFLAGS = ["-fprofile-arcs", "-ftest-coverage"])
-if env.get("valgrind", 0) :
- env["TEST_RUNNER"] = "valgrind --suppressions=QA/valgrind.supp -q --leak-check=full --track-origins=yes "
-
if env["PLATFORM"] == "win32" :
env.Append(LIBS = ["dnsapi", "ws2_32", "wsock32"])
env.Append(CCFLAGS = "/EHsc")
@@ -94,6 +93,15 @@ if env["PLATFORM"] == "win32" :
if env["PLATFORM"] == "darwin" :
env.Append(FRAMEWORKS = "AppKit")
+# Testing
+env["TEST_TYPE"] = env["test"]
+env.Alias("check", ".")
+if "check" in ARGUMENTS or "check" in COMMAND_LINE_TARGETS :
+ env["TEST_TYPE"] = "unit"
+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 "
+
# Packaging
if ARGUMENTS.get("SWIFT_INSTALLDIR", "") :
env["SWIFT_INSTALLDIR"] = Dir(ARGUMENTS["SWIFT_INSTALLDIR"]).abspath