Skip to content

Commit 17845a0

Browse files
committed
test: added resolve path unittest
1 parent 4934adc commit 17845a0

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/lib/tools.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ export function sortedWorkspaceFolders(): string[] | undefined {
7777
* @returns outer most workspace folder
7878
*/
7979
export function getOuterMostWorkspaceFolder(
80-
folder: vscode.WorkspaceFolder
81-
): vscode.WorkspaceFolder {
80+
folder: vscode.WorkspaceFolder | undefined
81+
): vscode.WorkspaceFolder | undefined {
82+
if (folder === undefined) return undefined;
8283
const sorted = sortedWorkspaceFolders();
8384
for (const element of sorted) {
8485
let uri = folder.uri.toString();

test/tools.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ suite('Tools tests', () => {
5151
assert.strictEqual(stderr, 'Errors');
5252
});
5353

54-
test('Resolve local paths: default workspace', () => {
55-
const absPath = pathRelToAbs('./sample.f90');
56-
assert.strictEqual(absPath, path.resolve(__dirname, '../../test/fortran/sample.f90'));
54+
test('Resolve local paths: undefined', () => {
55+
const root = Uri.parse('/home/user/project');
56+
const absPath = pathRelToAbs('./sample.f90', root);
57+
console.log(absPath, root);
58+
assert.strictEqual(absPath, undefined);
5759
});
5860

5961
test('Resolve local paths: workspace selection', () => {

0 commit comments

Comments
 (0)