vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

gen_testset.py (1074B)


      1 #!/usr/bin/env python3
      2 
      3 import argparse
      4 import itertools
      5 import json
      6 import re
      7 import subprocess
      8 
      9 
     10 def generate_testset(n):
     11     cp = subprocess.run(["make", "-C", "src/testdir", "-npq"], capture_output=True)
     12 
     13     tests = set()
     14     for line in cp.stdout.decode().split("\n"):
     15         if re.match(r"^(NEW_TESTS_RES|TEST_VIM9_RES) = ", line):
     16             tests.update(re.findall(r"\btest\w+\.res\b", line))
     17 
     18     tests = sorted(list(tests))
     19     # move test_alot*.res to the end
     20     tests = (
     21         [t for t in tests if not t.startswith("test_alot")]
     22         + [t for t in tests if t.startswith("test_alot_")]
     23         + ["test_alot.res"]
     24     )
     25     targets = tests
     26 
     27     if n > 1:
     28         targets = [ts for ts in itertools.batched(tests, n)]
     29         targets = [[t for t in ts if t] for ts in itertools.zip_longest(*targets)]
     30 
     31     return targets
     32 
     33 
     34 def main():
     35     parser = argparse.ArgumentParser()
     36     parser.add_argument("n", type=int, nargs="?", default=1)
     37     args = parser.parse_args()
     38 
     39     print(json.dumps(generate_testset(args.n)))
     40 
     41 
     42 if __name__ == "__main__":
     43     main()