generate_matrix.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. import os
  2. import sys
  3. import glob
  4. import json
  5. # If we have arguments passed to the script, use them as the test names to run
  6. if len(sys.argv) > 1:
  7. suites = sys.argv[1:]
  8. valid_suites = []
  9. # Validate if the path is a valid file or directory with files
  10. for suite in suites:
  11. test_path = os.path.join("dirsrvtests/tests/suites/", suite)
  12. if os.path.exists(test_path) and not os.path.islink(test_path):
  13. if os.path.isfile(test_path) and test_path.endswith(".py"):
  14. valid_suites.append(suite)
  15. elif os.path.isdir(test_path):
  16. valid_suites.append(suite)
  17. suites = valid_suites
  18. else:
  19. # Use tests from the source
  20. suites = next(os.walk('dirsrvtests/tests/suites/'))[1]
  21. # Run each replication test module separately to speed things up
  22. suites.remove('replication')
  23. repl_tests = glob.glob('dirsrvtests/tests/suites/replication/*_test.py')
  24. suites += [repl_test.replace('dirsrvtests/tests/suites/', '') for repl_test in repl_tests]
  25. suites.sort()
  26. suites_list = [{ "suite": suite} for suite in suites]
  27. matrix = {"include": suites_list}
  28. print(json.dumps(matrix))