Skip to content

Commit

Permalink
test: fix incorrect assumptions on uid and gid
Browse files Browse the repository at this point in the history
Add a invalidArgTypeErrorCount variable to adjust the number of expected
errors if the uid and gid options cannot be properly validated.

Fixes: #19371
PR-URL: #19554
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
  • Loading branch information
garwahl authored and gireeshpunathil committed Mar 29, 2018
1 parent 37db277 commit 42c7402
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/parallel/test-child-process-spawnsync-validation-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ const spawnSync = require('child_process').spawnSync;
const signals = process.binding('constants').os.signals;

let invalidArgTypeError;
let invalidArgTypeErrorCount = 62;

if (common.isWindows) {
invalidArgTypeError =
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 42);
} else {
invalidArgTypeError =
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 62);
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError },
invalidArgTypeErrorCount);
}

const invalidRangeError =
Expand Down Expand Up @@ -76,6 +78,9 @@ if (!common.isWindows) {
fail('uid', Infinity, invalidArgTypeError);
fail('uid', 3.1, invalidArgTypeError);
fail('uid', -3.1, invalidArgTypeError);
} else {
//Decrement invalidArgTypeErrorCount if validation isn't possible
invalidArgTypeErrorCount -= 10;
}
}

Expand All @@ -95,6 +100,9 @@ if (!common.isWindows) {
fail('gid', Infinity, invalidArgTypeError);
fail('gid', 3.1, invalidArgTypeError);
fail('gid', -3.1, invalidArgTypeError);
} else {
//Decrement invalidArgTypeErrorCount if validation isn't possible
invalidArgTypeErrorCount -= 10;
}
}
}
Expand Down

0 comments on commit 42c7402

Please sign in to comment.