Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test coverage attribution #228

Merged
merged 8 commits into from
Jan 18, 2025
Merged
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
32 changes: 18 additions & 14 deletions .circleci/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,26 @@ run_lint () {
local ESLINT_FILE=artifacts/eslint_report
mkdir -p artifacts

if ! npm run lint -- -f unix -o "${ESLINT_FILE}.txt"; then
echo "eslint plain failed"
fi
if ! npm run lint -- -f json -o "${ESLINT_FILE}.json"; then
## sonarqube report
echo "eslint json failed"
fi
ESLINT_RETURN_CODE=0
npm run lint -- -f json -o "${ESLINT_FILE}.json.tmp" || ESLINT_RETURN_CODE=$?
echo "eslint returned code=$ESLINT_RETURN_CODE"

jq '.' < "${ESLINT_FILE}.json.tmp" > "${ESLINT_FILE}.json"
sed -i 's|/home/circleci/project/|/root/project/|g' "${ESLINT_FILE}.json"
if [ "$(find artifacts -name "eslint_report.json" | wc -l)" != "0" ]; then
jq '.' < "${ESLINT_FILE}.json" > "${ESLINT_FILE}_pretty.json"
else
echo "ERROR: ${ESLINT_FILE}.json not found"
exit 1
fi
echo 'eslint successful'

if [ ! -f "${ESLINT_FILE}.json" ]; then
echo "ERROR: ${ESLINT_FILE}.json not found"
exit 1
fi

MESSAGE_COUNT=$(jq '[.[] | .messages | length] | add' < ${ESLINT_FILE}.json.tmp)
ERROR_COUNT=$(jq '[.[] | .errorCount] | add' < ${ESLINT_FILE}.json.tmp)
WARNING_COUNT=$(jq '[.[] | .warningCount] | add' < ${ESLINT_FILE}.json.tmp)

echo 'eslint summary:'
echo " - message count: $MESSAGE_COUNT"
echo " - error count: $ERROR_COUNT"
echo " - warning count: $WARNING_COUNT"
}

########## MAIN BLOCK ##########
Expand Down
98 changes: 0 additions & 98 deletions .eslintrc.json

This file was deleted.

