#!/usr/bin/env python3

import os
import sys

projectlibrary = sys.argv[1]

with open('scripts/fulltest-top') as f:
  sys.stdout.write(f.read().replace('PROJECT',projectlibrary))

print('')
print('todo = [')

usedop = {}

for line in sys.stdin:
  line = line.split('/')
  o,p = line[:2]
  if (o,p) not in usedop:
    assert "'" not in o
    assert "'" not in p
    assert "\\" not in o
    assert "\\" not in p
    usedop[o,p] = 0
    print(f"  ('{o}','{p}',-1),")
  print(f" ('{o}','{p}',{usedop[o,p]}),")
  usedop[o,p] += 1

print(']')
print('')
print('todo = [task+(offset,) for task in todo for offset in range(1 if task[0] == "sort" else 2)]')
print('todo = [(False,)+task for task in todo]+[(True,)+task for task in todo if task[-1] == 0]')
print('')
print('if not doit(todo):')
print("  print('some tests failed')")
print('  sys.exit(111)')
print("print('full tests succeeded')")

sys.stdout.flush()
os.fchmod(sys.stdout.fileno(),0o755)
