Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 28 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"main": "out/extension.js",
"activationEvents": [
"workspaceContains:**/UNITDATA.VCD",
"workspaceContains:**/*.vcm"
"workspaceContains:**/*.vcm",
"workspaceContains:**/*.vcp"
],
"contributes": {
"viewsWelcome": [
Expand Down Expand Up @@ -989,97 +990,97 @@
{
"command": "vectorcastTestExplorer.updateProjectEnvironment",
"group": "vcast.project",
"when": "(testId =~ /^vcast:.*$/ && (testId in vectorcastTestExplorer.vcastUnbuiltEnviroList || testId in vectorcastTestExplorer.vcastEnviroList) && vectorcastTestExplorer.globalProjectIsOpenedChecker) && !config.vectorcastTestExplorer.automaticallyUpdateManageProject"
"when": "(testId =~ /^vcast:.*$/ && (testId in vectorcastTestExplorer.vcastUnbuiltEnviroList || testId in vectorcastTestExplorer.vcastEnviroList) && vectorcastTestExplorer.globalProjectIsOpenedChecker) && !config.vectorcastTestExplorer.automaticallyUpdateManageProject && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.buildProjectEnviro",
"group": "vcast.build",
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastUnbuiltEnviroList"
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastUnbuiltEnviroList && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.getEnvFullReport",
"group": "vcast.build",
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList"
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.buildExecuteIncremental",
"group": "vcast.build",
"when": "vectorcastTestExplorer.globalProjectIsOpenedChecker && ( testId =~ /\\.vcm$/ || testId in vectorcastTestExplorer.globalProjectCompilers || testId in vectorcastTestExplorer.globalProjectTestsuites || (testId =~ /^vcast:.*$/ && ( testId in vectorcastTestExplorer.vcastEnviroList || testId in vectorcastTestExplorer.vcastUnbuiltEnviroList)))"
"when": "vectorcastTestExplorer.globalProjectIsOpenedChecker && ( testId =~ /\\.vcm$/ || testId in vectorcastTestExplorer.globalProjectCompilers || testId in vectorcastTestExplorer.globalProjectTestsuites || (testId =~ /^vcast:.*$/ && ( testId in vectorcastTestExplorer.vcastEnviroList || testId in vectorcastTestExplorer.vcastUnbuiltEnviroList))) && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.rebuildEnviro",
"group": "vcast.build",
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.cleanEnviro",
"group": "vcast.build",
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && vectorcastTestExplorer.globalProjectIsOpenedChecker && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && vectorcastTestExplorer.globalProjectIsOpenedChecker && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.openVCAST",
"group": "vcast.enviroManagement",
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.deleteEnviro",
"group": "vcast.enviroManagement",
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && !vectorcastTestExplorer.globalProjectIsOpenedChecker"
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && !vectorcastTestExplorer.globalProjectIsOpenedChecker && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.deleteEnviroFromProject",
"group": "vcast.enviroManagement",
"when": "testId =~ /^vcast:.*$/ && (testId in vectorcastTestExplorer.vcastUnbuiltEnviroList || testId in vectorcastTestExplorer.vcastEnviroList) && vectorcastTestExplorer.globalProjectIsOpenedChecker"
"when": "testId =~ /^vcast:.*$/ && (testId in vectorcastTestExplorer.vcastUnbuiltEnviroList || testId in vectorcastTestExplorer.vcastEnviroList) && vectorcastTestExplorer.globalProjectIsOpenedChecker && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.removeTestsuite",
"group": "vcast.enviroManagement",
"when": "testId =~ /^vcast:.*$/ && (testId in vectorcastTestExplorer.vcastUnbuiltEnviroList || testId in vectorcastTestExplorer.vcastEnviroList) && vectorcastTestExplorer.globalProjectIsOpenedChecker"
"when": "testId =~ /^vcast:.*$/ && (testId in vectorcastTestExplorer.vcastUnbuiltEnviroList || testId in vectorcastTestExplorer.vcastEnviroList) && vectorcastTestExplorer.globalProjectIsOpenedChecker && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.editTestScript",
"group": "vcast.testScript",
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.createTestScript",
"group": "vcast.testScript",
"when": "testId =~ /^vcast:.*$/ && testId not in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && !(testId =~ /.*coded_tests_driver.*/ )"
"when": "testId =~ /^vcast:.*$/ && testId not in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && !(testId =~ /.*coded_tests_driver.*/ ) && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.editCodedTest",
"group": "vcast.testScript",
"when": "testId =~ /^vcast:.*$/ && testId not in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && testId =~ /.*coded_tests_driver.+/"
"when": "testId =~ /^vcast:.*$/ && testId not in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && testId =~ /.*coded_tests_driver.+/ && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.addCodedTests",
"group": "vcast.testScript",
"when": "testId =~ /^vcast:.*$/ && testId =~ /.*coded_tests_driver$/ && testId not in vectorcastTestExplorer.vcastHasCodedTestsList"
"when": "testId =~ /^vcast:.*$/ && testId =~ /.*coded_tests_driver$/ && testId not in vectorcastTestExplorer.vcastHasCodedTestsList && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.generateCodedTests",
"group": "vcast.testScript",
"when": "testId =~ /^vcast:.*$/ && testId =~ /.*coded_tests_driver$/ && testId not in vectorcastTestExplorer.vcastHasCodedTestsList"
"when": "testId =~ /^vcast:.*$/ && testId =~ /.*coded_tests_driver$/ && testId not in vectorcastTestExplorer.vcastHasCodedTestsList && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.removeCodedTests",
"group": "vcast.testScript",
"when": "testId =~ /^vcast:.*$/ && testId =~ /.*coded_tests_driver$/ && testId in vectorcastTestExplorer.vcastHasCodedTestsList"
"when": "testId =~ /^vcast:.*$/ && testId =~ /.*coded_tests_driver$/ && testId in vectorcastTestExplorer.vcastHasCodedTestsList && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.insertBasisPathTests",
"group": "vcast.testGeneration",
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /^.*<<COMPOUND>>.*$/) && !(testId =~ /^.*<<INIT>>.*$/) && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /^.*<<COMPOUND>>.*$/) && !(testId =~ /^.*<<INIT>>.*$/) && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.insertATGTests",
"group": "vcast.testGeneration",
"when": "testId =~ /^vcast:.*$/ && vectorcastTestExplorer.atgAvailable && !(testId =~ /^.*<<COMPOUND>>.*$/) && !(testId =~ /^.*<<INIT>>.*$/) && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
"when": "testId =~ /^vcast:.*$/ && vectorcastTestExplorer.atgAvailable && !(testId =~ /^.*<<COMPOUND>>.*$/) && !(testId =~ /^.*<<INIT>>.*$/) && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.deleteTest",
"group": "vcast.delete",
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.deleteTestsuite",
Expand All @@ -1094,37 +1095,37 @@
{
"command": "vectorcastTestExplorer.importRequirementsFromGateway",
"group": "vcast@8",
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && vectorcastTestExplorer.reqs2xFeatureEnabled && testId not in vectorcastTestExplorer.vcastRequirementsAvailable && vectorcastTestExplorer.generateRequirementsEnabled"
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && vectorcastTestExplorer.reqs2xFeatureEnabled && testId not in vectorcastTestExplorer.vcastRequirementsAvailable && vectorcastTestExplorer.generateRequirementsEnabled && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.generateRequirements",
"group": "vcast@8",
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && vectorcastTestExplorer.reqs2xFeatureEnabled && testId not in vectorcastTestExplorer.vcastRequirementsAvailable && vectorcastTestExplorer.generateRequirementsEnabled"
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && vectorcastTestExplorer.reqs2xFeatureEnabled && testId not in vectorcastTestExplorer.vcastRequirementsAvailable && vectorcastTestExplorer.generateRequirementsEnabled && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.showRequirements",
"group": "vcast@9",
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && vectorcastTestExplorer.reqs2xFeatureEnabled && testId in vectorcastTestExplorer.vcastRequirementsAvailable && vectorcastTestExplorer.generateRequirementsEnabled"
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && vectorcastTestExplorer.reqs2xFeatureEnabled && testId in vectorcastTestExplorer.vcastRequirementsAvailable && vectorcastTestExplorer.generateRequirementsEnabled && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.generateTestsFromRequirements",
"group": "vcast@10",
"when": "testId =~ /^vcast:.*$/ && vectorcastTestExplorer.reqs2xFeatureEnabled"
"when": "testId =~ /^vcast:.*$/ && vectorcastTestExplorer.reqs2xFeatureEnabled && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.removeRequirements",
"group": "vcast@9",
"when": "testId =~ /^vcast:.*$/ && vectorcastTestExplorer.reqs2xFeatureEnabled && testId in vectorcastTestExplorer.vcastRequirementsAvailable && vectorcastTestExplorer.generateRequirementsEnabled"
"when": "testId =~ /^vcast:.*$/ && vectorcastTestExplorer.reqs2xFeatureEnabled && testId in vectorcastTestExplorer.vcastRequirementsAvailable && vectorcastTestExplorer.generateRequirementsEnabled && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.populateRequirementsGateway",
"group": "vcast@9",
"when": "testId =~ /^vcast:.*$/ && vectorcastTestExplorer.reqs2xFeatureEnabled && testId in vectorcastTestExplorer.vcastRequirementsAvailable && vectorcastTestExplorer.generateRequirementsEnabled"
"when": "testId =~ /^vcast:.*$/ && vectorcastTestExplorer.reqs2xFeatureEnabled && testId in vectorcastTestExplorer.vcastRequirementsAvailable && vectorcastTestExplorer.generateRequirementsEnabled && !(testId =~ /\\.vcp$/)"
},
{
"command": "vectorcastTestExplorer.viewResults",
"group": "vcast.results",
"when": "testId =~ /^vcast:.*$/ && testId not in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
"when": "testId =~ /^vcast:.*$/ && testId not in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && !(testId =~ /\\.vcp$/)"
}
]
},
Expand Down
23 changes: 17 additions & 6 deletions python/mcdcReport.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import argparse
import pathlib
import sys
import os