33 changes: 8 additions & 25 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
{
// "eslint.lintTask.enable": true,
"eslint.codeActionsOnSave.mode": "problems",
// "extension-test-runner.extractSettings": {
// "suite": [ "suite" ],
// "test": [ "test" ],
// // "extractWith": "syntax",
// "extractWith": "evaluation",
// },
"git.branchProtection": [
"main"
"circleci.filters.branchFilter": "allBranches",
"circleci.persistedProjectSelection": [
"gh/kenherring/ablunit-test-runner"
],
"extension-test-runner.extractSettings": {
"suite": [
"describe",
"suite"
],
"test": [
"it",
"test"
],
"extractWith": "syntax"
},
"eslint.lintTask.enable": true,
"eslint.codeActionsOnSave.mode": "problems",
"files.associations": {
"ablunit-test-profile*.json": "jsonc"
},
Expand All @@ -37,6 +21,9 @@
"out": true,
"node_modules": true
},
"git.branchProtection": [
"main"
],
"json.schemas": [
{
"fileMatch": [
Expand Down Expand Up @@ -66,8 +53,4 @@
"task.autoDetect": "on",
"typescript.preferences.quoteStyle": "single",
"typescript.validate.enable": true,
"circleci.filters.branchFilter": "allBranches",
"circleci.persistedProjectSelection": [
"gh/kenherring/ablunit-test-runner"
],
}
3 changes: 0 additions & 3 deletions TODO.md

This file was deleted.

8 changes: 8 additions & 0 deletions docker/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@
<echo>compile successful!</echo>
</target>

<target name="extract">
<echo>extracting ${env.DLC}/tty/ablunit.pl</echo>
<copy todir="../resources/tty/ablunit/">
<plfileset src="${env.DLC}/tty/ablunit.pl" includes="**/*" />
</copy>
<echo>extract complete</echo>
</target>

</project>
14 changes: 7 additions & 7 deletions docker/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ options:
alternative: set the ABLUNIT_TEST_RUNNER_VSCODE_VERSION environment variable
-b drop to bash shell inside container on failure
-B same as -b, but only on error
-C | -d delete volume 'test-runner-cache' before running tests
-C | -d delete volumes 'vscode-cli-cache' and 'test-runner-cache' before running tests
-i run install and run test
-m copy modified files and staged files
-n run tests without coverage
Expand Down Expand Up @@ -120,10 +120,10 @@ initialize () {
fi

## create volume for .vscode-test directory to persist vscode application downloads
if ! docker volume ls | grep -q test-runner-cache; then
echo "creating test-runner-cache volume"
docker volume create --name test-runner-cache
fi
# if ! docker volume ls | grep -q test-runner-cache; then
# echo "creating test-runner-cache volume"
# docker volume create --name test-runner-cache
# fi
if ! docker volume ls | grep -q vscode-cli-cache; then
echo "creating vscode-cli-cache"
docker volume create --name vscode-cli-cache
Expand All @@ -149,7 +149,7 @@ initialize () {
}

run_tests_in_docker () {
echo "[$(date +%Y-%m-%d:%H:%M:%S) $0 ${FUNCNAME[0]}] pwd=$(pwd)"
echo "[$(date +%Y-%m-%d:%H:%M:%S) $0 ${FUNCNAME[0]}] pwd=$(pwd) ABLUNIT_TEST_RUNNER_OE_VERSION=$ABLUNIT_TEST_RUNNER_OE_VERSION"
local ABLUNIT_TEST_RUNNER_OE_VERSION

for ABLUNIT_TEST_RUNNER_OE_VERSION in "${OE_VERSIONS[@]}"; do
Expand Down Expand Up @@ -178,7 +178,7 @@ run_tests_in_docker () {
[ -n "${ABLUNIT_TEST_RUNNER_PROJECT_NAME:-}" ] && ARGS+=(-e ABLUNIT_TEST_RUNNER_PROJECT_NAME)
ARGS+=(
-v "${PWD}":/home/circleci/ablunit-test-runner:ro
-v vscode-cli-cache:/home/circleci/project/.vscode-test
-v "vscode-cli-cache-$ABLUNIT_TEST_RUNNER_OE_VERSION":/home/circleci/project/.vscode-test
kherring/ablunit-test-runner:"${ABLUNIT_TEST_RUNNER_OE_VERSION}"
bash -c "/home/circleci/ablunit-test-runner/docker/$SCRIPT.sh $OPTS;"
)
Expand Down
24 changes: 16 additions & 8 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,29 @@ export default [{
'@typescript-eslint/no-unnecessary-condition': 0,
'no-unused-vars': 'off',

'@typescript-eslint/no-unused-vars': ['warn', {
argsIgnorePattern: '^_',
vars: 'all',
args: 'none',
ignoreRestSiblings: false,
}],
'@typescript-eslint/no-unused-vars': [
'error',
{
'args': 'all',
'argsIgnorePattern': '^_',
'caughtErrors': 'all',
'caughtErrorsIgnorePattern': '^_',
'destructuredArrayIgnorePattern': '^_',
'varsIgnorePattern': '^_',
'ignoreRestSiblings': true,
}
],

'@typescript-eslint/prefer-readonly': 'warn',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/switch-exhaustiveness-check': 'warn',
'@typescript-eslint/switch-exhaustiveness-check': ['warn', {
considerDefaultExhaustiveForUnions: true,
}],
'promise/catch-or-return': 'warn',
'promise/no-callback-in-promise': 'off',

'promise/always-return': ['warn', {
ignoreLastCallback: true,
ignoreLastCallback: true
}],

'no-console': 'warn',
Expand Down
2 changes: 1 addition & 1 deletion openedge-project.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ablunit-test-runner",
"buildPath": [
{ "type": "source", "path": "resources/VSCodeTestRunner", "includes": "**/*.p,**/*.cls"},
{ "type": "source", "path": "resources/VSCodeTestRunner", "includes": "**/*.p,**/*.cls", "build": "resources/VSCodeTestRunner"},
{ "type": "propath", "path": "${DLC}/tty/ablunit.pl", "includes": "**/*" }
],
"buildDirectory": "target"
Expand Down
23 changes: 20 additions & 3 deletions resources/VSCodeTestRunner/ABLUnitCore.p
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
// This file replaces the standard ABLUnitCore.p when the basedir is
// included as part of the propath ahead of ablunit.pl.

using VSCode.ABLUnit.Runner.ABLRunner.

block-level on error undo, throw.
create widget-pool.

define variable quitOnEnd as logical init false no-undo.
define variable VERBOSE as logical no-undo.
VERBOSE = (os-getenv('VERBOSE') = 'true' or os-getenv('VERBOSE') = '1').

if VERBOSE then
run printPropath.
run main.
if quitOnEnd then
quit.
else
return.

////////// FUNCS AND PROCS //////////
procedure printPropath :
message "PROPATH:~n" + replace(PROPATH, ',', '~n - ').
define variable cnt as integer no-undo.
do cnt = 1 to num-entries(propath, ','):
message ' - '+ entry(cnt, propath).
end.
end procedure.

procedure createDatabaseAliases :
define variable aliasesSessionParam as character no-undo.
Expand All @@ -34,6 +47,7 @@ procedure createDatabaseAliases :
do dbCount = 1 to num-entries(aliasesSessionParam,';'):
assign aliasList = entry(dbCount, aliasesSessionParam,';').
assign databaseName = entry(1,aliasList).
if VERBOSE then message "databaseName=" + databaseName.

do aliasCount = 2 to num-entries(aliaslist,','):
assign aliasName = entry(aliasCount, aliasList).
Expand Down Expand Up @@ -64,12 +78,12 @@ function writeErrorToLog returns logical (outputLocation as character, msg as ch
else
log-manager:logfile-name = session:temp-dir + "ablunit.log".
end.
log-manager:write-message (msg).
log-manager:write-message(msg).
return true.
end function.

procedure main :
define variable ablRunner as class OpenEdge.ABLUnit.Runner.ABLRunner no-undo.
define variable ablRunner as class ABLRunner no-undo.
define variable testConfig as class OpenEdge.ABLUnit.Runner.TestConfig no-undo.
define variable updateFile as character no-undo.

Expand All @@ -80,7 +94,7 @@ procedure main :
testConfig = readTestConfig(getParameter(trim(trim(session:parameter,'"'),"'"), 'CFG')).
quitOnEnd = (testConfig = ?) or testConfig:quitOnEnd.

ablRunner = new OpenEdge.ABLUnit.Runner.ABLRunner(testConfig, updateFile).
ablRunner = new ABLRunner(testConfig, updateFile).
ablRunner:RunTests().

// the `-catchStop 1` startup parameter is default in 11.7+
Expand Down Expand Up @@ -109,7 +123,10 @@ procedure main :
writeErrorToLog(testConfig:outputLocation, s:CallStack).
end.
if testConfig:ShowErrorMessage then
do:
message e:GetMessage(1) view-as alert-box error.
message e:CallStack.
end.
if testConfig:ThrowError then
undo, throw e.
end.
Expand Down
Loading