forked from PowerShell/vscode-powershell
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests to verify platform module behavior
- Loading branch information
Showing
5 changed files
with
162 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/*--------------------------------------------------------- | ||
* Copyright (C) Microsoft Corporation. All rights reserved. | ||
*--------------------------------------------------------*/ | ||
|
||
import * as assert from 'assert'; | ||
import * as vscode from 'vscode'; | ||
import * as platform from '../src/platform'; | ||
|
||
function checkDefaultPowerShellPath(platformDetails, expectedPath) { | ||
test("returns correct default path", () => { | ||
assert.equal( | ||
platform.getDefaultPowerShellPath(platformDetails), | ||
expectedPath); | ||
}); | ||
} | ||
|
||
function checkAvailableWindowsPowerShellPaths( | ||
platformDetails: platform.PlatformDetails, | ||
expectedPaths: platform.PowerShellExeDetails[]) { | ||
test("correctly enumerates available Windows PowerShell paths", () => { | ||
|
||
// The system may return PowerShell Core paths so only | ||
// enumerate the first list items. | ||
let enumeratedPaths = platform.getAvailablePowerShellExes(platformDetails); | ||
for (var i; i < expectedPaths.length; i++) { | ||
assert.equal(enumeratedPaths[i], expectedPaths[i]); | ||
} | ||
}); | ||
} | ||
|
||
function checkFixedWindowsPowerShellpath(platformDetails, inputPath, expectedPath) { | ||
test("fixes incorrect Windows PowerShell Sys* path", () => { | ||
assert.equal( | ||
platform.fixWindowsPowerShellPath(inputPath, platformDetails), | ||
expectedPath); | ||
}); | ||
} | ||
|
||
suite("Platform module", () => { | ||
|
||
suite("64-bit Windows, 64-bit VS Code", () => { | ||
let platformDetails: platform.PlatformDetails = { | ||
operatingSystem: platform.OperatingSystem.Windows, | ||
isOS64Bit: true, | ||
isProcess64Bit: true | ||
}; | ||
|
||
checkDefaultPowerShellPath( | ||
platformDetails, | ||
platform.System32PowerShellPath); | ||
|
||
checkAvailableWindowsPowerShellPaths( | ||
platformDetails, | ||
[ | ||
{ | ||
versionName: platform.WindowsPowerShell64BitLabel, | ||
exePath: platform.System32PowerShellPath | ||
}, | ||
{ | ||
versionName: platform.WindowsPowerShell32BitLabel, | ||
exePath: platform.SysWow64PowerShellPath | ||
} | ||
]); | ||
|
||
checkFixedWindowsPowerShellpath( | ||
platformDetails, | ||
platform.SysnativePowerShellPath, | ||
platform.System32PowerShellPath); | ||
}); | ||
|
||
suite("64-bit Windows, 32-bit VS Code", () => { | ||
let platformDetails: platform.PlatformDetails = { | ||
operatingSystem: platform.OperatingSystem.Windows, | ||
isOS64Bit: true, | ||
isProcess64Bit: false | ||
}; | ||
|
||
checkDefaultPowerShellPath( | ||
platformDetails, | ||
platform.SysnativePowerShellPath); | ||
|
||
checkAvailableWindowsPowerShellPaths( | ||
platformDetails, | ||
[ | ||
{ | ||
versionName: platform.WindowsPowerShell64BitLabel, | ||
exePath: platform.SysnativePowerShellPath | ||
}, | ||
{ | ||
versionName: platform.WindowsPowerShell32BitLabel, | ||
exePath: platform.System32PowerShellPath | ||
} | ||
]); | ||
|
||
checkFixedWindowsPowerShellpath( | ||
platformDetails, | ||
platform.SysWow64PowerShellPath, | ||
platform.System32PowerShellPath); | ||
}); | ||
|
||
suite("32-bit Windows, 32-bit VS Code", () => { | ||
let platformDetails: platform.PlatformDetails = { | ||
operatingSystem: platform.OperatingSystem.Windows, | ||
isOS64Bit: false, | ||
isProcess64Bit: false | ||
}; | ||
|
||
checkDefaultPowerShellPath( | ||
platformDetails, | ||
platform.System32PowerShellPath); | ||
|
||
checkAvailableWindowsPowerShellPaths( | ||
platformDetails, | ||
[ | ||
{ | ||
versionName: platform.WindowsPowerShell32BitLabel, | ||
exePath: platform.System32PowerShellPath | ||
} | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters