db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1839222 - /db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/RunOnlyOnSourceChangeTest.java
Date Sun, 26 Aug 2018 14:59:14 GMT
Author: tv
Date: Sun Aug 26 14:59:14 2018
New Revision: 1839222

URL: http://svn.apache.org/viewvc?rev=1839222&view=rev
Log:
Fix TORQUE-351 by synchronizing file timestamps between runs

Modified:
    db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/RunOnlyOnSourceChangeTest.java

Modified: db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/RunOnlyOnSourceChangeTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/RunOnlyOnSourceChangeTest.java?rev=1839222&r1=1839221&r2=1839222&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/RunOnlyOnSourceChangeTest.java
(original)
+++ db/torque/torque4/trunk/torque-generator/src/test/java/org/apache/torque/generator/control/RunOnlyOnSourceChangeTest.java
Sun Aug 26 14:59:14 2018
@@ -25,7 +25,10 @@ import static org.junit.Assert.assertTru
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.logging.Log;
@@ -47,6 +50,7 @@ public class RunOnlyOnSourceChangeTest e
     private static Log log = LogFactory.getLog(Controller.class);
 
     @Test
+    @SuppressWarnings("unchecked")
     public void testRunOnlyOnSourceChange() throws Exception
     {
         File targetDir = new File("target/test/runOnlyOnSourceChange");
@@ -55,6 +59,15 @@ public class RunOnlyOnSourceChangeTest e
         File srcDir2 = new File(targetDir, "src/2");
         FileUtils.copyDirectory(new File("src/test/runOnlyOnSourceChange/src/main/torque-gen/src"),
srcDir1);
         FileUtils.copyDirectory(new File("src/test/runOnlyOnSourceChange/src/main/torque-gen/src"),
srcDir2);
+
+        // Fix TORQUE-351, timestamps of files in src and secondSource must be identical
+        Collection<File> srcFiles = FileUtils.listFiles(new File(targetDir, "src"),
null, true);
+        Map<String, Long> srcFileStamps = new HashMap<>();
+        for (File file : srcFiles)
+        {
+            srcFileStamps.put(file.getAbsolutePath(), Long.valueOf(file.lastModified()));
+        }
+
         Controller controller = new Controller();
 
         // run first generation with two unit descriptors to reproduce TORQUE-338
@@ -104,6 +117,18 @@ public class RunOnlyOnSourceChangeTest e
         FileUtils.deleteDirectory(srcDir2);
         FileUtils.copyDirectory(new File("src/test/runOnlyOnSourceChange/src/main/torque-gen/secondSource"),
srcDir1);
         FileUtils.copyDirectory(new File("src/test/runOnlyOnSourceChange/src/main/torque-gen/secondSource"),
srcDir2);
+
+        srcFiles = FileUtils.listFiles(new File(targetDir, "src"), null, true);
+        for (File file : srcFiles)
+        {
+            Long ts = srcFileStamps.get(file.getAbsolutePath());
+            if (ts != null && ts.longValue() != file.lastModified())
+            {
+                log.debug("Fixing timestamp of " + file);
+                file.setLastModified(ts.longValue());
+            }
+        }
+
         controller.run(unitDescriptors);
         log.debug("End time of generation " + System.currentTimeMillis());
 



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message