#!/usr/bin/env python
import testsuite
import os
import sys

if __name__ == '__main__':
    suite = testsuite.ALSTestsuite(os.path.dirname(__file__))
    result = suite.testsuite_main()
    index = suite.report_index
    # Print the results that are not OK
    all_ok = True
    for k in suite.results:
        entry = index.entries[k]
        status = entry.status.name
        if status not in ('PASS', 'XFAIL'):
            all_ok = False
            print("--- {} : {} ---".format(k, status))
            test_result = entry.load()
            print(f"Output:\n{test_result.out}")

    if all_ok:
        print("SUCCESS")

    sys.exit(result)
