Skip to content

Commit 4934adc

Browse files
committed
test: add unittest for relative path resolution
1 parent 5788da7 commit 4934adc

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

test/tools.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as path from 'path';
22
import * as assert from 'assert';
3-
import { shellTask, spawnAsPromise } from '../src/lib/tools';
3+
import { Uri } from 'vscode';
4+
import { shellTask, spawnAsPromise, pathRelToAbs } from '../src/lib/tools';
45

56
suite('Tools tests', () => {
67
test('shellTask returns correct output', async () => {
@@ -49,4 +50,15 @@ suite('Tools tests', () => {
4950
assert.strictEqual(stdout, 'Hello World!');
5051
assert.strictEqual(stderr, 'Errors');
5152
});
53+
54+
test('Resolve local paths: default workspace', () => {
55+
const absPath = pathRelToAbs('./sample.f90');
56+
assert.strictEqual(absPath, path.resolve(__dirname, '../../test/fortran/sample.f90'));
57+
});
58+
59+
test('Resolve local paths: workspace selection', () => {
60+
const root = Uri.parse(path.resolve(__dirname, '../../test/fortran'));
61+
const absPath = pathRelToAbs('./sample.f90', root);
62+
assert.strictEqual(absPath, path.resolve(__dirname, '../../test/fortran/sample.f90'));
63+
});
5264
});

0 commit comments

Comments
 (0)