This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

win: fix test-process-env

Remove support for setting process.env.TZ as it doesn't seem we can do it
x-platform without fixing V8.
  • Loading branch information...
ry committed Aug 11, 2011
1 parent e62cdd0 commit e6b06bc6c5393b31f3b45dbcd0deeb95271fc8b8
Showing with 35 additions and 2 deletions.
  1. +1 −0 Makefile
  2. +23 −2 src/node.cc
  3. +11 −0 test/simple/test-process-env.js
View
@@ -177,6 +177,7 @@ UVTEST += simple/test-module-load-list
UVTEST += simple/test-path
UVTEST += simple/test-pipe-stream
UVTEST += simple/test-pipe-file-to-http
+UVTEST += simple/test-process-env
UVTEST += simple/test-pump-file2tcp
UVTEST += simple/test-pump-file2tcp-noexist
UVTEST += simple/test-punycode
View
@@ -2002,13 +2002,23 @@ static Handle<Value> EnvGetterWarn(Local<String> property,
static Handle<Value> EnvSetter(Local<String> property,
Local<Value> value,
const AccessorInfo& info) {
+ HandleScope scope;
String::Utf8Value key(property);
String::Utf8Value val(value);
+
#ifdef __POSIX__
setenv(*key, *val, 1);
#else // __WIN32__
- NO_IMPL_MSG(setenv)
+ int n = key.length() + val.length() + 2;
+ char* pair = new char[n];
+ snprintf(pair, n, "%s=%s", *key, *val);
+ int r = _putenv(pair);
+ if (r) {
+ fprintf(stderr, "error putenv: '%s'\n", pair);
+ }
+ delete [] pair;
#endif
+
return value;
}
@@ -2026,15 +2036,26 @@ static Handle<Integer> EnvQuery(Local<String> property,
static Handle<Boolean> EnvDeleter(Local<String> property,
const AccessorInfo& info) {
+ HandleScope scope;
+
String::Utf8Value key(property);
+
if (getenv(*key)) {
#ifdef __POSIX__
unsetenv(*key); // prototyped as `void unsetenv(const char*)` on some platforms
#else
- NO_IMPL_MSG(unsetenv)
+ int n = key.length() + 2;
+ char* pair = new char[n];
+ snprintf(pair, n, "%s=", *key);
+ int r = _putenv(pair);
+ if (r) {
+ fprintf(stderr, "error unsetenv: '%s'\n", pair);
+ }
+ delete [] pair;
#endif
return True();
}
+
return False();
}
@@ -25,10 +25,21 @@ process.env.TZ = 'Europe/Amsterdam';
assert = require('assert');
spawn = require('child_process').spawn;
+/* For the moment we are not going to support setting the timezone via the
+ * environment variables. The problem is that various V8 platform backends
+ * deal with timezone in different ways. The windows platform backend caches
+ * the timezone value while the Linux one hits libc for every query.
+
+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
+
+
// time difference between Greenwich and Amsterdam is +2 hours in the summer
date = new Date('Fri, 10 Sep 1982 03:15:00 GMT');
assert.equal(3, date.getUTCHours());
assert.equal(5, date.getHours());
+*/
+
// changes in environment should be visible to child processes
if (process.argv[2] == 'you-are-the-child') {

0 comments on commit e6b06bc

Please sign in to comment.