@@ -89,6 +89,14 @@ function test_simple_error_callback(realpath, realpathSync, cb) {
89
89
} ) ) ;
90
90
}
91
91
92
+ function test_simple_error_cb_with_null_options ( realpath , realpathSync , cb ) {
93
+ realpath ( '/this/path/does/not/exist' , null , common . mustCall ( function ( err , s ) {
94
+ assert ( err ) ;
95
+ assert ( ! s ) ;
96
+ cb ( ) ;
97
+ } ) ) ;
98
+ }
99
+
92
100
function test_simple_relative_symlink ( realpath , realpathSync , callback ) {
93
101
console . log ( 'test_simple_relative_symlink' ) ;
94
102
if ( skipSymlinks ) {
@@ -395,6 +403,7 @@ function test_up_multiple(realpath, realpathSync, cb) {
395
403
396
404
assertEqualPath ( realpathSync ( abedabeda ) , abedabeda_real ) ;
397
405
assertEqualPath ( realpathSync ( abedabed ) , abedabed_real ) ;
406
+
398
407
realpath ( abedabeda , function ( er , real ) {
399
408
assert . ifError ( er ) ;
400
409
assertEqualPath ( abedabeda_real , real ) ;
@@ -407,6 +416,48 @@ function test_up_multiple(realpath, realpathSync, cb) {
407
416
}
408
417
409
418
419
+ // Going up with .. multiple times with options = null
420
+ // .
421
+ // `-- a/
422
+ // |-- b/
423
+ // | `-- e -> ..
424
+ // `-- d -> ..
425
+ // realpath(a/b/e/d/a/b/e/d/a) ==> a
426
+ function test_up_multiple_with_null_options ( realpath , realpathSync , cb ) {
427
+ console . error ( 'test_up_multiple' ) ;
428
+ if ( skipSymlinks ) {
429
+ common . printSkipMessage ( 'symlink test (no privs)' ) ;
430
+ return cb ( ) ;
431
+ }
432
+ const tmpdir = require ( '../common/tmpdir' ) ;
433
+ tmpdir . refresh ( ) ;
434
+ fs . mkdirSync ( tmp ( 'a' ) , 0o755 ) ;
435
+ fs . mkdirSync ( tmp ( 'a/b' ) , 0o755 ) ;
436
+ fs . symlinkSync ( '..' , tmp ( 'a/d' ) , 'dir' ) ;
437
+ unlink . push ( tmp ( 'a/d' ) ) ;
438
+ fs . symlinkSync ( '..' , tmp ( 'a/b/e' ) , 'dir' ) ;
439
+ unlink . push ( tmp ( 'a/b/e' ) ) ;
440
+
441
+ const abedabed = tmp ( 'abedabed' . split ( '' ) . join ( '/' ) ) ;
442
+ const abedabed_real = tmp ( '' ) ;
443
+
444
+ const abedabeda = tmp ( 'abedabeda' . split ( '' ) . join ( '/' ) ) ;
445
+ const abedabeda_real = tmp ( 'a' ) ;
446
+
447
+ assertEqualPath ( realpathSync ( abedabeda ) , abedabeda_real ) ;
448
+ assertEqualPath ( realpathSync ( abedabed ) , abedabed_real ) ;
449
+
450
+ realpath ( abedabeda , null , function ( er , real ) {
451
+ assert . ifError ( er ) ;
452
+ assertEqualPath ( abedabeda_real , real ) ;
453
+ realpath ( abedabed , null , function ( er , real ) {
454
+ assert . ifError ( er ) ;
455
+ assertEqualPath ( abedabed_real , real ) ;
456
+ cb ( ) ;
457
+ } ) ;
458
+ } ) ;
459
+ }
460
+
410
461
// Absolute symlinks with children.
411
462
// .
412
463
// `-- a/
@@ -474,10 +525,19 @@ function test_root(realpath, realpathSync, cb) {
474
525
} ) ;
475
526
}
476
527
528
+ function test_root_with_null_options ( realpath , realpathSync , cb ) {
529
+ realpath ( '/' , null , function ( err , result ) {
530
+ assert . ifError ( err ) ;
531
+ assertEqualPath ( root , result ) ;
532
+ cb ( ) ;
533
+ } ) ;
534
+ }
535
+
477
536
// ----------------------------------------------------------------------------
478
537
479
538
const tests = [
480
539
test_simple_error_callback ,
540
+ test_simple_error_cb_with_null_options ,
481
541
test_simple_relative_symlink ,
482
542
test_simple_absolute_symlink ,
483
543
test_deep_relative_file_symlink ,
@@ -491,7 +551,9 @@ const tests = [
491
551
test_upone_actual ,
492
552
test_abs_with_kids ,
493
553
test_up_multiple ,
554
+ test_up_multiple_with_null_options ,
494
555
test_root ,
556
+ test_root_with_null_options
495
557
] ;
496
558
const numtests = tests . length ;
497
559
let testsRun = 0 ;
0 commit comments