-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #595 from splunk/release/2.1.0
Release/2.1.0
- Loading branch information
Showing
13 changed files
with
374 additions
and
127 deletions.
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
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
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
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 |
---|---|---|
|
@@ -14,124 +14,15 @@ | |
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from setuptools import setup, Command | ||
|
||
import os | ||
import sys | ||
from setuptools import setup | ||
|
||
import splunklib | ||
|
||
failed = False | ||
|
||
def run_test_suite(): | ||
import unittest | ||
|
||
def mark_failed(): | ||
global failed | ||
failed = True | ||
|
||
class _TrackingTextTestResult(unittest._TextTestResult): | ||
def addError(self, test, err): | ||
unittest._TextTestResult.addError(self, test, err) | ||
mark_failed() | ||
|
||
def addFailure(self, test, err): | ||
unittest._TextTestResult.addFailure(self, test, err) | ||
mark_failed() | ||
|
||
class TrackingTextTestRunner(unittest.TextTestRunner): | ||
def _makeResult(self): | ||
return _TrackingTextTestResult( | ||
self.stream, self.descriptions, self.verbosity) | ||
|
||
original_cwd = os.path.abspath(os.getcwd()) | ||
os.chdir('tests') | ||
suite = unittest.defaultTestLoader.discover('.') | ||
runner = TrackingTextTestRunner(verbosity=2) | ||
runner.run(suite) | ||
os.chdir(original_cwd) | ||
|
||
return failed | ||
|
||
|
||
def run_test_suite_with_junit_output(): | ||
try: | ||
import unittest2 as unittest | ||
except ImportError: | ||
import unittest | ||
import xmlrunner | ||
original_cwd = os.path.abspath(os.getcwd()) | ||
os.chdir('tests') | ||
suite = unittest.defaultTestLoader.discover('.') | ||
xmlrunner.XMLTestRunner(output='../test-reports').run(suite) | ||
os.chdir(original_cwd) | ||
|
||
|
||
class CoverageCommand(Command): | ||
"""setup.py command to run code coverage of the test suite.""" | ||
description = "Create an HTML coverage report from running the full test suite." | ||
user_options = [] | ||
|
||
def initialize_options(self): | ||
pass | ||
|
||
def finalize_options(self): | ||
pass | ||
|
||
def run(self): | ||
try: | ||
import coverage | ||
except ImportError: | ||
print("Could not import coverage. Please install it and try again.") | ||
exit(1) | ||
cov = coverage.coverage(source=['splunklib']) | ||
cov.start() | ||
run_test_suite() | ||
cov.stop() | ||
cov.html_report(directory='coverage_report') | ||
|
||
|
||
class TestCommand(Command): | ||
"""setup.py command to run the whole test suite.""" | ||
description = "Run test full test suite." | ||
user_options = [] | ||
|
||
def initialize_options(self): | ||
pass | ||
|
||
def finalize_options(self): | ||
pass | ||
|
||
def run(self): | ||
failed = run_test_suite() | ||
if failed: | ||
sys.exit(1) | ||
|
||
|
||
class JunitXmlTestCommand(Command): | ||
"""setup.py command to run the whole test suite.""" | ||
description = "Run test full test suite with JUnit-formatted output." | ||
user_options = [] | ||
|
||
def initialize_options(self): | ||
pass | ||
|
||
def finalize_options(self): | ||
pass | ||
|
||
def run(self): | ||
run_test_suite_with_junit_output() | ||
|
||
|
||
setup( | ||
author="Splunk, Inc.", | ||
|
||
author_email="[email protected]", | ||
|
||
cmdclass={'coverage': CoverageCommand, | ||
'test': TestCommand, | ||
'testjunit': JunitXmlTestCommand}, | ||
|
||
description="The Splunk Software Development Kit for Python.", | ||
|
||
license="http://www.apache.org/licenses/LICENSE-2.0", | ||
|
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
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
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
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
Oops, something went wrong.