From c2a2ea95105d06eb1c7c9f6fe40fefdf88281ed3 Mon Sep 17 00:00:00 2001 From: Xuefeng Date: Mon, 2 Mar 2015 10:07:53 -0500 Subject: [PATCH 1/2] Pythonize run_unit_tests.sh This helper script for Seattle Testbed, https://seattle.poly.edu/, * downloads Seattle Testbed's sources from GitHub, * builds them using Seattle's build scripts, and finally * runs Seattle's unit tests. --- run_unit_tests.py | 76 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 run_unit_tests.py diff --git a/run_unit_tests.py b/run_unit_tests.py new file mode 100644 index 0000000..d42bc6c --- /dev/null +++ b/run_unit_tests.py @@ -0,0 +1,76 @@ +''' +This helper script for Seattle Testbed, https://seattle.poly.edu/, + * downloads Seattle Testbed's sources from GitHub, + * builds them using Seattle's build scripts, and finally + * runs Seattle's unit tests. + + Find documentation for Seattle's build scripts and unit test framework at + https://seattle.poly.edu/wiki/BuildInstructions + https://seattle.poly.edu/wiki/UnitTestFramework + + The list of components (i.e. source repositories) for which the + tests are run is configurable via the REPOLIST variable, see below. + + Since other testbeds use the Seattle codebase, we make the testbed + name (and thus repo address) configurable too: +''' +import os +import sys +import subprocess +import time +import string + +def main(): + TESTBED = 'SeattleTestbed' + # If you like to test the complete set of repos, get the list of + # $TESTBED repositories via the GitHub API, grab entries like + # "full_name": "SeattleTestbed/foo", + # cut out the repo names, and create a space-separated list: + # + # REPOLIST=`curl https://api.github.com/orgs/$TESTBED/repos | awk '/full_name/ {gsub("\"", ""); gsub(",", ""); split($2, a, "/"); printf a[2] " "}'` + + + # Otherwise, just supply the list yourself. + # + # Here's a mostly complete one, omitting but a few backup/outdated repos: + # REPOLIST="advertiseserver affix buildscripts common demokit experimentmanager geoip_server nodemanager overlord portability repy_v1 repy_v2 seash seattlelib_v1 seattlelib_v2 softwareupdater timeserver utf zenodotus" + + # This is the "bare minimum" list. Whatever changes you make to the + # Seattle codebase, do make sure these tests pass (in addition to the + # repo you changed, of course!) + REPOLIST = "common nodemanager repy_v2 seattlelib_v2 seash softwareupdater utf" + print "Running tests for this list of "+ TESTBED +"\'s repositories: " + REPOLIST + + # We will also measure the time elapsed for all tests + TEST_SUITE_STARTED_AT = time.time() + + # For every repo name, ... + for REPO in REPOLIST.split(): + print "Testing " + TESTBED + '/' + REPO + " now..." + print "https://github.com/" + TESTBED + "/" + REPO + ".git" + # Clone the repo + subprocess.call(["git", "clone","https://github.com/" + TESTBED + "/" + REPO + ".git"]) + + # If $REPO has a "tests" subdir, then prepare the + # test files and run the tests + if os.path.isdir(REPO +os.path.sep +"tests"): + # Measure the time for this single repo's tests + REPO_TEST_STARTED_AT = time.time() + os.chdir(REPO + os.path.sep +"scripts") + subprocess.call(["python", "initialize.py"]) + subprocess.call(["python", "build.py", "-t"]) + os.chdir(".." + os.path.sep +"RUNNABLE") + subprocess.call(["python", "utf.py", "-a"]) + REPO_TEST_FINISHED_AT = time.time() + REPO_TEST_TIME = str(REPO_TEST_FINISHED_AT - REPO_TEST_STARTED_AT) + print "Tests for " + TESTBED + "/" + REPO + " took " + REPO_TEST_TIME + " seconds, excluding download and build" + os.chdir(".." + os.path.sep + "..") + else: + print TESTBED + "/" + REPO + "has no \"tests\" directory. Skipping." + + TEST_SUITE_FINISHED_AT = time.time() + TEST_SUITE_TIME = str(TEST_SUITE_FINISHED_AT - TEST_SUITE_STARTED_AT) + print "Done running tests for " + TESTBED + ", which took me " + TEST_SUITE_TIME + " seconds overall." + +if __name__ == '__main__': + main() From c1bb5dc29fa6034c5b2e94e0c2348c44925342e9 Mon Sep 17 00:00:00 2001 From: Xuefeng Date: Mon, 9 Mar 2015 16:51:37 -0400 Subject: [PATCH 2/2] Fixed variable names and make a list for repo name --- run_unit_tests.py | 94 ++++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/run_unit_tests.py b/run_unit_tests.py index d42bc6c..8da5741 100644 --- a/run_unit_tests.py +++ b/run_unit_tests.py @@ -1,6 +1,6 @@ ''' -This helper script for Seattle Testbed, https://seattle.poly.edu/, - * downloads Seattle Testbed's sources from GitHub, +This helper script for Seattle testbed, https://seattle.poly.edu/, + * downloads Seattle testbed's sources from GitHub, * builds them using Seattle's build scripts, and finally * runs Seattle's unit tests. @@ -9,7 +9,7 @@ https://seattle.poly.edu/wiki/UnitTestFramework The list of components (i.e. source repositories) for which the - tests are run is configurable via the REPOLIST variable, see below. + tests are run is configurable via the repolist variable, see below. Since other testbeds use the Seattle codebase, we make the testbed name (and thus repo address) configurable too: @@ -21,56 +21,58 @@ import string def main(): - TESTBED = 'SeattleTestbed' - # If you like to test the complete set of repos, get the list of - # $TESTBED repositories via the GitHub API, grab entries like - # "full_name": "SeattleTestbed/foo", - # cut out the repo names, and create a space-separated list: - # - # REPOLIST=`curl https://api.github.com/orgs/$TESTBED/repos | awk '/full_name/ {gsub("\"", ""); gsub(",", ""); split($2, a, "/"); printf a[2] " "}'` + testbed = 'Seattletestbed' + # If you like to test the complete set of repos, get the list of + # $testbed repositories via the GitHub API, grab entries like + # "full_name": "Seattletestbed/foo", + # cut out the repo names, and create a space-separated list: + # + # repolist=`curl https://api.github.com/orgs/$testbed/repos | awk '/full_name/ {gsub("\"", ""); gsub(",", ""); split($2, a, "/"); printf a[2] " "}'` - # Otherwise, just supply the list yourself. - # - # Here's a mostly complete one, omitting but a few backup/outdated repos: - # REPOLIST="advertiseserver affix buildscripts common demokit experimentmanager geoip_server nodemanager overlord portability repy_v1 repy_v2 seash seattlelib_v1 seattlelib_v2 softwareupdater timeserver utf zenodotus" + # Otherwise, just supply the list yourself. + # + # Here's a mostly complete one, omitting but a few backup/outdated repos: + # repolist="advertiseserver affix buildscripts common demokit experimentmanager geoip_server nodemanager overlord portability repy_v1 repy_v2 seash seattlelib_v1 seattlelib_v2 softwareupdater timeserver utf zenodotus" - # This is the "bare minimum" list. Whatever changes you make to the - # Seattle codebase, do make sure these tests pass (in addition to the - # repo you changed, of course!) - REPOLIST = "common nodemanager repy_v2 seattlelib_v2 seash softwareupdater utf" - print "Running tests for this list of "+ TESTBED +"\'s repositories: " + REPOLIST + # This is the "bare minimum" list. Whatever changes you make to the + # Seattle codebase, do make sure these tests pass (in addition to the + # repo you changed, of course!) + repolist = ["common", "nodemanager", "repy_v2", "seattlelib_v2", "seash", "softwareupdater", "utf"] + for repo in repolist: + print "Running tests for this list of "+ testbed +"\'s repositories: " + repo - # We will also measure the time elapsed for all tests - TEST_SUITE_STARTED_AT = time.time() + # We will also measure the time elapsed for all tests + test_suite_started_at = time.time() - # For every repo name, ... - for REPO in REPOLIST.split(): - print "Testing " + TESTBED + '/' + REPO + " now..." - print "https://github.com/" + TESTBED + "/" + REPO + ".git" - # Clone the repo - subprocess.call(["git", "clone","https://github.com/" + TESTBED + "/" + REPO + ".git"]) + # For every repo name, ... + for repo in repolist: + print "Testing " + testbed + '/' + repo + " now..." + print "https://github.com/" + testbed + "/" + repo + ".git" + # Clone the repo + subprocess.call(["git", "clone","https://github.com/" + testbed + "/" + repo + ".git"]) - # If $REPO has a "tests" subdir, then prepare the - # test files and run the tests - if os.path.isdir(REPO +os.path.sep +"tests"): - # Measure the time for this single repo's tests - REPO_TEST_STARTED_AT = time.time() - os.chdir(REPO + os.path.sep +"scripts") - subprocess.call(["python", "initialize.py"]) - subprocess.call(["python", "build.py", "-t"]) - os.chdir(".." + os.path.sep +"RUNNABLE") - subprocess.call(["python", "utf.py", "-a"]) - REPO_TEST_FINISHED_AT = time.time() - REPO_TEST_TIME = str(REPO_TEST_FINISHED_AT - REPO_TEST_STARTED_AT) - print "Tests for " + TESTBED + "/" + REPO + " took " + REPO_TEST_TIME + " seconds, excluding download and build" - os.chdir(".." + os.path.sep + "..") - else: - print TESTBED + "/" + REPO + "has no \"tests\" directory. Skipping." + # If $repo has a "tests" subdir, then prepare the + # test files and run the tests + if os.path.isdir(repo +os.path.sep +"tests"): + # Measure the time for this single repo's tests + repo_test_started_at = time.time() + os.chdir(repo + os.path.sep +"scripts") + subprocess.call([sys.executable, "initialize.py"]) + subprocess.call([sys.executable, "build.py", "-t"]) + os.chdir(".." + os.path.sep +"RUNNABLE") + subprocess.call([sys.executable, "utf.py", "-a"]) + repo_test_finished_at = time.time() + repo_test_time = str(repo_test_finished_at - repo_test_started_at) + print "Tests for " + testbed + "/" + repo + " took " + repo_test_time + " seconds, excluding download and build" + os.chdir(".." + os.path.sep + "..") + else: + print testbed + "/" + repo + "has no \"tests\" directory. Skipping." - TEST_SUITE_FINISHED_AT = time.time() - TEST_SUITE_TIME = str(TEST_SUITE_FINISHED_AT - TEST_SUITE_STARTED_AT) - print "Done running tests for " + TESTBED + ", which took me " + TEST_SUITE_TIME + " seconds overall." + test_suite_finished_at = time.time() + test_suite_time = str(test_suite_finished_at - test_suite_started_at) + print "Done running tests for " + testbed + ", which took me " + test_suite_time + " seconds overall." if __name__ == '__main__': main() +