from vector.apps.DataAPI.unit_test_api import UnitTestApi
from vector.apps.DataAPI.cover_api import CoverApi

from pythonUtilities import monkeypatch_custom_css
from pythonUtilities import monkeypatch_custom_css, get_api_context


def parse_args():
Expand Down Expand Up @@ -32,8 +34,13 @@ def parse_args():
def get_mcdc_lines(env):
all_lines_with_data = {}

with UnitTestApi(env) as api:
for unit in api.Unit.filter():
ApiClass, entity_attr = get_api_context(env)

with ApiClass(env) as api:
# Access the API property (api.Unit or api.File) dynamically
source_modules = getattr(api, entity_attr)

for unit in source_modules.filter():
for mcdc_dec in unit.cover_data.mcdc_decisions:
if not mcdc_dec.num_conditions:
continue
Expand Down Expand Up @@ -63,11 +70,15 @@ def generate_mcdc_report(env, unit_filter, line_filter, output):
# Patch get_option to use our CSS without setting the CFG option
monkeypatch_custom_css(custom_css)

# Open-up the unit test API
with UnitTestApi(env) as api:
# We have to check whether env is the path to a "Normal" env or to a "Cover Project"
# and therefore use a different API
ApiClass, entity_attr = get_api_context(env)

with ApiClass(env) as api:
source_modules = getattr(api, entity_attr)
# Find and check for our unit
unit_found = False
for unit in api.Unit.filter(name=unit_filter):
for unit in source_modules.filter(name=unit_filter):
unit_found = True

