@@ -44,7 +44,7 @@ interface ITestPlatform {
44
44
name : string ;
45
45
platformDetails : platform . IPlatformDetails ;
46
46
filesystem : FileSystem . DirectoryItems ;
47
- environmentVars ? : Record < string , string > ;
47
+ environmentVars : Record < string , string > ;
48
48
}
49
49
50
50
/**
@@ -442,6 +442,7 @@ if (process.platform === "win32") {
442
442
isOS64Bit : true ,
443
443
isProcess64Bit : true ,
444
444
} ,
445
+ environmentVars : { } ,
445
446
expectedPowerShellSequence : [
446
447
{
447
448
exePath : "/usr/bin/pwsh" ,
@@ -482,6 +483,7 @@ if (process.platform === "win32") {
482
483
isOS64Bit : true ,
483
484
isProcess64Bit : true ,
484
485
} ,
486
+ environmentVars : { } ,
485
487
expectedPowerShellSequence : [
486
488
{
487
489
exePath : "/usr/local/bin/pwsh" ,
@@ -508,6 +510,7 @@ if (process.platform === "win32") {
508
510
isOS64Bit : true ,
509
511
isProcess64Bit : true ,
510
512
} ,
513
+ environmentVars : { } ,
511
514
expectedPowerShellSequence : [
512
515
{
513
516
exePath : "/usr/bin/pwsh" ,
@@ -528,6 +531,7 @@ if (process.platform === "win32") {
528
531
isOS64Bit : true ,
529
532
isProcess64Bit : true ,
530
533
} ,
534
+ environmentVars : { } ,
531
535
expectedPowerShellSequence : [
532
536
{
533
537
exePath : "/snap/bin/pwsh" ,
@@ -548,6 +552,7 @@ if (process.platform === "win32") {
548
552
isOS64Bit : true ,
549
553
isProcess64Bit : true ,
550
554
} ,
555
+ environmentVars : { } ,
551
556
expectedPowerShellSequence : [
552
557
{
553
558
exePath : "/usr/local/bin/pwsh" ,
@@ -620,6 +625,7 @@ const errorTestCases: ITestPlatform[] = [
620
625
isOS64Bit : true ,
621
626
isProcess64Bit : true ,
622
627
} ,
628
+ environmentVars : { } ,
623
629
filesystem : { } ,
624
630
} ,
625
631
{
@@ -629,17 +635,16 @@ const errorTestCases: ITestPlatform[] = [
629
635
isOS64Bit : true ,
630
636
isProcess64Bit : true ,
631
637
} ,
638
+ environmentVars : { } ,
632
639
filesystem : { } ,
633
640
} ,
634
641
] ;
635
642
636
643
function setupTestEnvironment ( testPlatform : ITestPlatform ) {
637
644
mockFS ( testPlatform . filesystem ) ;
638
645
639
- if ( testPlatform . environmentVars ) {
640
- for ( const envVar of Object . keys ( testPlatform . environmentVars ) ) {
641
- sinon . stub ( process . env , envVar ) . value ( testPlatform . environmentVars [ envVar ] ) ;
642
- }
646
+ for ( const envVar of Object . keys ( testPlatform . environmentVars ) ) {
647
+ sinon . stub ( process . env , envVar ) . value ( testPlatform . environmentVars [ envVar ] ) ;
643
648
}
644
649
}
645
650
@@ -712,9 +717,9 @@ describe("Platform module", function () {
712
717
const defaultPowerShell = await powerShellExeFinder . getFirstAvailablePowerShellInstallation ( ) ;
713
718
const expectedPowerShell = testPlatform . expectedPowerShellSequence [ 0 ] ;
714
719
715
- assert . strictEqual ( defaultPowerShell . exePath , expectedPowerShell . exePath ) ;
716
- assert . strictEqual ( defaultPowerShell . displayName , expectedPowerShell . displayName ) ;
717
- assert . strictEqual ( defaultPowerShell . supportsProperArguments , expectedPowerShell . supportsProperArguments ) ;
720
+ assert . strictEqual ( defaultPowerShell . exePath , expectedPowerShell ! . exePath ) ;
721
+ assert . strictEqual ( defaultPowerShell . displayName , expectedPowerShell ! . displayName ) ;
722
+ assert . strictEqual ( defaultPowerShell . supportsProperArguments , expectedPowerShell ! . supportsProperArguments ) ;
718
723
} ) ;
719
724
}
720
725
@@ -748,9 +753,9 @@ describe("Platform module", function () {
748
753
const foundPowerShell = foundPowerShells [ i ] ;
749
754
const expectedPowerShell = testPlatform . expectedPowerShellSequence [ i ] ;
750
755
751
- assert . strictEqual ( foundPowerShell && foundPowerShell . exePath , expectedPowerShell . exePath ) ;
752
- assert . strictEqual ( foundPowerShell && foundPowerShell . displayName , expectedPowerShell . displayName ) ;
753
- assert . strictEqual ( foundPowerShell && foundPowerShell . supportsProperArguments , expectedPowerShell . supportsProperArguments ) ;
756
+ assert . strictEqual ( foundPowerShell && foundPowerShell . exePath , expectedPowerShell ! . exePath ) ;
757
+ assert . strictEqual ( foundPowerShell && foundPowerShell . displayName , expectedPowerShell ! . displayName ) ;
758
+ assert . strictEqual ( foundPowerShell && foundPowerShell . supportsProperArguments , expectedPowerShell ! . supportsProperArguments ) ;
754
759
}
755
760
756
761
assert . strictEqual (
@@ -786,7 +791,7 @@ describe("Platform module", function () {
786
791
787
792
function getWinPSPath ( systemDir : string ) {
788
793
return path . join (
789
- testPlatform . environmentVars ! . windir ,
794
+ testPlatform . environmentVars . windir ! ,
790
795
systemDir ,
791
796
"WindowsPowerShell" ,
792
797
"v1.0" ,
0 commit comments