Package com.google.devtools.moe.client

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


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

    RepositoryConfig mockConfig = control.createMock(RepositoryConfig.class);
    expect(mockConfig.getUrl()).andReturn("http://foo/svn/trunk/").anyTimes();
    expect(mockConfig.getProjectSpace()).andReturn("internal").anyTimes();
    expect(mockConfig.getIgnoreFileRes()).andReturn(ImmutableList.<String>of()).anyTimes();

    Revision result = new Revision("45", "");
    expect(fileSystem.getTemporaryDirectory("svn_writer_45_")).
        andReturn(new File("/dummy/path/45"));
    expect(revisionHistory.findHighestRevision("45")).andReturn(result);
    expect(cmd.runCommand(
        "svn",
        ImmutableList.of("--no-auth-cache", "co", "-r", "45", "http://foo/svn/trunk/",
                         "/dummy/path/45"), "")).andReturn("");

    control.replay();
View Full Code Here


public class ScrubbingEditorTest extends TestCase {
  public void testScrubbing() 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 scrubberTemp = new File("/scrubber_extraction_foo");
    File scrubberBin = new File(scrubberTemp, "scrubber.par");
    File scrubberRun = new File("/scrubber_run_foo");
    File outputTar = new File(scrubberRun, "scrubbed.tar");
    File codebaseFile = new File("/codebase");
    File expandedDir = new File("/expanded_tar_foo");
   
    Codebase codebase = new Codebase(codebaseFile,
                                     "internal",
                                     null /* CodebaseExpression is not needed here. */);

    Gson gson = ProjectConfig.makeGson();
    JsonObject scrubberConfig = gson.fromJson("{\"foo\":\"bar\"}", JsonObject.class);


    expect(fileSystem.getResourceAsFile("/devtools/moe/scrubber/scrubber.par")).andReturn(
        scrubberBin);
    fileSystem.setExecutable(scrubberBin);

    expect(fileSystem.getTemporaryDirectory("scrubber_run_")).andReturn(scrubberRun);
    expect(cmd.runCommand(
        // Matches the ./scrubber.par used in ScrubbingEditor.java
        "./scrubber.par",
        ImmutableList.of("--temp_dir", "/scrubber_run_foo",
                         "--output_tar", "/scrubber_run_foo/scrubbed.tar",
                         "--config_data", "{\"foo\":\"bar\"}", "/codebase"),
        "/scrubber_extraction_foo")).andReturn("");

    expect(fileSystem.getTemporaryDirectory("expanded_tar_")).andReturn(expandedDir);
    fileSystem.makeDirs(expandedDir);
    expect(cmd.runCommand(
        "tar",
        ImmutableList.of("-xf", "/scrubber_run_foo/scrubbed.tar"),
        "/expanded_tar_foo")).andReturn("");
    control.replay();

View Full Code Here

    AppContextForTesting.initForTest();
    Revision result = new Revision("45", "");
    IMocksControl control = EasyMock.createControl();
    SvnRevisionHistory revisionHistory = control.createMock(SvnRevisionHistory.class);
    FileSystem fileSystem = control.createMock(FileSystem.class);
    CommandRunner cmd = control.createMock(CommandRunner.class);
    AppContext.RUN.cmd = cmd;
    AppContext.RUN.fileSystem = fileSystem;
   
    RepositoryConfig mockConfig = control.createMock(RepositoryConfig.class);
    expect(mockConfig.getUrl()).andReturn("http://foo/svn/trunk/").anyTimes();
    expect(mockConfig.getProjectSpace()).andReturn("internal").anyTimes();
    expect(mockConfig.getIgnoreFileRes()).andReturn(ImmutableList.<String>of()).anyTimes();

    expect(revisionHistory.findHighestRevision("46")).andReturn(result);
    expect(fileSystem.getTemporaryDirectory("svn_export_testing_45_")).
        andReturn(new File("/dummy/path/45"));
    expect(cmd.runCommand(
        "svn",
        ImmutableList.of("--no-auth-cache", "export", "http://foo/svn/trunk/", "-r", "45",
                         "/dummy/path/45"), "")).andReturn("");
    // Short-circuit Utils.filterFiles for ignore_files_re.
    expect(AppContext.RUN.fileSystem.findFiles(new File("/dummy/path/45")))
View Full Code Here

  public void testShellStuff() 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 shellRun = new File("/shell_run_foo");
    File codebaseFile = new File("/codebase");

    Codebase codebase = new Codebase(codebaseFile,
                                     "internal",
                                     null /* CodebaseExpression is not needed here. */);


    expect(fileSystem.getTemporaryDirectory("shell_run_")).andReturn(shellRun);
    fileSystem.makeDirsForFile(shellRun);
    expect(fileSystem.isFile(codebaseFile)).andReturn(false);
    expect(fileSystem.listFiles(codebaseFile)).andReturn(new File[] {});

    Vector<String> argsList = new Vector<String>();
    argsList.add("-c");
    argsList.add("touch test.txt");

    expect(cmd.runCommand("bash", argsList, "/shell_run_foo")).andReturn("");

    control.replay();

    new ShellEditor("shell_editor", "touch test.txt")
        .edit(codebase,
View Full Code Here

  }

