// Validate that the user didn"t provide any passthru args that conflict
// with those we must set ourselves.
for arg in self.get_passthru_args():
if arg.startswith("--junitxml") or arg.startswith("--confcutdir"):
raise TaskError("Cannot pass this arg through to pytest: {}".format(arg))
junitxml_path = self._get_junit_xml_path(targets)
// N.B. the `--confcutdir` here instructs pytest to stop scanning for conftest.py files at the
// top of the buildroot. This prevents conftest.py files from outside (e.g. in users home dirs)
// from leaking into pants test runs. See: https://github.com/pantsbuild/pants/issues/2726
args = ["--junitxml", junitxml_path, "--confcutdir", get_buildroot()]
if self.get_options().fail_fast:
args.extend(["-x"])
if self._debug:
args.extend(["-s"])
if self.get_options().colors:
args.extend(["--color", "yes"])
for options in self.get_options().options + self.get_passthru_args():
args.extend(safe_shlex_split(options))
args.extend(test_args)
args.extend(sources)
result = self._do_run_tests_with_args(pex, workunit, args)
external_junit_xml_dir = self.get_options().junit_xml_dir
if external_junit_xml_dir:
safe_mkdir(external_junit_xml_dir)
shutil.copy(junitxml_path, external_junit_xml_dir)
failed_targets = self._get_failed_targets_from_junitxml(junitxml_path, targets)