org.junit.jupiter.api.condition.DisabledOnOs Java Examples
The following examples show how to use
org.junit.jupiter.api.condition.DisabledOnOs.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommandLineTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldLogPasswordsOnEnvironemntAsStarsUnderLinux() { CommandLine line = CommandLine.createCommandLine("echo") .withArg("My Password is:") .withArg("secret") .withArg(new PasswordArgument("secret")) .withEncoding("utf-8"); EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext(); environmentVariableContext.setProperty("ENV_PASSWORD", "secret", false); InMemoryStreamConsumer output = new InMemoryStreamConsumer(); InMemoryStreamConsumer forDisplay = InMemoryStreamConsumer.inMemoryConsumer(); ProcessWrapper processWrapper = line.execute(output, environmentVariableContext, null); processWrapper.waitForExit(); assertThat(forDisplay.getAllOutput(), not(containsString("secret"))); assertThat(output.getAllOutput(), containsString("secret")); }
Example #2
Source File: MaterialsTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldFailIfMultipleMaterialsHaveSameFolderNameSet_CaseInSensitive() { HgMaterialConfig materialOne = hg("http://url1", null); materialOne.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "folder")); HgMaterialConfig materialTwo = hg("http://url2", null); materialTwo.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "foLder")); CruiseConfig config = GoConfigMother.configWithPipelines("one"); PipelineConfig pipelineOne = config.pipelineConfigByName(new CaseInsensitiveString("one")); pipelineOne.setMaterialConfigs(new MaterialConfigs(materialOne, materialTwo)); MaterialConfigs materials = pipelineOne.materialConfigs(); materials.validate(ConfigSaveValidationContext.forChain(config)); assertThat(materials.get(0).errors().isEmpty()).isFalse(); assertThat(materials.get(1).errors().isEmpty()).isFalse(); assertThat(materials.get(0).errors().on(ScmMaterialConfig.FOLDER)).isEqualTo("The destination directory must be unique across materials."); assertThat(materials.get(1).errors().on(ScmMaterialConfig.FOLDER)).isEqualTo("The destination directory must be unique across materials."); }
Example #3
Source File: BuilderTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldReportErrorWhenCancelCommandDoesNotExist() { StubBuilder stubBuilder = new StubBuilder(); CommandBuilder cancelBuilder = new CommandBuilder("echo2", "cancel task", new File("."), new RunIfConfigs(FAILED), stubBuilder, ""); CommandBuilder builder = new CommandBuilder("echo", "normal task", new File("."), new RunIfConfigs(FAILED), cancelBuilder, ""); builder.cancel(goPublisher, new EnvironmentVariableContext(), null, null, "utf-8"); assertThat(goPublisher.getMessage()).contains("Error happened while attempting to execute 'echo2 cancel task'"); }
Example #4
Source File: SvnCommandTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldRecogniseSvnAsTheSameIfURLContainsChineseCharacters() throws Exception { File working = temporaryFolder.newFolder("shouldRecogniseSvnAsTheSameIfURLContainsSpaces"); SvnTestRepo repo = new SvnTestRepo(temporaryFolder, "a directory with 司徒空在此"); SvnMaterial material = repo.material(); assertThat(material.getUrl()).contains("%20"); InMemoryStreamConsumer output = new InMemoryStreamConsumer(); material.freshCheckout(output, new SubversionRevision("3"), working); assertThat(output.getAllOutput()).contains("Checked out revision 3"); InMemoryStreamConsumer output2 = new InMemoryStreamConsumer(); updateMaterial(material, new SubversionRevision("4"), working, output2); assertThat(output2.getAllOutput()).contains("Updated to revision 4"); }
Example #5
Source File: SvnCommandTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldRecogniseSvnAsTheSameIfURLContainsSpaces() throws Exception { File working = temporaryFolder.newFolder("shouldRecogniseSvnAsTheSameIfURLContainsSpaces"); SvnTestRepo repo = new SvnTestRepo(temporaryFolder, "a directory with spaces"); SvnMaterial material = repo.material(); assertThat(material.getUrl()).contains("%20"); InMemoryStreamConsumer output = new InMemoryStreamConsumer(); material.freshCheckout(output, new SubversionRevision("3"), working); assertThat(output.getAllOutput()).contains("Checked out revision 3"); InMemoryStreamConsumer output2 = new InMemoryStreamConsumer(); material.updateTo(output2, working, new RevisionContext(new SubversionRevision("4")), new TestSubprocessExecutionContext()); assertThat(output2.getAllOutput()).contains("Updated to revision 4"); }
Example #6
Source File: CommandRepositoryDirectoryWalkerTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldUpdateServerHealthServiceIfACommandSnippetXMLIsUnReadableAndRemoveItOnceItsReadable() throws IOException { File dirWithUnreadableFile = temporaryFolder.newFolder("dirWithUnreadableFile"); File unreadableFile = new File(dirWithUnreadableFile, "unreadable.xml"); FileUtils.copyFile(xmlFile, unreadableFile); unreadableFile.setReadable(false); walker.getAllCommandSnippets(dirWithUnreadableFile.getPath()); verify(serverHealthService).update(serverHealthWarningMessageWhichContains("Failed to access command snippet XML file located in Go Server Directory at " + unreadableFile.getPath() + ". Go does not have sufficient permissions to access it.")); unreadableFile.setReadable(true); walker.getAllCommandSnippets(dirWithUnreadableFile.getPath()); verify(serverHealthService, times(2)).update(serverHealthMessageWhichSaysItsOk()); verifyNoMoreInteractions(serverHealthService); }
Example #7
Source File: CommandLineTest.java From gocd with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldNotLogPasswordsOnExceptionThrown() throws IOException { File dir = temporaryFolder.newFolder(); File file = new File(dir, "test.sh"); FileOutputStream out = new FileOutputStream(file); out.write("echo $1 && exit 10".getBytes()); out.close(); CommandLine line = CommandLine.createCommandLine("/bin/sh").withArg(file.getAbsolutePath()).withArg(new PasswordArgument("secret")).withEncoding("utf-8"); try { line.runOrBomb(null); } catch (CommandLineException e) { assertThat(e.getMessage(), not(containsString("secret"))); } }
Example #8
Source File: SimpleFileFinderTest.java From synopsys-detect with Apache License 2.0 | 6 votes |
@UnitTest @DisabledOnOs(WINDOWS) public void testSymlinksNotFollowed() throws IOException { // Create a subDir with a symlink that loops back to its parent final File initialDirectory = initialDirectoryPath.toFile(); final File subDir = new File(initialDirectory, "sub"); subDir.mkdirs(); final File link = new File(subDir, "linkToInitial"); final Path linkPath = link.toPath(); Files.createSymbolicLink(linkPath, initialDirectoryPath); final File regularDir = new File(subDir, "regularDir"); regularDir.mkdir(); final File regularFile = new File(subDir, "regularFile"); regularFile.createNewFile(); final SimpleFileFinder finder = new SimpleFileFinder(); final List<String> filenamePatterns = Arrays.asList("sub", "linkToInitial", "regularDir", "regularFile"); final List<File> foundFiles = finder.findFiles(initialDirectoryPath.toFile(), filenamePatterns, 10); // make sure symlink not followed during dir traversal assertEquals(4, foundFiles.size()); }
Example #9
Source File: DockerExtractorTest.java From synopsys-detect with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(WINDOWS) public void testExtractImageReturningContainerFileSystem() throws ExecutableRunnerException { final String image = "ubuntu:latest"; final String imageId = null; final String tar = null; final ExecutableRunner executableRunner = Mockito.mock(ExecutableRunner.class); final Extraction extraction = extract(image, imageId, tar, fakeContainerFileSystemFile, null, executableRunner); assertEquals("ubuntu:latest", extraction.getMetaData(DockerExtractor.DOCKER_IMAGE_NAME_META_DATA).get()); assertTrue(extraction.getMetaData(DockerExtractor.DOCKER_TAR_META_DATA).get().getName().endsWith("_containerfilesystem.tar.gz")); final ArgumentCaptor<Executable> executableArgumentCaptor = ArgumentCaptor.forClass(Executable.class); Mockito.verify(executableRunner).execute(executableArgumentCaptor.capture()); final Executable executableToVerify = executableArgumentCaptor.getValue(); final List<String> command = executableToVerify.getCommand(); assertTrue(command.get(0).endsWith("/fake/test/java")); assertEquals("-jar", command.get(1)); assertTrue(command.get(2).endsWith("/fake/test/dockerinspector.jar")); assertTrue(command.get(3).startsWith("--spring.config.location=")); assertTrue(command.get(3).endsWith("/application.properties")); assertEquals("--docker.image=ubuntu:latest", command.get(4)); }
Example #10
Source File: DockerExtractorTest.java From synopsys-detect with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(WINDOWS) public void testExtractImageReturningSquashedImage() throws ExecutableRunnerException { final String image = "ubuntu:latest"; final String imageId = null; final String tar = null; final ExecutableRunner executableRunner = Mockito.mock(ExecutableRunner.class); final Extraction extraction = extract(image, imageId, tar, fakeContainerFileSystemFile, fakeSquashedImageFile, executableRunner); assertEquals("ubuntu:latest", extraction.getMetaData(DockerExtractor.DOCKER_IMAGE_NAME_META_DATA).get()); // When Detect gets both .tar.gz files back, should prefer the squashed image assertTrue(extraction.getMetaData(DockerExtractor.DOCKER_TAR_META_DATA).get().getName().endsWith("_squashedimage.tar.gz")); final ArgumentCaptor<Executable> executableArgumentCaptor = ArgumentCaptor.forClass(Executable.class); Mockito.verify(executableRunner).execute(executableArgumentCaptor.capture()); final Executable executableToVerify = executableArgumentCaptor.getValue(); final List<String> command = executableToVerify.getCommand(); assertTrue(command.get(0).endsWith("/fake/test/java")); assertEquals("-jar", command.get(1)); assertTrue(command.get(2).endsWith("/fake/test/dockerinspector.jar")); assertTrue(command.get(3).startsWith("--spring.config.location=")); assertTrue(command.get(3).endsWith("/application.properties")); assertEquals("--docker.image=ubuntu:latest", command.get(4)); }
Example #11
Source File: DockerExtractorTest.java From synopsys-detect with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(WINDOWS) public void testExtractTarReturningContainerFileSystem() throws ExecutableRunnerException { final String image = null; final String imageId = null; final String tar = fakeDockerTarFile.getAbsolutePath(); final ExecutableRunner executableRunner = Mockito.mock(ExecutableRunner.class); final Extraction extraction = extract(image, imageId, tar, fakeContainerFileSystemFile, null, executableRunner); assertTrue(extraction.getMetaData(DockerExtractor.DOCKER_IMAGE_NAME_META_DATA).get().endsWith("testDockerTarfile.tar")); assertTrue(extraction.getMetaData(DockerExtractor.DOCKER_TAR_META_DATA).get().getName().endsWith("_containerfilesystem.tar.gz")); final ArgumentCaptor<Executable> executableArgumentCaptor = ArgumentCaptor.forClass(Executable.class); Mockito.verify(executableRunner).execute(executableArgumentCaptor.capture()); final Executable executableToVerify = executableArgumentCaptor.getValue(); final List<String> command = executableToVerify.getCommand(); assertTrue(command.get(0).endsWith("/fake/test/java")); assertEquals("-jar", command.get(1)); assertTrue(command.get(2).endsWith("/fake/test/dockerinspector.jar")); assertTrue(command.get(3).startsWith("--spring.config.location=")); assertTrue(command.get(3).endsWith("/application.properties")); assertTrue(command.get(4).startsWith("--docker.tar=")); assertTrue(command.get(4).endsWith("testDockerTarfile.tar")); }
Example #12
Source File: DockerExtractorTest.java From synopsys-detect with Apache License 2.0 | 6 votes |
@Test @DisabledOnOs(WINDOWS) public void testGetImageIdentifierFromOutputDirectoryIfImageIdPresent() throws URISyntaxException { String testString = "test"; String imageIdArgument = "--docker.image.id="; String imageName = "ubuntu:latest"; final File outputDirectoryWithPopulatedResultsFile = new File(DockerExtractorTest.class.getClassLoader().getSystemResource("detectables/functional/docker/unit/outputDirectoryWithPopulatedResultsFile").toURI()); final File outputDirectoryWithNonPopulatedResultsFile = new File(DockerExtractorTest.class.getClassLoader().getSystemResource("detectables/functional/docker/unit/outputDirectoryWithNonPopulatedResultsFile").toURI()); ExecutableRunner executableRunner = Mockito.mock(ExecutableRunner.class); FileFinder fileFinder = Mockito.mock(FileFinder.class); Mockito.when(fileFinder.findFile(outputDirectoryWithPopulatedResultsFile, DockerExtractor.RESULTS_FILENAME_PATTERN)).thenReturn(new File(outputDirectoryWithPopulatedResultsFile, "results.json")); Mockito.when(fileFinder.findFile(outputDirectoryWithNonPopulatedResultsFile, DockerExtractor.RESULTS_FILENAME_PATTERN)).thenReturn(new File(outputDirectoryWithNonPopulatedResultsFile, "results.json")); DockerExtractor dockerExtractor = getMockDockerExtractor(executableRunner, fileFinder); assertEquals(imageName, dockerExtractor.getImageIdentifierFromOutputDirectoryIfImageIdPresent(outputDirectoryWithPopulatedResultsFile, testString, ImageIdentifierType.IMAGE_ID)); assertEquals(testString, dockerExtractor.getImageIdentifierFromOutputDirectoryIfImageIdPresent(outputDirectoryWithPopulatedResultsFile, testString, ImageIdentifierType.IMAGE_NAME)); assertEquals(testString, dockerExtractor.getImageIdentifierFromOutputDirectoryIfImageIdPresent(outputDirectoryWithNonPopulatedResultsFile, testString, ImageIdentifierType.IMAGE_ID)); }
Example #13
Source File: CommandLineTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldBeAbleToRunCommandsFromRelativeDirectories() throws IOException { File shellScript = temporaryFolder.newFile("hello-world.sh"); FileUtils.writeStringToFile(shellScript, "echo ${PWD}", UTF_8); assertThat(shellScript.setExecutable(true), is(true)); CommandLine line = CommandLine.createCommandLine("../hello-world.sh").withWorkingDir(subFolder).withEncoding("utf-8"); InMemoryStreamConsumer out = new InMemoryStreamConsumer(); line.execute(out, new EnvironmentVariableContext(), null).waitForExit(); assertThat(out.getAllOutput().trim(), endsWith("subFolder")); }
Example #14
Source File: TildeInPathResolverTest.java From synopsys-detect with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(WINDOWS) // Due to backslashes being flipped. public void testResolvingTilde() { final TildeInPathResolver resolver = new TildeInPathResolver("/Users/ekerwin"); final Path resolved = resolver.resolvePath("~/Documents/source/funtional/detect"); Assertions.assertNotNull(resolved, "Resolved path should not be null."); Assertions.assertEquals("/Users/ekerwin/Documents/source/funtional/detect", resolved.toString(), "Tilde's should be resolved on Unix operating systems."); }
Example #15
Source File: ArtifactsServiceTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldProvideArtifactRootForAJobOnLinux() throws Exception { assumeArtifactsRoot(fakeRoot); ArtifactsService artifactsService = new ArtifactsService(resolverService, stageService, artifactsDirHolder, zipUtil); artifactsService.initialize(); JobIdentifier oldId = new JobIdentifier("cruise", 1, "1.1", "dev", "2", "linux-firefox", null); when(resolverService.actualJobIdentifier(oldId)).thenReturn(new JobIdentifier("cruise", 2, "2.2", "functional", "3", "mac-safari")); String artifactRoot = artifactsService.findArtifactRoot(oldId); assertThat(artifactRoot).isEqualTo("pipelines/cruise/2/functional/3/mac-safari"); }
Example #16
Source File: CommandRepositoryDirectoryWalkerTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldUpdateServerHealthServiceIfTheCommandRepositoryDirectoryIsUnReadable() { sampleDir.setReadable(false); walker.getAllCommandSnippets(sampleDir.getPath()); verify(serverHealthService).update(serverHealthWarningMessageWhichContains("Failed to access command repository located in Go Server Directory at " + sampleDir.getPath() + ". The directory does not exist or Go does not have sufficient permissions to access it.")); }
Example #17
Source File: CommandRepositoryDirectoryWalkerTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldUpdateServerHealthServiceIfTheCommandRepositoryDirectoryIsNotExecutable() { sampleDir.setReadable(true); sampleDir.setExecutable(false); walker.getAllCommandSnippets(sampleDir.getPath()); verify(serverHealthService).update(serverHealthWarningMessageWhichContains("Failed to access command repository located in Go Server Directory at " + sampleDir.getPath() + ". The directory does not exist or Go does not have sufficient permissions to access it.")); }
Example #18
Source File: CommandRepositoryDirectoryWalkerTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldUpdateServerHealthServiceIfTheCommandRepositoryDirectoryDoesNotExist() { File nonExistentDirectory = new File("dirDoesNotExist"); walker.getAllCommandSnippets(nonExistentDirectory.getPath()); verify(serverHealthService).update(serverHealthWarningMessageWhichContains("Failed to access command repository located in Go Server Directory at " + nonExistentDirectory.getPath() + ". The directory does not exist or Go does not have sufficient permissions to access it.")); }
Example #19
Source File: CommandRepositoryDirectoryWalkerTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldUpdateServerHealthServiceIfTheCommandRepositoryDirectoryIsUnReadableAndRemoveItOnceItsReadable() { sampleDir.setReadable(false); walker.getAllCommandSnippets(sampleDir.getPath()); verify(serverHealthService).update(serverHealthWarningMessageWhichContains("Failed to access command repository located in Go Server Directory at " + sampleDir.getPath() + ". The directory does not exist or Go does not have sufficient permissions to access it.")); sampleDir.setReadable(true); walker.getAllCommandSnippets(sampleDir.getPath()); verify(serverHealthService, times(2)).update(serverHealthMessageWhichSaysItsOk()); verifyNoMoreInteractions(serverHealthService); }
Example #20
Source File: DockerExtractorTest.java From synopsys-detect with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(WINDOWS) public void testExtractTarReturningOriginalTar() throws ExecutableRunnerException { final String image = null; final String imageId = null; final String tar = fakeDockerTarFile.getAbsolutePath(); final ExecutableRunner executableRunner = Mockito.mock(ExecutableRunner.class); final Extraction extraction = extract(image, imageId, tar, null, null, executableRunner); // No returned .tar.gz: scan given docker tar instead assertTrue(extraction.getMetaData(DockerExtractor.DOCKER_IMAGE_NAME_META_DATA).get().endsWith("testDockerTarfile.tar")); assertTrue(extraction.getMetaData(DockerExtractor.DOCKER_TAR_META_DATA).get().getName().endsWith("testDockerTarfile.tar")); final ArgumentCaptor<Executable> executableArgumentCaptor = ArgumentCaptor.forClass(Executable.class); Mockito.verify(executableRunner).execute(executableArgumentCaptor.capture()); final Executable executableToVerify = executableArgumentCaptor.getValue(); final List<String> command = executableToVerify.getCommand(); assertTrue(command.get(0).endsWith("/fake/test/java")); assertEquals("-jar", command.get(1)); assertTrue(command.get(2).endsWith("/fake/test/dockerinspector.jar")); assertTrue(command.get(3).startsWith("--spring.config.location=")); assertTrue(command.get(3).endsWith("/application.properties")); assertTrue(command.get(4).startsWith("--docker.tar=")); assertTrue(command.get(4).endsWith("testDockerTarfile.tar")); }
Example #21
Source File: CommandRepositoryDirectoryWalkerTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldUpdateServerHealthServiceIfTheCommandRepositoryDirectoryIsActuallyAFile() throws IOException { walker.getAllCommandSnippets(xmlFile.getPath()); verify(serverHealthService).update(serverHealthWarningMessageWhichContains("Failed to access command repository located in Go Server Directory at " + xmlFile.getPath() + ". The directory does not exist or Go does not have sufficient permissions to access it.")); }
Example #22
Source File: NantTaskBuilderTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldUseAbsoluteNantPathIfAbsoluteNantPathIsSpecifiedOnLinux() { NantTask nantTask = new NantTask(); nantTask.setNantPath("/usr/bin"); CommandBuilder builder = (CommandBuilder) nantTaskBuilder.createBuilder(builderFactory, nantTask, pipeline, resolver); assertThat(new File(builder.getCommand())).isEqualTo(new File("/usr/bin/nant")); }
Example #23
Source File: NantTaskBuilderTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void nantTaskShouldNormalizeWorkingDirectory() { NantTask nantTask = new NantTask(); nantTask.setWorkingDirectory("folder1\\folder2"); CommandBuilder builder = (CommandBuilder) nantTaskBuilder.createBuilder(builderFactory, nantTask, ExecTaskBuilderTest.pipelineStub("label", "/var/cruise-agent/pipelines/cruise"), resolver); assertThat(builder.getWorkingDir()).isEqualTo(new File("/var/cruise-agent/pipelines/cruise/folder1/folder2")); }
Example #24
Source File: RakeTaskBuilderTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void rakeTaskShouldNormalizeWorkingDirectory() { RakeTask task = new RakeTask(); task.setWorkingDirectory("folder1\\folder2"); CommandBuilder commandBuilder = (CommandBuilder) rakeTaskBuilder.createBuilder(builderFactory, task, ExecTaskBuilderTest.pipelineStub("label", "/var/cruise-agent/pipelines/cruise"), resolver); assertThat(commandBuilder.getWorkingDir().getPath()).isEqualTo("/var/cruise-agent/pipelines/cruise/folder1/folder2"); }
Example #25
Source File: ExecTaskBuilderTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldNormalizeWorkingDirectory() { ExecTask execTask = new ExecTask("ant", "", "folder\\child"); CommandBuilder builder = (CommandBuilder) execTaskBuilder.createBuilder(builderFactory, execTask, pipelineStub("label", "."), resolver); assertThat(builder.getWorkingDir().getPath()).isEqualTo("./folder/child"); }
Example #26
Source File: AntTaskBuilderTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void antTaskShouldNormalizeWorkingDirectory() { AntTask task = new AntTask(); task.setWorkingDirectory("folder1\\folder2"); CommandBuilder commandBuilder = (CommandBuilder) antTaskBuilder.createBuilder(builderFactory, task, ExecTaskBuilderTest.pipelineStub("label", "/var/cruise-agent/pipelines/cruise"), resolver); assertThat(commandBuilder.getWorkingDir().getPath()).isEqualTo("/var/cruise-agent/pipelines/cruise/folder1/folder2"); }
Example #27
Source File: BuildWorkTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldReportErrorWhenComandIsNotExistOnLinux() throws Exception { buildWork = (BuildWork) getWork(CMD_NOT_EXIST, PIPELINE_NAME); buildWork.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, buildRepository, artifactManipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"), packageRepositoryExtension, scmExtension, taskExtension, null, pluginRequestProcessorRegistry)); assertConsoleOut(artifactManipulator.consoleOut()).printedAppsMissingInfoOnUnix(SOMETHING_NOT_EXIST); assertThat(buildRepository.results).contains(Failed); }
Example #28
Source File: HgMaterialTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldNotRefreshWorkingFolderWhenFileProtocolIsUsedOnLinux() throws Exception { final UrlArgument repoUrl = hgTestRepo.url(); new HgCommand(null, workingFolder, "default", repoUrl.originalArgument(), null).clone(inMemoryConsumer(), repoUrl); File testFile = createNewFileInWorkingFolder(); hgMaterial = MaterialsMother.hgMaterial("file://" + hgTestRepo.projectRepositoryUrl()); updateMaterial(hgMaterial, new StringRevision("0")); String workingUrl = new HgCommand(null, workingFolder, "default", repoUrl.originalArgument(), null).workingRepositoryUrl().outputAsString(); assertThat(workingUrl).isEqualTo(hgTestRepo.projectRepositoryUrl()); assertThat(testFile.exists()).isTrue(); }
Example #29
Source File: FileUtilTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldCreateFileURIForFile() { assertThat(FileUtil.toFileURI(new File("/var/lib/foo/"))).isEqualTo("file:///var/lib/foo"); assertThat(FileUtil.toFileURI(new File("/var/a dir with spaces/foo"))).isEqualTo("file:///var/a%20dir%20with%20spaces/foo"); assertThat(FileUtil.toFileURI(new File("/var/司徒空在此/foo"))).isEqualTo("file:///var/%E5%8F%B8%E5%BE%92%E7%A9%BA%E5%9C%A8%E6%AD%A4/foo"); }
Example #30
Source File: ScriptRunnerTest.java From gocd with Apache License 2.0 | 5 votes |
@Test @DisabledOnOs(OS.WINDOWS) void shouldBeAbleToSpecifyEncoding() throws CheckedCommandLineException { String chrisWasHere = "司徒空在此"; CommandLine command = CommandLine.createCommandLine("echo").withArg(chrisWasHere).withEncoding("UTF-8"); InMemoryConsumer output = new InMemoryConsumer(); ExecScript script = new ExecScript("FOO"); command.runScript(script, output, new EnvironmentVariableContext(), null); assertThat(output.toString()).contains(chrisWasHere); }