  public void testGetHighestRevision() {
    AppContextForTesting.initForTest();
    IMocksControl control = EasyMock.createControl();
    CommandRunner cmd = control.createMock(CommandRunner.class);
    AppContext.RUN.cmd = cmd;

    try {
      expect(cmd.runCommand(
          "svn",
          ImmutableList.of("--no-auth-cache", "log", "--xml", "-l", "1", "-r", "HEAD:1",
                           "http://foo/svn/trunk/"),
          "")).andReturn("<log><logentry revision=\"3\" /></log>");
      expect(cmd.runCommand(
          "svn",
          ImmutableList.of("--no-auth-cache", "log", "--xml", "-l", "1", "-r", "2:1",
                           "http://foo/svn/trunk/"),
          "")).andReturn("<log><logentry revision=\"2\" /></log>");
    } catch (CommandException e) {
View Full Code Here

  }

  public void testGetMetadata() {
    AppContextForTesting.initForTest();
    IMocksControl control = EasyMock.createControl();
    CommandRunner cmd = control.createMock(CommandRunner.class);
    AppContext.RUN.cmd = cmd;

    try {
      expect(cmd.runCommand(
          "svn",
          ImmutableList.of("--no-auth-cache", "log", "--xml", "-l", "2", "-r", "3:1",
                           "http://foo/svn/trunk/"),
          "")).andReturn("<log><logentry revision=\"3\">" +
                             "<author>uid@google.com</author>" +
View Full Code Here

  }

  public void testFindNewRevisions() {
    AppContextForTesting.initForTest();
    IMocksControl control = EasyMock.createControl();
    CommandRunner cmd = control.createMock(CommandRunner.class);
    AppContext.RUN.cmd = cmd;
    DummyDb db = new DummyDb(false);

    // Mock call for findHighestRevision
    try {
      expect(cmd.runCommand(
          "svn",
          ImmutableList.of("--no-auth-cache", "log", "--xml", "-l", "1", "-r", "HEAD:1",
                           "http://foo/svn/trunk/"),
          "")).andReturn("<log><logentry revision=\"3\">" +
                             "<author>uid@google.com</author>" +
                             "<date>yyyy-mm-dd</date>" +
                             "<msg>description</msg></logentry></log>");
    } catch (CommandException e) {
      throw new RuntimeException(e);
    }

    // revision 3 metadata
    try {
      expect(cmd.runCommand(
          "svn",
          ImmutableList.of("--no-auth-cache", "log", "--xml", "-l", "2", "-r", "3:1",
                           "http://foo/svn/trunk/"),
          "")).andReturn("<log><logentry revision=\"3\">" +
                             "<author>uid@google.com</author>" +
                             "<date>yyyy-mm-dd</date>" +
                             "<msg>message</msg></logentry>" +
                             "<logentry revision =\"2\">" +
                             "<author>user@google.com</author>" +
                             "<date>zzzz-nn-ee</date>" +
                             "<msg>description</msg></logentry></log>");
    } catch (CommandException e) {
      throw new RuntimeException(e);
    }


    // revision 2 metadata
    try {
      expect(cmd.runCommand(
          "svn",
          ImmutableList.of("--no-auth-cache", "log", "--xml", "-l", "2", "-r", "2:1",
                           "http://foo/svn/trunk/"),
          "")).andReturn("<log><logentry revision=\"2\">" +
                             "<author>uid@google.com</author>" +
View Full Code Here

   * @throws Exception
   */
  public void testFindLastEquivalence() throws Exception {
    AppContextForTesting.initForTest();
    IMocksControl control = EasyMock.createControl();
    CommandRunner cmd = control.createMock(CommandRunner.class);
    AppContext.RUN.cmd = cmd;

    expect(cmd.runCommand("svn", ImmutableList.of("--no-auth-cache", "log", "--xml", "-l", "2",
        "-r", "4:1", "http://foo/svn/trunk/"), ""))
        .andReturn("<log><logentry revision=\"4\">" +
                   "<author>uid@google.com</author>" +
                   "<date>yyyy-mm-dd</date>" +
                   "<msg>message</msg></logentry>" +
                   "<logentry revision =\"3\">" +
                   "<author>user@google.com</author>" +
                   "<date>zzzz-nn-ee</date>" +
                   "<msg>description</msg></logentry></log>");

    expect(cmd.runCommand("svn", ImmutableList.of("--no-auth-cache", "log", "--xml", "-l", "2",
        "-r", "3:1", "http://foo/svn/trunk/"), ""))
        .andReturn("<log><logentry revision=\"3\">" +
                   "<author>uid@google.com</author>" +
                   "<date>yyyy-mm-dd</date>" +
                   "<msg>message</msg></logentry>" +
View Full Code Here

   * @throws Exception
   */
  public void testFindLastEquivalenceNull() throws Exception {
    AppContextForTesting.initForTest();
    IMocksControl control = EasyMock.createControl();
    CommandRunner cmd = control.createMock(CommandRunner.class);
    AppContext.RUN.cmd = cmd;

    expect(cmd.runCommand("svn", ImmutableList.of("--no-auth-cache", "log", "--xml", "-l", "2",
        "-r", "2:1", "http://foo/svn/trunk/"), ""))
        .andReturn("<log><logentry revision=\"2\">" +
                   "<author>uid@google.com</author>" +
                   "<date>yyyy-mm-dd</date>" +
                   "<msg>message</msg></logentry>" +
                   "<logentry revision =\"1\">" +
                   "<author>user@google.com</author>" +
                   "<date>zzzz-nn-ee</date>" +
                   "<msg>description</msg></logentry></log>");

    expect(cmd.runCommand("svn", ImmutableList.of("--no-auth-cache", "log", "--xml", "-l", "2",
        "-r", "1:1", "http://foo/svn/trunk/"), ""))
        .andReturn("<log><logentry revision=\"1\">" +
                   "<author>uid@google.com</author>" +
                   "<date>yyyy-mm-dd</date>" +
                   "<msg>message</msg></logentry></log>");
View Full Code Here

  public void testCopyDirectoryAndRename() 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 srcContents = new File("/src/olddummy/file1");
    File srcContents2 = new File("/src/olddummy/file2");
View Full Code Here

TOP

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

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.