Skip to content

Commit

Permalink
refactor: URI representation
Browse files Browse the repository at this point in the history
  • Loading branch information
jirimosinger authored Jun 3, 2022
1 parent 2a7f8cb commit 1f664c2
Show file tree
Hide file tree
Showing 132 changed files with 2,909 additions and 1,635 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: cd build && cmake --build . --parallel --config Release
- name: Server Test
shell: cmd
run: cd build\bin && library_test.exe && server_test.exe
run: cd build\bin && library_test.exe && server_test.exe && hlasm_utils_test.exe
- name: Actions artifact
uses: actions/upload-artifact@v1
with:
Expand All @@ -68,7 +68,7 @@ jobs:
- name: Build
run: cd build && cmake --build .
- name: Server Test
run: cd build/bin && ./server_test && ./library_test
run: cd build/bin && ./server_test && ./library_test && ./hlasm_utils_test
- name: Actions artifact
uses: actions/upload-artifact@v1
with:
Expand All @@ -94,7 +94,7 @@ jobs:
- name: Build
run: cd build && cmake --build .
- name: Server Test
run: cd build/bin && node --experimental-wasm-threads --experimental-wasm-bulk-memory ./server_test.js && node --experimental-wasm-threads --experimental-wasm-bulk-memory ./library_test.js
run: cd build/bin && node --experimental-wasm-threads --experimental-wasm-bulk-memory ./server_test.js && node --experimental-wasm-threads --experimental-wasm-bulk-memory ./library_test.js && node --experimental-wasm-threads --experimental-wasm-bulk-memory ./hlasm_utils_test.js
- name: Actions artifact
uses: actions/upload-artifact@v2
with:
Expand All @@ -121,7 +121,7 @@ jobs:
- name: Build
run: cd build && cmake --build . -- -v
- name: Server Test
run: cd build/bin && ./server_test && ./library_test
run: cd build/bin && ./server_test && ./library_test && ./hlasm_utils_test
- name: Actions artifact
uses: actions/upload-artifact@v1
with:
Expand Down Expand Up @@ -258,7 +258,7 @@ jobs:
- name: Build
run: chown `id -u`:`id -g` ./clients/vscode-hlasmplugin && cd build && cmake --build .
- name: Server Test
run: cd build/bin && ./server_test && ./library_test
run: cd build/bin && ./server_test && ./library_test && ./hlasm_utils_test
- name: Get VSIX filename
run: echo VSIX_FILENAME=$(ls build/bin/*.vsix) >> $GITHUB_ENV
- name: Get version
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Build
run: cd build && cmake --build .
- name: Test
run: cd build/bin && ./server_test && ./library_test
run: cd build/bin && ./server_test && ./library_test && ./hlasm_utils_test

clang-tsan:
name: Clang TSAN
Expand All @@ -61,7 +61,7 @@ jobs:
- name: Build
run: cd build && cmake --build .
- name: Test
run: cd build/bin && ./server_test && ./library_test
run: cd build/bin && ./server_test && ./library_test && ./hlasm_utils_test

clang-format-check:
name: Code format
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/Sonarcloud-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ jobs:
cd build/bin
LLVM_PROFILE_FILE="library.rawprof" ./library_test
LLVM_PROFILE_FILE="server.rawprof" ./server_test
LLVM_PROFILE_FILE="utils.rawprof" ./hlasm_utils_test
- name: Extension Test
uses: GabrielBB/xvfb-action@v1.0
with:
run: npm --prefix clients/vscode-hlasmplugin test
- name: Merge raw profiles
run: cd build/bin && llvm-profdata-12 merge -o hlasm_profile library.rawprof server.rawprof
run: cd build/bin && llvm-profdata-12 merge -o hlasm_profile library.rawprof server.rawprof utils.rawprof
- name: Generate lcov coverage
run: cd build/bin && llvm-cov-12 show -instr-profile hlasm_profile library_test -object server_test > ../coverage.txt
run: cd build/bin && llvm-cov-12 show -instr-profile hlasm_profile library_test -object server_test -object hlasm_utils_test > ../coverage.txt
- name: Pull request event info
if: github.event_name == 'pull_request'
run: |
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/Sonarcloud-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,11 @@ jobs:
sonar-scanner
-Dsonar.projectKey=$(echo "$GITHUB_REPOSITORY" | tr "/" "_")
-Dsonar.organization=$(echo "$GITHUB_REPOSITORY_OWNER" | tr "[:upper:]" "[:lower:]")
-Dsonar.sources=benchmark,clients/vscode-hlasmplugin/src/,language_server/src,parser_library/src,parser_library/include,build/generated_parser/
-Dsonar.tests=parser_library/test,language_server/test,clients/vscode-hlasmplugin/src/test
-Dsonar.sources=benchmark,clients/vscode-hlasmplugin/src/,language_server/src,parser_library/src,parser_library/include,build/generated_parser/,utils/src,utils/include
-Dsonar.tests=parser_library/test,language_server/test,clients/vscode-hlasmplugin/src/test,utils/test
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.login=${{ secrets.SONAR_TOKEN }}
-Dsonar.cfamily.build-wrapper-output=build/bw-output
-Dsonar.cfamily.threads=4
-Dsonar.cfamily.llvm-cov.reportPath=build/coverage.txt
-Dsonar.cfamily.cache.enabled=false
-Dsonar.javascript.lcov.reportPaths=clients/vscode-hlasmplugin/coverage/lcov.info
Expand Down
4 changes: 2 additions & 2 deletions benchmark/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#include "config/pgm_conf.h"
#include "diagnostic_counter.h"
#include "nlohmann/json.hpp"
#include "utils/utf8text.h"
#include "workspace_manager.h"
#include "workspaces/file_impl.h"

/*
* The benchmark is used to evaluate multiple aspects about the performance and accuracy of the parse library.
Expand Down Expand Up @@ -98,7 +98,7 @@ json parse_one_file(const std::string& source_file,
s.program_count++;
// program's contents
auto content = std::string((std::istreambuf_iterator<char>(in)), (std::istreambuf_iterator<char>()));
content = hlasm_plugin::parser_library::workspaces::file_impl::replace_non_utf8_chars(content);
content = hlasm_plugin::utils::replace_non_utf8_chars(content);

// new workspace manager
hlasm_plugin::parser_library::workspace_manager ws;
Expand Down
1 change: 1 addition & 0 deletions clients/vscode-hlasmplugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- The language server may crash when a complex expression is used as a variable symbol index
- References to CA variables in strings are not reported
- Structured macro variables were not forwarded correctly when a dot separator was used in the macro operand
- URIs and paths are now represented by a designated data type
- Return correct variable type for values provided in the macro's name field
- Revise machine instructions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ suite('Completion List Test Suite', () => {
});

suiteTeardown(async function () {
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
await helper.closeAllEditors();
});

// test completion list for instructions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import * as path from 'path';
import { HLASMConfigurationProvider, getCurrentProgramName } from '../../debugProvider';
import { DebugConfigurationMock } from '../mocks';

suite('Debug Test Suite', () => {
suite('Debug Provider Test Suite', () => {

test('Debug Configuration Provider test', () => {
const debugProvider = new HLASMConfigurationProvider();
Expand Down
102 changes: 102 additions & 0 deletions clients/vscode-hlasmplugin/src/test/suite/debugging.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright (c) 2022 Broadcom.
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Broadcom, Inc. - initial API and implementation
*/

import * as assert from 'assert';
import * as vscode from 'vscode';
import * as path from 'path';
import * as helper from './testHelper';

suite('Debugging Test Suite', () => {
let editor: vscode.TextEditor;
const workspace_file = 'open';

suiteSetup(async function () {
this.timeout(10000);

await helper.showDocument(workspace_file);
editor = helper.get_editor(workspace_file);
});

suiteTeardown(async function () {
this.timeout(10000);

await helper.removeAllBreakpoints();
await helper.closeAllEditors();
});

// debug open code test
test('Debug test', async () => {
const session = await helper.debugStartSession();

// Start by stepping into a macro and checking the file has been accessed
await helper.debugStepOver(4);
await helper.debugStepInto();
assert.ok(vscode.window.activeTextEditor.document.uri.fsPath === path.join(helper.getWorkspacePath(), 'libs', 'mac.asm'), 'Wrong macro file entered');

// Step out and check the file
await helper.debugStepOver(3);
assert.ok(vscode.window.activeTextEditor.document.uri.fsPath === editor.document.uri.fsPath, 'Stepped out to a wrong file');

await helper.debugStop();

}).timeout(20000).slow(10000);

test('Breakpoint test', async () => {
await helper.toggleBreakpoints(path.join('libs', 'mac.asm'), [3]);
await helper.toggleBreakpoints('open', [3, 9]);

await helper.debugStartSession();

// Continue until breakpoint is hit
await helper.debugContinue();
assert.ok(vscode.window.activeTextEditor.document.uri.fsPath === editor.document.uri.fsPath, 'Expected to be in the source file');

// Continue until breakpoint is hit
await helper.debugContinue();
assert.ok(vscode.window.activeTextEditor.document.uri.fsPath == path.join(helper.getWorkspacePath(), 'libs', 'mac.asm'), 'Expected to be in the macro file');

// Continue until breakpoint is hit
await helper.debugContinue();
assert.ok(vscode.window.activeTextEditor.document.uri.fsPath === editor.document.uri.fsPath, 'Expected to be in the source file');

await helper.debugStop();

}).timeout(20000).slow(10000);

// verify that virtual files are working
test('Virtual files', async () => {
await helper.toggleBreakpoints('virtual', [7, 11, 12]);

await helper.debugStartSession();

// Continue until breakpoint is hit
await helper.debugContinue();
assert.ok(vscode.window.activeTextEditor.document.uri.fsPath === path.join(helper.getWorkspacePath(), 'virtual'), 'Expected to be in the source file');

// Step into a virtual file
await helper.debugStepInto();
assert.ok(vscode.window.activeTextEditor.document.uri.path === '/AINSERT:1.hlasm', 'Expected to be in the virtual AINSERT file');

// Continue until breakpoint is hit and enter the virtual file again
await helper.debugContinue();
await helper.debugStepInto();
assert.ok(vscode.window.activeTextEditor.document.uri.path === '/AINSERT:1.hlasm', 'Expected to be in the virtual AINSERT file');

// Continue until breakpoint is hit and enter virtual file through generated macro
await helper.debugContinue();
assert.ok(vscode.window.activeTextEditor.document.uri.fsPath === path.join(helper.getWorkspacePath(), 'virtual'), 'Expected to be in the source file');

await helper.debugStop();
}).timeout(20000).slow(10000);
});
29 changes: 8 additions & 21 deletions clients/vscode-hlasmplugin/src/test/suite/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ suite('Integration Test Suite', () => {
});

const allDiags = await diagnostic_event;
const openDiags = allDiags.find(pair => pair[0].path.endsWith("open"))[1]
assert.ok(allDiags.length === 1, 'Wrong number of diagnosed files');
assert.ok(allDiags[0][0].path === editor.document.uri.path, 'Wrong path');

const openDiags = allDiags[0][1];
assert.ok(openDiags.length == 1 && openDiags[0].code == 'M003', 'Wrong diagnostic');
}).timeout(10000).slow(1000);

