/hg/gfx-test: Code refactoring and added missing JavaDoc in Exte...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Mon Aug 1 02:13:11 PDT 2011
changeset ffd2c01dbe1d in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=ffd2c01dbe1d
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Aug 01 11:14:46 2011 +0200
Code refactoring and added missing JavaDoc in ExternalCommands.java.
diffstat:
ChangeLog | 4 +
src/org/gfxtest/harness/ExternalCommands.java | 149 ++++++++++++++++++++-----
2 files changed, 124 insertions(+), 29 deletions(-)
diffs (237 lines):
diff -r f1aa5b49eb61 -r ffd2c01dbe1d ChangeLog
--- a/ChangeLog Fri Jul 29 16:39:12 2011 +0200
+++ b/ChangeLog Mon Aug 01 11:14:46 2011 +0200
@@ -1,3 +1,7 @@
+2011-08-01 Pavel Tisnovsky <ptisnovs at redhat.com>
+ * src/org/gfxtest/harness/ExternalCommands.java:
+ Code refactoring and added missing JavaDoc.
+
2011-07-29 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/testsuites/AALines.java: improved JavaDoc.
diff -r f1aa5b49eb61 -r ffd2c01dbe1d src/org/gfxtest/harness/ExternalCommands.java
--- a/src/org/gfxtest/harness/ExternalCommands.java Fri Jul 29 16:39:12 2011 +0200
+++ b/src/org/gfxtest/harness/ExternalCommands.java Mon Aug 01 11:14:46 2011 +0200
@@ -56,7 +56,9 @@
/**
* Read all lines from buffered reader and converts all lines to one string.
+ *
* @param bufferedReader
+ * reader used to read text lines
* @return all lines concatenated into one string
* @throws IOException
*/
@@ -73,8 +75,10 @@
/**
* Read standard output from the command and put it to String
+ *
* @param process
- * @return
+ * compile or run process
+ * @return standard output from given process
* @throws IOException
*/
private static String fetchStandardOutput(Process process) throws IOException
@@ -85,8 +89,10 @@
/**
* Read error output from the command and put it to String
+ *
* @param process
- * @return
+ * compile or run process
+ * @return error output from given process
* @throws IOException
*/
private static String fetchErrorOutput(Process process) throws IOException
@@ -95,12 +101,36 @@
return copyFromBufferedReaderToString(stdError);
}
+ /**
+ * This method constructs string containing external command to build
+ * (compile) selected test suite.
+ *
+ * @param selectedTestSuite
+ * name of selected test suite
+ * @param verboseOperation
+ * whether to use verbose operation during compile
+ * @return string containing external command
+ */
private static String constructBuildCommand(String selectedTestSuite, boolean verboseOperation)
{
return "javac -d " + Paths.BUILD_DIRECTORY + (verboseOperation ? " -verbose " : "") + " -sourcepath "
+ Paths.SOURCE_DIRECTORY + "/ " + Paths.PATH_TO_TESTSUITES + "/" + selectedTestSuite + ".java";
}
+ /**
+ * This method constructs string containing external command to run selected
+ * test suite.
+ *
+ * @param pathToJava
+ * path to selected JVM (may be tested JVM or reference one)
+ * @param selectedTestName
+ * name of selected test suite
+ * @param outputDirectoryForSelectedTest
+ * name of directory, where the output files might be created
+ * @param verboseOperation
+ * whether to use verbose operation during test run
+ * @return string containing external command
+ */
private static String constructRunCommand(String pathToJava, String selectedTestName, String outputDirectoryForSelectedTest, boolean verboseOperation)
{
return pathToJava + (verboseOperation ? " -verbose " : "") + " -cp " + Paths.BUILD_DIRECTORY
@@ -108,35 +138,55 @@
" -o=" + outputDirectoryForSelectedTest;
}
+ /**
+ * This method tries to compile selected test suite.
+ *
+ * @param selectedTestSuite
+ * name of selected test suite
+ * @param verboseOperation
+ * whether to use verbose operation during test run
+ * @return standard and error output of external process
+ * @throws IOException
+ * @throws InterruptedException
+ * @throws RuntimeException
+ */
public static String compileSelectedTestSuite(String selectedTestSuite, boolean verboseOperation) throws IOException, InterruptedException, RuntimeException
{
FileSystemTools.createDirectory(Paths.BUILD_DIRECTORY);
String compilationCommand = constructBuildCommand(selectedTestSuite, verboseOperation);
Process process = Runtime.getRuntime().exec(compilationCommand);
StringBuffer output = new StringBuffer();
-
- output.append("Compilation command:\n");
- output.append(compilationCommand + "\n");
-
- output.append("\n");
- output.append("Standard output for compilation: \n");
- output.append("---------------------------------\n");
-
+ appendCompilationMessageHeader(compilationCommand, output);
output.append(fetchStandardOutput(process));
-
- output.append("\n");
- output.append("Error output: \n");
- output.append("---------------------------------\n");
-
+ appendErrorMessageHeader(output);
output.append(fetchErrorOutput(process));
+ // wait for the external process to finish
process.waitFor();
+ // check external process's exit value
if (process.exitValue() != 0)
{
throw new RuntimeException("Exit code = " + process.exitValue());
}
return output.toString();
}
-
+
+ /**
+ * This method tries to run selected test suite on selected JDK (or to be
+ * more precise - JVM)
+ *
+ * @param pathToJava
+ * path to selected JVM (may be tested JVM or reference one)
+ * @param selectedTestName
+ * name of selected test suite
+ * @param outputDirectory
+ * name of directory, where the output files might be created
+ * @param verboseOperation
+ * whether to use verbose operation during test run
+ * @return standard and error output of external process
+ * @throws IOException
+ * @throws InterruptedException
+ * @throws RuntimeException
+ */
public static String runTestOnGivenJDK(String pathToJava, String selectedTestName, String outputDirectory, boolean verboseOperation) throws IOException, InterruptedException, RuntimeException
{
String outputDirectoryForSelectedTest = FileSystemTools.constructTestDirectoryName(outputDirectory, selectedTestName);
@@ -146,22 +196,13 @@
String runCommand = constructRunCommand(pathToJava, selectedTestName, outputDirectoryForSelectedTest, verboseOperation);
Process process = Runtime.getRuntime().exec(runCommand);
StringBuffer output = new StringBuffer();
-
- output.append("Run command:\n");
- output.append(runCommand + "\n");
-
- output.append("\n");
- output.append("Standard output for test run: \n");
- output.append("---------------------------------\n");
-
+ appendRunMessageHeader(runCommand, output);
output.append(fetchStandardOutput(process));
-
- output.append("\n");
- output.append("Error output: \n");
- output.append("---------------------------------\n");
-
+ appendErrorMessageHeader(output);
output.append(fetchErrorOutput(process));
+ // wait for the external process to finish
process.waitFor();
+ // check external process's exit value
if (process.exitValue() != 0)
{
throw new RuntimeException("Exit code = " + process.exitValue());
@@ -169,4 +210,54 @@
return output.toString();
}
+ /**
+ * Append basic information about compile process to a given output stored
+ * in a StringBuffer.
+ *
+ * @param compilationCommand
+ * compilation command
+ * @param output
+ * output stored in StringBuffer.
+ */
+ private static void appendCompilationMessageHeader(String compilationCommand, StringBuffer output)
+ {
+ output.append("Compilation command:\n");
+ output.append(compilationCommand + "\n");
+ output.append("\n");
+ output.append("Standard output for compilation: \n");
+ output.append("---------------------------------\n");
+ }
+
+ /**
+ * Append basic information about compile and/or run failures to a given
+ * output stored in a StringBuffer.
+ *
+ * @param output
+ * output stored in StringBuffer.
+ */
+ private static void appendErrorMessageHeader(StringBuffer output)
+ {
+ output.append("\n");
+ output.append("Error output: \n");
+ output.append("---------------------------------\n");
+ }
+
+ /**
+ * Append basic information test run to a given output stored in a
+ * StringBuffer.
+ *
+ * @param runCommand
+ * run command
+ * @param output
+ * output stored in StringBuffer.
+ */
+ private static void appendRunMessageHeader(String runCommand, StringBuffer output)
+ {
+ output.append("Run command:\n");
+ output.append(runCommand + "\n");
+ output.append("\n");
+ output.append("Standard output for test run: \n");
+ output.append("---------------------------------\n");
+ }
+
}
More information about the distro-pkg-dev
mailing list