chore(web): fix coverage-reporting artifact

Fixes: #13195
This commit is contained in:
Joshua Horton 2025-02-11 15:51:26 +07:00
parent 3e456bbf3b
commit b2598e76ba
20 changed files with 83 additions and 32 deletions

View file

@ -7,7 +7,17 @@
"reporter": ["text", "text-summary"],
"reports-dir": "build/coverage",
"src": [
"**/src/",
"src/**",
"../common/**/src"
],
"include": [
"src/**"
],
"exclude": [
"src/test/**",
"**/src/tests/**",
"**/build/**",
"src/tools/**",
"../node_modules/*"
]
}

View file

@ -141,12 +141,26 @@ test_action() {
coverage_action() {
builder_echo "Creating coverage report..."
cd "$KEYMAN_ROOT"
mkdir -p web/build/coverage/tmp
find . -type f -name coverage-\*.json -print0 | xargs -0 cp -t web/build/coverage/tmp
c8 report --config web/.c8rc.json ---reporter html --clean=false --reports-dir=web/build/coverage
rm -rf web/build/coverage/tmp
cd web
# Always ensure our collation folder is clean, just in case something went wrong on a prior run.
rm -rf build/coverage/tmp
# Also clean out the sub-report directories + main index.html; don't keep old ones if we fail!
rm -rf build/coverage/app
rm -rf build/coverage/engine
rm -f build/coverage/index.html
# Collate the results into a single folder
mkdir build/coverage/tmp
find . -type f -name coverage-\*.json -print0 | xargs -0 cp -t build/coverage/tmp
# Note for maintainers: the .c8rc.json config needs to be written from the perspective of
# the working directory - including its `include` and `exclude` entries. All ignores and
# such must be redefined in whatever that top-level .c8rc.json is.
c8 report --reporter html
# No need to keep the collation folder around afterward; we can always redo that work.
rm -rf build/coverage/tmp
}
builder_run_child_actions build:engine/dom-utils

View file

@ -108,22 +108,11 @@ function test-headless() {
TEST_CD_REQD=true
fi
if [ $TEST_CD_REQD ]; then
# The mocha config needed to live-compile TS-based tests only applies
# if the command is started within the appropriate subfolder.
pushd "${TEST_BASE}" > /dev/null
TEST_BASE=
fi
if [[ -e .c8rc.json ]]; then
c8 mocha --recursive "${TEST_BASE}${TEST_FOLDER}" $TEST_OPTS
else
mocha --recursive "${TEST_BASE}${TEST_FOLDER}" $TEST_OPTS
fi
if [ $TEST_CD_REQD ]; then
popd > /dev/null
fi
}
# Runs all headless tests (written in typescript) corresponding to the

View file

@ -0,0 +1,10 @@
{
"check-coverage": false,
"clean": true,
"exclude-after-remap": true,
"reporter": ["text", "text-summary"],
"reports-dir": "../../../build/coverage/raw/app/browser",
"src": [
"src/"
]
}

View file

@ -3,7 +3,7 @@
"clean": true,
"exclude-after-remap": true,
"reporter": ["text", "text-summary"],
"reports-dir": "build/coverage",
"reports-dir": "../../../build/coverage/raw/engine/attachment",
"src": [
"src/"
]

View file

@ -10,7 +10,7 @@
],
"exclude-after-remap": true,
"reporter": ["text", "text-summary"],
"reports-dir": "build/coverage",
"reports-dir": "../../../build/coverage/raw/raw/engine/common/web-utils",
"src": [
"src/"
]

View file

@ -3,7 +3,7 @@
"clean": true,
"exclude-after-remap": true,
"reporter": ["text", "text-summary"],
"reports-dir": "build/coverage",
"reports-dir": "../../../build/coverage/raw/engine/events",
"src": [
"src/"
]

View file

