1
1
import assert from 'assert' ;
2
- import { envHasExec , getSymbols , which } from '../../../src/helpers' ;
2
+ import { envHasExec , findAdaMain , getSymbols , which } from '../../../src/helpers' ;
3
3
import { DocumentSymbol , SymbolKind , Uri , commands , workspace } from 'vscode' ;
4
4
import { rangeToStr } from '../utils' ;
5
5
6
6
suite ( 'which and envHasExec' , function ( ) {
7
7
test ( 'existing' , function ( ) {
8
8
switch ( process . platform ) {
9
9
case 'win32' :
10
- assert ( which ( 'where' ) ?. endsWith ( 'where.exe' ) ) ;
10
+ /* which() relies on PATHEXT which could contain .EXE or .exe.
11
+ Lowercase the comparison for this test.
12
+ */
13
+ assert ( which ( 'where' ) ?. toLowerCase ( ) . endsWith ( 'where.exe' ) ) ;
11
14
assert ( envHasExec ( 'where' ) ) ;
12
15
break ;
13
16
@@ -23,6 +26,27 @@ suite('which and envHasExec', function () {
23
26
} ) ;
24
27
} ) ;
25
28
29
+ suite ( 'findAdaMain' , function ( ) {
30
+ test ( 'Find one main (simple case)' , async function ( ) {
31
+ /* Test that findAdaMain works in a simple case */
32
+ const uri = Uri . joinPath ( workspace . workspaceFolders ! [ 0 ] . uri , 'src' , 'main1.adb' ) ;
33
+ const adaMain = await findAdaMain ( uri . fsPath ) ;
34
+ assert ( adaMain ) ;
35
+ } ) ;
36
+ test ( 'Find one main (case sensitivity)' , async function ( ) {
37
+ /* Test the behavior of findAdaMain with respect to case sensitivity */
38
+ const uri_uppercase = Uri . joinPath ( workspace . workspaceFolders ! [ 0 ] . uri , 'src' , 'MAIN1.ADB' ) ;
39
+ const adaMain_from_uppercase = await findAdaMain ( uri_uppercase . fsPath ) ;
40
+
41
+ /* On Windows we should have a main here, otherwise we should not */
42
+ if ( process . platform === 'win32' ) {
43
+ assert ( adaMain_from_uppercase ) ;
44
+ } else {
45
+ assert ( ! adaMain_from_uppercase ) ;
46
+ }
47
+ } ) ;
48
+ } ) ;
49
+
26
50
suite ( 'getSymbols' , function ( ) {
27
51
let symbols : DocumentSymbol [ ] ;
28
52
0 commit comments