# Spin through all MCDC decisions looking for the one on our line
Expand Down
21 changes: 21 additions & 0 deletions python/pythonUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import re
from vector.apps.DataAPI.configuration import EnvironmentMixin

from vector.apps.DataAPI.unit_test_api import UnitTestApi
from vector.apps.DataAPI.cover_api import CoverApi


# This contains the clicast command that was used to start the data server
globalClicastCommand = ""

Expand Down Expand Up @@ -233,3 +237,20 @@ def repl(match):
return match.group(0)

return env_var_pattern.sub(repl, path)


def get_api_context(env_path):
"""
Determines if the environment is a Cover Project or a standard Unit Test env.
And returns what API we need to use.
"""
clean_path = os.path.normpath(env_path)

# Check if it's a Cover project by checking if there is a vcp file
# with the same name on the same level like the build dir (env_path)
vcp_file = clean_path + ".vcp"
if os.path.isfile(vcp_file):
return CoverApi, "File"

# If there is no vcp file --> normal env
return UnitTestApi, "Unit"
53 changes: 47 additions & 6 deletions python/vTestInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from vector.apps.DataAPI.manage_api import VCProjectApi
from vector.apps.DataAPI.vcproject_models import EnvironmentType
from vector.apps.DataAPI.unit_test_api import UnitTestApi
from vector.apps.DataAPI.cover_api import CoverApi
from vector.lib.core.system import cd
from vector.enums import COVERAGE_TYPE_TYPE_T

