Skip to content

Commit

Permalink
Showing unittests in Testing extension on win fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Egeberg Hansen committed Sep 20, 2023
1 parent 5c1f2ca commit 5f2c60a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
3 changes: 2 additions & 1 deletion vs-code-extension/Cobol-check/config.properties
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ concatenated.test.suites = Cobol-check/ALLTESTS
# Example:
# gnucobol.compile.options = -std=ibm,-fsingle-quote
#---------------------------------------------------------------------------------------------------------------------
gnucobol.compile.options = null
gnucobol.compile.options = -std=ibm,-fsingle-quote,-fnot-reserved=EVENT

#---------------------------------------------------------------------------------------------------------------------
# Shell scripts and JCL files for executing your test suites.
Expand All @@ -195,3 +195,4 @@ zos.process =
unix.process = linux_gnucobol_run_tests
cobol_run_tests
cobol_run_tests

33 changes: 17 additions & 16 deletions vs-code-extension/client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,13 @@ async function createDirectoryItems( controller:vscode.TestController, uri: vsco
// Create TestFile for each directory

var isInsideTestSuite: boolean = await getIsInsideTestSuiteDirectory1(uri.fsPath)
// const dirArr = vscode.workspace.asRelativePath(uri.fsPath).split(getFileSeperatorForOS(currentPlatform))
const dirArr = vscode.workspace.asRelativePath(uri.fsPath).split("/")
const rootDir = uri.fsPath.replace(vscode.workspace.asRelativePath(uri.fsPath),"")
const rootUri = rootDir+dirArr[0]
const directory = vscode.workspace.asRelativePath(uri.fsPath)
let splitChar = '/'
if(!directory.includes(splitChar))
splitChar = '\\'
const dirArr = directory.split(splitChar);
const rootDir = vscode.workspace.getWorkspaceFolder(uri).uri.fsPath;
const rootUri = rootDir + '/' + dirArr[0]

let tmpUri = vscode.Uri.file(rootUri);
var file :vscode.TestItem = null;
Expand Down Expand Up @@ -272,8 +275,7 @@ async function createDirectoryItems( controller:vscode.TestController, uri: vsco
var tmpData = null

for(var i =1;i<dirArr.length;i++){
// tmpDir = tmpDir + getFileSeperatorForOS(currentPlatform) + dirArr[i]
tmpDir = tmpDir + "/"+ dirArr[i]
tmpDir = tmpDir + '/' + dirArr[i]
const existing = prevFile.children.get(tmpDir);

if(!existing){
Expand Down Expand Up @@ -307,18 +309,20 @@ async function createDirectoryItems( controller:vscode.TestController, uri: vsco
}

function getDirectoryItems( controller:vscode.TestController, uri: vscode.Uri){
// const dirArr = vscode.workspace.asRelativePath(uri.fsPath).split(getFileSeperatorForOS(currentPlatform))
const dirArr = vscode.workspace.asRelativePath(uri.fsPath).split("/")
const rootDir = uri.fsPath.replace(vscode.workspace.asRelativePath(uri.fsPath),"")
const directory = vscode.workspace.asRelativePath(uri.fsPath)
let splitChar = '/';
if(!directory.includes(splitChar))
splitChar = '\\';
const dirArr = directory.split(splitChar);
const rootDir = vscode.workspace.getWorkspaceFolder(uri).uri.fsPath;

var tmpDir = rootDir+dirArr[0];
var tmpDir = rootDir + '/' + dirArr[0];

var existing :vscode.TestItem = controller.items.get(tmpDir);
if(!existing) return null

for(var i = 1; i<dirArr.length ;i++){
// tmpDir = tmpDir +getFileSeperatorForOS(currentPlatform) + dirArr[i];
tmpDir = tmpDir + "/" + dirArr[i];
tmpDir = tmpDir + '/' + dirArr[i];
existing = existing.children.get(tmpDir);
if(!existing) return null
}
Expand Down Expand Up @@ -405,7 +409,4 @@ function startWatchingWorkspace(controller: vscode.TestController, fileChangedEm

return watcher;
});
}



}
5 changes: 4 additions & 1 deletion vs-code-extension/client/src/services/CobolCheckLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ export function getFileName(path : string, includeExtension : boolean) : string{
export function getCutName(path : string) : string{

// const name = path.split(getFileSeperatorForOS(currentPlatform)).pop()
const name = path.split("/").pop()
let splitChar = '/';
if(!path.includes(splitChar))
splitChar = '\\'
const name = path.split(splitChar).pop()
if(!name.endsWith(".cut")) return null
return name;
}
Expand Down
5 changes: 3 additions & 2 deletions vs-code-extension/client/src/services/TestTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ export class TestFile {
item.error = undefined;
this.updateFromContents(controller, content, item, item.children.size);

}else{
}
else {
for (const nestedItem of item.children) {
const data = testData.get(nestedItem[1]);
if(data instanceof TestFile){
await this.updateFromDisk(controller,nestedItem[1] )
}
}
}
}
} catch (e) {
item.error = (e as Error).stack;
}
Expand Down
2 changes: 1 addition & 1 deletion vs-code-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"Snippets"
],
"description": "Extension for running unit tests in Cobol",
"version": "0.4.1",
"version": "0.4.2",
"icon": "images/cobol-check-logo-small.png",
"engines": {
"vscode": "^1.46.0"
Expand Down

0 comments on commit 5f2c60a

Please sign in to comment.