11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci// Flags: --expose-internals 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_cirequire('../common'); 51cb0ef41Sopenharmony_ciconst { internalBinding } = require('internal/test/binding'); 61cb0ef41Sopenharmony_ciconst assert = require('assert'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci// Monkey patch the os binding before requiring any other modules, including 91cb0ef41Sopenharmony_ci// common, which requires the os module. 101cb0ef41Sopenharmony_ciinternalBinding('os').getHomeDirectory = function(ctx) { 111cb0ef41Sopenharmony_ci ctx.syscall = 'foo'; 121cb0ef41Sopenharmony_ci ctx.code = 'bar'; 131cb0ef41Sopenharmony_ci ctx.message = 'baz'; 141cb0ef41Sopenharmony_ci}; 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciconst os = require('os'); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ciassert.throws(os.homedir, { 191cb0ef41Sopenharmony_ci message: /^A system error occurred: foo returned bar \(baz\)$/ 201cb0ef41Sopenharmony_ci}); 21