Search in sources :

Example 21 with CommandBuilder

use of com.thoughtworks.go.domain.builder.CommandBuilder in project gocd by gocd.

the class AntTaskBuilderTest method antTaskShouldNormalizeWorkingDirectory.

@Test
@RunIf(value = EnhancedOSChecker.class, arguments = { DO_NOT_RUN_ON, WINDOWS })
public void antTaskShouldNormalizeWorkingDirectory() {
    AntTask task = new AntTask();
    task.setWorkingDirectory("folder1\\folder2");
    CommandBuilder commandBuilder = (CommandBuilder) antTaskBuilder.createBuilder(builderFactory, task, TasksTest.pipelineStub("label", "/var/cruise-agent/pipelines/cruise"), resolver);
    assertThat(commandBuilder.getWorkingDir().getPath(), is("/var/cruise-agent/pipelines/cruise/folder1/folder2"));
}
Also used : AntTask(com.thoughtworks.go.config.AntTask) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test) TasksTest(com.thoughtworks.go.domain.TasksTest)

Example 22 with CommandBuilder

use of com.thoughtworks.go.domain.builder.CommandBuilder in project gocd by gocd.

the class ExecTaskBuilderTest method shouldUseProjectDefaultWorkingDirectoryIfNotSpecified.

@Test
public void shouldUseProjectDefaultWorkingDirectoryIfNotSpecified() throws Exception {
    ExecTask task = new ExecTask("command", "", (String) null);
    final File defaultWorkingDir = new File("foo");
    CommandBuilder builder = (CommandBuilder) execTaskBuilder.createBuilder(builderFactory, task, TasksTest.pipelineStub("label", "foo"), resolver);
    assertThat(builder.getWorkingDir(), isSamePath(defaultWorkingDir));
}
Also used : ExecTask(com.thoughtworks.go.config.ExecTask) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) File(java.io.File) Test(org.junit.Test) TasksTest(com.thoughtworks.go.domain.TasksTest)

Example 23 with CommandBuilder

use of com.thoughtworks.go.domain.builder.CommandBuilder in project gocd by gocd.

the class NantTaskBuilderTest method shouldSetNAntWorkingDirectoryAbsolutelyIfSpecified.

@Test
public void shouldSetNAntWorkingDirectoryAbsolutelyIfSpecified() throws Exception {
    final File absoluteFile = new File("project").getAbsoluteFile();
    NantTask task = new NantTask();
    task.setWorkingDirectory(absoluteFile.getPath());
    CommandBuilder builder = (CommandBuilder) nantTaskBuilder.createBuilder(builderFactory, task, pipeline, resolver);
    assertThat(builder.getWorkingDir(), is(absoluteFile));
}
Also used : NantTask(com.thoughtworks.go.config.NantTask) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) File(java.io.File) Test(org.junit.Test) TasksTest(com.thoughtworks.go.domain.TasksTest)

Example 24 with CommandBuilder

use of com.thoughtworks.go.domain.builder.CommandBuilder in project gocd by gocd.

the class NantTaskBuilderTest method shouldUseAbsoluteNantPathIfAbsoluteNantPathIsSpecifiedOnWindows.

@Test
@RunIf(value = EnhancedOSChecker.class, arguments = { EnhancedOSChecker.WINDOWS })
public void shouldUseAbsoluteNantPathIfAbsoluteNantPathIsSpecifiedOnWindows() throws Exception {
    NantTask nantTask = new NantTask();
    nantTask.setNantPath("c:\\nantdir");
    CommandBuilder builder = (CommandBuilder) nantTaskBuilder.createBuilder(builderFactory, nantTask, pipeline, resolver);
    assertThat(new File(builder.getCommand()), is(new File("c:\\nantdir\\nant")));
}
Also used : NantTask(com.thoughtworks.go.config.NantTask) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) File(java.io.File) RunIf(com.googlecode.junit.ext.RunIf) Test(org.junit.Test) TasksTest(com.thoughtworks.go.domain.TasksTest)

Example 25 with CommandBuilder

use of com.thoughtworks.go.domain.builder.CommandBuilder in project gocd by gocd.

the class NantTaskBuilderTest method shouldJoinNantPathWithWorkingDirectoryIfRelativeNantPathIsSpecified.

@Test
public void shouldJoinNantPathWithWorkingDirectoryIfRelativeNantPathIsSpecified() throws Exception {
    NantTask nantTask = new NantTask();
    nantTask.setNantPath("lib");
    CommandBuilder builder = (CommandBuilder) nantTaskBuilder.createBuilder(builderFactory, nantTask, pipeline, resolver);
    assertThat(new File(builder.getCommand()), is(new File("lib/nant")));
}
Also used : NantTask(com.thoughtworks.go.config.NantTask) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) File(java.io.File) Test(org.junit.Test) TasksTest(com.thoughtworks.go.domain.TasksTest)

Aggregations

CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)26 Test (org.junit.Test)18 File (java.io.File)17 TasksTest (com.thoughtworks.go.domain.TasksTest)16 NantTask (com.thoughtworks.go.config.NantTask)9 Builder (com.thoughtworks.go.domain.builder.Builder)9 RunIf (com.googlecode.junit.ext.RunIf)6 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)4 NullBuilder (com.thoughtworks.go.domain.builder.NullBuilder)4 ArtifactStores (com.thoughtworks.go.config.ArtifactStores)3 ArrayList (java.util.ArrayList)3 ExecTask (com.thoughtworks.go.config.ExecTask)2 RunIfConfigs (com.thoughtworks.go.domain.RunIfConfigs)2 StubBuilder (com.thoughtworks.go.domain.builder.StubBuilder)2 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)2 AntTask (com.thoughtworks.go.config.AntTask)1 RakeTask (com.thoughtworks.go.config.RakeTask)1 Materials (com.thoughtworks.go.config.materials.Materials)1 StubGoPublisher (com.thoughtworks.go.domain.StubGoPublisher)1 CommandBuilderWithArgList (com.thoughtworks.go.domain.builder.CommandBuilderWithArgList)1