Skip to content

Commit d6ea573

Browse files
authored
Merge pull request #33051 from compnerd/encoded
validation-test: make scale-test explicitly handle encoding
2 parents 3dc8b38 + deff87d commit d6ea573

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

utils/scale-test

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ from __future__ import print_function
1616

1717
import argparse
1818
import functools
19+
import io
1920
import json
2021
import math
2122
import os
@@ -55,7 +56,7 @@ def has_debuginfo(swiftc):
5556
def write_input_file(args, ast, d, n):
5657
fname = "in%d.swift" % n
5758
pathname = os.path.join(d, fname)
58-
with open(pathname, 'w+') as f:
59+
with io.open(pathname, 'w+', encoding='utf-8', newline='\n') as f:
5960
f.write(gyb.execute_template(ast, '', N=n))
6061
return fname
6162

@@ -217,7 +218,11 @@ def run_many(args):
217218
print("**************************************************")
218219
args.llvm_stat_reporter = True
219220

220-
ast = gyb.parse_template(args.file.name, args.file.read())
221+
if args.file == '-':
222+
ast = gyb.parse_template('stdin', sys.stdin.read())
223+
else:
224+
with io.open(args.file, 'r', encoding='utf-8') as f:
225+
ast = gyb.parse_template(args.file, f.read())
221226
rng = range(args.begin, args.end, args.step)
222227
if args.step > (args.end - args.begin):
223228
print("Step value", args.step,
@@ -695,7 +700,7 @@ def report(args, rng, runs):
695700
def main():
696701
parser = argparse.ArgumentParser()
697702
parser.add_argument(
698-
'file', type=argparse.FileType(),
703+
'file', type=str,
699704
help='Path to GYB template file (defaults to stdin)', nargs='?',
700705
default=sys.stdin)
701706
parser.add_argument(

0 commit comments

Comments
 (0)