chore(common/web): Merge branch 'master' into test/common/web/types/9052-unit-tests-kvk-file-writer

This commit is contained in:
Dr Mark C. Sinclair 2024-11-29 03:48:05 +00:00
commit 42191bcf7d
23 changed files with 202 additions and 93 deletions

View file

@ -1,5 +1,17 @@
# Keyman Version History
## 18.0.147 alpha 2024-11-28
* docs(android): Add android/docs/internal/README (#12717)
* test(common/web/types): unit tests for string-list (#12702)
* docs(common): linux and macOS emscripten setup (#12701)
* refactor(developer): output number of tests when running on TC (#12710)
* refactor(common): output number of tests when running on TC (#12719)
* chore(web): rename file missed in #12704 (#12720)
* fix(core): permanently disable logging (#12724)
* fix(linux): disable assertions in release builds of ibus-keyman (#12725)
* chore(common): improve offline builds (#12739)
## 18.0.146 alpha 2024-11-27
* test(developer): kmcmplib compiler unit tests 5 (#12612)

View file

@ -1 +1 @@
18.0.147
18.0.148

View file

@ -80,13 +80,20 @@ function do_configure() {
}
function do_test() {
local MOCHA_FLAGS=
if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then
# we're running in TeamCity
MOCHA_FLAGS="-reporter mocha-teamcity-reporter"
fi
eslint .
tsc --build test
readonly C8_THRESHOLD=60
# Excludes are defined in .c8rc.json
c8 -skip-full --reporter=lcov --reporter=text --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha "${builder_extra_params[@]}"
c8 -skip-full --reporter=lcov --reporter=text --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha ${MOCHA_FLAGS} "${builder_extra_params[@]}"
builder_echo warning "Coverage thresholds are currently $C8_THRESHOLD%, which is lower than ideal."
builder_echo warning "Please increase threshold in build.sh as test coverage improves."
}

View file

@ -1,7 +1,7 @@
/*
* Keyman is copyright (C) SIL Global. MIT License.
*
* Created by Dr Mark C. Sinclair on 2024-11-28
* Created by Dr Mark C. Sinclair on 2024-11-29
*
* Test code for unicodeset-parser-api.ts
*/
@ -10,23 +10,15 @@ import 'mocha';
import { assert } from 'chai';
import { UnicodeSet } from '../../src/ldml-keyboard/unicodeset-parser-api.js';
class MockUnicodeSet extends UnicodeSet {
constructor(public pattern: string, public ranges: number[][]) {
super(pattern, ranges); // does nothing
this.pattern = pattern;
this.ranges = ranges;
}
}
describe('Test of Unicode-Parser-API', () => {
describe('Test UnicodeSet', () => {
it('can provide a correct ranges length', () => {
const unicodeSet = new MockUnicodeSet("[ħa-z]", [[0x41, 0x7A], [0x0127, 0x0127]]);
const unicodeSet = new UnicodeSet("[ħa-z]", [[0x41, 0x7A], [0x0127, 0x0127]]);
assert.equal(unicodeSet.length, 2);
});
it('can provide a correct string representation', () => {
const unicodeSet = new MockUnicodeSet("[ħa-z]", [[0x41, 0x7A], [0x0127, 0x0127]]);
const unicodeSet = new UnicodeSet("[ħa-z]", [[0x41, 0x7A], [0x0127, 0x0127]]);
assert.deepEqual(unicodeSet.toString(), "[ħa-z]");
});
});
});
});

View file

@ -12,7 +12,7 @@ using namespace kmx;
/* Globals */
KMX_BOOL km::core::kmx::g_debug_ToConsole = FALSE;
KMX_BOOL km::core::kmx::g_debug_KeymanLog = TRUE;
KMX_BOOL km::core::kmx::g_debug_KeymanLog = FALSE; // workaround for #12661
KMX_BOOL km::core::kmx::g_silent = FALSE;
/*

View file

@ -46,18 +46,24 @@ function do_build() {
tsc --build
}
builder_run_action clean rm -rf ./build/
builder_run_action configure verify_npm_setup
builder_run_action build do_build
function do_test() {
local MOCHA_FLAGS=
if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then
# we're running in TeamCity
MOCHA_FLAGS="-reporter mocha-teamcity-reporter"
fi
if builder_start_action test; then
eslint .
tsc --build test
readonly C8_THRESHOLD=50
c8 --reporter=lcov --reporter=text --exclude-after-remap --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha
c8 --reporter=lcov --reporter=text --exclude-after-remap --check-coverage=false --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha ${MOCHA_FLAGS}
builder_echo warning "Coverage thresholds are currently $C8_THRESHOLD%, which is lower than ideal."
builder_echo warning "Please increase threshold in build.sh as test coverage improves."
builder_finish_action success test
fi
}
builder_run_action publish builder_publish_npm
builder_run_action clean rm -rf ./build/
builder_run_action configure verify_npm_setup
builder_run_action build do_build
builder_run_action test do_test
builder_run_action publish builder_publish_npm

View file

@ -26,12 +26,19 @@ builder_parse "$@"
#-------------------------------------------------------------------------------------------------------------------
function do_test() {
local MOCHA_FLAGS=
if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then
# we're running in TeamCity
MOCHA_FLAGS="-reporter mocha-teamcity-reporter"
fi
eslint .
cd test
tsc --build
cd ..
readonly C8_THRESHOLD=70
c8 --reporter=lcov --reporter=text --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha
c8 --reporter=lcov --reporter=text --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha ${MOCHA_FLAGS}
}
builder_run_action clean rm -rf ./build/

View file

@ -32,12 +32,19 @@ builder_parse "$@"
do_test() {
# note: `export TEST_SAVE_ARTIFACTS=1` to save a copy of artifacts to temp path
# note: `export TEST_SAVE_FIXTURES=1` to get a copy of cloud-based fixtures saved to online/
local MOCHA_FLAGS=
if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then
# we're running in TeamCity
MOCHA_FLAGS="-reporter mocha-teamcity-reporter"
fi
eslint .
cd test
tsc --build
cd ..
readonly C8_THRESHOLD=70
c8 -skip-full --reporter=lcov --reporter=text --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha "${builder_extra_params[@]}"
c8 -skip-full --reporter=lcov --reporter=text --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha ${MOCHA_FLAGS} "${builder_extra_params[@]}"
builder_echo warning "Coverage thresholds are currently $C8_THRESHOLD%, which is lower than ideal."
builder_echo warning "Please increase threshold in build.sh as test coverage improves."
}

View file

@ -37,11 +37,18 @@ do_build() {
}
do_test() {
local MOCHA_FLAGS=
if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then
# we're running in TeamCity
MOCHA_FLAGS="-reporter mocha-teamcity-reporter"
fi
eslint .
cd test
tsc --build
cd ..
c8 --reporter=lcov --reporter=text mocha "${builder_extra_params[@]}"
c8 --reporter=lcov --reporter=text mocha ${MOCHA_FLAGS} "${builder_extra_params[@]}"
}
builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo

View file

@ -32,23 +32,28 @@ function do_configure() {
mkdir -p src/imports
echo 'export default ' > src/imports/langtags.js
cat "$KEYMAN_ROOT/resources/standards-data/langtags/langtags.json" >> src/imports/langtags.js
}
function do_test() {
local MOCHA_FLAGS=
if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then
# we're running in TeamCity
MOCHA_FLAGS="-reporter mocha-teamcity-reporter"
fi
eslint .
tsc --build test
c8 --reporter=lcov --reporter=text --exclude-after-remap --check-coverage=false mocha ${MOCHA_FLAGS}
}
#-------------------------------------------------------------------------------------------------------------------
builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo
builder_run_action configure do_configure
builder_run_action build tsc --build
builder_run_action api api-extractor run --local --verbose
#-------------------------------------------------------------------------------------------------------------------
if builder_start_action test; then
eslint .
tsc --build test
c8 --reporter=lcov --reporter=text --exclude-after-remap mocha
builder_finish_action success test
fi
builder_run_action test do_test
#-------------------------------------------------------------------------------------------------------------------

View file

@ -56,27 +56,31 @@ function copy_deps() {
cp ../kmcmplib/build/wasm/$BUILDER_CONFIGURATION/src/wasm-host.wasm ./build/src/import/kmcmplib/wasm-host.wasm
}
if builder_start_action build; then
function do_build() {
copy_deps
tsc --build
builder_finish_action success build
fi
}
builder_run_action api api-extractor run --local --verbose
function do_test() {
local MOCHA_FLAGS=
#-------------------------------------------------------------------------------------------------------------------
if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then
# we're running in TeamCity
MOCHA_FLAGS="-reporter mocha-teamcity-reporter"
fi
if builder_start_action test; then
copy_deps
tsc --build test/
npm run lint
readonly C8_THRESHOLD=80
c8 --reporter=lcov --reporter=text --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha
c8 --reporter=lcov --reporter=text --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha ${MOCHA_FLAGS}
builder_echo warning "Coverage thresholds are currently $C8_THRESHOLD%, which is lower than ideal."
builder_echo warning "Please increase threshold in build.sh as test coverage improves."
}
builder_finish_action success test
fi
builder_run_action build do_build
builder_run_action api api-extractor run --local --verbose
builder_run_action test do_test
#-------------------------------------------------------------------------------------------------------------------

View file

@ -33,30 +33,19 @@ builder_describe_outputs \
builder_parse "$@"
#-------------------------------------------------------------------------------------------------------------------
if builder_start_action clean; then
function do_clean() {
rm -rf ./build/ ./tsconfig.tsbuildinfo
builder_finish_action success clean
fi
}
#-------------------------------------------------------------------------------------------------------------------
if builder_start_action configure; then
function do_configure() {
verify_npm_setup
builder_finish_action success configure
fi
}
#-------------------------------------------------------------------------------------------------------------------
if builder_start_action build; then
function do_build() {
npm run build
builder_finish_action success build
fi
}
#-------------------------------------------------------------------------------------------------------------------
if builder_start_action build-fixtures; then
function do_build_fixtures() {
# Build basic.kmx and emit its checksum
mkdir -p ./build/test/fixtures
node ../kmc build ./test/fixtures/basic.xml --no-compiler-version --debug --out-file ./build/test/fixtures/basic-xml.kmx
@ -65,22 +54,29 @@ if builder_start_action build-fixtures; then
# Generate a binary file from basic.txt for comparison purposes
node ../../../common/tools/hextobin/build/hextobin.js ./test/fixtures/basic.txt ./build/test/fixtures/basic-txt.kmx
}
builder_finish_action success build-fixtures
fi
function do_test() {
local MOCHA_FLAGS=
builder_run_action api api-extractor run --local --verbose
if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then
# we're running in TeamCity
MOCHA_FLAGS="-reporter mocha-teamcity-reporter"
fi
#-------------------------------------------------------------------------------------------------------------------
if builder_start_action test; then
eslint .
cd test
tsc -b
cd ..
c8 --reporter=lcov --reporter=text mocha "${builder_extra_params[@]}"
builder_finish_action success test
fi
c8 --reporter=lcov --reporter=text mocha ${MOCHA_FLAGS} "${builder_extra_params[@]}"
}
builder_run_action clean do_clean
builder_run_action configure do_configure
builder_run_action build do_build
builder_run_action build-fixtures do_build_fixtures
builder_run_action api api-extractor run --local --verbose
builder_run_action test do_test
#-------------------------------------------------------------------------------------------------------------------

View file

@ -50,13 +50,20 @@ builder_run_action api api-extractor run --local --verbose
#-------------------------------------------------------------------------------------------------------------------
if builder_start_action test; then
function do_test() {
local MOCHA_FLAGS=
if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then
# we're running in TeamCity
MOCHA_FLAGS="-reporter mocha-teamcity-reporter"
fi
eslint .
tsc --build test
c8 --reporter=lcov --reporter=text --exclude-after-remap --lines 80 mocha
c8 --reporter=lcov --reporter=text --exclude-after-remap --check-coverage=false --lines 80 mocha ${MOCHA_FLAGS}
# TODO: remove --lines 80 and improve coverage
builder_finish_action success test
fi
}
builder_run_action test do_test
#-------------------------------------------------------------------------------------------------------------------

View file

@ -35,10 +35,24 @@ function do_build() {
npm run build
}
function do_test() {
local MOCHA_FLAGS=
if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then
# we're running in TeamCity
MOCHA_FLAGS="-reporter mocha-teamcity-reporter"
fi
npm run lint
cd test
tsc -b
cd ..
c8 --reporter=lcov --reporter=text mocha ${MOCHA_FLAGS}
}
builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo
builder_run_action configure verify_npm_setup
builder_run_action build do_build
builder_run_action api api-extractor run --local --verbose
builder_run_action test npm test
builder_run_action test do_test
builder_run_action publish builder_publish_npm

View file

@ -18,7 +18,7 @@
"scripts": {
"build": "tsc -b",
"lint": "eslint .",
"test": "npm run lint && cd test && tsc -b && cd .. && c8 --reporter=lcov --reporter=text mocha"
"test": "./build.sh test"
},
"author": "Marc Durdin <marc@keyman.com> (https://github.com/mcdurdin)",
"contributors": [

View file

@ -30,20 +30,25 @@ builder_describe_outputs \
builder_parse "$@"
function do_test() {
local MOCHA_FLAGS=
if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then
# we're running in TeamCity
MOCHA_FLAGS="-reporter mocha-teamcity-reporter"
fi
eslint .
cd test
tsc --build
cd ..
c8 --reporter=lcov --reporter=text mocha ${MOCHA_FLAGS}
}
#-------------------------------------------------------------------------------------------------------------------
builder_run_action clean rm -rf ./build/ ./tsconfig.tsbuildinfo
builder_run_action configure verify_npm_setup
builder_run_action build tsc --build
builder_run_action api api-extractor run --local --verbose
if builder_start_action test; then
eslint .
cd test
tsc --build
cd ..
c8 --reporter=lcov --reporter=text mocha
builder_finish_action success test
fi
builder_run_action test do_test
builder_run_action publish builder_publish_npm

View file

@ -62,10 +62,17 @@ function do_api() {
#-------------------------------------------------------------------------------------------------------------------
function do_test() {
local MOCHA_FLAGS=
if [[ "${TEAMCITY_GIT_PATH:-}" != "" ]]; then
# we're running in TeamCity
MOCHA_FLAGS="-reporter mocha-teamcity-reporter"
fi
eslint .
tsc --build test/
readonly C8_THRESHOLD=50
c8 --reporter=lcov --reporter=text --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha
c8 --reporter=lcov --reporter=text --lines $C8_THRESHOLD --statements $C8_THRESHOLD --branches $C8_THRESHOLD --functions $C8_THRESHOLD mocha ${MOCHA_FLAGS}
builder_echo warning "Coverage thresholds are currently $C8_THRESHOLD%, which is lower than ideal."
builder_echo warning "Please increase threshold in build.sh as test coverage improves."
}

View file

@ -70,10 +70,23 @@ git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install 3.1.58
./emsdk activate 3.1.58
export EMSCRIPTEN_BASE="$(pwd)/upstream/emscripten"
cd upstream/emscripten
npm install
export EMSCRIPTEN_BASE="$(pwd)"
echo "export EMSCRIPTEN_BASE=\"$EMSCRIPTEN_BASE\"" >> .bashrc
```
If you are updating an existing install of Emscripten:
```bash
cd emsdk
git pull
./emsdk install 3.1.58
./emsdk activate 3.1.58
cd upstream/emscripten
npm install
```
> ![WARNING]
> Don't put EMSDK on the path, i.e. don't source `emsdk_env.sh`.
>

15
docs/build/macos.md vendored
View file

@ -101,10 +101,23 @@ git clone https://github.com/emscripten-core/emsdk
cd emsdk
emsdk install 3.1.58
emsdk activate 3.1.58
export EMSCRIPTEN_BASE="$(pwd)/upstream/emscripten"
cd upstream/emscripten
npm install
export EMSCRIPTEN_BASE="$(pwd)"
echo "export EMSCRIPTEN_BASE=\"$EMSCRIPTEN_BASE\"" >> .bashrc
```
If you are updating an existing install of Emscripten:
```bash
cd emsdk
git pull
emsdk install 3.1.58
emsdk activate 3.1.58
cd upstream/emscripten
npm install
```
You will want to add `EMSCRIPTEN_BASE` to your .bashrc.
> ![WARNING]

View file

@ -8,6 +8,11 @@ project('ibus-keyman', 'c', 'cpp',
# meson doesn't allow us to reference a file outside its root
subdir('resources')
if get_option('buildtype') != 'debug'
# Disable assertions on release builds
defns += ['-DG_DISABLE_ASSERT']
endif
conf = configuration_data()
ibus = dependency('ibus-1.0', version: '>= 1.2.0')

View file

@ -40,6 +40,8 @@ configure_file(
exe = executable(
'ibus-engine-keyman',
c_args: defns,
cpp_args: defns,
sources: [engine_files, util_files],
dependencies: deps,
include_directories: include_dirs,

View file

@ -41,8 +41,8 @@ type -t nvm >/dev/null || {
}
}
nvm install "$REQUIRED_NODE_VERSION"
nvm use "$REQUIRED_NODE_VERSION"
nvm use "$REQUIRED_NODE_VERSION" || \
(nvm install "$REQUIRED_NODE_VERSION" && nvm use "$REQUIRED_NODE_VERSION")
# Beware the hardcoded path below -- it should already be in the system PATH