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