Author: hdu Date: Tue Dec 17 08:31:50 2013 New Revision: 1551484 URL: http://svn.apache.org/r1551484 Log: #i123847# provide start/end times and duration in autotest result page
Modified: openoffice/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java Modified: openoffice/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java URL: http://svn.apache.org/viewvc/openoffice/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java?rev=1551484&r1=1551483&r2=1551484&view=diff ============================================================================== --- openoffice/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java (original) +++ openoffice/trunk/test/testcommon/source/org/openoffice/test/common/XMLReporter.java Tue Dec 17 08:31:50 2013 @@ -64,6 +64,7 @@ public class XMLReporter extends RunList private long ignored = 0; + private long runStart = 0; private long testStart = 0; @Override @@ -139,6 +140,7 @@ public class XMLReporter extends RunList public void testRunStarted(Description description) throws Exception { suiteName = description.getDisplayName(); FileUtil.deleteFile(outputDir);//clear all old output + runStart = System.currentTimeMillis(); startSuite(); } @@ -191,8 +193,15 @@ public class XMLReporter extends RunList props.appendChild(prop); } - SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd HH-mm-ss"); - System.setProperty( "info.test.date", dateFormat.format( new Date())); + SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy/MM/dd HH:mm:ss"); + String aRunStartStr = dateFormat.format( new Date( runStart)); + long nRunEnd = System.currentTimeMillis(); + String aRunEndStr = dateFormat.format( new Date( nRunEnd)); + double fDuration = (nRunEnd - runStart) / 1000.0; + if( fDuration < 20*3600e3) // strip the end date if it is obvious + aRunEndStr = aRunEndStr.substring( 11); + String aTestTimeStr = String.format( "From %s to %s (%.1f secs)", aRunStartStr, aRunEndStr, fDuration); + System.setProperty( "info.test.date", aTestTimeStr); FileUtil.storeXML(doc, file); File htmlFile = new File(outputDir, "result.html");