From 7601854ddd5428a600b4a860981dd087df3adfa0 Mon Sep 17 00:00:00 2001 From: Alexander Schulze Date: Mon, 21 Feb 2022 21:37:31 +0000 Subject: [PATCH] [v8] py3 migration of tools/predictable_wrapper.py Migrate predictable_wrapper to py3. Run test in v8_presubmit. R=liviurau@chromium.org, machenbach@chromium.org Bug: chromium:1245634 Change-Id: I941e248ffcf12ce26a55a5f5889dab06ee74e66e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3448379 Reviewed-by: Michael Achenbach Reviewed-by: Liviu Rau Commit-Queue: Alexander Schulze Cr-Commit-Position: refs/heads/main@{#79200} --- tools/predictable_wrapper.py | 10 ++++++++-- tools/unittests/predictable_wrapper_test.py | 2 +- tools/unittests/testdata/predictable_mocked.py | 2 +- tools/v8_presubmit.py | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/predictable_wrapper.py b/tools/predictable_wrapper.py index ad5adf7d29..ea80653c86 100644 --- a/tools/predictable_wrapper.py +++ b/tools/predictable_wrapper.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2017 the V8 project authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -31,10 +31,16 @@ TIMEOUT = 120 # Predictable mode works only when run on the host os. command.setup(utils.GuessOS(), None) +def maybe_decode(message): + if not isinstance(message, str): + return message.decode() + return message + + def main(args): def allocation_str(stdout): for line in reversed((stdout or '').splitlines()): - if line.startswith('### Allocations = '): + if maybe_decode(line).startswith('### Allocations = '): return line return None diff --git a/tools/unittests/predictable_wrapper_test.py b/tools/unittests/predictable_wrapper_test.py index c085fb8879..2f806e7c11 100755 --- a/tools/unittests/predictable_wrapper_test.py +++ b/tools/unittests/predictable_wrapper_test.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2017 the V8 project authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/tools/unittests/testdata/predictable_mocked.py b/tools/unittests/testdata/predictable_mocked.py index b9e73f6454..cd1a54d54e 100644 --- a/tools/unittests/testdata/predictable_mocked.py +++ b/tools/unittests/testdata/predictable_mocked.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright 2017 the V8 project authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/tools/v8_presubmit.py b/tools/v8_presubmit.py index 57bc5ea1ba..c7cf50474f 100755 --- a/tools/v8_presubmit.py +++ b/tools/v8_presubmit.py @@ -743,6 +743,7 @@ def PyTests(workspace): for script in [ join(workspace, 'tools', 'clusterfuzz', 'foozzie', 'v8_foozzie_test.py'), join(workspace, 'tools', 'release', 'test_scripts.py'), + join(workspace, 'tools', 'unittests', 'predictable_wrapper_test.py'), join(workspace, 'tools', 'unittests', 'run_tests_test.py'), join(workspace, 'tools', 'unittests', 'run_perf_test.py'), join(workspace, 'tools', 'testrunner', 'testproc', 'variant_unittest.py'),