#!/usr/bin/env python3

"""Wrapper script for running the Pitivi integration tests."""

import os
import subprocess
import sys

GST_VALIDATE_LAUNCHER_COMMAND = "gst-validate-launcher"

try:
    subprocess.check_call("which %s" % GST_VALIDATE_LAUNCHER_COMMAND, shell=True)
except subprocess.CalledProcessError as e:
    print("ERROR: Cannot find %s: %s" % (GST_VALIDATE_LAUNCHER_COMMAND, e))
    print("Make sure to install gst-devtools:")
    print("    http://cgit.freedesktop.org/gstreamer/gst-devtools/tree/validate/")
    sys.exit(127)

path = os.path.abspath(os.path.join(os.path.dirname(__file__)))  # pylint: disable=invalid-name
# Path to scan for GstValidate TestsManager subclasses.
os.environ["GST_VALIDATE_APPS_DIR"] = path
testsuite = os.path.join(path, "suite.py")  # pylint: disable=invalid-name
command = [GST_VALIDATE_LAUNCHER_COMMAND, testsuite]  # pylint: disable=invalid-name
command.extend(sys.argv[1:])
sys.exit(subprocess.call(command))
