@Test public void doNothingIfItWillNotShortenThePath() throws Exception { DumbSlave s = j.createOnlineSlave(); // Would be turned into 'short_project...XXXXXXXX' which is in fact longer than the original FreeStyleProject p = j.createFreeStyleProject("short_project_name"); p.setAssignedNode(s); // Not enough for anything setMaxPathLength(s, 1); FreeStyleBuild b = p.scheduleBuild2(0).get(); assertThat( b.getWorkspace().getRemote(), equalTo(s.getRootPath() + DS + "workspace" + DS + p.getFullName().replace("/", DS))); }
@Test public void doNothingIfThereIsEnoughRoom() throws Exception { DumbSlave s = j.createOnlineSlave(); MockFolder f = j.createFolder("this_is_my_folder_alright"); FreeStyleProject p = f.createProject(FreeStyleProject.class, "and_a_project_in_it"); p.setAssignedNode(s); // Enough for the test - even on windows setMaxPathLength(s, 4096); FreeStyleBuild b = p.scheduleBuild2(0).get(); assertThat( b.getWorkspace().getRemote(), equalTo(s.getRootPath() + DS + "workspace" + DS + p.getFullName().replace("/", DS))); }
@Test public void unwrapFolders() throws Exception { DumbSlave s = j.createOnlineSlave(); MockFolder f = j.createFolder("this_is_my_folder_alright"); FreeStyleProject p = f.createProject(FreeStyleProject.class, "and_a_project_in_it"); p.setAssignedNode(s); // Not enough for anything setMaxPathLength(s, 1); FreeStyleBuild b = p.scheduleBuild2(0).get(); String buildWs = b.getWorkspace().getRemote(); String wsDir = s.getRootPath() + DS + "workspace" + DS; assertThat(buildWs, startsWith(wsDir + "and_a_pro")); assertThat(buildWs, buildWs.length(), equalTo(wsDir.length() + 24)); }