Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
  • 7 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 29, 2012
@bigeasy Testing Travis CI.
Travis CI is timing out because my tests take longer than 10 minutes. The
reports stop on the transition tests, the process is killed before
`t/zones/olson/transitions.t` prints its results.

This runs only 10000 assertions in each of the transition tests, to get an idea
of how long it take Travis CI to run these tests.
b6b88a4
@bigeasy Olson transition test now in Ruby for Travis CI.
Reimplemented the test that verifies the clock transition we've discovered in
the Olson files in Ruby. Travis CI doesn't like our bash program. I suspect that
it doesn't like programs that fork a bunch, and our bash test forks `date` 48266
times currently.

Tried to write the test in Perl, but Perl's `strftime` does not support `%::z`.

Ruby's does, but only in 1.9.3. The next few commits are going to explore using
`rvm` on the Node.js worker at Travis CI to install Ruby 1.9.3, for the sake of
this one test.
a725f49
@bigeasy Install Ruby 1.9.3 using `apt-get` at Travis CI.
It's not enough to use the `rvm` YAML property. It's not recognized on a Node.js
worker. Wasn't able to use `rvm`, because there wasn't a ruby 1.9.3 already
installed in the `~/.rvm` directory of Travis CI's `vagrant` user. Couldn't
install one, because building Ruby 1.9.3 takes too long.

