This repository was archived by the owner on Oct 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Pythonize run_unit_tests.sh #58
Open
XuefengHuang
wants to merge
2
commits into
SeattleTestbed:master
Choose a base branch
from
XuefengHuang:add-run_unit_tests.py
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| ''' | ||
| 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"] | ||
| 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() | ||
|
|
||
| # For every repo name, ... | ||
| for repo in repolist: | ||
| print "Testing " + testbed + '/' + repo + " now..." | ||
| print "https://github.com/" + testbed + "/" + repo + ".git" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we make the domain name configurable, too? For example, if a local or non-github git repository is needed. |
||
| # 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([sys.executable, "initialize.py"]) | ||
| subprocess.call([sys.executable, "build.py", "-t"]) | ||
| os.chdir(".." + os.path.sep +"RUNNABLE") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason why os.path.join() isn't used? |
||
| 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." | ||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation says that
repolistandtestbedare configurable. It appears that they must modified directly in the code. Does it make sense to make them configurable from the command-line?