Skip to content
/ rust Public
forked from rust-lang/rust

Commit

Permalink
[fuchsia-test-runner] Reformat fuchsia-test-runner.py
Browse files Browse the repository at this point in the history
Applied formatting suggestions from isort and black via pylsp.
  • Loading branch information
c6c7 committed Jul 7, 2024
1 parent 54aa9e8 commit 3d5b4d8
Showing 1 changed file with 15 additions and 37 deletions.
52 changes: 15 additions & 37 deletions src/ci/docker/scripts/fuchsia-test-runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
"""

import argparse
from concurrent.futures import ThreadPoolExecutor
from dataclasses import dataclass
import glob
import io
import json
Expand All @@ -20,6 +18,8 @@
import shutil
import subprocess
import sys
from concurrent.futures import ThreadPoolExecutor
from dataclasses import dataclass
from pathlib import Path
from typing import ClassVar, List, Optional

Expand All @@ -42,12 +42,8 @@ def exhaust_pipe(handler, pipe):
for line in pipe:
handler(line.rstrip())

executor_out = executor.submit(
exhaust_pipe, stdout_handler, process.stdout
)
executor_err = executor.submit(
exhaust_pipe, stderr_handler, process.stderr
)
executor_out = executor.submit(exhaust_pipe, stdout_handler, process.stdout)
executor_err = executor.submit(exhaust_pipe, stderr_handler, process.stderr)
executor_out.result()
executor_err.result()
retcode = process.poll()
Expand Down Expand Up @@ -203,9 +199,7 @@ def build_id(self, binary):
raise Exception(f"Unreadable build-id for binary {binary}")
data = json.loads(process.stdout)
if len(data) != 1:
raise Exception(
f"Unreadable output from llvm-readelf for binary {binary}"
)
raise Exception(f"Unreadable output from llvm-readelf for binary {binary}")
notes = data[0]["Notes"]
for note in notes:
note_section = note["NoteSection"]
Expand Down Expand Up @@ -265,9 +259,7 @@ def write_to_file(self):
def setup_logging(self, log_to_file=False):
fs = logging.Formatter("%(asctime)s %(levelname)s:%(name)s:%(message)s")
if log_to_file:
logfile_handler = logging.FileHandler(
self.tmp_dir().joinpath("log")
)
logfile_handler = logging.FileHandler(self.tmp_dir().joinpath("log"))
logfile_handler.setLevel(logging.DEBUG)
logfile_handler.setFormatter(fs)
logging.getLogger().addHandler(logfile_handler)
Expand Down Expand Up @@ -447,9 +439,7 @@ def start(self):
# Initialize temp directory
os.makedirs(self.tmp_dir(), exist_ok=True)
if len(os.listdir(self.tmp_dir())) != 0:
raise Exception(
f"Temp directory is not clean (in {self.tmp_dir()})"
)
raise Exception(f"Temp directory is not clean (in {self.tmp_dir()})")
self.setup_logging(log_to_file=True)
os.mkdir(self.output_dir)

Expand Down Expand Up @@ -486,9 +476,7 @@ def start(self):
shutil.rmtree(self.local_pb_path, ignore_errors=True)

# Look up the product bundle transfer manifest.
self.env_logger.info(
"Looking up the product bundle transfer manifest..."
)
self.env_logger.info("Looking up the product bundle transfer manifest...")
product_name = "minimal." + self.triple_to_arch(self.target)
sdk_version = self.read_sdk_version()

Expand All @@ -510,9 +498,7 @@ def start(self):
)

try:
transfer_manifest_url = json.loads(output)[
"transfer_manifest_url"
]
transfer_manifest_url = json.loads(output)["transfer_manifest_url"]
except Exception as e:
print(e)
raise Exception("Unable to parse transfer manifest") from e
Expand Down Expand Up @@ -762,9 +748,7 @@ def run(self, args):
# Use /tmp as the test temporary directory
env_vars += '\n "RUST_TEST_TMPDIR=/tmp",'

cml.write(
self.CML_TEMPLATE.format(env_vars=env_vars, exe_name=exe_name)
)
cml.write(self.CML_TEMPLATE.format(env_vars=env_vars, exe_name=exe_name))

runner_logger.info("Compiling CML...")

Expand Down Expand Up @@ -915,17 +899,13 @@ def run(self, args):

if stdout_path is not None:
if not os.path.exists(stdout_path):
runner_logger.error(
f"stdout file {stdout_path} does not exist."
)
runner_logger.error(f"stdout file {stdout_path} does not exist.")
else:
with open(stdout_path, encoding="utf-8", errors="ignore") as f:
sys.stdout.write(f.read())
if stderr_path is not None:
if not os.path.exists(stderr_path):
runner_logger.error(
f"stderr file {stderr_path} does not exist."
)
runner_logger.error(f"stderr file {stderr_path} does not exist.")
else:
with open(stderr_path, encoding="utf-8", errors="ignore") as f:
sys.stderr.write(f.read())
Expand Down Expand Up @@ -1030,7 +1010,7 @@ def debug(self, args):
f"--symbol-path={self.rust_dir}/lib/rustlib/{self.target}/lib",
]

# Add rust source if it's available
# Add rust source if it's available
rust_src_map = None
if args.rust_src is not None:
# This matches the remapped prefix used by compiletest. There's no
Expand Down Expand Up @@ -1203,7 +1183,7 @@ def print_help(args):
start_parser.add_argument(
"--use-local-product-bundle-if-exists",
help="if the product bundle already exists in the local path, use "
"it instead of downloading it again",
"it instead of downloading it again",
action="store_true",
)
start_parser.set_defaults(func=start)
Expand Down Expand Up @@ -1239,9 +1219,7 @@ def print_help(args):
)
cleanup_parser.set_defaults(func=cleanup)

syslog_parser = subparsers.add_parser(
"syslog", help="prints the device syslog"
)
syslog_parser = subparsers.add_parser("syslog", help="prints the device syslog")
syslog_parser.set_defaults(func=syslog)

debug_parser = subparsers.add_parser(
Expand Down

0 comments on commit 3d5b4d8

Please sign in to comment.