Beispiel #1
0
  @Test
  public void merge_a_branch_without_a_dep() throws Exception {
    setup();

    // do a merges.
    WithCwd wd = new WithCwd(project.getRepo().getWorkTree());
    {
      // switch to the branch with the lib
      git.args("checkout", "blue").start().get();

      // merge the master branch, which doesn't have the lib yet
      git.args("merge", "--no-ff", "master").start().get();

      // that should have just committed cleanly, that's it
    }
    wd.close();

    // now verify.
    File depWorkTreePath =
        new File(project.getRepo().getWorkTree() + "/lib/beta").getCanonicalFile();
    File depGitDataPath =
        new File(project.getRepo().getDirectory() + "/modules/lib/beta").getCanonicalFile();

    // i do hope there's a filesystem there now
    assertTrue("dependency module path exists on fs", depWorkTreePath.exists());
    assertTrue("dependency module path is dir", depWorkTreePath.isDirectory());

    // check that anyone else can read this state with a straight face; status should be clean
    new Josh("git")
        .args("status")
        .cwd(project.getRepo().getWorkTree()) /*.opts(Opts.NullIO)*/
        .start()
        .get();
    new Josh("git").args("status").cwd(depWorkTreePath) /*.opts(Opts.NullIO)*/.start().get();
  }
Beispiel #2
0
  @Test
  public void update_while_merging_a_branch_without_a_dep() throws Exception {
    setup();

    // do a merges.
    WithCwd wd = new WithCwd(project.getRepo().getWorkTree());
    {
      // switch to the branch with the lib
      git.args("checkout", "blue").start().get();

      // add a conflicting file so we get halted mid merge (inb4: no, '--no-commit' isn't quite the
      // same)
      IOForge.saveFile("qwer", new File("somefile").getCanonicalFile());
      git.args("add", "--", "somefile").start().get();
      git.args("commit", "-m", "bluecommit").start().get();

      // merge the master branch, which doesn't have the lib yet.  should conflict (exit code is
      // nonzero)
      git.args("merge", "--no-ff", "master").okExit(1).start().get();

      // we're stuck in a merge conflict.  try to mdm-update during it
      assertJoy(Mdm.run("update", "--strict"));

      // finish the merge.
      git.args("add", "somefile").start().get();
      git.args("commit", "--no-edit").start().get();
    }
    wd.close();

    // now verify.
    File depWorkTreePath =
        new File(project.getRepo().getWorkTree() + "/lib/beta").getCanonicalFile();
    File depGitDataPath =
        new File(project.getRepo().getDirectory() + "/modules/lib/beta").getCanonicalFile();

    // i do hope there's a filesystem there now
    assertTrue("dependency module path exists on fs", depWorkTreePath.exists());
    assertTrue("dependency module path is dir", depWorkTreePath.isDirectory());

    // check that anyone else can read this state with a straight face; status should be clean
    new Josh("git")
        .args("status")
        .cwd(project.getRepo().getWorkTree()) /*.opts(Opts.NullIO)*/
        .start()
        .get();
    new Josh("git").args("status").cwd(depWorkTreePath) /*.opts(Opts.NullIO)*/.start().get();
  }
Beispiel #3
0
  public static void main(String[] arg) {
    Vector<Boolean> containerTypes = new Vector<Boolean>();
    Vector<String> environmentTypes = new Vector<String>();
    Vector<String> testNames = new Vector<String>();
    Vector<Class> argTests = new Vector<Class>();
    Class[] tests = {};

    for (int i = 0; i < arg.length; i++) {
      if (arg[i].startsWith("-")) {
        switch (arg[i].charAt(1)) {
          case 'c':
            String cType = arg[++i];
            if (cType.equalsIgnoreCase(NODE)) containerTypes.add(true);
            else if (cType.equalsIgnoreCase(WHOLE)) containerTypes.add(false);
            else if (cType.equalsIgnoreCase(ALL)) {
              containerTypes.add(true);
              containerTypes.add(false);
            } else usage();
            break;
          case 'e':
            String eType = arg[++i];
            if (eType.equalsIgnoreCase(NONE)
                || eType.equalsIgnoreCase(TXN)
                || eType.equalsIgnoreCase(CDS)) environmentTypes.add(eType);
            else if (eType.equalsIgnoreCase(ALL)) {
              environmentTypes.add(NONE);
              environmentTypes.add(TXN);
              environmentTypes.add(CDS);
            } else usage();
            break;
          default:
            usage();
        }
      } else testNames.add(arg[i]);
    }
    if (containerTypes.size() == 0) {
      containerTypes.add(true);
      containerTypes.add(false);
    }
    if (environmentTypes.size() == 0) {
      environmentTypes.add(NONE);
      environmentTypes.add(TXN);
      environmentTypes.add(CDS);
    }

    // Get the tests to run
    if (testNames.size() != 0) {
      for (int i = 0; i < testNames.size(); i++) {
        Class testClass = null;
        try {
          testClass = Class.forName("dbxmltest." + testNames.get(i));
        } catch (ClassNotFoundException e) {
          System.out.println("Skipping test " + testClass + ". Test not found.");
        }
        if (testClass != null) argTests.add(testClass);
      }
      if (argTests.size() != 0) tests = argTests.toArray(tests);
      else tests = allTests;
    } else tests = allTests;

    // Run the tests
    int failureCount = 0;
    boolean success = true;
    File errorFile = new File(getEnvironmentPath() + "/errorLog.txt");
    try {
      if (errorFile.exists()) errorFile.delete();
      errorFile.createNewFile();
      System.setErr(new PrintStream(new FileOutputStream(errorFile)));
    } catch (IOException e) {
    }
    for (int j = 0; j < environmentTypes.size(); j++) {
      System.out.println("Testing env type " + environmentTypes.get(j));
      for (int i = 0; i < containerTypes.size(); i++) {
        System.out.println("\tContainer type " + (containerTypes.get(i) ? "node" : "whole"));
        NODE_CONTAINER = containerTypes.get(i);
        ENV_TYPE = environmentTypes.get(j);
        Result res = org.junit.runner.JUnitCore.runClasses(tests);
        if (!res.wasSuccessful()) {
          System.err.println(
              "Number of failures for environment type "
                  + ENV_TYPE
                  + " and is node container "
                  + NODE_CONTAINER
                  + " are "
                  + res.getFailureCount());
          List<Failure> testFailures = res.getFailures();
          ListIterator<Failure> iter = testFailures.listIterator();
          while (iter.hasNext()) {
            Failure fail = iter.next();
            System.err.println(fail.getDescription());
            Throwable e = fail.getException();
            if (e != null) e.printStackTrace();
            else System.err.println(fail.getTrace());
          }
          failureCount += res.getFailureCount();
          success = res.wasSuccessful();
        }
      }
    }
    if (success) System.out.println("All tests successful.");
    else System.out.println(failureCount + " tests failed.");
    System.out.println("Failures printed to " + errorFile.getName());
  }