@ -3,7 +3,7 @@
"clean": true,
"exclude-after-remap": true,
"reporter": ["text", "text-summary"],
"reports-dir": "../../../build/engine/interfaces/coverage",
"reports-dir": "../../../build/coverage/raw/engine/interfaces",
"src": [
"src/"
]

View file

@ -3,7 +3,7 @@
"clean": true,
"exclude-after-remap": true,
"reporter": ["text", "text-summary"],
"reports-dir": "build/coverage",
"reports-dir": "../../../build/coverage/raw/engine/keyboard-storage",
"src": [
"src/"
]

View file

@ -8,7 +8,7 @@
],
"exclude-after-remap": true,
"reporter": ["text", "text-summary"],
"reports-dir": "build/coverage",
"reports-dir": "../../../build/coverage/raw/engine/keyboard",
"src": [
"src/"
]

View file

@ -11,7 +11,7 @@
"src/engine/headless/*"
],
"reporter": ["text", "text-summary"],
"reports-dir": "build/coverage",
"reports-dir": "../../../../build/coverage/raw/engine/osk/gesture-processor",
"src": [
"src/engine/headless/*"
]

View file

@ -7,7 +7,7 @@
],
"exclude-after-remap": true,
"reporter": ["text", "text-summary"],
"reports-dir": "build/coverage",
"reports-dir": "../../../../build/coverage/raw/engine/predictive-text/templates",
"src": [
"src/"
]

View file

@ -7,7 +7,7 @@
],
"exclude-after-remap": true,
"reporter": ["text", "text-summary"],
"reports-dir": "build/coverage",
"reports-dir": "../../../../build/coverage/raw/engine/predictive-text/wordbreakers",
"src": [
"src/"
]

View file

