-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test for Doxygen Warnings #8
Open
jackdunger
wants to merge
2
commits into
mastbaum:master
Choose a base branch
from
jackdunger:doxy_test
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 1 commit
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 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,112 @@ | ||
'''A task that looks for Doxygen warnings. A single warning triggers a failure''' | ||
|
||
import os | ||
import subprocess | ||
import cog.task | ||
|
||
# Sub directories that must be Doxygenated (for help output) | ||
doxy_dirs = ["src/du","src/ds"] | ||
|
||
class DoxyCheck(cog.task.Task): | ||
''' | ||
Grab the Doxygen Log, and fail if there are warnings | ||
''' | ||
def __init__(self, *args): | ||
cog.task.Task.__init__(self, *args) | ||
|
||
def run(self, document, work_dir): | ||
'''Run the task. | ||
|
||
:param document: Task document from the database | ||
:param work_dir: Temporary working directory | ||
''' | ||
kwargs = document.get('kwargs', {}) | ||
sha = kwargs.get('sha', None) | ||
git_url = kwargs.get('git_url', None) | ||
base_repo_ref = kwargs.get('base_repo_ref', None) | ||
base_repo_url = kwargs.get('base_repo_url', None) | ||
|
||
if sha is None: | ||
return {'success': False, 'reason': 'missing revision id'} | ||
if git_url is None: | ||
return {'success': False, 'reason': 'missing git url'} | ||
if (base_repo_url and base_repo_ref is None or | ||
base_repo_ref and base_repo_url is None): | ||
return {'success': False, | ||
'reason': 'incomplete base specification for merge'} | ||
|
||
# get the new pull request | ||
code = cog.task.git_clone(git_url, sha, sha, work_dir=work_dir) | ||
if code is None or (code != 0 and code != 1): | ||
return {'success': False, 'reason': 'git clone failed', | ||
'code': str(code)} | ||
|
||
# Get doxy log | ||
rat_dir = os.join(work_dir,sha) if work_dir else sha | ||
doxy_log = self.get_doxy_log(rat_dir) | ||
|
||
# pass if no warnings, print log to HTML | ||
if doxy_log is None: | ||
return {'success': False, 'reason': "could not get doxy log"} | ||
|
||
web_page = self.print_HTML(doxy_log,"doxy_check.html") | ||
attachment = {"filename" : "doxycheck.html", "contents": web_page, "link_name": "doxycheck"} | ||
success = (doxy_log.count("warning:") == 0) | ||
return {'success': success, "attachments":[attachment]} | ||
|
||
def get_doxy_log(self,rat_dir): | ||
''' | ||
Get the Doxygen log. Must be run inside rat directory. doxyfile exists only after scons - | ||
but doxyfile-in is missing only the rat version and exists from clone | ||
:param doxyfile_path relative or abs path to doxyfile to run | ||
:returns: doxygen make log as a string, none if fails | ||
''' | ||
doxyfile = os.path.join("dox","doxyfile-in") | ||
cmd = "cd %s && doxygen %s" %(rat_dir,doxyfile) | ||
try: | ||
doxy_log = cog.task.system_output(cmd) | ||
return doxy_log | ||
except subprocess.CalledProcessError as exc: | ||
print "Error grabbing Doxygen log:" | ||
print exc.output | ||
return None | ||
|
||
|
||
def print_HTML(self,log_string,out_file): | ||
''' | ||
Write HTML file results to file and return as string | ||
:param doxygen log | ||
:returns: doxygen log HTML as string | ||
''' | ||
n_warnings = log_string.count("warning:") | ||
test_passed = (n_warnings == 0) | ||
web_page = """ | ||
<html> | ||
<head> | ||
<title> Doxygen Warning Checker </title> | ||
</head> | ||
<body> | ||
<h1> Doxygen Warning Checker </h1> | ||
<h2 style="color: %s"> Test %s </h2> | ||
""" %("green" if test_passed else "red", | ||
"PASSED" if test_passed else "FAILED with %s warnings" %n_warnings) | ||
|
||
if not test_passed: | ||
web_page += "<p>Headers in %s need Doxygen tags -- docDB-1018</p>" %(", ".join(doxy_dirs)) | ||
web_page += """ | ||
<h2> Doxygen Log:</h2> | ||
<p> %s </p> | ||
""" %(log_string) | ||
web_page += """ | ||
</body> | ||
</html> | ||
""" | ||
with open(out_file,"w") as f: | ||
f.write(web_page) | ||
return web_page | ||
|
||
|
||
if __name__ == '__main__': | ||
import sys | ||
task = DoxyCheck(*(sys.argv[1:])) | ||
task() |
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.
I think this should be
os.path.join
.