#!/usr/bin/env python
"""Usage: run-test [options] test_dir

Run a test located in test_dir
"""

from gnatpython.main import Main
from gnatpython.testdriver import TestRunner, add_run_test_options

import sys

def main():
    """Run a single test"""
    m = Main(add_targets_options=True)
    add_run_test_options(m)
    m.parse_args()
    if not m.args:
        sys.exit("Error: 1 argument expected. See -h")

    if m.options.restricted_discs is not None:
        m.options.restricted_discs = m.options.restricted_discs.split(',')
    t = TestRunner(m.args[0],
                   m.options.discs,
                   m.options.output_dir,
                   m.options.tmp,
                   m.options.enable_cleanup,
                   m.options.restricted_discs,
                   len(m.args) > 1 and m.args[1:] or None)

    t.execute()
if __name__ == '__main__':
    main()
