@ -2,11 +2,8 @@
/* eslint-disable max-len */
/* eslint-disable max-len */
require ( '../common' ) ;
require ( '../common' ) ;
// first things first, set the timezone; see tzset(3)
const assert = require ( 'assert' ) ;
process . env . TZ = 'Europe/Amsterdam' ;
const spawn = require ( 'child_process' ) . spawn ;
var assert = require ( 'assert' ) ;
var spawn = require ( 'child_process' ) . spawn ;
/ * F o r t h e m o m e n t w e a r e n o t g o i n g t o s u p p o r t s e t t i n g t h e t i m e z o n e v i a t h e
/ * F o r t h e m o m e n t w e a r e n o t g o i n g t o s u p p o r t s e t t i n g t h e t i m e z o n e v i a t h e
* environment variables . The problem is that various V8 platform backends
* environment variables . The problem is that various V8 platform backends
@ -16,6 +13,8 @@ var spawn = require('child_process').spawn;
https : //github.com/joyent/node/blob/08782931205bc4f6d28102ebc29fd806e8ccdf1f/deps/v8/src/platform-linux.cc#L339-345
https : //github.com/joyent/node/blob/08782931205bc4f6d28102ebc29fd806e8ccdf1f/deps/v8/src/platform-linux.cc#L339-345
https : //github.com/joyent/node/blob/08782931205bc4f6d28102ebc29fd806e8ccdf1f/deps/v8/src/platform-win32.cc#L590-596
https : //github.com/joyent/node/blob/08782931205bc4f6d28102ebc29fd806e8ccdf1f/deps/v8/src/platform-win32.cc#L590-596
// first things first, set the timezone; see tzset(3)
process . env . TZ = 'Europe/Amsterdam' ;
// time difference between Greenwich and Amsterdam is +2 hours in the summer
// time difference between Greenwich and Amsterdam is +2 hours in the summer
date = new Date ( 'Fri, 10 Sep 1982 03:15:00 GMT' ) ;
date = new Date ( 'Fri, 10 Sep 1982 03:15:00 GMT' ) ;
@ -27,28 +26,28 @@ assert.equal(5, date.getHours());
// changes in environment should be visible to child processes
// changes in environment should be visible to child processes
if ( process . argv [ 2 ] == 'you-are-the-child' ) {
if ( process . argv [ 2 ] == 'you-are-the-child' ) {
// failed assertion results in process exiting with status code 1
// failed assertion results in process exiting with status code 1
assert . e qual( false , 'NODE_PROCESS_ENV_DELETED' in process . env ) ;
assert . strictE qual( false , 'NODE_PROCESS_ENV_DELETED' in process . env ) ;
assert . equal ( 42 , process . env . NODE_PROCESS_ENV ) ;
assert . strictEqual ( '42' , process . env . NODE_PROCESS_ENV ) ;
assert . e qual( 'asdf' , process . env . hasOwnProperty ) ;
assert . strictE qual( 'asdf' , process . env . hasOwnProperty ) ;
var hasOwnProperty = Object . prototype . hasOwnProperty ;
var hasOwnProperty = Object . prototype . hasOwnProperty ;
const has = hasOwnProperty . call ( process . env , 'hasOwnProperty' ) ;
const has = hasOwnProperty . call ( process . env , 'hasOwnProperty' ) ;
assert . e qual( true , has ) ;
assert . strictE qual( true , has ) ;
process . exit ( 0 ) ;
process . exit ( 0 ) ;
} else {
} else {
assert . e qual( Object . prototype . hasOwnProperty , process . env . hasOwnProperty ) ;
assert . strictE qual( Object . prototype . hasOwnProperty , process . env . hasOwnProperty ) ;
const has = process . env . hasOwnProperty ( 'hasOwnProperty' ) ;
const has = process . env . hasOwnProperty ( 'hasOwnProperty' ) ;
assert . e qual( false , has ) ;
assert . strictE qual( false , has ) ;
process . env . hasOwnProperty = 'asdf' ;
process . env . hasOwnProperty = 'asdf' ;
process . env . NODE_PROCESS_ENV = 42 ;
process . env . NODE_PROCESS_ENV = 42 ;
assert . equal ( 42 , process . env . NODE_PROCESS_ENV ) ;
assert . strictEqual ( '42' , process . env . NODE_PROCESS_ENV ) ;
process . env . NODE_PROCESS_ENV_DELETED = 42 ;
process . env . NODE_PROCESS_ENV_DELETED = 42 ;
assert . e qual( true , 'NODE_PROCESS_ENV_DELETED' in process . env ) ;
assert . strictE qual( true , 'NODE_PROCESS_ENV_DELETED' in process . env ) ;
delete process . env . NODE_PROCESS_ENV_DELETED ;
delete process . env . NODE_PROCESS_ENV_DELETED ;
assert . e qual( false , 'NODE_PROCESS_ENV_DELETED' in process . env ) ;
assert . strictE qual( false , 'NODE_PROCESS_ENV_DELETED' in process . env ) ;
var child = spawn ( process . argv [ 0 ] , [ process . argv [ 1 ] , 'you-are-the-child' ] ) ;
var child = spawn ( process . argv [ 0 ] , [ process . argv [ 1 ] , 'you-are-the-child' ] ) ;
child . stdout . on ( 'data' , function ( data ) { console . log ( data . toString ( ) ) ; } ) ;
child . stdout . on ( 'data' , function ( data ) { console . log ( data . toString ( ) ) ; } ) ;
@ -59,3 +58,8 @@ if (process.argv[2] == 'you-are-the-child') {
}
}
} ) ;
} ) ;
}
}
// delete should return true except for non-configurable properties
// https://github.com/nodejs/node/issues/7960
delete process . env . NON_EXISTING_VARIABLE ;
assert . strictEqual ( true , delete process . env . NON_EXISTING_VARIABLE ) ;