forked from checkstyle/regression-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue checkstyle#21: Report Component
- Loading branch information
Showing
4 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/main/java/com/github/checkstyle/regression/report/ReportGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2017 the original author or authors. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
package com.github.checkstyle.regression.report; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Generates the regression diff report. | ||
* @author LuoLiangchen | ||
*/ | ||
public final class ReportGenerator { | ||
/** Prevents instantiation. */ | ||
private ReportGenerator() { | ||
} | ||
|
||
/** | ||
* Generates the regression diff report. | ||
* @param testerPath the path to the directory which holds 'diff.groovy' | ||
* @param repoPath the path to the checkstyle repository | ||
* @param branch the name of the PR branch | ||
* @param configFile the generated config file | ||
* @return the directory of the generated reports | ||
* @throws InterruptedException failure of running CLI | ||
* @throws IOException failure of running CLI | ||
*/ | ||
public static File generate( | ||
String testerPath, String repoPath, String branch, File configFile) | ||
throws InterruptedException, IOException { | ||
if (!configFile.exists()) { | ||
throw new IllegalArgumentException("config file does not exist: " + configFile); | ||
} | ||
final Process process = new ProcessBuilder() | ||
.directory(new File(testerPath)) | ||
.command( | ||
"groovy", "diff.groovy", | ||
"-r", repoPath, | ||
"-b", "master", | ||
"-p", branch, | ||
"-c", configFile.getAbsolutePath(), | ||
"-l", "projects-to-test-on.properties" | ||
) | ||
.inheritIO() | ||
.start(); | ||
final int code = process.waitFor(); | ||
if (code != 0) { | ||
throw new IllegalStateException("an error occurred when running diff.groovy"); | ||
} | ||
return new File(testerPath, "reports/diff"); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/github/checkstyle/regression/report/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2017 the original author or authors. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
/** | ||
* Contains the regression test runner and the report deployer. | ||
* @author LuoLiangchen | ||
*/ | ||
package com.github.checkstyle.regression.report; |
31 changes: 31 additions & 0 deletions
31
src/test/java/com/github/checkstyle/regression/report/ReportGeneratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// checkstyle: Checks Java source code for adherence to a set of rules. | ||
// Copyright (C) 2001-2017 the original author or authors. | ||
// | ||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
// | ||
// This library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
package com.github.checkstyle.regression.report; | ||
|
||
import static com.github.checkstyle.regression.internal.TestUtils.assertUtilsClassHasPrivateConstructor; | ||
|
||
import org.junit.Test; | ||
|
||
public class ReportGeneratorTest { | ||
@Test | ||
public void testIsProperUtilsClass() throws Exception { | ||
assertUtilsClassHasPrivateConstructor(ReportGenerator.class); | ||
} | ||
} |