@@ -34,13 +34,41 @@ test('normalizeError falls back to context metadata', () => {
3434
3535test ( 'normalizeError enriches generic command-failed message with stderr excerpt' , ( ) => {
3636 const err = new AppError ( 'COMMAND_FAILED' , 'xcrun exited with code 1' , {
37+ exitCode : 1 ,
38+ processExitError : true ,
3739 stderr : '\nOperation not permitted\nUnderlying error details' ,
3840 } ) ;
3941 const normalized = normalizeError ( err ) ;
40- assert . equal ( normalized . message , 'xcrun exited with code 1: Operation not permitted' ) ;
42+ assert . equal ( normalized . message , 'Operation not permitted' ) ;
4143} ) ;
4244
43- test ( 'normalizeError does not alter non-generic command-failed message' , ( ) => {
45+ test ( 'normalizeError skips simctl boilerplate wrappers in stderr' , ( ) => {
46+ const err = new AppError ( 'COMMAND_FAILED' , 'xcrun exited with code 1' , {
47+ exitCode : 1 ,
48+ processExitError : true ,
49+ stderr : [
50+ 'An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=1):' ,
51+ 'Simulator device failed to complete the requested operation.' ,
52+ 'Operation not permitted' ,
53+ 'Underlying error (domain=NSPOSIXErrorDomain, code=1):' ,
54+ '\tFailed to reset access' ,
55+ '\tOperation not permitted' ,
56+ ] . join ( '\n' ) ,
57+ } ) ;
58+ const normalized = normalizeError ( err ) ;
59+ assert . equal ( normalized . message , 'Operation not permitted' ) ;
60+ } ) ;
61+
62+ test ( 'normalizeError does not alter generic command-failed message without process-exit marker' , ( ) => {
63+ const err = new AppError ( 'COMMAND_FAILED' , 'xcrun exited with code 1' , {
64+ exitCode : 1 ,
65+ stderr : 'Operation not permitted' ,
66+ } ) ;
67+ const normalized = normalizeError ( err ) ;
68+ assert . equal ( normalized . message , 'xcrun exited with code 1' ) ;
69+ } ) ;
70+
71+ test ( 'normalizeError does not alter non-generic command-failed message without exitCode details' , ( ) => {
4472 const err = new AppError ( 'COMMAND_FAILED' , 'Failed to reset access' , {
4573 stderr : 'Operation not permitted' ,
4674 } ) ;
0 commit comments