This is an automated email from the ASF dual-hosted git repository.
bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git
The following commit(s) were added to refs/heads/master by this push:
new 51e5624 try making test independent of timezone
51e5624 is described below
commit 51e5624af4527c31ca9ae9b42cf171714f00a868
Author: Stefan Bodewig <[email protected]>
AuthorDate: Sat Aug 22 20:41:14 2020 +0200
try making test independent of timezone
---
src/tests/antunit/taskdefs/tstamp-test.xml | 40 +++++++++++++++++++++++++++---
1 file changed, 37 insertions(+), 3 deletions(-)
diff --git a/src/tests/antunit/taskdefs/tstamp-test.xml
b/src/tests/antunit/taskdefs/tstamp-test.xml
index ec7e2d6..20c3227 100644
--- a/src/tests/antunit/taskdefs/tstamp-test.xml
+++ b/src/tests/antunit/taskdefs/tstamp-test.xml
@@ -18,11 +18,45 @@
<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
<import file="../antunit-base.xml" />
- <target name="testMagicProperty">
+ <target name="-adjust-for-offset-at-epoch">
+ <property name="ant-package" location="${input}/org/apache/ant"/>
+ <mkdir dir="${ant-package}"/>
+ <mkdir dir="${output}"/>
+ <echo file="${ant-package}/IsEpochIn1969Here.java"><![CDATA[
+package org.apache.ant;
+
+import org.apache.tools.ant.taskdefs.condition.Condition;
+import java.util.Calendar;
+import java.util.Date;
+
+public class IsEpochIn1969Here implements Condition {
+ @Override
+ public boolean eval() {
+ final Calendar c = Calendar.getInstance();
+ c.setTime(new Date(0));
+ final int offset = (c.get(Calendar.ZONE_OFFSET) +
c.get(Calendar.DST_OFFSET));
+ return offset < 0;
+ }
+}
+]]></echo>
+ <javac srcdir="${input}" destdir="${output}"/>
+ <typedef name="isepochin1969here"
classname="org.apache.ant.IsEpochIn1969Here">
+ <classpath>
+ <pathelement location="${output}"/>
+ </classpath>
+ </typedef>
+ <condition property="expected-dstamp" value="19700101">
+ <isepochin1969here/>
+ </condition>
+ <property name="expected-dstamp" value="19700102"/>
+ <echo>${expected-dstamp}</echo>
+ </target>
+
+ <target name="testMagicProperty" depends="-adjust-for-offset-at-epoch">
<local name="ant.tstamp.now"/>
- <property name="ant.tstamp.now" value="100000"/>
+ <property name="ant.tstamp.now" value="86400"/>
<tstamp/>
- <au:assertPropertyEquals name="DSTAMP" value="19700102"/>
+ <au:assertPropertyEquals name="DSTAMP" value="${expected-dstamp}"/>
</target>
<target name="testMagicPropertyIso">