Browse files

Merge branch `travis-ci` into `master`.

  • Loading branch information...
2 parents ac5d8b0 + 189dce0 commit 1671063ae5ef933c7b2928875a2d96948135c18d @bigeasy committed Apr 29, 2012
Showing with 103 additions and 37 deletions.
  1. +20 −0 bin/test
  2. +42 −0 bin/transitions.t
  3. +1 −1 package.json
  4. +40 −36 t/zones/olson/transitions.t
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 :

0 comments on commit 1671063

Please sign in to comment.