2018-08-20 09:10:06 -04:00
|
|
|
'use strict';
|
2020-03-29 00:01:29 -05:00
|
|
|
// Flags: --expose-internals
|
2018-12-17 23:45:24 +09:00
|
|
|
|
2019-12-25 18:02:16 +01:00
|
|
|
require('../common');
|
2018-12-17 23:45:24 +09:00
|
|
|
const { internalBinding } = require('internal/test/binding');
|
2019-12-25 18:02:16 +01:00
|
|
|
const assert = require('assert');
|
2018-12-17 23:45:24 +09:00
|
|
|
|
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');
|
|
|
|
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(os.homedir, {
|
2018-08-20 09:10:06 -04:00
|
|
|
message: /^A system error occurred: foo returned bar \(baz\)$/
|
|
|
|
});
|