private void configure(DefaultGoogleTestTestSuiteBinary testBinary, File buildDir) {
      BinaryNamingScheme namingScheme = testBinary.getNamingScheme();
      PlatformToolProvider toolProvider = testBinary.getPlatformToolProvider();
      File binaryOutputDir =
          new File(new File(buildDir, "binaries"), namingScheme.getOutputDirectoryBase());
      String baseName = testBinary.getComponent().getBaseName();

      testBinary.setExecutableFile(
          new File(binaryOutputDir, toolProvider.getExecutableName(baseName)));

      ((ExtensionAware) testBinary)
          .getExtensions()
          .create("cppCompiler", DefaultPreprocessingTool.class);

      // TODO:DAZ Not sure if this should be here...
      // Need "-pthread" when linking on Linux
      if (testBinary.getToolChain() instanceof GccCompatibleToolChain
          && testBinary.getTargetPlatform().getOperatingSystem().isLinux()) {
        testBinary.getLinker().args("-pthread");
      }
    }
    @Finalize
    public void createTestTasks(final TaskContainer tasks, BinaryContainer binaries) {
      for (NativeTestSuiteBinarySpec testBinary :
          binaries.withType(NativeTestSuiteBinarySpec.class)) {
        NativeBinarySpecInternal binary = (NativeBinarySpecInternal) testBinary;
        final BinaryNamingScheme namingScheme = binary.getNamingScheme();

        RunTestExecutable runTask =
            tasks.create(namingScheme.getTaskName("run"), RunTestExecutable.class);
        final Project project = runTask.getProject();
        runTask.setDescription(String.format("Runs the %s", binary));

        final InstallExecutable installTask =
            binary.getTasks().withType(InstallExecutable.class).iterator().next();
        runTask.getInputs().files(installTask.getOutputs().getFiles());
        runTask.setExecutable(installTask.getRunScript().getPath());
        runTask.setOutputDir(
            new File(
                project.getBuildDir(), "/test-results/" + namingScheme.getOutputDirectoryBase()));

        testBinary.getTasks().add(runTask);
      }
    }