Skip to content

Commit

Permalink
Lit tests: print failing module index (#4614)
Browse files Browse the repository at this point in the history
When a .wat file has lots of modules inside it, printing the index of the
module is helpful to find which is erroring.
  • Loading branch information
kripken authored Apr 26, 2022
1 parent 2093823 commit b337a11
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scripts/foreach.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import sys
import subprocess

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


Expand Down

0 comments on commit b337a11

Please sign in to comment.