Skip to content

Commit

Permalink
Add support for compound only tests (#6)
Browse files Browse the repository at this point in the history
### Add support for "compound only" tests
- Add support for TEST.COMPOUND_ONLY in the script editor
- Includ compound only tests in the test tree to allow editing
- Append "[compound only]" to test names in the test explorer tree
- Add logic to skip execution of compound only tests

### Fix a race condition on Load Test Script command
- In some cases, the automatic save of the test script was not complete
by the time clicast was called to load the script.

### Add support for test script option: STRUCT_BASE_CTOR_ADDS_POINTER
- This option is new for VectorCAST 23 sp2

### Fix spelling errors / typos in source code comments
  • Loading branch information
johnpaliotta authored Aug 8, 2023
1 parent e267d35 commit a321244
Show file tree
Hide file tree
Showing 21 changed files with 111 additions and 61 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,20 @@ and will be checked for by the extension in the following order
- The path set in the extension option **Vectorcast Installation Location**
- The path set via the VECTORCAST_DIR environment variable
- The system PATH

## [1.0.3] - 2023-08-07

### Added support for "compound only" tests
- Added support for TEST.COMPOUND_ONLY in the script editor
- Included compound only tests in the test tree to allow editing
- Appended "[compound only]" to test names in the test explorer tree
- Added logic to skip execution of compound only tests

### Fixed a race condition on Load Test Script command
In some cases, the automatic save of the test script was not complete
by the time clicast was called to load the script.

### Added support for test script option: STRUCT_BASE_CTOR_ADDS_POINTER
This option is new for VectorCAST 23 sp2

### Fixed spelling errors / typos in source code comments
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ This extension contributes the following settings:
before building a new environment
- Debugging is only supported for GNU compilers
- LSE features for Class Instances have not yet been implemented
- LSE featrures for TEST.FLOW have not been implemented
- LSE features for TEST.FLOW have not been implemented
- Deleting a test does not remove the TC annotations in the File Explorer pane

## Contributing
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vectorcasttestexplorer",
"displayName": "VectorCAST Test Explorer",
"description": "VectorCAST Test Explorer for VS Code",
"version": "1.0.2",
"version": "1.0.3",
"license": "See License in file: LICENSE",
"repository": {
"type": "git",
Expand Down
16 changes: 8 additions & 8 deletions python/tstUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def processType(type, commandPieces, currentIndex, triggerCharacter):
)

elif typeClassification == "array":
# VS Code gives us the closing ] for freee ...
# VS Code gives us the closing ] for free ...
# so we only need to recurse when we are past this
if len(commandPieces) > currentIndex:
# make sure that the string has an index expression ...
Expand Down Expand Up @@ -295,7 +295,7 @@ def getTestList (api, unitName, functionName):


# choiceKindType should match the VS Code CompletionItemKind type
# Suprisingly there is no "parameter" kind, so I just use Field for parameters
# Surprisingly there is no "parameter" kind, so I just use Field for parameters
class choiceKindType(str, Enum):
Constant='Constant'
Enum='Enum'
Expand Down Expand Up @@ -442,7 +442,7 @@ def processLine(enviroName, line):
It will build the choice list for the "next" field
based on the line the user has entered so far.
To make this simpler, I did not hande all the edge cases,
To make this simpler, I did not handle all the edge cases,
for now I'm using the exception handler.
Input examples:
Expand All @@ -467,18 +467,18 @@ def processLine(enviroName, line):
# Intelligently split the line into its fields
pieces = splitExistingLine(line)

# if the line ended in a delimeter than the last item in the
# if the line ended in a delimiter than the last item in the
# list will be a zero length string, if not it will be a partial
# field so we pop it and add a null string
if len(pieces[-1]) == 0:
triggerCharacter = line[-1]
else:
pieces.pop()
pieces.append("")
# find all delimeters, regex cuz we might have :: in function names.
delimeterList = re.findall(r"(?<!:)[:\.\,](?!:)", line)
# the last delimter is the one we want
triggerCharacter = delimeterList[-1]
# find all delimiters, regex cuz we might have :: in function names.
delimiterList = re.findall(r"(?<!:)[:\.\,](?!:)", line)
# the last delimiter is the one we want
triggerCharacter = delimiterList[-1]

# when we get here, the last element in the list of pieces will always be ""

Expand Down
8 changes: 5 additions & 3 deletions python/vTestInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def setupArgs():
parser.add_argument(
"--path",
required=True,
help="Path to Envionment Directory",
help="Path to Environment Directory",
)

parser.add_argument("--test", help="Test ID")
Expand Down Expand Up @@ -126,6 +126,8 @@ def generateTestInfo(test):
testInfo = dict()
testInfo["testName"] = test.name
testInfo["notes"] = test.notes
# stored as 0 or 1
testInfo["compoundOnly"] = test.for_compound_only
testInfo["time"] = getTime(test.start_time)
testInfo["status"] = textStatus(test.status)
testInfo["passfail"] = getPassFailString(test)
Expand Down Expand Up @@ -180,7 +182,7 @@ def getTestDataVCAST(enviroPath):
functionNode["name"] = function.vcast_name
functionNode["tests"] = list()
for test in function.testcases:
if test.is_csv_map or test.for_compound_only:
if test.is_csv_map:
pass
else:
testInfo = generateTestInfo(test)
Expand Down Expand Up @@ -264,7 +266,7 @@ def getCoverageData(sourceObject):
# line is of type 'class SourceLine'
checksum = sourceObject.checksum

# if iterate_coverrage crashes if the original
# if iterate_coverage crashes if the original
# file path does not exist.
if os.path.exists (sourceObject.path):
for line in sourceObject.iterate_coverage():
Expand Down
2 changes: 1 addition & 1 deletion server/pythonUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function runPythonScript(enviroName: string, paramString: string): any {

// As an alternative to using a server, we call vpython each time we need some data

// NOTE: we cannot use executCommand() here because it is in the client only!
// NOTE: we cannot use executeCommand() here because it is in the client only!
// commandOutput is a buffer: (Uint8Array)
// RUN mode is a single shot mode where we run the python script and communicate with stdin/stdout and
const commandToRun = `${vPythonCommandToUse} ${testEditorScriptPath} CLI ${enviroName} "${paramString}"`;
Expand Down
2 changes: 1 addition & 1 deletion server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ documents.onDidChangeContent((change) => {
connection.sendDiagnostics({ uri: change.document.uri, diagnostics });
});

// This handler gets called whenever "completion" is triggerd by
// This handler gets called whenever "completion" is triggered by
// the characters in the "triggerCharacters" array that onInitialize sets

connection.onCompletion(
Expand Down
6 changes: 4 additions & 2 deletions server/serverUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function getPieceAtColumn(pieces: string[], columnIndex: number) {
let index: number;
let endOfPieceIndex: number = 0;
for (index = 0; index < pieces.length; index++) {
// +1 for the delimeter
// +1 for the delimiter
endOfPieceIndex += pieces[index].length + 1;
if (endOfPieceIndex > columnIndex) {
return {
Expand All @@ -45,7 +45,7 @@ export function completionList(
choiceKind: CompletionItemKind
): CompletionItem[] {
// the format of what comes in here looks like a list of strings
// formated as textValue or textValue@extraInfo
// formatted as textValue or textValue@extraInfo

let i;
let returnList: CompletionItem[] = [];
Expand Down Expand Up @@ -205,6 +205,7 @@ export const testCommandList = [
"END_EXPECTED_USER_CODE",
"IMPORT_FAILURES",
"END_IMPORT_FAILURES",
"COMPOUND_ONLY",
];

export const scriptFeatureList = [
Expand All @@ -219,6 +220,7 @@ export const scriptFeatureList = [
"MULTIPLE_UUT_SUPPORT",
"OVERLOADED_CONST_SUPPORT",
"STANDARD_SPACING_R2",
"STRUCT_BASE_CTOR_ADDS_POINTER",
"STRUCT_DTOR_ADDS_POINTER",
"STRUCT_FIELD_CTOR_ADDS_POINTER",
"STATIC_HEADER_FUNCS_IN_UUTS",
Expand Down
4 changes: 1 addition & 3 deletions server/tstHover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {
getLineFragment,
getLineText,
getPieceAtColumn,
completionList,
convertKind,
} from "./serverUtilities";

import { TextDocuments, CompletionParams } from "vscode-languageserver";
Expand All @@ -30,7 +28,7 @@ export function getHoverString(
const fullLine = getLineText(document, completionData.position.line);

// generate a list of pieces ...
// this regex creates a set of dilimeters that are either . or : but NOT ::
// this regex creates a set of delimiters that are either . or : but NOT ::
const pieces = fullLine.split(/(?<!:)[:\.](?!:)/);

const upperCaseLine: string = fullLine.toUpperCase();
Expand Down
6 changes: 2 additions & 4 deletions server/tstValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const specialSubprogramNames = ["<<INIT>>", "<<COMPOUND>>"];

export function validateTextDocument(textDocument: TextDocument) {
// this function does the error checking for the test script
// and generates diagostics for any issues
// and generates diagnostics for any issues

let diagnosticList: Diagnostic[] = [];

Expand Down Expand Up @@ -188,7 +188,7 @@ export function validateTextDocument(textDocument: TextDocument) {
)
);
}
} else if (command == "SCRIPT_FEATURE") {
} else if (command == "SCRIPT_FEATURE" && pieces.length>2) {
const featureName = pieces[2].trim();
if (scriptFeatureList.indexOf(featureName) < 0) {
diagnosticList.push(
Expand Down Expand Up @@ -232,8 +232,6 @@ export function validateTextDocument(textDocument: TextDocument) {
diagnosticList.push(diagnostic(lineIndex, 0, 1000, message));
}

// TBD The lsp example implemented some .relatedInfomration
// for the diagnostic object here ???
} // end for loop

return diagnosticList;
Expand Down
6 changes: 3 additions & 3 deletions src-common/commonUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ export function getEnviroNameFromScript(
return enviroName;
}

// Initially I thought I needed to get multiple option, so I implmented this way to make that easy
// but it turns out that I did not really need the SOURCE_EXTENSION ... but I am leaving this as an exmaple
// Initially I thought I needed to get multiple option, so I implemented this way to make that easy
// but it turns out that I did not really need the SOURCE_EXTENSION ... but I am leaving this as an example

export interface cfgOptionType {
C_DEBUG_CMD: string;
SOURCE_EXTENSION: string;
}

// we keeep a cache so we don't have to do the parse if
// we keep a cache so we don't have to do the parse if
// we've seen this path before
var cfgOptionCache: Map<string, cfgOptionType> = new Map();

Expand Down
1 change: 0 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import {
addSettingsFileFilter,
checkIfInstallationIsOK,
executeClicastCommand,
initializeChecksumCommand,
initializeInstallerFiles,
vcastCommandtoUse,
} from "./utilities";
Expand Down
4 changes: 2 additions & 2 deletions src/fileDecorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class TreeFileDecorationProvider
// this function will replace the existing decorations
await this.removeAllCoverageDecorations();

// convienece function to update a list of files
// convenience function to update a list of files
for (let filePath of fileList) {
this.addCoverageDecorationToFile(filePath);
}
Expand All @@ -81,7 +81,7 @@ export class TreeFileDecorationProvider

async removeAllCoverageDecorations(): Promise<void> {
// this will spin through the list of decorated files and remove them
// create a copy of the list so we can destoy the real list was we process each item
// create a copy of the list so we can destroy the real list was we process each item
const listCopy = [...this.filesWithCoverage];
for (let index = 0; index < listCopy.length; index++) {
// remove the filePath from the real list
Expand Down
4 changes: 2 additions & 2 deletions src/helper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from "vscode";

// some functions that are used across functional areas of the extentions
// some functions that are used across functional areas of the extensions

import { updateDisplayedCoverage } from "./coverage";
import {
Expand All @@ -22,7 +22,7 @@ export function showSettings() {
export function updateDataForEnvironment(enviroPath: string) {
// this function does all of the "common" work when an environment is updated
// sources of environment update are things like:
// - opening the environent in the vcast gui
// - opening the environment in the vcast gui
// - building a new environment
// - ...

Expand Down
7 changes: 5 additions & 2 deletions src/testData.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const compoundOnlyString = " [compound only]";

export interface testNodeType {
enviroPath: string; // the full path including the enviro directory
enviroName: string; // the directory name
Expand All @@ -6,7 +8,7 @@ export interface testNodeType {
testName: string;
}
// this is a lookup table for the nodes in the test tree
// the key is the nodeID, the data is an testNodeDataType
// the key is the nodeID, the data is an testNodeType
var testNodeCache = new Map();

export function createTestNodeinCache(
Expand Down Expand Up @@ -66,5 +68,6 @@ export function getFunctionNameFromID(nodeID: string): string {
}

export function getTestNameFromID(nodeID: string): string {
return testNodeCache.get(nodeID).testName;
const testName = testNodeCache.get(nodeID).testName;
return testName.replace (compoundOnlyString,"");
}
Loading

0 comments on commit a321244

Please sign in to comment.