test: case sensitivity of env variables

Environment variables should be treated case-insensitive on Windows
platforms and case-sensitive on UNIX platforms.

This commit ensures this behavior persists.

Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/9166
Fixes: https://github.com/nodejs/node/issues/9157
This commit is contained in:
Oliver Salzburg 2016-10-18 22:02:19 +02:00 committed by Benjamin Gruenbaum
parent 0a8d0eaa9b
commit 2a456162b6

View File

@ -1,6 +1,6 @@
'use strict';
require('../common');
const common = require('../common');
const assert = require('assert');
// changes in environment should be visible to child processes
@ -67,3 +67,17 @@ assert.equal(3, date.getUTCHours());
assert.equal(5, date.getHours());
*/
/* eslint-enable max-len */
// Environment variables should be case-insensitive on Windows, and
// case-sensitive on other platforms.
process.env.TEST = 'test';
assert.strictEqual(process.env.TEST, 'test');
// Check both mixed case and lower case, to avoid any regressions that might
// simply convert input to lower case.
if (common.isWindows) {
assert.strictEqual(process.env.test, 'test');
assert.strictEqual(process.env.teST, 'test');
} else {
assert.strictEqual(process.env.test, undefined);
assert.strictEqual(process.env.teST, undefined);
}