2018-08-20 09:10:06 -04:00
|
|
|
'use strict';
|
2018-12-17 23:45:24 +09:00
|
|
|
// Flags: --expose_internals
|
|
|
|
|
2019-12-12 10:44:28 -05:00
|
|
|
const common = require('../common');
|
2018-12-17 23:45:24 +09:00
|
|
|
const { internalBinding } = require('internal/test/binding');
|
|
|
|
|
2018-08-20 09:10:06 -04:00
|
|
|
// Monkey patch the os binding before requiring any other modules, including
|
|
|
|
// common, which requires the os module.
|
2018-12-17 23:45:24 +09:00
|
|
|
internalBinding('os').getHomeDirectory = function(ctx) {
|
2018-08-20 09:10:06 -04:00
|
|
|
ctx.syscall = 'foo';
|
|
|
|
ctx.code = 'bar';
|
|
|
|
ctx.message = 'baz';
|
|
|
|
};
|
|
|
|
|
|
|
|
const os = require('os');
|
|
|
|
|
|
|
|
common.expectsError(os.homedir, {
|
|
|
|
message: /^A system error occurred: foo returned bar \(baz\)$/
|
|
|
|
});
|