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

chore(developer): add baseline tests for bcp47 codes to kmc-package #12506

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Package>
<System>
<KeymanDeveloperVersion>10.0.700.0</KeymanDeveloperVersion>
<FileVersion>7.0</FileVersion>
</System>
<Info>
<Version>1.0</Version>
<Name>valid_bcp47</Name>
</Info>
<Files>
<File>
<Name>test.kmx</Name>
</File>
</Files>
<Keyboards>
<Keyboard>
<Name>Invalid BCP 47</Name>
<ID>test</ID>
<Version>1.0</Version>
<Languages>
<Language ID="km-mm-mm">Not a language tag</Language>
</Languages>
</Keyboard>
</Keyboards>
<Strings/>
</Package>
Binary file not shown.
39 changes: 39 additions & 0 deletions developer/src/kmc-package/test/fixtures/bcp47/valid_bcp47.kps
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<Package>
<System>
<KeymanDeveloperVersion>10.0.700.0</KeymanDeveloperVersion>
<FileVersion>7.0</FileVersion>
</System>
<Options>
<ExecuteProgram></ExecuteProgram>
<MSIFileName></MSIFileName>
<MSIOptions></MSIOptions>
</Options>
<StartMenu>
<Folder></Folder>
<Items/>
</StartMenu>
<Info>
<Version URL="">1.0</Version>
<Name URL="">valid_bcp47</Name>
</Info>
<Files>
<File>
<Name>test.kmx</Name>
</File>
</Files>
<Keyboards>
<Keyboard>
<Name>Valid BCP 47</Name>
<ID>test</ID>
<Version>1.0</Version>
<Languages>
<Language ID="km">Central Khmer (Khmer, Cambodia)</Language>
<Language ID="str-x-sencoten">SENCOTEN</Language>
<Language ID="str-sencoten">Unregistered variant of Straits Salish</Language>
<Language ID="km-Khmr-KM-x-boran">Private variant of "Old" Khmer</Language>
</Languages>
</Keyboard>
</Keyboards>
<Strings/>
</Package>
24 changes: 24 additions & 0 deletions developer/src/kmc-package/test/test-package-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { makePathToFixture } from './helpers/index.js';

import { KmpCompiler } from '../src/compiler/kmp-compiler.js';
import { PackageCompilerMessages } from '../src/compiler/package-compiler-messages.js';
import { PackageValidation } from '../src/compiler/package-validation.js';

const debug = false;

Expand All @@ -29,6 +30,13 @@ describe('KmpCompiler', function () {
assert.isTrue(await kmpCompiler.init(callbacks, null));
});

this.afterEach(function() {
if(this.currentTest?.isFailed()) {
callbacks.printMessages();
}
callbacks.clear();
});

for (let modelID of MODELS) {
const kpsPath = modelID.includes('withfolders') ?
makePathToFixture(modelID, 'source', `${modelID}.model.kps`) : makePathToFixture(modelID, `${modelID}.model.kps`);
Expand Down Expand Up @@ -284,4 +292,20 @@ describe('KmpCompiler', function () {
assert.equal(kmpJson.keyboards[0].version, '4.0'); // picks up example.kmx's version
});

it(`should handle a range of valid BCP47 tags`, function () {
const inputFilename = makePathToFixture('bcp47', 'valid_bcp47.kps');
const kmpJson = kmpCompiler.transformKpsToKmpObject(inputFilename);
assert.isNotNull(kmpJson);
const validation = new PackageValidation(callbacks, {});
assert.isTrue(validation.validate(inputFilename, kmpJson));
});

it(`should reject an invalid BCP47 tag`, function () {
const inputFilename = makePathToFixture('bcp47', 'invalid_bcp47_1.kps');
const kmpJson = kmpCompiler.transformKpsToKmpObject(inputFilename);
assert.isNotNull(kmpJson);
const validation = new PackageValidation(callbacks, {});
assert.isFalse(validation.validate(inputFilename, kmpJson));
});

});
Loading