Installing a 3rd party Ruby 1.9.3 from
[Brightbox](http://blog.brightbox.co.uk/) using their Ubuntu Personal Package
Archive. Installing Ruby 1.9.3 using apt-get gets Ruby 1.9.3 installed fast
enough for a Travis CI test run.

We need Ruby 1.9.3 for the `%::z` format specifier. The `strftime` in 1.9.2 and
earlier does not support it.

I've created a bash program `bin/test` that will perform this apt-get install if
we're on Travis CI.

The clock transition tests are key tests of the integrity of this library. It
was well worth the effort to add those tests to continuous integration.
e6ded8b
@bigeasy Move Ruby Olson clock transitions test into place.
The `bash` version of this program was moved to the `bin` directory two commits
back. The Ruby version is now being moved into its place.
0640808
@bigeasy Travis CI output tidy.
There's an error message in the Travis CI output, saying that it can't link to
the `ruby` `man` page to the `ruby.1.9.3` `man` page, because it does not exist.

Deleted the link assignment.
189dce0
@bigeasy Merge branch `travis-ci` into `master`. 1671063
Commits on Apr 30, 2012
@bigeasy Merge branch `master` into `travis-ci`. 5329ce3
View
20 bin/test
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+if [ "$TRAVIS" = "true" ]; then
+ (echo -e "\n\n\n" | sudo apt-add-repository ppa:brightbox/ruby-ng-experimental) >/dev/null 2>&1 && echo "brightbox added"
+ sudo apt-get -q update >/dev/null 2>&1 && echo "apt-get update"
+ sudo apt-get -q install ruby rubygems ruby-switch >/dev/null 2>&1 && echo "apt-get install ruby rubygems ruby-switch"
+ sudo apt-get -q install ruby1.9.3 >/dev/null 2>&1 && echo "apt-get install ruby1.9.3"
+ sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.3 400 \
+ --slave /usr/bin/ri ri /usr/bin/ri1.9.3 \
+ --slave /usr/bin/irb irb /usr/bin/irb1.9.3
+ sudo update-alternatives --set ruby /usr/bin/ruby1.9.3
+ PATH=/usr/local/gradle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
+ PATH=/usr/local/gradle/bin:/home/vagrant/.nvm/v0.6.15/bin:./node_modules/.bin:$PATH
+ PATH=/home/vagrant/builds/bigeasy/timezone/node_modules/.bin:./node_modules/.bin:$PATH
+ PATH=/home/vagrant/.nvm/v0.6.15/lib/node_modules/npm/bin/node-gyp-bin:$PATH
+ export PATH
+ ruby -v
+fi
+
+proof t/*/*.t t/locale/*/*.t t/zones/*/*.t || exit 1
View
42 bin/transitions.t
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+IANA="$( cd "$DIR/../iana" && pwd )"
+
+count=0
+while read line
+do
+ array=($line)
+ utc=${array[2]}
+ if [ "${utc%%-*}" -lt 1902 ]; then continue; fi
+ let count=count+1
+done < "$IANA/zones.txt"
+
+#echo "1..$(expr $count '*' 2)"
+echo "1..10000"
+
+count=1
+while read line
+do
+ if [ $count -eq 10001 ]; then break; fi
+ array=($line)
+ utc=${array[2]/T/ }
+ if [ "${utc%%-*}" -lt 1902 ]; then continue; fi
+ # Date cannot do zone shifts with to the second accuracy.
+ before=$(TZ=":$IANA/zoneinfo/${array[0]}" date -d 'TZ="UTC" -1 minute '"$utc" +"%::z/%Z")
+ after=$(TZ=":$IANA/zoneinfo/${array[0]}" date -d 'TZ="UTC" +1 minute '"$utc" +"%::z/%Z")
+ if [ "$before" = "${array[3]}" ]
+ then
+ echo "ok ${count} # before ${array[0]} ${array[1]}"
+ else
+ echo "not ok ${count} ${array[0]} ${array[1]} ${array[2]} ${array[2]} != $before"
+ fi
+ let count=count+1
+ if [ "$after" = "${array[4]}" ]
+ then
+ echo "ok ${count} # after ${array[0]} ${array[1]}"
+ else
+ echo "not ok ${count} ${array[0]} ${array[1]} ${array[2]} ${array[4]} != $after"
+ fi
+ let count=count+1
+done < "$IANA/zones.txt"
View
2  package.json
@@ -10,6 +10,6 @@
, "proof": ">=0.0.1" }
, "lib" : "lib"
, "main" : "./lib/timezone"
-, "scripts" : { "test": "proof t/*/*.t t/locale/*/*.t t/zones/*/*.t" }
+, "scripts" : { "test": "bin/test" }
, "engines" : { "node": "> 0.4.0" }
}
View
76 t/zones/olson/transitions.t
@@ -1,40 +1,44 @@
-#!/bin/bash
+#!/usr/bin/env ruby
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-IANA="$( cd "$DIR/../../../iana" && pwd )"
+require "time"
+require "date"
-count=0
-while read line
-do
- array=($line)
- utc=${array[2]}
- if [ "${utc%%-*}" -lt 1902 ]; then continue; fi
- let count=count+1
-done < "$IANA/zones.txt"
+DIR = File.expand_path(File.dirname(__FILE__))
+IANA = File.expand_path("#{DIR}/../../../iana")
-echo "1..$(expr $count '*' 2)"
+ENV["TZ"] = "UTC"
+counter = 0
+File.open("#{IANA}/zones.txt", "r") do |infile|
+ while (line = infile.gets)
+ name, wallclock, posix, before, after = line.split(/\s/)
+ time = Time.parse posix
+ if time.year > 1902
+ counter = counter + 2
+ end
+ end
+end
-count=1
-while read line
-do
- array=($line)
- utc=$(echo ${array[2]} | tr T ' ')
- if [ "${utc%%-*}" -lt 1902 ]; then continue; fi
- # Date cannot do zone shifts with to the second accuracy.
- before=$(TZ=":$IANA/zoneinfo/${array[0]}" date -d 'TZ="UTC" -1 minute '"$utc" +"%::z/%Z")
- after=$(TZ=":$IANA/zoneinfo/${array[0]}" date -d 'TZ="UTC" +1 minute '"$utc" +"%::z/%Z")
- if [ "$before" = "${array[3]}" ]
- then
- echo "ok ${count} # before ${array[0]} ${array[1]}"
- else
- echo "not ok ${count} ${array[0]} ${array[1]} ${array[2]} ${array[2]} != $before"
- fi
- let count=count+1
- if [ "$after" = "${array[4]}" ]
- then
- echo "ok ${count} # after ${array[0]} ${array[1]}"
- else
- echo "not ok ${count} ${array[0]} ${array[1]} ${array[2]} ${array[4]} != $after"
- fi
- let count=count+1
-done < "$IANA/zones.txt"
+puts "1..#{counter}"
+
+counter = 1
+File.open("#{IANA}/zones.txt", "r") do |infile|
+ while (line = infile.gets)
+ name, wallclock, posix, before, after = line.split(/\s/)
+ ENV["TZ"] = "UTC"
+ time = Time.parse posix
+ if time.year > 1902
+ ENV["TZ"] = ":#{IANA}/zoneinfo/#{name}"
+ time = Time.at(time.to_i)
+ offsetAbbrevation = (time + 60).strftime("%::z/%Z")
+ ok = after == offsetAbbrevation ? "ok" : "not ok"
+ puts "#{ok} #{counter} after #{name} #{wallclock} #{posix} #{after} #{offsetAbbrevation}"
+ counter = counter + 1
+ offsetAbbrevation = (time - 60).strftime("%::z/%Z")
+ ok = (before == offsetAbbrevation ? "ok" : "not ok")
+ puts "#{ok} #{counter} before #{name} #{wallclock} #{posix} #{before} #{offsetAbbrevation}"
+ counter = counter + 1
+ end
+ end
+end
+
+# vim: ft=ruby :

No commit comments for this range

Something went wrong with that request. Please try again.