2017-01-03 13:16:48 -08:00
|
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the
|
|
|
|
// "Software"), to deal in the Software without restriction, including
|
|
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
|
|
// following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2017-10-06 09:53:41 -07:00
|
|
|
require('../common');
|
|
|
|
const fixtures = require('../common/fixtures');
|
2016-01-20 11:38:35 -08:00
|
|
|
const assert = require('assert');
|
|
|
|
const execFile = require('child_process').execFile;
|
2017-10-06 09:53:41 -07:00
|
|
|
const depmod = fixtures.path('deprecated.js');
|
2016-01-20 11:38:35 -08:00
|
|
|
const node = process.execPath;
|
2012-06-21 11:42:33 -07:00
|
|
|
|
2016-07-12 23:09:12 +02:00
|
|
|
const depUserlandFunction =
|
2017-10-06 09:53:41 -07:00
|
|
|
fixtures.path('deprecated-userland-function.js');
|
2016-07-12 23:09:12 +02:00
|
|
|
|
|
|
|
const depUserlandClass =
|
2017-10-06 09:53:41 -07:00
|
|
|
fixtures.path('deprecated-userland-class.js');
|
2016-07-12 23:09:12 +02:00
|
|
|
|
|
|
|
const depUserlandSubClass =
|
2017-10-06 09:53:41 -07:00
|
|
|
fixtures.path('deprecated-userland-subclass.js');
|
2015-06-13 16:44:39 +00:00
|
|
|
|
2016-01-20 11:38:35 -08:00
|
|
|
const normal = [depmod];
|
|
|
|
const noDep = ['--no-deprecation', depmod];
|
|
|
|
const traceDep = ['--trace-deprecation', depmod];
|
2012-06-21 11:42:33 -07:00
|
|
|
|
|
|
|
execFile(node, normal, function(er, stdout, stderr) {
|
|
|
|
console.error('normal: show deprecation warning');
|
2017-01-08 15:36:25 +00:00
|
|
|
assert.strictEqual(er, null);
|
|
|
|
assert.strictEqual(stdout, '');
|
2021-08-29 10:14:22 +02:00
|
|
|
assert.match(stderr, /this function is deprecated/);
|
2012-06-21 11:42:33 -07:00
|
|
|
console.log('normal ok');
|
|
|
|
});
|
|
|
|
|
|
|
|
execFile(node, noDep, function(er, stdout, stderr) {
|
|
|
|
console.error('--no-deprecation: silence deprecations');
|
2017-01-08 15:36:25 +00:00
|
|
|
assert.strictEqual(er, null);
|
|
|
|
assert.strictEqual(stdout, '');
|
2019-01-07 13:19:49 -05:00
|
|
|
assert.strictEqual(stderr.trim(), 'This is deprecated');
|
2012-06-21 11:42:33 -07:00
|
|
|
console.log('silent ok');
|
|
|
|
});
|
|
|
|
|
|
|
|
execFile(node, traceDep, function(er, stdout, stderr) {
|
|
|
|
console.error('--trace-deprecation: show stack');
|
2017-01-08 15:36:25 +00:00
|
|
|
assert.strictEqual(er, null);
|
|
|
|
assert.strictEqual(stdout, '');
|
2017-01-08 13:19:00 +00:00
|
|
|
const stack = stderr.trim().split('\n');
|
2019-03-07 01:03:53 +01:00
|
|
|
// Just check the top and bottom.
|
2021-08-29 10:14:22 +02:00
|
|
|
assert.match(stack[1], /this function is deprecated/);
|
|
|
|
assert.match(stack[0], /This is deprecated/);
|
2012-06-21 11:42:33 -07:00
|
|
|
console.log('trace ok');
|
|
|
|
});
|
2015-06-13 16:44:39 +00:00
|
|
|
|
2016-07-12 23:09:12 +02:00
|
|
|
execFile(node, [depUserlandFunction], function(er, stdout, stderr) {
|
2015-06-13 16:44:39 +00:00
|
|
|
console.error('normal: testing deprecated userland function');
|
2017-01-08 15:36:25 +00:00
|
|
|
assert.strictEqual(er, null);
|
|
|
|
assert.strictEqual(stdout, '');
|
2021-08-29 10:14:22 +02:00
|
|
|
assert.match(stderr, /deprecatedFunction is deprecated/);
|
2015-06-13 16:44:39 +00:00
|
|
|
console.error('normal: ok');
|
|
|
|
});
|
2016-07-12 23:09:12 +02:00
|
|
|
|
|
|
|
execFile(node, [depUserlandClass], function(er, stdout, stderr) {
|
|
|
|
assert.strictEqual(er, null);
|
|
|
|
assert.strictEqual(stdout, '');
|
2021-08-29 10:14:22 +02:00
|
|
|
assert.match(stderr, /deprecatedClass is deprecated/);
|
2016-07-12 23:09:12 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
execFile(node, [depUserlandSubClass], function(er, stdout, stderr) {
|
|
|
|
assert.strictEqual(er, null);
|
|
|
|
assert.strictEqual(stdout, '');
|
2021-08-29 10:14:22 +02:00
|
|
|
assert.match(stderr, /deprecatedClass is deprecated/);
|
2016-07-12 23:09:12 +02:00
|
|
|
});
|