Commit 00550736 authored by nednguyen's avatar nednguyen Committed by Commit bot

Reland of ll typ to v0.9.7. (patchset #1 id:1 of https://codereview.chromium.org/2317473002/ )

Reason for revert:
This is probably not the root cause of crbug.com/643320

Original issue's description:
> Revert of Roll typ to v0.9.7. (patchset #1 id:1 of https://codereview.chromium.org/2289303002/ )
>
> Reason for revert:
> Let's see if reverting this helps w/ crbug.com/643320.
>
> Original issue's description:
> > Roll typ to v0.9.7.
> >
> > This picks up a change that will help address flaky telemetry failures.
> >
> > This includes the following changes (v0.9.5..v0.9.7):
> >
> >   79fe79db Change typ's interpretation of a test that first fails
> >            and is then skipped.
> >   101acd31 Bump version to 0.9.6, clean up Python 3 failures
> >   2f8787b8 rework run script to remove python3 log
> >   d5023636 rework sharding tests
> >
> > TBR=rnephew@chromium.org, nednguyen@google.com
> > BUG=618330
> >
> > Committed: https://crrev.com/71c9ade4e91e16846779311f1ae800ed550c8b69
> > Cr-Commit-Position: refs/heads/master@{#415392}
>
> TBR=nednguyen@google.com,rnephew@chromium.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=618330, 643320
>
> Committed: https://crrev.com/1023620c13385de9fcea55ec35f66dc22b454ff8
> Cr-Commit-Position: refs/heads/master@{#416573}

TBR=rnephew@chromium.org,nednguyen@chromium.org,dpranke@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=618330, 643320

Review-Url: https://codereview.chromium.org/2328753002
Cr-Commit-Position: refs/heads/master@{#417415}
parent 40db8701
Name: typ Name: typ
URL: https://github.com/dpranke/typ.git URL: https://github.com/dpranke/typ.git
Version: 0.9.5 Version: 0.9.7
Revision: a277897604718c50b8353b4bce15d6b78cacdfca Revision: 79fe79dbb4cdd56fd4fe0491f31ad61619652668
Security Critical: no Security Critical: no
License: Apache 2.0 License: Apache 2.0
License File: NOT_SHIPPED License File: NOT_SHIPPED
......
# This file is used by gcl to get repository specific information.
CODE_REVIEW_SERVER: codereview.chromium.org
PROJECT: typ
...@@ -10,9 +10,8 @@ import sys ...@@ -10,9 +10,8 @@ import sys
from tools import cov from tools import cov
is_python3 = bool(sys.version_info.major == 3)
has_python34 = False
verbose = False verbose = False
repo_dir = os.path.abspath(os.path.dirname(__file__)) repo_dir = os.path.abspath(os.path.dirname(__file__))
path_to_cov = os.path.join(repo_dir, 'tools', 'cov.py') path_to_cov = os.path.join(repo_dir, 'tools', 'cov.py')
path_to_runner = os.path.join(repo_dir, 'typ', 'runner.py') path_to_runner = os.path.join(repo_dir, 'typ', 'runner.py')
...@@ -28,8 +27,6 @@ def call(*args, **kwargs): ...@@ -28,8 +27,6 @@ def call(*args, **kwargs):
def main(argv): def main(argv):
parser = argparse.ArgumentParser(prog='run') parser = argparse.ArgumentParser(prog='run')
parser.add_argument('--no3', action='store_true',
help='Do not run the tests under Python 3.')
parser.add_argument('-v', '--verbose', action='store_true') parser.add_argument('-v', '--verbose', action='store_true')
subps = parser.add_subparsers() subps = parser.add_subparsers()
...@@ -60,13 +57,6 @@ def main(argv): ...@@ -60,13 +57,6 @@ def main(argv):
global verbose global verbose
if args.verbose: if args.verbose:
verbose = True verbose = True
global has_python34
if not args.no3:
try:
ver = subprocess.check_output(['python3', '--version'])
has_python34 = ver.split()[1] >= '3.4'
except:
pass
args.func(args) args.func(args)
...@@ -81,11 +71,8 @@ def run_coverage(args): ...@@ -81,11 +71,8 @@ def run_coverage(args):
args.source = [os.path.join(repo_dir, 'typ')] args.source = [os.path.join(repo_dir, 'typ')]
argv = cov.argv_from_args(args) argv = cov.argv_from_args(args)
cov_args = [path_to_runner, '-j', '1'] cov_args = [path_to_runner, '-j', '1']
print('Running coverage of unit tests for Python 2.7.') python = sys.executable
call(['python', path_to_cov] + argv + cov_args) call([python, path_to_cov] + argv + cov_args)
if has_python34:
print('Running coverage of unit tests for Python 3.4.')
call(['python3', path_to_cov] + argv + cov_args)
def run_help(args): def run_help(args):
...@@ -99,20 +86,17 @@ def run_lint(args): ...@@ -99,20 +86,17 @@ def run_lint(args):
def run_tests(args): def run_tests(args):
print('Testing running the typ module directly if it is in sys.path.') python = sys.executable
call(['python', '-m', 'typ', 'typ.tests.main_test.TestMain.test_basic']) # Test running the typ module directly if it is in sys.path.
call([python, '-m', 'typ', 'typ.tests.main_test.TestMain.test_basic'])
print('Testing running the runner directly if nothing is in sys.path.') # Testing running the runner directly if nothing is in sys.path.'
home_dir = os.environ['HOME'] home_dir = os.environ['HOME']
call(['python', path_to_runner, 'typ.tests.main_test.TestMain.test_basic'], call([python, path_to_runner, 'typ.tests.main_test.TestMain.test_basic'],
cwd=home_dir) cwd=home_dir)
# Now run all the tests under Python2 and Python3. # Run the remaining tests.
print('Running the unit tests under Python 2.') call([python, path_to_runner])
call(['python', path_to_runner])
if has_python34:
print('Running the unit tests under Python 3.4.')
call(['python3', path_to_runner])
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -91,12 +91,11 @@ def make_full_results(metadata, seconds_since_epoch, all_test_names, results): ...@@ -91,12 +91,11 @@ def make_full_results(metadata, seconds_since_epoch, all_test_names, results):
for test_name in all_test_names: for test_name in all_test_names:
value = OrderedDict() value = OrderedDict()
value['actual'] = _actual_results_for_test(test_name, results)
if test_name in skipped_tests: if test_name in skipped_tests:
value['expected'] = 'SKIP' value['expected'] = 'SKIP'
value['actual'] = 'SKIP'
else: else:
value['expected'] = 'PASS' value['expected'] = 'PASS'
value['actual'] = _actual_results_for_test(test_name, results)
if value['actual'].endswith('FAIL'): if value['actual'].endswith('FAIL'):
value['is_unexpected'] = True value['is_unexpected'] = True
_add_path_to_trie(full_results['tests'], test_name, value) _add_path_to_trie(full_results['tests'], test_name, value)
...@@ -127,7 +126,13 @@ def failed_test_names(results): ...@@ -127,7 +126,13 @@ def failed_test_names(results):
for r in results.results: for r in results.results:
if r.actual == ResultType.Failure: if r.actual == ResultType.Failure:
names.add(r.name) names.add(r.name)
elif r.actual == ResultType.Pass and r.name in names: elif ((r.actual == ResultType.Pass or r.actual == ResultType.Skip)
and r.name in names):
# This check indicates that a test failed, and then either passed
# or was skipped on a retry. It is somewhat counterintuitive
# that a test that failed and then skipped wouldn't be considered
# failed, but that's at least consistent with a test that is
# skipped every time.
names.remove(r.name) names.remove(r.name)
return names return names
...@@ -144,8 +149,10 @@ def _actual_results_for_test(test_name, results): ...@@ -144,8 +149,10 @@ def _actual_results_for_test(test_name, results):
actuals.append('FAIL') actuals.append('FAIL')
elif r.actual == ResultType.Pass: elif r.actual == ResultType.Pass:
actuals.append('PASS') actuals.append('PASS')
elif r.actual == ResultType.Skip:
assert actuals, 'We did not find any result data for %s.' % test_name actuals.append('SKIP')
if not actuals:
actuals.append('SKIP')
return ' '.join(actuals) return ' '.join(actuals)
......
...@@ -407,6 +407,11 @@ class Runner(object): ...@@ -407,6 +407,11 @@ class Runner(object):
add_tests(suite) add_tests(suite)
else: else:
add_tests(loader.loadTestsFromName(name)) add_tests(loader.loadTestsFromName(name))
if hasattr(loader, 'errors') and loader.errors:
# In Python3's version of unittest, loader failures get converted
# into failed test cases, rather than raising exceptions. However,
# the errors also get recorded so you can err out immediately.
raise ImportError(loader.errors)
def _run_tests(self, result_set, test_set): def _run_tests(self, result_set, test_set):
h = self.host h = self.host
......
This diff is collapsed.
...@@ -157,11 +157,11 @@ class TestPool(test_case.TestCase): ...@@ -157,11 +157,11 @@ class TestPool(test_case.TestCase):
host = Host() host = Host()
jobs = 2 jobs = 2
self.assertRaises(ValueError, make_pool, self.assertRaises(Exception, make_pool,
host, jobs, _stub, unpicklable_fn, None, None) host, jobs, _stub, unpicklable_fn, None, None)
self.assertRaises(ValueError, make_pool, self.assertRaises(Exception, make_pool,
host, jobs, _stub, None, unpicklable_fn, None) host, jobs, _stub, None, unpicklable_fn, None)
self.assertRaises(ValueError, make_pool, self.assertRaises(Exception, make_pool,
host, jobs, _stub, None, None, unpicklable_fn) host, jobs, _stub, None, None, unpicklable_fn)
def test_no_close(self): def test_no_close(self):
......
...@@ -12,4 +12,4 @@ ...@@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
VERSION = '0.9.5' VERSION = '0.9.7'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment