Exemplo n.º 1
0
  @Test
  public void shouldRefreshWorkingDirectoryIfUsernameInUrlChanges() throws Exception {
    HgMaterial material = new HgMaterial("http://*****:*****@localhost:9999", null);
    final List<Modification> modifications =
        material.latestModification(workingFolder, new TestSubprocessExecutionContext());
    final File unversionedFile = new File(workingFolder, "unversioned.txt");
    FileUtil.writeContentToFile("something", unversionedFile);
    assertTrue(unversionedFile.exists());

    material = new HgMaterial("http://*****:*****@localhost:9999", null);
    material.modificationsSince(
        workingFolder,
        new StringRevision(modifications.get(0).getRevision()),
        new TestSubprocessExecutionContext());
    assertFalse(unversionedFile.exists());
  }
Exemplo n.º 2
0
  @Test
  @RunIf(
      value = EnhancedOSChecker.class,
      arguments = {DO_NOT_RUN_ON, OSChecker.WINDOWS})
  public void shouldBeAbleToRunCommandsFromRelativeDirectories() throws IOException {
    File shellScript = new File(tempFolder, "hello-world.sh");
    FileUtil.writeContentToFile("echo ${PWD}", shellScript);
    assertThat(shellScript.setExecutable(true), is(true));

    CommandLine line = CommandLine.createCommandLine("../hello-world.sh").withWorkingDir(subFolder);

    InMemoryStreamConsumer out = new InMemoryStreamConsumer();
    line.execute(out, new EnvironmentVariableContext(), null).waitForExit();

    assertThat(out.getAllOutput().trim(), endsWith("subFolder"));
  }
Exemplo n.º 3
0
  private File createScript(String name, String content) throws IOException {
    File shellScript = new File(subFolder, name);

    FileUtil.writeContentToFile(content, shellScript);
    return shellScript;
  }