@ -6,6 +6,10 @@ import { LMLayerWorkerCode, LMLayerWorkerSourcemapComment } from "@keymanapp/lm-
export default class Worker {
static constructInstance(): Worker {
let scriptStr = unwrap(LMLayerWorkerCode);
const srcMapUrlIndex = scriptStr.indexOf("//# sourceMappingURL")
if(srcMapUrlIndex > 0) {
scriptStr = scriptStr.substring(0, srcMapUrlIndex);
}
scriptStr += '\n' + LMLayerWorkerSourcemapComment;
let worker = new MappedWorker(scriptStr);

View file

@ -7,7 +7,7 @@
],
"exclude-after-remap": true,
"reporter": ["text", "text-summary"],
"reports-dir": "build/coverage",
"reports-dir": "../../../../build/coverage/raw/engine/predictive-text/worker-thread",
"src": [
"src/main"
]

View file

@ -9,6 +9,9 @@ import { KeyboardInterface } from 'keyman/engine/js-processor';
import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader';
import { KeyboardTest, NodeProctor } from '@keymanapp/recorder-core';
import { getKeymanRoot } from '../../getKeymanRoot.mjs';
const KEYMAN_ROOT = getKeymanRoot();
describe('Engine - Basic Simulation', function() {
let testJSONtext = fs.readFileSync(require.resolve('@keymanapp/common-test-resources/json/engine_tests/basic_lao_simulation.json'));
// Common test suite setup.
@ -25,7 +28,7 @@ describe('Engine - Basic Simulation', function() {
before(async function() {
// -- START: Standard Recorder-based unit test loading boilerplate --
let keyboardLoader = new NodeKeyboardLoader(new KeyboardInterface({}, MinimalKeymanGlobal));
let keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../../common/test/' + testSuite.keyboard.filename);
let keyboard = await keyboardLoader.loadKeyboardFromPath(KEYMAN_ROOT + '/common/test/' + testSuite.keyboard.filename);
keyboardWithHarness = keyboardLoader.harness;
keyboardWithHarness.activeKeyboard = keyboard;

View file

@ -10,6 +10,9 @@ import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader'
import { KeyboardTest, NodeProctor } from '@keymanapp/recorder-core';
import { ModifierKeyConstants } from '@keymanapp/common-types';
import { getKeymanRoot } from '../../getKeymanRoot.mjs';
const KEYMAN_ROOT = getKeymanRoot();
describe('Engine - Chirality', function() {
let testJSONtext = fs.readFileSync(require.resolve('@keymanapp/common-test-resources/json/engine_tests/chirality.json'));
// Common test suite setup.
@ -26,7 +29,7 @@ describe('Engine - Chirality', function() {
before(async function() {
// -- START: Standard Recorder-based unit test loading boilerplate --
let keyboardLoader = new NodeKeyboardLoader(new KeyboardInterface({}, MinimalKeymanGlobal));
let keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../../common/test/' + testSuite.keyboard.filename);
let keyboard = await keyboardLoader.loadKeyboardFromPath(KEYMAN_ROOT + '/common/test/' + testSuite.keyboard.filename);
keyboardWithHarness = keyboardLoader.harness;
keyboardWithHarness.activeKeyboard = keyboard;

View file

@ -9,6 +9,9 @@ import { KeyboardInterface } from 'keyman/engine/js-processor';
import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader';
import { KeyboardTest, NodeProctor } from '@keymanapp/recorder-core';
import { getKeymanRoot } from '../../getKeymanRoot.mjs';
const KEYMAN_ROOT = getKeymanRoot();
describe('Engine - Deadkeys', function() {
let testJSONtext = fs.readFileSync(require.resolve('@keymanapp/common-test-resources/json/engine_tests/deadkeys.json'));
// Common test suite setup.
@ -25,7 +28,7 @@ describe('Engine - Deadkeys', function() {
before(async function() {
// -- START: Standard Recorder-based unit test loading boilerplate --
let keyboardLoader = new NodeKeyboardLoader(new KeyboardInterface({}, MinimalKeymanGlobal));
let keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../../common/test/' + testSuite.keyboard.filename);
let keyboard = await keyboardLoader.loadKeyboardFromPath(KEYMAN_ROOT + '/common/test/' + testSuite.keyboard.filename);
keyboardWithHarness = keyboardLoader.harness;
keyboardWithHarness.activeKeyboard = keyboard;

View file

@ -9,6 +9,9 @@ import { KeyboardInterface } from 'keyman/engine/js-processor';
import { NodeKeyboardLoader } from 'keyman/engine/keyboard/node-keyboard-loader';
import { KeyboardTest, NodeProctor } from '@keymanapp/recorder-core';
import { getKeymanRoot } from '../../../getKeymanRoot.mjs';
const KEYMAN_ROOT = getKeymanRoot();
describe('Engine - Unmatched Final Groups', function() {
let testJSONtext = fs.readFileSync(require.resolve('@keymanapp/common-test-resources/json/engine_tests/ghp_enter.json'));
// Common test suite setup.
@ -24,7 +27,7 @@ describe('Engine - Unmatched Final Groups', function() {
before(async function() {
// -- START: Standard Recorder-based unit test loading boilerplate --
let keyboardLoader = new NodeKeyboardLoader(new KeyboardInterface({}, MinimalKeymanGlobal));
const keyboard = await keyboardLoader.loadKeyboardFromPath('../../../../../common/test/' + testSuite.keyboard.filename);
const keyboard = await keyboardLoader.loadKeyboardFromPath(KEYMAN_ROOT + '/common/test/' + testSuite.keyboard.filename);
keyboardWithHarness = keyboardLoader.harness;
keyboardWithHarness.activeKeyboard = keyboard;

View file

@ -0,0 +1,12 @@
import { createRequire } from 'module';
import * as path from 'path'
const require = createRequire(import.meta.url);
export function getKeymanRoot() {
let anchorPath = require.resolve('@keymanapp/common-test-resources/index.mjs');
let root = path.dirname(anchorPath);
for(let i=0; i < 3; i++) {
root = path.dirname(root);
}
return root;
}