protected <T extends ExecutionResult> T checkResult(T result) { if (stackTraceChecksOn) { // Assert that nothing unexpected was logged assertOutputHasNoStackTraces(result); assertErrorHasNoStackTraces(result); } if (deprecationChecksOn) { assertOutputHasNoDeprecationWarnings(result); } if (getExecutable() == null) { // Assert that no temp files are left lying around // Note: don't do this if a custom executable is used, as we don't know (and probably don't // care) whether the executable cleans up or not TestFile[] testFiles = getTmpDir().listFiles(); if (testFiles != null) { List<String> unexpectedFiles = new ArrayList<String>(); for (File file : testFiles) { if (!file.getName().matches("maven-artifact\\d+.tmp")) { unexpectedFiles.add(file.getName()); } } // Assert.assertThat(unexpectedFiles, Matchers.isEmpty()); } } return result; }
public void beforeExecute(Task task) { assertThat(current, nullValue()); assertTrue(planned.contains(task)); current = task; String taskPath = path(task); if (taskPath.startsWith(":buildSrc:")) { return; } executedTasks.add(taskPath); }
public GradleExecuter reset() { args.clear(); tasks.clear(); initScripts.clear(); workingDir = null; projectDir = null; buildScript = null; settingsFile = null; quiet = false; taskList = false; dependencyList = false; searchUpwards = false; executable = null; javaHome = null; environmentVars.clear(); stdin = null; defaultCharacterEncoding = null; noDefaultJvmArgs = false; deprecationChecksOn = true; stackTraceChecksOn = true; return this; }
protected List<String> getAllArgs() { List<String> allArgs = new ArrayList<String>(); if (buildScript != null) { allArgs.add("--build-file"); allArgs.add(buildScript.getAbsolutePath()); } if (projectDir != null) { allArgs.add("--project-dir"); allArgs.add(projectDir.getAbsolutePath()); } for (File initScript : initScripts) { allArgs.add("--init-script"); allArgs.add(initScript.getAbsolutePath()); } if (settingsFile != null) { allArgs.add("--settings-file"); allArgs.add(settingsFile.getAbsolutePath()); } if (quiet) { allArgs.add("--quiet"); } if (taskList) { allArgs.add("tasks"); } if (dependencyList) { allArgs.add("dependencies"); } if (!searchUpwards) { boolean settingsFoundAboveInTestDir = false; TestFile dir = new TestFile(getWorkingDir()); while (dir != null && getTestDirectoryProvider().getTestDirectory().isSelfOrDescendent(dir)) { if (dir.file("settings.gradle").isFile()) { settingsFoundAboveInTestDir = true; break; } dir = dir.getParentFile(); } if (!settingsFoundAboveInTestDir) { allArgs.add("--no-search-upward"); } } // This will cause problems on Windows if the path to the Gradle executable that is used has a // space in it (e.g. the user's dir is c:/Users/Luke Daley/) // This is fundamentally a windows issue: You can't have arguments with spaces in them if the // path to the batch script has a space // We could work around this by setting -Dgradle.user.home but GRADLE-1730 (which affects // 1.0-milestone-3) means that that // is problematic as well. For now, we just don't support running the int tests from a path with // a space in it on Windows. // When we stop testing against M3 we should change to use the system property. if (getGradleUserHomeDir() != null) { allArgs.add("--gradle-user-home"); allArgs.add(getGradleUserHomeDir().getAbsolutePath()); } allArgs.addAll(args); allArgs.addAll(tasks); return allArgs; }
public GradleExecuter withTasks(List<String> names) { tasks.clear(); tasks.addAll(names); return this; }
public GradleExecuter usingInitScript(File initScript) { initScripts.add(initScript); return this; }
public GradleExecuter copyTo(GradleExecuter executer) { executer.withGradleUserHomeDir(gradleUserHomeDir); executer.withDaemonIdleTimeoutSecs(daemonIdleTimeoutSecs); executer.withDaemonBaseDir(daemonBaseDir); if (workingDir != null) { executer.inDirectory(workingDir); } if (projectDir != null) { executer.usingProjectDirectory(projectDir); } if (buildScript != null) { executer.usingBuildScript(buildScript); } if (settingsFile != null) { executer.usingSettingsFile(settingsFile); } if (javaHome != null) { executer.withJavaHome(javaHome); } for (File initScript : initScripts) { executer.usingInitScript(initScript); } executer.withTasks(tasks); executer.withArguments(args); executer.withEnvironmentVars(getAllEnvironmentVars()); executer.usingExecutable(executable); if (quiet) { executer.withQuietLogging(); } if (taskList) { executer.withTaskList(); } if (dependencyList) { executer.withDependencyList(); } if (userHomeDir != null) { executer.withUserHomeDir(userHomeDir); } if (stdin != null) { executer.withStdIn(stdin); } if (defaultCharacterEncoding != null) { executer.withDefaultCharacterEncoding(defaultCharacterEncoding); } executer.withGradleOpts(gradleOpts.toArray(new String[gradleOpts.size()])); if (noDefaultJvmArgs) { executer.withNoDefaultJvmArgs(); } executer.setAllowExtraLogging(allowExtraLogging); if (!deprecationChecksOn) { executer.withDeprecationChecksDisabled(); } if (!stackTraceChecksOn) { executer.withStackTraceChecksDisabled(); } executer.requireGradleHome(isRequireGradleHome()); return executer; }