Commit 274aecdd authored by Daniel Clifford's avatar Daniel Clifford Committed by Commit Bot

Fix nits in presubmit.py and handling of .tq otherwise formatting

Change-Id: I69a4db1d8be47bad56df74447a29526e9623cb80
Reviewed-on: https://chromium-review.googlesource.com/1243107
Commit-Queue: Daniel Clifford <danno@chromium.org>
Reviewed-by: 's avatarSergiy Byelozyorov <sergiyb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56219}
parent 55ecf51e
......@@ -94,7 +94,8 @@ def _V8PresubmitChecks(input_api, output_api):
input_api.AffectedFiles(file_filter=FilterFile, include_deletes=False)):
results.append(output_api.PresubmitError("C++ lint check failed"))
if not TorqueFormatProcessor().RunOnFiles(
input_api.AffectedFiles(file_filter=FilterTorqueFile, include_deletes=False)):
input_api.AffectedFiles(file_filter=FilterTorqueFile,
include_deletes=False)):
results.append(output_api.PresubmitError("Torque format check failed"))
if not SourceProcessor().RunOnFiles(
input_api.AffectedFiles(include_deletes=False)):
......
......@@ -751,10 +751,10 @@ module array {
let runLength: Smi = 2;
const elementLow: Object = CallLoad(
context, sortState, load, elements, low) otherwise Bailout;
const elementLowPred: Object = CallLoad(
context, sortState, load, elements, low - 1) otherwise Bailout;
const elementLow: Object =
CallLoad(context, sortState, load, elements, low) otherwise Bailout;
const elementLowPred: Object =
CallLoad(context, sortState, load, elements, low - 1) otherwise Bailout;
let order: Number =
CallCompareFn(context, sortState, elementLow, elementLowPred)
otherwise Bailout;
......@@ -767,8 +767,8 @@ module array {
let previousElement: Object = elementLow;
for (let idx: Smi = low + 1; idx < high; ++idx) {
const currentElement: Object = CallLoad(
context, sortState, load, elements, idx) otherwise Bailout;
const currentElement: Object =
CallLoad(context, sortState, load, elements, idx) otherwise Bailout;
order = CallCompareFn(context, sortState, currentElement, previousElement)
otherwise Bailout;
elements = ReloadElements(sortState);
......@@ -800,10 +800,10 @@ module array {
let high: Smi = to - 1;
while (low < high) {
const elementLow: Object = CallLoad(
context, sortState, load, elements, low) otherwise Bailout;
const elementHigh: Object = CallLoad(
context, sortState, load, elements, high) otherwise Bailout;
const elementLow: Object =
CallLoad(context, sortState, load, elements, low) otherwise Bailout;
const elementHigh: Object =
CallLoad(context, sortState, load, elements, high) otherwise Bailout;
CallStore(context, sortState, store, elements, low++, elementHigh)
otherwise Bailout;
CallStore(context, sortState, store, elements, high--, elementLow)
......
......@@ -109,11 +109,11 @@ def TorqueLintWorker(command):
while True:
out_line = process.stderr.readline()
if out_line == '' and process.poll() != None:
break;
break
out_lines += out_line
error_count += 1
sys.stdout.write(out_lines)
if (error_count != 0):
if error_count != 0:
sys.stdout.write("tip: use 'tools/torque/format-torque.py -i <filename>'\n");
return error_count
except KeyboardInterrupt:
......@@ -310,10 +310,10 @@ class TorqueFormatProcessor(SourceFileProcessor):
def GetTorquelintScript(self):
torque_tools = os.path.join(TOOLS_PATH, "torque")
torque_link = os.path.join(torque_tools, "format-torque.py")
torque_path = os.path.join(torque_tools, "format-torque.py")
if os.path.isfile(torque_link):
return torque_link
if os.path.isfile(torque_path):
return torque_path
return None
......@@ -327,8 +327,7 @@ class TorqueFormatProcessor(SourceFileProcessor):
torquelint = self.GetTorquelintScript()
if torquelint is None:
print('Could not find format-torque. Make sure '
'depot_tools is installed and in the path.')
print('Could not find format-torque.')
sys.exit(1)
command = [sys.executable, torquelint, '-l']
......@@ -337,7 +336,7 @@ class TorqueFormatProcessor(SourceFileProcessor):
count = multiprocessing.cpu_count()
pool = multiprocessing.Pool(count)
try:
results = pool.map_async(TorqueLintWorker, commands).get(999999)
results = pool.map_async(TorqueLintWorker, commands).get()
except KeyboardInterrupt:
print "\nCaught KeyboardInterrupt, terminating workers."
sys.exit(1)
......
......@@ -25,6 +25,10 @@ def preprocess(input):
r' _GeNeRaTeS00_/*\1@*/', input)
input = re.sub(r'\sconstexpr\s+\'([^\']+)\'\s*',
r' _CoNsExP_/*\1@*/', input)
input = re.sub(r'\notherwise',
r'\n otherwise', input)
input = re.sub(r'(\n\s*\S[^\n]*\s)otherwise',
r'\1_OtheSaLi', input)
return input
def postprocess(output):
......@@ -43,8 +47,12 @@ def postprocess(output):
r"generates '\1'", output)
output = re.sub(r'_CoNsExP_\s*\/\*([^@]+)@\*\/',
r"constexpr '\1'", output)
output = re.sub(r'(\n\s*)otherwise(\s+\S+\s*[\(\;])',
r"\1 otherwise\2", output)
output = re.sub(r'\n(\s+)otherwise',
r"\n\1 otherwise", output)
output = re.sub(r'\n(\s+)_OtheSaLi',
r"\n\1otherwise", output)
output = re.sub(r'_OtheSaLi',
r"otherwise", output)
return output
if len(sys.argv) < 2 or len(sys.argv) > 3:
......
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