Expand Down Expand Up @@ -720,19 +721,28 @@ def getProjectCompilerData(api):
return compilerList


def find_vce_files(root_dir):
def find_environment_files(root_dir):
"""
Scans the directory tree once and returns two lists:
1. vce_files: Paths to vce files for Unit Test environments
2. vcp_files: Paths to vcp files for Cover Projects
"""
vce_files = []
vcp_files = []

def scan_dir(path):
with os.scandir(path) as entries:
for entry in entries:
if entry.is_file() and entry.name.endswith(".vce"):
vce_files.append(entry.path)
if entry.is_file():
if entry.name.endswith(".vce"):
vce_files.append(entry.path)
elif entry.name.endswith(".vcp"):
vcp_files.append(entry.path)
elif entry.is_dir(follow_symlinks=False):
scan_dir(entry.path)

scan_dir(root_dir)
return vce_files
return vce_files, vcp_files


def processCommandLogic(mode, clicast, pathToUse, testString="", options=""):
Expand Down Expand Up @@ -780,10 +790,14 @@ def processCommandLogic(mode, clicast, pathToUse, testString="", options=""):

elif mode == "getWorkspaceEnviroData":
enviro_list = []
vcp_list = []
errors = []
topLevel = {}
vce_files = find_vce_files(pathToUse)

# Scan directory for both file types
vce_files, vcp_files = find_environment_files(pathToUse)

# Process VCE Files
for vce_path in vce_files:
try:
api = UnitTestApi(vce_path)
Expand All @@ -800,13 +814,40 @@ def processCommandLogic(mode, clicast, pathToUse, testString="", options=""):
"mockingSupport": mocking_support,
}
)

except Exception as err:
errors.append(f"{vce_path}: {str(err)}")

# Process VCP Files
for vcp_path in vcp_files:
try:
api = CoverApi(vcp_path)
test_data = [] # Cover projects do not have test data
unit_data = getUnitData(api)
mocking_support = False # Cover projects do not support mocking
api.close()

vcp_list.append(
{
"vcpPath": normalize_path(vcp_path),
"testData": test_data,
"unitData": unit_data,
"mockingSupport": mocking_support,
}
)
except Exception as err:
errors.append(f"{vcp_path}: {str(err)}")

# Construct Top Level Object
# Defaulting top-level data to the first VCE environment found (if any)
topLevel["testData"] = enviro_list[0]["testData"] if enviro_list else []
topLevel["unitData"] = enviro_list[0]["unitData"] if enviro_list else []

if not topLevel["unitData"] and vcp_list:
topLevel["unitData"] = vcp_list[0]["unitData"]

topLevel["enviro"] = enviro_list
topLevel["vcp"] = vcp_list

if errors:
topLevel["errors"] = errors

Expand Down
Loading
Loading