Expand Down Expand Up @@ -117,25 +119,10 @@ suite('Integration Test Suite', () => {

// debug open code test
test('Debug test', async () => {
const session_started_event = new Promise<vscode.DebugSession>((resolve) => {
// when the debug session starts
const disposable = vscode.debug.onDidStartDebugSession((session) => {
disposable.dispose();
resolve(session);
});
});
// start debugging
if (!await vscode.debug.startDebugging(vscode.workspace.workspaceFolders[0], 'Macro tracer: current program'))
throw new Error("Failed to start a debugging session");
const session = await helper.debugStartSession();

const session = await session_started_event;

// wait a second to let the debug session complete
await helper.sleep(1000);
// step over once
await vscode.commands.executeCommand('workbench.action.debug.stepOver');
// wait 1 more second to let step over take place
await helper.sleep(1000);
await helper.debugStepOver(1);
// then check for VAR2 variable
const scopesResult = await session.customRequest('scopes', { frameId: 0 });

Expand All @@ -144,12 +131,12 @@ suite('Integration Test Suite', () => {
const reference = scopes.find((scope: { name: string }) => scope.name == 'Locals').variablesReference;
const variablesResult = await session.customRequest('variables', { variablesReference: reference });

await vscode.commands.executeCommand('workbench.action.debug.stop');

const variables = variablesResult.body ? variablesResult.body.variables : variablesResult.variables;

assert.ok(variables.length == 1 && variables[0].value == 'SOMETHING' && variables[0].name == '&VAR2', 'Wrong debug variable &VAR2');
}).timeout(10000).slow(4000);

await helper.debugStop();
}).timeout(20000).slow(10000);

// verify that library patterns are working
test('Test library patterns', async () => {
Expand Down
72 changes: 71 additions & 1 deletion clients/vscode-hlasmplugin/src/test/suite/testHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
import * as assert from 'assert';
import * as vscode from "vscode";
import * as path from 'path';
import { integer } from 'vscode-languageclient';

export function getWorkspacePath(): string {
return vscode.workspace.workspaceFolders[0].uri.fsPath;;
return vscode.workspace.workspaceFolders[0].uri.fsPath;
}

export function get_editor(workspace_file: string): vscode.TextEditor {
Expand All @@ -38,6 +39,75 @@ export async function showDocument(workspace_file: string) {
await vscode.window.showTextDocument(document);
}

export async function closeAllEditors() {
while (vscode.window.activeTextEditor !== undefined) {
await vscode.commands.executeCommand('workbench.action.closeActiveEditor');
await sleep(500);
}
}

export function moveCursor(editor: vscode.TextEditor, position: vscode.Position) {
editor.selection = new vscode.Selection(position, position);
}

export async function toggleBreakpoints(file: string, lines: Array<integer>) {
await showDocument(file);
await sleep(1000);

for (const line of lines) {
moveCursor(get_editor(file), new vscode.Position(line, 0));
await vscode.commands.executeCommand('editor.debug.action.toggleBreakpoint');
}

await sleep(1000);
}

export async function removeAllBreakpoints() {

await vscode.commands.executeCommand('workbench.debug.viewlet.action.removeAllBreakpoints');
await sleep(1000);
}

export async function debugStartSession(): Promise<vscode.DebugSession> {
const session_started_event = new Promise<vscode.DebugSession>((resolve) => {
// when the debug session starts
const disposable = vscode.debug.onDidStartDebugSession((session) => {
disposable.dispose();
resolve(session);
});
});
// start debugging
if (!await vscode.debug.startDebugging(vscode.workspace.workspaceFolders[0], 'Macro tracer: current program'))
throw new Error("Failed to start a debugging session");

const session = await session_started_event;
await sleep(1000);

return session;
}

export async function debugContinue() {
await vscode.commands.executeCommand('workbench.action.debug.continue');
await sleep(1000);
}

export async function debugStepOver(steps: integer) {
while (steps) {
await vscode.commands.executeCommand('workbench.action.debug.stepOver');
await sleep(1000);
steps--;
}
}

export async function debugStepInto() {
await vscode.commands.executeCommand('workbench.action.debug.stepInto');
await sleep(1000);
}

export async function debugStop() {
await vscode.commands.executeCommand('workbench.action.debug.stop');
}

export async function insertString(editor: vscode.TextEditor, position: vscode.Position, str: string): Promise<vscode.Position> {
await editor.edit(edit => {
edit.insert(position, str);
Expand Down
Loading

0 comments on commit 1f664c2

Please sign in to comment.