4 not
() { "$@" && exit 1 ||
:; }
7 # Some tests for the '--match' flag, specifically the date-matching
21 echo "$1/tester/a///" |
tr / \\012 | darcs record
-m "" --pipe bar
26 darcs record
-m "" bar
-a -A tester
29 # parse_date just checks for parsing, while match_date checks for an actual match.
30 # It's better if we can use "match_date", but we have to be able to construct such a date
31 # based on a date dynamically generated by this test script.
33 # alternately, it might be more useful to build a random date string generator
34 # using QuickCheck... for any n random CalendarTimes, have it generate some
35 # possible variants and roundtrip them to see if they match
38 darcs changes
--match "date \"$1\"" > log
43 darcs changes
--match "date \"$1\"" > log
49 darcs changes
--match "date \"$1\"" > log
58 # this block of dates should all refer to the same thing
63 create_entry
"$year-$mm-$dd $hhmmss"
64 echo "/tester/a///" |
tr / \\012 | darcs record
-m "" --pipe bar
65 match_date
"$year-$mm-$dd"
66 match_date
"$year$mm$dd"
67 match_date
"$year-$mm"
71 # week dates. note that 2007 was selected as it starts on Monday
73 create_entry
"2007-01-04 15:00"
74 match_date
'2007-W01-4'
75 nomatch_date
'2007-W01-1'
78 nomatch_date
'2007-W02-1'
79 create_entry
"2007-01-08 15:00"
81 match_date
'2007-W02-1'
82 create_entry
"2007-05-20 15:00"
84 nomatch_date
'2007-W21'
85 nomatch_date
'2007-W19'
86 # ordinal dates. eh... why not?
87 match_date
'2007-004'; # fourth day of 2007
89 nomatch_date
'2007-005'
93 create_entry
"1992-10-15 00:00"
94 match_date
'1992-10-14 24:00'
95 match_date
'1992-10-15 00:00'
97 # all the same date/time
99 create_entry
"1992-02-12T22:32:11"
100 match_date
'1992-02-12T22:32:11'
101 match_date
'1992-02-12 22:32:11'
102 match_date
'1992-02-12T223211.0000'
104 # english dates - the old hard coded from < darcs 1.0.6
109 hhmmss
=`date +%k:%M:%S`
111 create_entry
"$(($year-1))-$mm-$dd"
113 nomatch_date
'yesterday'
114 nomatch_date
'day before yesterday'
115 nomatch_date
'last week'
116 nomatch_date
'last month'
117 # note: this test might fail if you run it just before midnight
121 nomatch_date
'yesterday'
122 nomatch_date
'day before yesterday'
123 match_date
'last week'
124 match_date
'last month'
127 create_entry
"$(($year-1))-$mm-$dd"
128 # english dates - new possibilities
129 nomatch_date
'yesterday at 14:00:00'
130 match_date
'last 3 years'
131 match_date
'last year'
132 nomatch_date
'2 days ago'
133 nomatch_date
'last month 13:00'
134 nomatch_date
'3 days before last week'
137 match_date
'day after yesterday'
138 match_date
'week after last week'
139 create_entry
"1992-10-02 00:15"
140 match_date
'15 minutes after 1992-10-02'
142 create_entry
"1992-10-02 00:15+05"
143 # note that earlier dates will always match
144 match_date
'15 minutes after 1992-10-02 00:00+05'; # same time
145 match_date
'15 minutes after 1992-10-01 23:00+04'; # same time
146 nomatch_date
'15 minutes after 1992-10-02 01:00+05'; # 1 hour later
147 nomatch_date
'15 minutes after 1992-10-02 00:00+04'; # 1 hour later
148 nomatch_date
'1 hour, 15 minutes after 1992-10-02 00:00+05'; # 1 hour later
149 match_date
'1 hour, 15 minutes after 1992-10-02 00:00+06'; # same time
150 match_date
'1 hour, 15 minutes after 1992-10-01 23:00+05'; # same time
154 create_entry
1992-10-02 00:15
156 nomatch_date
'between last fortnight and day before yesterday'
157 match_date
'between last fortnight and today'
158 match_date
'in the last 45 seconds'
159 match_date
'after 1992'
162 parse_date
'1992-10-02 00:00Z/1992-10-02 00:16Z'
163 match_date
'1992-10-02 00:00/1992-10-02 00:16'
164 match_date
'between 1992-10-02 00:00 and 1992-10-12 00:16'
165 parse_date
'P3YT3M/1992'
166 parse_date
'1992/P3Y3M4DT5H3M2S'
167 parse_date
'1992/P3Y3M'
169 # stuff from the manual
172 nomatch_date
'between 2004-03-12 and last week'
173 match_date
'last week'
174 parse_date
'yesterday'
175 parse_date
'today 14:00'
176 nomatch_date
'3 days before last year at 17:00'
177 # We can't in general parse the raw date output by darcs. If we change the
178 # format to not include timezone information, this would be possible. But
179 # maybe that's not desireable. For now, we just won't test the raw date.
180 #match_date "$raw_date"
181 parse_date
'after 2005'
182 parse_date
'in the last 3 weeks'
183 parse_date
'P3M/2006-03-17'
184 parse_date
'2004-01-02/2006-03-17'
188 parse_date
'2006/01/19 21:14:20 UTC'
189 # We can't handle all timezones in the old style dates
190 # so this test will not work everywhere
191 # match_date "$year/$mm/$dd $hhmmss $tz"