[mousetrap/gnome3-wip: 40/240] Update test framework.
- From: Heidi Ellis <heidiellis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mousetrap/gnome3-wip: 40/240] Update test framework.
- Date: Mon, 8 Sep 2014 15:15:53 +0000 (UTC)
commit 41769ae94d69d02f09802a5a6c36bd0352728ac3
Author: Stoney Jackson <dr stoney gmail com>
Date: Fri May 16 15:38:41 2014 -0400
Update test framework.
* Test runner now adds the mousetrap source directory and the site-package
directory to the python import path.
* Rename bin/test.sh to bin/run_tests.sh
* Move python test runner (bin/test.py) to bin/lib/run_python_tests.py
bin/lib/run_python_tests.py | 49 ++++++++++++++++++++++++++++++++++++++++
bin/lib/run_shell_tests.sh | 7 +++++
bin/lib/test_environment_up.sh | 2 +-
bin/{test.sh => run_tests.sh} | 4 +-
bin/test.py | 27 ----------------------
5 files changed, 59 insertions(+), 30 deletions(-)
---
diff --git a/bin/lib/run_python_tests.py b/bin/lib/run_python_tests.py
new file mode 100755
index 0000000..48d6a20
--- /dev/null
+++ b/bin/lib/run_python_tests.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+from unittest import TestLoader
+from unittest.runner import TextTestRunner
+from os.path import dirname, abspath
+import sys
+
+
+def main():
+ initialize_import_path()
+ tests = load_tests()
+ run_tests(tests)
+
+
+def initialize_import_path():
+ paths = [
+ get_source_directory(),
+ get_project_directory()
+ ]
+ sys.path += paths
+
+
+def get_source_directory():
+ return get_project_directory() + '/src'
+
+
+def get_project_directory():
+ return dirname(dirname(dirname(abspath(__file__))))
+
+
+def get_site_package_directory():
+ # FIXME: this path could be different on different platforms.
+ # Use autotools to determine its location by changing this file
+ # into a .in file, and replace the string below with an automake(?)
+ # variable.
+ return '/usr/local/lib64/python2.7/site-packages'
+
+
+def load_tests():
+ directory = get_source_directory()
+ tests = TestLoader().discover(directory)
+ return tests
+
+
+def run_tests(tests):
+ TextTestRunner().run(tests)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/bin/lib/run_shell_tests.sh b/bin/lib/run_shell_tests.sh
new file mode 100755
index 0000000..aa38c36
--- /dev/null
+++ b/bin/lib/run_shell_tests.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+test -z "$PROJECT_DIRECTORY" && . "$(dirname "$0")"/environment_up.sh
+cd "$PROJECT_DIRECTORY"
+
+find . -name "test_*.sh" -exec "{}" \;
+
+cd -
diff --git a/bin/lib/test_environment_up.sh b/bin/lib/test_environment_up.sh
index 8b97a71..7d9e559 100755
--- a/bin/lib/test_environment_up.sh
+++ b/bin/lib/test_environment_up.sh
@@ -33,4 +33,4 @@ test_last_modified_file() {
rm "$file"
}
-. shunit2
+. /usr/share/shunit2/shunit2
diff --git a/bin/test.sh b/bin/run_tests.sh
similarity index 68%
rename from bin/test.sh
rename to bin/run_tests.sh
index a30938b..51c9262 100755
--- a/bin/test.sh
+++ b/bin/run_tests.sh
@@ -2,7 +2,7 @@
test -z "$PROJECT_DIRECTORY" && . "$(dirname "$0")"/lib/environment_up.sh
cd "$PROJECT_DIRECTORY"
-find . -name "test_*.sh" -exec "{}" \;
-bin/test.py
+bin/lib/run_shell_tests.sh
+bin/lib/run_python_tests.py
cd -
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]