Skip to content

Commit

Permalink
Make mach test-tidy --self-test compatible with Python3
Browse files Browse the repository at this point in the history
  • Loading branch information
marmeladema committed Dec 14, 2019
1 parent 3f663d7 commit 4fc5154
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 78 deletions.
2 changes: 1 addition & 1 deletion etc/taskcluster/decision_task.py
Expand Up @@ -213,7 +213,7 @@ def linux_tidy_unit():
python3 ./mach build --dev --features layout-2020
python3 ./mach build --dev --libsimpleservo
python3 ./mach build --dev -p servo-gst-plugin
./mach test-tidy --no-progress --self-test
python3 ./mach test-tidy --no-progress --self-test
./etc/memory_reports_over_time.py --test
./etc/taskcluster/mock.py
Expand Down
16 changes: 8 additions & 8 deletions python/tidy/servo_tidy/tidy.py
Expand Up @@ -447,16 +447,16 @@ def check_shell(file_name, lines):
if not file_name.endswith(".sh"):
raise StopIteration

shebang = b"#!/usr/bin/env bash"
required_options = {"set -o errexit", "set -o nounset", "set -o pipefail"}
shebang = "#!/usr/bin/env bash"
required_options = ["set -o errexit", "set -o nounset", "set -o pipefail"]

did_shebang_check = False

if not lines:
yield (0, 'script is an empty file')
return

if lines[0].rstrip() != shebang:
if lines[0].rstrip() != shebang.encode("utf-8"):
yield (1, 'script does not have shebang "{}"'.format(shebang))

for idx, line in enumerate(map(lambda line: line.decode("utf-8"), lines[1:])):
Expand Down Expand Up @@ -506,7 +506,7 @@ def check_manifest_dirs(config_file, print_text=True):
return

# Load configs from include.ini
with open(config_file) as content:
with open(config_file, "rb") as content:
conf_file = content.read()
lines = conf_file.splitlines(True)

Expand Down Expand Up @@ -808,7 +808,7 @@ def check_yaml(file_name, contents):
line = e.problem_mark.line + 1 if hasattr(e, 'problem_mark') else None
yield (line, e)
except KeyError as e:
yield (None, "Duplicated Key ({})".format(e.message))
yield (None, "Duplicated Key ({})".format(e.args[0]))
except voluptuous.MultipleInvalid as e:
yield (None, str(e))

Expand Down Expand Up @@ -844,11 +844,11 @@ def check_json(filename, contents):
try:
json.loads(contents, object_pairs_hook=check_json_requirements(filename))
except ValueError as e:
match = re.search(r"line (\d+) ", e.message)
match = re.search(r"line (\d+) ", e.args[0])
line_no = match and match.group(1)
yield (line_no, e.message)
yield (line_no, e.args[0])
except KeyError as e:
yield (None, e.message)
yield (None, e.args[0])


def check_spec(file_name, lines):
Expand Down

0 comments on commit 4fc5154

Please sign in to comment.