Bug 1089745 - Fix jstest failures outside PST timezone. r=terrence
authorJan de Mooij <jdemooij@mozilla.com>
Tue, 28 Oct 2014 21:53:26 +0100
changeset 212761 99072302a3f4f9b3c4a65baba7a66e9bc39854c8
parent 212760 679819e8236fffba5dc67ed9b6ac206b400f2429
child 212762 4f040d3522a451aed00ce3a420ef8e62e378719b
push id51047
push userjandemooij@gmail.com
push dateTue, 28 Oct 2014 21:03:36 +0000
treeherdermozilla-inbound@99072302a3f4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs1089745
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1089745 - Fix jstest failures outside PST timezone. r=terrence
js/src/tests/ecma_3/Date/15.9.5.5.js
js/src/tests/ecma_3/Date/15.9.5.6.js
js/src/tests/jstests.py
--- a/js/src/tests/ecma_3/Date/15.9.5.5.js
+++ b/js/src/tests/ecma_3/Date/15.9.5.5.js
@@ -45,18 +45,18 @@ expect = "string";
 addTestCase();
 
 status = "Date.prototype.toLocaleString.length";  
 actual =  Date.prototype.toLocaleString.length;
 expect =  0;  
 addTestCase();
 
 // Date.parse is accurate to the second;  valueOf() to the millisecond  -
-status = "Math.abs(Date.parse(now.toLocaleString()) - now.valueOf()) < 1000";  
-actual =   Math.abs(Date.parse(now.toLocaleString()) -  now.valueOf()) < 1000;
+status = "Math.abs(Date.parse(now.toLocaleString('en-US')) - now.valueOf()) < 1000";
+actual =   Math.abs(Date.parse(now.toLocaleString('en-US')) -  now.valueOf()) < 1000;
 expect = true;
 addTestCase();
 
 
 
 // 1970
 addDateTestCase(0);
 addDateTestCase(TZ_ADJUST);  
@@ -98,14 +98,14 @@ function addTestCase()
     actual);
 }
 
 
 function addDateTestCase(date_given_in_milliseconds)
 {
   var givenDate = new Date(date_given_in_milliseconds);
 
-  status = 'Date.parse('   +   givenDate   +   ').toLocaleString())';  
-  actual =  Date.parse(givenDate.toLocaleString());
+  status = 'Date.parse('   +   givenDate   +   ').toLocaleString("en-US"))';
+  actual =  Date.parse(givenDate.toLocaleString("en-US"));
   expect = date_given_in_milliseconds;
   addTestCase();
 }
 
--- a/js/src/tests/ecma_3/Date/15.9.5.6.js
+++ b/js/src/tests/ecma_3/Date/15.9.5.6.js
@@ -45,18 +45,18 @@ addTestCase();
 
 status = "Date.prototype.toLocaleDateString.length";  
 actual =  Date.prototype.toLocaleDateString.length;
 expect =  0;  
 addTestCase();
 
 /* Date.parse is accurate to the second;  valueOf() to the millisecond.
    Here we expect them to coincide, as we expect a time of exactly midnight -  */
-status = "(Date.parse(now.toLocaleDateString()) - (midnight(now)).valueOf()) == 0";  
-actual =   (Date.parse(now.toLocaleDateString()) - (midnight(now)).valueOf()) == 0;
+status = "(Date.parse(now.toLocaleDateString('en-US')) - (midnight(now)).valueOf()) == 0";
+actual =   (Date.parse(now.toLocaleDateString('en-US')) - (midnight(now)).valueOf()) == 0;
 expect = true;
 addTestCase();
 
 
 
 // 1970
 addDateTestCase(0);
 addDateTestCase(TZ_ADJUST);  
@@ -99,18 +99,18 @@ function addTestCase()
     actual);
 }
 
 
 function addDateTestCase(date_given_in_milliseconds)
 {
   var givenDate = new Date(date_given_in_milliseconds);
 
-  status = 'Date.parse('   +   givenDate   +   ').toLocaleDateString())';  
-  actual =  Date.parse(givenDate.toLocaleDateString());
+  status = 'Date.parse('   +   givenDate   +   ').toLocaleDateString("en-US"))';
+  actual =  Date.parse(givenDate.toLocaleDateString("en-US"));
   expect = Date.parse(midnight(givenDate));
   addTestCase();
 }
 
 
 function midnight(givenDate)
 {
   // midnight on the given date -
--- a/js/src/tests/jstests.py
+++ b/js/src/tests/jstests.py
@@ -301,16 +301,19 @@ def main():
             os.chdir(test_dir)
         call(cmd)
         return 0
 
     curdir = os.getcwd()
     if test_dir not in ('', '.'):
         os.chdir(test_dir)
 
+    # Force Pacific time zone to avoid failures in Date tests.
+    os.environ['TZ'] = 'PST8PDT'
+
     results = None
     try:
         results = ResultsSink(options, len(skip_list) + len(test_list))
         for t in skip_list:
             results.push(NullTestOutput(t))
         run_tests(options, test_list, results)
     finally:
         os.chdir(curdir)