A MiniC++ (C++ subset) compiler for a course.

test.py 834B

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env python3
  2. import os
  3. import sys
  4. import subprocess
  5. if len(sys.argv) < 2:
  6. sys.exit(1)
  7. error = 0
  8. error_list = list()
  9. FNULL = open(os.devnull, 'w')
  10. files = [i for i in os.listdir(sys.argv[1]) if i.endswith(".cpp")]
  11. for i in files:
  12. try:
  13. print("\n"+i)
  14. subprocess.check_call(["./minic++",
  15. "--type-only",
  16. sys.argv[1]+"/"+i],
  17. #stdout=FNULL,
  18. #stderr=FNULL)
  19. )
  20. except subprocess.CalledProcessError:
  21. error += 1
  22. error_list.append(i)
  23. print(str(len(files))+" fichiers testés.")
  24. print(str(error)+" erreurs.\n")
  25. print("Différences entre les deux listes :")
  26. for i in list(set(files) - set(error_list)):
  27. print("\t"+sys.argv[1]+"/"+i)