private MatrixProject createMatrixArtifactProject() throws IOException {
   MatrixProject p = createMatrixProject();
   p.setAxes(new AxisList(new Axis("FOO", "one", "two")));
   p.getBuildersList().add(new ArtifactBuilder());
   p.getPublishersList().add(new ArtifactArchiver("**", "", false));
   return p;
 }
 /** Test copying artifacts from all configurations of a matrix job */
 public void testMatrixAll() throws Exception {
   MatrixProject mp = createMatrixProject();
   mp.setAxes(new AxisList(new Axis("ARCH", "sparc", "x86")));
   mp.getBuildersList().add(new ArchMatrixBuilder());
   mp.getPublishersList().add(new ArtifactArchiver("target/*", "", false));
   assertBuildStatusSuccess(mp.scheduleBuild2(0, new UserCause()).get());
   FreeStyleProject p = createProject(mp.getName(), "", "", true, false, false);
   FreeStyleBuild b = p.scheduleBuild2(0, new UserCause()).get();
   assertBuildStatusSuccess(b);
   assertFile(true, "ARCH=sparc/target/readme.txt", b);
   assertFile(true, "ARCH=sparc/target/sparc.out", b);
   assertFile(true, "ARCH=x86/target/readme.txt", b);
   assertFile(true, "ARCH=x86/target/x86.out", b);
 }
Пример #3
0
 public void testNoInterpreter() throws Exception {
   ToxBuilder builder = new ToxBuilder("tox.ini", false, null);
   MatrixProject project = createMatrixProject();
   AxisList axes = new AxisList(new ToxAxis(new String[] {"py27"}));
   project.setAxes(axes);
   project.getBuildersList().add(builder);
   MatrixBuild build = project.scheduleBuild2(0).get();
   List<MatrixRun> runs = build.getRuns();
   assertEquals(1, runs.size());
   MatrixRun run = runs.get(0);
   String log = FileUtils.readFileToString(run.getLogFile());
   assertTrue(
       "should not have found an interpreter:\n" + log,
       log.contains(Messages.BuilderUtil_NoInterpreterFound()));
 }
Пример #4
0
 public void testNoAxis() throws Exception {
   ToxBuilder builder = new ToxBuilder("tox.ini", false, null);
   MatrixProject project = createMatrixProject();
   AxisList axes = new AxisList(new TextAxis("TOTO", "TUTU"));
   project.setAxes(axes);
   project.getBuildersList().add(builder);
   MatrixBuild build = project.scheduleBuild2(0).get();
   List<MatrixRun> runs = build.getRuns();
   assertEquals(1, runs.size());
   MatrixRun run = runs.get(0);
   String log = FileUtils.readFileToString(run.getLogFile());
   assertTrue(
       "should not have found a tox axis:\n" + log,
       log.contains(Messages.ToxBuilder_ToxAxis_Required()));
 }
Пример #5
0
 public void testToxAxisSuccessful() throws Exception {
   configureCPython2();
   ToxBuilder builder = new ToxBuilder("tox.ini", false, null);
   MatrixProject project = createMatrixProject();
   AxisList axes = new AxisList(new ToxAxis(new String[] {"py27"}));
   project.setScm(new ToxSCM("tox.ini", "[testenv]\ncommand = echo"));
   project.setAxes(axes);
   project.getBuildersList().add(builder);
   MatrixBuild build = project.scheduleBuild2(0).get();
   List<MatrixRun> runs = build.getRuns();
   assertEquals(1, runs.size());
   MatrixRun run = runs.get(0);
   String log = FileUtils.readFileToString(run.getLogFile());
   assertTrue("tox should have been successful:\n" + log, log.contains("congratulations :)"));
   assertTrue("build should have been successful:\n" + log, log.contains("SUCCESS"));
 }
