#!/usr/bin/env python
# Don't run tests from the root repo dir.
# We want to ensure we're importing from the installed
# binary package not from the CWD.

import os
import sys
from subprocess import check_call

_dname = os.path.dirname

REPO_ROOT = _dname(_dname(_dname(os.path.abspath(__file__))))
os.chdir(os.path.join(REPO_ROOT, 'tests'))


def run(command, env=None):
    return check_call(command, shell=True, env=env)

try:
    import awscrt
except ImportError:
    print("MISSING DEPENDENCY: awscrt must be installed to run the crt tests.")
    sys.exit(1)

run('nosetests s3transfer --with-xunit unit/ functional/')

# Run the serial implementation of s3transfer
os.environ['USE_SERIAL_EXECUTOR'] = 'True'
run('nosetests -v functional/', env=os.environ)
