#!/usr/bin/env python

import os
import sys
import json

args = json.loads(sys.argv[1])

collect_only = bool(args.get("collect-only", False))
files = args.get("files", [])
nodeids = args.get("nodeids", [])

# Create the command line to launch
cmd = ["pytest", "--litf", "-vvv"]

# Force the rootdir to have stable file names and node ids between
# collection and run
cmd.append("--rootdir=%s" % os.getcwd())


if collect_only:
    cmd.append("--collectonly")

if nodeids:
    cmd.extend(nodeids)
if files:
    cmd.extend(files)

# Replace current process with the cmd
os.execvp("pytest", cmd)
