Package com.google.devtools.moe.client

Examples of com.google.devtools.moe.client.FileSystem


  }

  public void testExistence2() throws Exception {
    AppContextForTesting.initForTest();
    IMocksControl control = EasyMock.createControl();
    FileSystem fileSystem = control.createMock(FileSystem.class);
    CommandRunner cmd = control.createMock(CommandRunner.class);
    AppContext.RUN.cmd = cmd;
    AppContext.RUN.fileSystem = fileSystem;

    File file1 = new File("/1/foo");
    File file2 = new File("/2/foo");

    expect(fileSystem.exists(file1)).andReturn(false);
    expect(fileSystem.exists(file2)).andReturn(true);
    expect(fileSystem.isExecutable(file1)).andReturn(false);
    expect(fileSystem.isExecutable(file2)).andReturn(false);
    expect(cmd.runCommand("diff", ImmutableList.of("-N", "/1/foo", "/2/foo"), "")).andThrow(
        new CommandRunner.CommandException(
            "diff", ImmutableList.of("-N", "/1/foo", "/2/foo"), "foo", "", 1));

    control.replay();
View Full Code Here


  }

  public void testExecutability() throws Exception {
    AppContextForTesting.initForTest();
    IMocksControl control = EasyMock.createControl();
    FileSystem fileSystem = control.createMock(FileSystem.class);
    CommandRunner cmd = control.createMock(CommandRunner.class);
    AppContext.RUN.cmd = cmd;
    AppContext.RUN.fileSystem = fileSystem;

    File file1 = new File("/1/foo");
    File file2 = new File("/2/foo");

    expect(fileSystem.exists(file1)).andReturn(true);
    expect(fileSystem.exists(file2)).andReturn(true);
    expect(fileSystem.isExecutable(file1)).andReturn(true);
    expect(fileSystem.isExecutable(file2)).andReturn(false);
    expect(cmd.runCommand("diff",
                          ImmutableList.of("-N", "/1/foo", "/2/foo"), "")).andReturn("");

    control.replay();
    FileDifference d = FileDifference.CONCRETE_FILE_DIFFER.diffFiles("foo", file1, file2);
View Full Code Here

    }
  }

  public void testFileCodebaseCreator() throws Exception {
    IMocksControl control = EasyMock.createControl();
    FileSystem mockFs = control.createMock(FileSystem.class);
    AppContext.RUN.fileSystem = mockFs;
    expect(mockFs.exists(new File("/foo"))).andReturn(true);
    expect(mockFs.isDirectory(new File("/foo"))).andReturn(true);
    File copyLocation = new File("/tmp/copy");
    expect(mockFs.getTemporaryDirectory("file_codebase_copy_")).andReturn(copyLocation);
    // Short-circuit Utils.copyDirectory().
    mockFs.makeDirsForFile(copyLocation);
    expect(mockFs.isFile(new File("/foo"))).andReturn(true);
    mockFs.copyFile(new File("/foo"), copyLocation);
    mockFs.setLifetime(EasyMock.eq(copyLocation), EasyMock.<Lifetime>anyObject());
    mockFs.cleanUpTempDirs();

    RepositoryExpression repoEx = new RepositoryExpression("file").withOption("path", "/foo");

    control.replay();
    Codebase c = repoEx.createCodebase(ProjectContext.builder().build());
View Full Code Here

  /**
   * Copy the destFile into the merged codebase. This is where the output of merge will be
   * written to.
   */
  private File copyToMergedCodebase(String filename, File destFile) {
    FileSystem fs = AppContext.RUN.fileSystem;
    File mergedFile = mergedCodebase.getFile(filename);
    try {
      fs.makeDirsForFile(mergedFile);
      fs.copyFile(destFile, mergedFile);
      return mergedFile;
    } catch (IOException e) {
      throw new MoeProblem(e.getMessage());
    }
  }
View Full Code Here

   * and this method will return leaving the merged codebase unchanged.
   *
   * @param filename the name of the file to merge
   */
  public void generateMergedFile(String filename) {
    FileSystem fs = AppContext.RUN.fileSystem;

    File origFile = originalCodebase.getFile(filename);
    boolean origExists = fs.exists(origFile);

    File destFile = destinationCodebase.getFile(filename);
    boolean destExists = fs.exists(destFile);

    File modFile = modifiedCodebase.getFile(filename);
    boolean modExists = fs.exists(modFile);

    if (!destExists && !modExists) {
      // This should never be thrown since generateMergedFile(...) is only called on filesToMerge
      // from merge() which is the union of the files in the destination and modified codebases.
      throw new MoeProblem(
View Full Code Here

TOP

Related Classes of com.google.devtools.moe.client.FileSystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.