Skip to content

Commit b337a11

Browse files
authored
Lit tests: print failing module index (#4614)
When a .wat file has lots of modules inside it, printing the index of the module is helpful to find which is erroring.
1 parent 2093823 commit b337a11

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

scripts/foreach.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
import os
1718
import sys
1819
import subprocess
1920

@@ -31,6 +32,7 @@ def main():
3132
tempfile = sys.argv[2]
3233
cmd = sys.argv[3:]
3334
returncode = 0
35+
all_modules = open(infile).read()
3436
for i, (module, asserts) in enumerate(support.split_wast(infile)):
3537
tempname = tempfile + '.' + str(i)
3638
with open(tempname, 'w') as temp:
@@ -39,6 +41,9 @@ def main():
3941
result = subprocess.run(new_cmd)
4042
if result.returncode != 0:
4143
returncode = result.returncode
44+
module_char_start = all_modules.find(module)
45+
module_line_start = all_modules[:module_char_start].count(os.linesep)
46+
print(f'[Failing module at line {module_line_start}]', file=sys.stderr)
4247
sys.exit(returncode)
4348

4449

0 commit comments

Comments
 (0)