#!/usr/bin/python3
'''run-tests: run the test suite'''
#
# Copyright (C) 2013 Canonical Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import sys
import unittest

# NOTE: changes to this file may also need to be made to
# 'collect-check-names-from-tests'

test_directory = 'clickreviews/tests/'
test_filename = 'test_*'
if len(sys.argv) > 1:
    test_filename = sys.argv[1]

suite = unittest.TestLoader().discover(test_directory, pattern=test_filename)
test_result = unittest.TextTestRunner(verbosity=2).run(suite)
if len(test_result.errors) > 0 or len(test_result.failures) > 0 or \
        len(test_result.unexpectedSuccesses) > 0:
    sys.exit(1)
