Skip to content

Commit

Permalink
fix(tests): Fixed unittests (#1493)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Wiseblatt authored Mar 21, 2017
1 parent 5a5e822 commit 30054b6
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 125 deletions.
2 changes: 1 addition & 1 deletion testing/citest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ but a suggestion.
sudo apt-get install python-pip

# Instal FFI package needed by pyopenssl
sudo apt-get install libffi-dev python-dev
sudo apt-get install libffi-dev libssl-dev python-dev

# Install virtualenv tools and setup a Virtual Environment.
pip install virtualenv
Expand Down
118 changes: 0 additions & 118 deletions unittest/abstract_packer_builder_test.py

This file was deleted.

3 changes: 2 additions & 1 deletion unittest/configurator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,5 @@ def tearDownClass(cls):
if __name__ == '__main__':
loader = unittest.TestLoader()
suite = loader.loadTestsFromTestCase(ConfiguratorTest)
unittest.TextTestRunner(verbosity=2).run(suite)
got = unittest.TextTestRunner(verbosity=2).run(suite)
sys.exit(len(got.failures) + len(got.errors))
34 changes: 34 additions & 0 deletions unittest/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

cd `dirname $0`
TEST_DIR=`pwd`

# Some tests need to be in the build directory
# so run them all from there.
cd $TEST_DIR/../..

passed_tests=()
failed_tests=()

for test in `cd $TEST_DIR; ls *_test.py`; do
echo "Running $test"
PYTHONPATH=$TEST_DIR/../pylib:$TEST_DIR/../dev python $TEST_DIR/$test

if [[ $? -eq 0 ]]; then
passed_tests+=("$test")
else
failed_tests+=("$test")
fi
done

if [[ ${#failed_tests[@]} -eq 0 ]]; then
echo "PASSED ALL ${#passed_tests[@]} TESTS"
exit 0
fi

>&2 echo "FAILED ${#failed_tests[@]} TESTS"
for test in ${failed_tests[@]}; do
>&2 echo "FAILED: $test"
done
exit -1

6 changes: 4 additions & 2 deletions unittest/source_annotator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.

import argparse
import sys
import unittest

from annotate_source import Annotator, CommitTag, VersionBump
Expand Down Expand Up @@ -156,9 +157,10 @@ def test_default_msgs(self):
if __name__ == '__main__':
parser = argparse.ArgumentParser()
Annotator.init_argument_parser(parser)
Annotator.init_extra_argument_parser(parser)
OPTIONS = parser.parse_args()

loader = unittest.TestLoader()
suite = loader.loadTestsFromTestCase(SourceAnnotatorTest)
unittest.TextTestRunner(verbosity=2).run(suite)
got = unittest.TextTestRunner(verbosity=2).run(suite)
sys.exit(len(got.errors) + len(got.failures))

5 changes: 3 additions & 2 deletions unittest/validate_configuration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os
import sys
import tempfile
import unittest

Expand Down Expand Up @@ -341,6 +342,6 @@ def test_verify_at_least_one_provider_enabled_bad(self):
if __name__ == '__main__':
loader = unittest.TestLoader()
suite = loader.loadTestsFromTestCase(ValidateConfigurationTest)
unittest.TextTestRunner(verbosity=2).run(suite)

got = unittest.TextTestRunner(verbosity=2).run(suite)
sys.exit(len(got.errors) + len(got.failures))

4 changes: 3 additions & 1 deletion unittest/yaml_util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os
import sys
import tempfile
import unittest

Expand Down Expand Up @@ -403,4 +404,5 @@ def test_update_yml_source(self):
if __name__ == '__main__':
loader = unittest.TestLoader()
suite = loader.loadTestsFromTestCase(YamlUtilTest)
unittest.TextTestRunner(verbosity=2).run(suite)
got = unittest.TextTestRunner(verbosity=2).run(suite)
sys.exit(len(got.errors) + len(got.failures))

0 comments on commit 30054b6

Please sign in to comment.