Пример #6
0
 public void testToxenvPatternBlank() throws Exception {
   configureCPython2();
   ToxBuilder builder = new ToxBuilder("tox.ini", false, "$FOOBAR");
   MatrixProject project = createMatrixProject();
   AxisList axes = new AxisList(new TextAxis("FOOBAR2", "badluck"));
   project.setScm(new ToxSCM("tox.ini", "[testenv]\ncommand = echo"));
   project.setAxes(axes);
   project.getBuildersList().add(builder);
   MatrixBuild build = project.scheduleBuild2(0).get();
   List<MatrixRun> runs = build.getRuns();
   assertEquals(1, runs.size());
   MatrixRun run = runs.get(0);
   String log = FileUtils.readFileToString(run.getLogFile());
   System.out.println(log);
   assertTrue(
       "should not be able to run with a blank TOXENV pattern:\n" + log,
       log.contains(Messages.ToxBuilder_ToxenvPattern_Invalid("$FOOBAR")));
 }
Пример #7
0
 public void testToxAxisAndToxenvPattern() throws Exception {
   configureCPython2();
   ToxBuilder builder = new ToxBuilder("tox.ini", false, "$INTERPRETER$VERSION");
   MatrixProject project = createMatrixProject();
   AxisList axes =
       new AxisList(
           new ToxAxis(new String[] {"py27"}),
           new TextAxis("INTERPRETER", "py"),
           new TextAxis("VERSION", "27"));
   project.setScm(new ToxSCM("tox.ini", "[testenv]\ncommand = echo"));
   project.setAxes(axes);
   project.getBuildersList().add(builder);
   MatrixBuild build = project.scheduleBuild2(0).get();
   List<MatrixRun> runs = build.getRuns();
   assertEquals(1, runs.size());
   MatrixRun run = runs.get(0);
   String log = FileUtils.readFileToString(run.getLogFile());
   System.out.println(log);
   assertTrue(
       "should not be able to run with both Tox axis and TOXENV pattern:\n" + log,
       log.contains(Messages.ToxBuilder_ToxAxis_And_ToxenvPattern()));
 }
 /** Test artifact copy between matrix jobs, for artifact from matching axis */
 public void testMatrixToMatrix() throws Exception {
   MatrixProject other = createMatrixArtifactProject(), p = createMatrixProject();
   p.setAxes(new AxisList(new Axis("FOO", "one", "two"))); // should match other job
   p.getBuildersList()
       .add(
           new CopyArtifact(
               other.getName() + "/FOO=$FOO",
               new StatusBuildSelector(true),
               "",
               "",
               false,
               false));
   assertBuildStatusSuccess(other.scheduleBuild2(0, new UserCause()).get());
   MatrixBuild b = p.scheduleBuild2(0, new UserCause()).get();
   assertBuildStatusSuccess(b);
   MatrixRun r = b.getRun(new Combination(Collections.singletonMap("FOO", "one")));
   assertFile(true, "one.txt", r);
   assertFile(false, "two.txt", r);
   r = b.getRun(new Combination(Collections.singletonMap("FOO", "two")));
   assertFile(false, "one.txt", r);
   assertFile(true, "two.txt", r);
 }
  /** projectName in CopyArtifact build steps should be updated if a job is renamed */
  public void testJobRename() throws Exception {
    FreeStyleProject other = createFreeStyleProject(),
        p = createProject(other.getName(), "", "", true, false, false);
    assertEquals(
        "before", other.getName(), ((CopyArtifact) p.getBuilders().get(0)).getProjectName());
    String newName = other.getName() + "-new";
    other.renameTo(newName);
    assertEquals("after", newName, ((CopyArtifact) p.getBuilders().get(0)).getProjectName());

    // Test reference to a matrix configuration
    MatrixProject otherm = createMatrixProject(), mp = createMatrixProject();
    mp.getBuildersList()
        .add(
            new CopyArtifact(
                otherm.getName() + "/FOO=$FOO", new SavedBuildSelector(), "", "", false, false));
    assertEquals(
        "before",
        otherm.getName() + "/FOO=$FOO",
        ((CopyArtifact) mp.getBuilders().get(0)).getProjectName());
    otherm.renameTo(newName = otherm.getName() + "-new");
    assertEquals(
        "after", newName + "/FOO=$FOO", ((CopyArtifact) mp.getBuilders().get(0)).getProjectName());
  }