From 09739656ea8ac8592b89390257f69aa6ad51c7fd Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Wed, 25 Oct 2023 10:59:27 +0100 Subject: [PATCH 01/26] chore(developer): add ERROR_FileDoesNotExist test --- developer/src/kmc/test/test-infrastructureMessages.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 2b481fe6c9..696ae31eec 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -36,13 +36,17 @@ describe('InfrastructureMessages', function () { assert.instanceOf(ncb.messages[0].exceptionVar, Error); }); -/* // ERROR_FileDoesNotExist it('should generate ERROR_FileDoesNotExist if a file does not exist', async function() { - await testForMessage(this, ['invalid-keyboards', 'error_file_does_not_exist.kmn'], CompilerMessages.ERROR_FileDoesNotExist); + const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); + await unitTestEndpoints.build(makePathToFixture('invalid-keyboards', 'Error_File_Does_Not_Exist.kmn'), ncb, {}); + assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileDoesNotExist), + `ERROR_FileDoesNotExist not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); +/* + // ERROR_FileTypeNotRecognized it('should generate ERROR_FileTypeNotRecognized if a file is not a recognized type', async function() { From 5301f7a176fdd2cb8ae062b51c6f256656860ec0 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Wed, 25 Oct 2023 11:19:27 +0100 Subject: [PATCH 02/26] chore(developer): add ERROR_FileTypeNotRecognized test --- .../invalid-keyboards/error_file_type_not_recognized.xxx | 1 + developer/src/kmc/test/test-infrastructureMessages.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 developer/src/kmc/test/fixtures/invalid-keyboards/error_file_type_not_recognized.xxx diff --git a/developer/src/kmc/test/fixtures/invalid-keyboards/error_file_type_not_recognized.xxx b/developer/src/kmc/test/fixtures/invalid-keyboards/error_file_type_not_recognized.xxx new file mode 100644 index 0000000000..cc8f8ee6ce --- /dev/null +++ b/developer/src/kmc/test/fixtures/invalid-keyboards/error_file_type_not_recognized.xxx @@ -0,0 +1 @@ +This is a file used to test the unrecognised file type error (sse test-infrastructureMessages.ts) \ No newline at end of file diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 696ae31eec..d7bb142e80 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -45,14 +45,17 @@ describe('InfrastructureMessages', function () { `ERROR_FileDoesNotExist not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); -/* - // ERROR_FileTypeNotRecognized it('should generate ERROR_FileTypeNotRecognized if a file is not a recognized type', async function() { - await testForMessage(this, ['invalid-keyboards', 'error_file_type_not_recognized.xxx'], CompilerMessages.ERROR_FileTypeNotRecognized); + const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); + await unitTestEndpoints.build(makePathToFixture('invalid-keyboards', 'error_file_type_not_recognized.xxx'), ncb, {}); + assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotRecognized), + `ERROR_FileTypeNotRecognized not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); +/* + // ERROR_OutFileNotValidForProjects it('should generate ERROR_OutFileNotValidForProjects if an output file is specified for a project build', async function() { From 3f383e64e3a9a08e882800ba01e108a635af3f6f Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 23 Nov 2023 10:22:21 +0000 Subject: [PATCH 03/26] chore(developer): correct typo in error_file_type_not_recognized.xxx --- .../invalid-keyboards/error_file_type_not_recognized.xxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/developer/src/kmc/test/fixtures/invalid-keyboards/error_file_type_not_recognized.xxx b/developer/src/kmc/test/fixtures/invalid-keyboards/error_file_type_not_recognized.xxx index cc8f8ee6ce..162d8d5f2e 100644 --- a/developer/src/kmc/test/fixtures/invalid-keyboards/error_file_type_not_recognized.xxx +++ b/developer/src/kmc/test/fixtures/invalid-keyboards/error_file_type_not_recognized.xxx @@ -1 +1 @@ -This is a file used to test the unrecognised file type error (sse test-infrastructureMessages.ts) \ No newline at end of file +This is a file used to test the unrecognised file type error (see test-infrastructureMessages.ts) \ No newline at end of file From af6ccc4d83c2a699acad55495dd765b7c620eedd Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 23 Nov 2023 11:01:18 +0000 Subject: [PATCH 04/26] chore(developer): add ERROR_OutFileNotValidForProjects unit test --- .../kmc/test/test-infrastructureMessages.ts | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index d7bb142e80..53bf0818a6 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -9,6 +9,7 @@ import { unitTestEndpoints } from '../src/commands/build.js'; import { KmnCompilerMessages } from '@keymanapp/kmc-kmn'; import { clearOptions } from '@keymanapp/developer-utils'; import { loadProject } from '../src/util/projectLoader.js'; +import { defaultCompilerOptions, CompilerOptions} from '@keymanapp/common-types'; describe('InfrastructureMessages', function () { @@ -40,7 +41,7 @@ describe('InfrastructureMessages', function () { it('should generate ERROR_FileDoesNotExist if a file does not exist', async function() { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); - await unitTestEndpoints.build(makePathToFixture('invalid-keyboards', 'Error_File_Does_Not_Exist.kmn'), ncb, {}); + await unitTestEndpoints.build(makePathToFixture('invalid-keyboards', 'Error_File_Does_Not_Exist.kmn'), '', ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileDoesNotExist), `ERROR_FileDoesNotExist not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); @@ -49,19 +50,24 @@ describe('InfrastructureMessages', function () { it('should generate ERROR_FileTypeNotRecognized if a file is not a recognized type', async function() { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); - await unitTestEndpoints.build(makePathToFixture('invalid-keyboards', 'error_file_type_not_recognized.xxx'), ncb, {}); + await unitTestEndpoints.build(makePathToFixture('invalid-keyboards', 'error_file_type_not_recognized.xxx'), '', ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotRecognized), `ERROR_FileTypeNotRecognized not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); +// ERROR_OutFileNotValidForProjects + +it('should generate ERROR_OutFileNotValidForProjects if an output file is specified for a project build', async function() { + const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); + const projectPath = makePathToFixture('kpj-2.0/khmer_angkor', 'khmer_angkor.kpj'); + const outFilePath = makePathToFixture('kpj-2.0/khmer_angkor', 'khmer_angkor.kmx'); + const options: CompilerOptions = {...defaultCompilerOptions}; + await unitTestEndpoints.build(projectPath, outFilePath, ncb, options); + assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_OutFileNotValidForProjects), + `ERROR_OutFileNotValidForProjects not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); +}); + /* - - // ERROR_OutFileNotValidForProjects - - it('should generate ERROR_OutFileNotValidForProjects if an output file is specified for a project build', async function() { - await testForMessage(this, ['invalid-keyboards', 'error_out_file_not_valid_for_projects.kpj'], CompilerMessages.ERROR_OutFileNotValidForProjects); - }); - // ERROR_InvalidProjectFile it('should generate ERROR_InvalidProjectFile if a project file is invalid', async function() { @@ -70,7 +76,7 @@ describe('InfrastructureMessages', function () { */ // ERROR_InvalidProjectFolder (invalid source folder) - + it('should generate ERROR_InvalidProjectFolder if there are no valid file types in the source folder when generating a default project file', async function() { const projectPath = makePathToFixture('invalid-source-folder', 'error_invalid_project_folder.kpj') const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); From 24e7105a9bf325d85ad278ad7540253b36ca8a48 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 30 Nov 2023 10:23:07 +0000 Subject: [PATCH 05/26] chore(developer): add ERROR_InvalidProjectFile unit test --- .../error_invalid_project_file.kpj | 1 + .../kmc/test/test-infrastructureMessages.ts | 27 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 developer/src/kmc/test/fixtures/invalid-project/error_invalid_project_file.kpj diff --git a/developer/src/kmc/test/fixtures/invalid-project/error_invalid_project_file.kpj b/developer/src/kmc/test/fixtures/invalid-project/error_invalid_project_file.kpj new file mode 100644 index 0000000000..e01a746e66 --- /dev/null +++ b/developer/src/kmc/test/fixtures/invalid-project/error_invalid_project_file.kpj @@ -0,0 +1 @@ +This is a file used to test the invalid project file error (see test-infrastructureMessages.ts) \ No newline at end of file diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 53bf0818a6..c7a097db1d 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -55,25 +55,26 @@ describe('InfrastructureMessages', function () { `ERROR_FileTypeNotRecognized not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); -// ERROR_OutFileNotValidForProjects + // ERROR_OutFileNotValidForProjects -it('should generate ERROR_OutFileNotValidForProjects if an output file is specified for a project build', async function() { - const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); - const projectPath = makePathToFixture('kpj-2.0/khmer_angkor', 'khmer_angkor.kpj'); - const outFilePath = makePathToFixture('kpj-2.0/khmer_angkor', 'khmer_angkor.kmx'); - const options: CompilerOptions = {...defaultCompilerOptions}; - await unitTestEndpoints.build(projectPath, outFilePath, ncb, options); - assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_OutFileNotValidForProjects), - `ERROR_OutFileNotValidForProjects not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); -}); + it('should generate ERROR_OutFileNotValidForProjects if an output file is specified for a project build', async function() { + const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); + const projectPath = makePathToFixture('kpj-2.0/khmer_angkor', 'khmer_angkor.kpj'); + const outFilePath = makePathToFixture('kpj-2.0/khmer_angkor', 'khmer_angkor.kmx'); + const options: CompilerOptions = {...defaultCompilerOptions}; + await unitTestEndpoints.build(projectPath, outFilePath, ncb, options); + assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_OutFileNotValidForProjects), + `ERROR_OutFileNotValidForProjects not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + }); -/* // ERROR_InvalidProjectFile it('should generate ERROR_InvalidProjectFile if a project file is invalid', async function() { - await testForMessage(this, ['invalid-keyboards', 'error_invalid_project_file.kpj'], CompilerMessages.ERROR_InvalidProjectFile); + const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); + await unitTestEndpoints.build(makePathToFixture('invalid-project', 'error_invalid_project_file.kpj'), '', ncb, {}); + assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_InvalidProjectFile), + `ERROR_InvalidProjectFile not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); - */ // ERROR_InvalidProjectFolder (invalid source folder) From 015b81014cd509ca33abb346564c70993fe4cbda Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 4 Dec 2023 10:04:08 +0000 Subject: [PATCH 06/26] chore(developer): add ERROR_NotAProjectFile unit test --- .../invalid-project/error_not_a_project_file.xxx | 1 + developer/src/kmc/test/test-infrastructureMessages.ts | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 developer/src/kmc/test/fixtures/invalid-project/error_not_a_project_file.xxx diff --git a/developer/src/kmc/test/fixtures/invalid-project/error_not_a_project_file.xxx b/developer/src/kmc/test/fixtures/invalid-project/error_not_a_project_file.xxx new file mode 100644 index 0000000000..f7fff35790 --- /dev/null +++ b/developer/src/kmc/test/fixtures/invalid-project/error_not_a_project_file.xxx @@ -0,0 +1 @@ +This is a file used to test the not a project file error (see test-infrastructureMessages.ts) \ No newline at end of file diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index c7a097db1d..174edd27e4 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -86,6 +86,16 @@ describe('InfrastructureMessages', function () { `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); + // ERROR_NotAProjectFile + + it('should generate ERROR_NotAProjectFile if a project file is not the correct type', async function() { + const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); + const projectPath = makePathToFixture('invalid-project', 'error_not_a_project_file.xxx') + loadProject(projectPath, ncb); + assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_NotAProjectFile), + `ERROR_NotAProjectFile not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + }); + // HINT_FilenameHasDifferingCase it('should generate HINT_FilenameHasDifferingCase if a referenced file has differing case', async function() { From 85d95ffa4f9c7a95fd4de69fe19cef2d73205347 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Tue, 5 Dec 2023 10:53:09 +0000 Subject: [PATCH 07/26] chore(developer): refactor to rename fixture/invalid-project to invalid-projects --- .../error_invalid_project_file.kpj | 0 .../error_not_a_project_file.xxx | 0 developer/src/kmc/test/test-infrastructureMessages.ts | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename developer/src/kmc/test/fixtures/{invalid-project => invalid-projects}/error_invalid_project_file.kpj (100%) rename developer/src/kmc/test/fixtures/{invalid-project => invalid-projects}/error_not_a_project_file.xxx (100%) diff --git a/developer/src/kmc/test/fixtures/invalid-project/error_invalid_project_file.kpj b/developer/src/kmc/test/fixtures/invalid-projects/error_invalid_project_file.kpj similarity index 100% rename from developer/src/kmc/test/fixtures/invalid-project/error_invalid_project_file.kpj rename to developer/src/kmc/test/fixtures/invalid-projects/error_invalid_project_file.kpj diff --git a/developer/src/kmc/test/fixtures/invalid-project/error_not_a_project_file.xxx b/developer/src/kmc/test/fixtures/invalid-projects/error_not_a_project_file.xxx similarity index 100% rename from developer/src/kmc/test/fixtures/invalid-project/error_not_a_project_file.xxx rename to developer/src/kmc/test/fixtures/invalid-projects/error_not_a_project_file.xxx diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 174edd27e4..06bf471a7b 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -71,7 +71,7 @@ describe('InfrastructureMessages', function () { it('should generate ERROR_InvalidProjectFile if a project file is invalid', async function() { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); - await unitTestEndpoints.build(makePathToFixture('invalid-project', 'error_invalid_project_file.kpj'), '', ncb, {}); + await unitTestEndpoints.build(makePathToFixture('invalid-projects', 'error_invalid_project_file.kpj'), '', ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_InvalidProjectFile), `ERROR_InvalidProjectFile not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); @@ -90,7 +90,7 @@ describe('InfrastructureMessages', function () { it('should generate ERROR_NotAProjectFile if a project file is not the correct type', async function() { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); - const projectPath = makePathToFixture('invalid-project', 'error_not_a_project_file.xxx') + const projectPath = makePathToFixture('invalid-projects', 'error_not_a_project_file.xxx') loadProject(projectPath, ncb); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_NotAProjectFile), `ERROR_NotAProjectFile not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); From e4821c872b8ca4263b10efa8a3c2c0be2a16d4f5 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 7 Dec 2023 11:44:53 +0000 Subject: [PATCH 08/26] chore(developer): add ERROR_UnknownFileFormat unit test and supporting endpoint --- developer/src/kmc/src/commands/analyze.ts | 7 +++++++ .../fixtures/analyze/error_unknown_file_format.xxx | 1 + developer/src/kmc/test/test-infrastructureMessages.ts | 11 +++++++++++ 3 files changed, 19 insertions(+) create mode 100644 developer/src/kmc/test/fixtures/analyze/error_unknown_file_format.xxx diff --git a/developer/src/kmc/src/commands/analyze.ts b/developer/src/kmc/src/commands/analyze.ts index 0ee8149d0b..fd6314ec86 100644 --- a/developer/src/kmc/src/commands/analyze.ts +++ b/developer/src/kmc/src/commands/analyze.ts @@ -121,3 +121,10 @@ async function analyzeOskRewritePua(callbacks: CompilerCallbacks, filenames: str return true; }); } + +/** + * these are exported only for unit tests, do not use + */ +export const analyzeUnitTestEndpoints = { + analyzeOskCharUse +}; \ No newline at end of file diff --git a/developer/src/kmc/test/fixtures/analyze/error_unknown_file_format.xxx b/developer/src/kmc/test/fixtures/analyze/error_unknown_file_format.xxx new file mode 100644 index 0000000000..5ae49a58cb --- /dev/null +++ b/developer/src/kmc/test/fixtures/analyze/error_unknown_file_format.xxx @@ -0,0 +1 @@ +This is a file used to test the unknown file format error (see test-infrastructureMessages.ts) \ No newline at end of file diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 06bf471a7b..5456c2bce3 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -10,6 +10,7 @@ import { KmnCompilerMessages } from '@keymanapp/kmc-kmn'; import { clearOptions } from '@keymanapp/developer-utils'; import { loadProject } from '../src/util/projectLoader.js'; import { defaultCompilerOptions, CompilerOptions} from '@keymanapp/common-types'; +import { analyzeUnitTestEndpoints } from '../src/commands/analyze.js'; describe('InfrastructureMessages', function () { @@ -96,6 +97,16 @@ describe('InfrastructureMessages', function () { `ERROR_NotAProjectFile not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); + // ERROR_UnknownFileFormat + + it('should generate ERROR_UnknownFileFormat if an analyze osk-char-use mapping file is not the correct type', async function() { + const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); + const options = {mappingFile: makePathToFixture('analyze', 'error_not_a_project_file.xxx')}; + await analyzeUnitTestEndpoints.analyzeOskCharUse(ncb, [], options); + assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_UnknownFileFormat), + `ERROR_NotAProjectFile not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + }); + // HINT_FilenameHasDifferingCase it('should generate HINT_FilenameHasDifferingCase if a referenced file has differing case', async function() { From f39ba347b25064f95909b28fe6d3a65882c8ed96 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 14 Dec 2023 11:10:58 +0000 Subject: [PATCH 09/26] chore(developer): add ERROR_FileTypeNotFound (BuildKeyboardInfo) unit test --- .../error_file_type_not_found_kbd.kpj | 24 +++++++++++++++++++ .../kmc/test/test-infrastructureMessages.ts | 12 ++++++++++ 2 files changed, 36 insertions(+) create mode 100644 developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_kbd.kpj diff --git a/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_kbd.kpj b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_kbd.kpj new file mode 100644 index 0000000000..dd35f982a1 --- /dev/null +++ b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_kbd.kpj @@ -0,0 +1,24 @@ + + + + $PROJECTPATH + False + False + False + keyboard + + + + error_file_type_not_found_kbd_1 + error_file_type_not_found_kbd.kmn + error_file_type_not_found_kbd.kmn + 1.0 + .kmn +
+ error_file_type_not_found_kbd + Copyright (C) Keyman Team +
+
+ +
+
diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 5456c2bce3..23ea542416 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -11,6 +11,7 @@ import { clearOptions } from '@keymanapp/developer-utils'; import { loadProject } from '../src/util/projectLoader.js'; import { defaultCompilerOptions, CompilerOptions} from '@keymanapp/common-types'; import { analyzeUnitTestEndpoints } from '../src/commands/analyze.js'; +import { BuildKeyboardInfo } from '../src/commands/buildClasses/BuildKeyboardInfo.js'; describe('InfrastructureMessages', function () { @@ -107,6 +108,17 @@ describe('InfrastructureMessages', function () { `ERROR_NotAProjectFile not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); + // ERROR_FileTypeNotFound (BuildKeyboardInfo) + + it('should generate ERROR_FileTypeNotFound if a project file does not contain a .kps file entry (BuildKeyboardInfo)', async function() { + const buildKeyboardInfo = new BuildKeyboardInfo(); + const projectPath = makePathToFixture('invalid-projects', 'error_file_type_not_found_kbd.kpj') + const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); + await buildKeyboardInfo.build(projectPath, ncb, {}); + assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotFound), + `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + }); + // HINT_FilenameHasDifferingCase it('should generate HINT_FilenameHasDifferingCase if a referenced file has differing case', async function() { From 8af4b93120afef5d9a536cbfc0bcf04bb1bfe931 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 29 Jan 2024 09:55:46 +0000 Subject: [PATCH 10/26] chore(developer): add ERROR_FileTypeNotFound (BuildModelInfo; .model.ts) unit test --- .../error_file_type_not_found_mdl_mdl.kpj | 35 +++++++++++++++++++ .../kmc/test/test-infrastructureMessages.ts | 12 +++++++ 2 files changed, 47 insertions(+) create mode 100644 developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_mdl.kpj diff --git a/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_mdl.kpj b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_mdl.kpj new file mode 100644 index 0000000000..0f17d70785 --- /dev/null +++ b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_mdl.kpj @@ -0,0 +1,35 @@ + + + + $PROJECTPATH + False + False + False + keyboard + + + + error_file_type_not_found_mdl_mdl_1 + error_file_type_not_found_mdl_mdl.kmn + error_file_type_not_found_mdl_mdl.kmn + 1.0 + .kmn +
+ error_file_type_not_found_mdl_mdl + Copyright (C) Keyman Team +
+
+ + + error_file_type_not_found_mdl_mdl_3 + error_file_type_not_found_mdl_mdl.kps + error_file_type_not_found_mdl_mdl.kps + + .kps +
+ error_file_type_not_found_mdl_mdl + Copyright (C) Keyman Team +
+
+
+
diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 23ea542416..2073b149f4 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -12,6 +12,7 @@ import { loadProject } from '../src/util/projectLoader.js'; import { defaultCompilerOptions, CompilerOptions} from '@keymanapp/common-types'; import { analyzeUnitTestEndpoints } from '../src/commands/analyze.js'; import { BuildKeyboardInfo } from '../src/commands/buildClasses/BuildKeyboardInfo.js'; +import { BuildModelInfo } from '../src/commands/buildClasses/BuildModelInfo.js'; describe('InfrastructureMessages', function () { @@ -119,6 +120,17 @@ describe('InfrastructureMessages', function () { `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); + // ERROR_FileTypeNotFound (BuildModelInfo; .model.ts) + + it('should generate ERROR_FileTypeNotFound if a project file does not contain a .model.ts file entry (BuildModelInfo)', async function() { + const buildModelInfo = new BuildModelInfo(); + const projectPath = makePathToFixture('invalid-projects', 'error_file_type_not_found_mdl_mdl.kpj') + const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); + await buildModelInfo.build(projectPath, ncb, {}); + assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotFound), + `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + }); + // HINT_FilenameHasDifferingCase it('should generate HINT_FilenameHasDifferingCase if a referenced file has differing case', async function() { From ca3362469f77489d4a2be40b9b44dc21842d5a2f Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 29 Jan 2024 10:21:35 +0000 Subject: [PATCH 11/26] chore(developer): add ERROR_FileTypeNotFound (BuildModelInfo; .kps) unit test --- .../error_file_type_not_found_mdl_kps.kpj | 35 +++++++++++++++++++ .../kmc/test/test-infrastructureMessages.ts | 11 ++++++ 2 files changed, 46 insertions(+) create mode 100644 developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_kps.kpj diff --git a/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_kps.kpj b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_kps.kpj new file mode 100644 index 0000000000..4fabebfa76 --- /dev/null +++ b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_kps.kpj @@ -0,0 +1,35 @@ + + + + $PROJECTPATH + False + False + False + keyboard + + + + error_file_type_not_found_mdl_kps_1 + error_file_type_not_found_mdl_kps.kmn + error_file_type_not_found_mdl_kps.kmn + 1.0 + .kmn +
+ error_file_type_not_found_mdl_kps + Copyright (C) Keyman Team +
+
+ + error_file_type_not_found_mdl_kps_2 + error_file_type_not_found_mdl_kps.model.ts + error_file_type_not_found_mdl_kps.model.ts + + .model.ts +
+ error_file_type_not_found_mdl_kps + Copyright (C) Keyman Team +
+
+ +
+
diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 2073b149f4..0079b65f0b 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -131,6 +131,17 @@ describe('InfrastructureMessages', function () { `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); + // ERROR_FileTypeNotFound (BuildModelInfo; .kps) + + it('should generate ERROR_FileTypeNotFound if a project file does not contain a .kps file entry (BuildModelInfo)', async function() { + const buildModelInfo = new BuildModelInfo(); + const projectPath = makePathToFixture('invalid-projects', 'error_file_type_not_found_mdl_kps.kpj') + const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); + await buildModelInfo.build(projectPath, ncb, {}); + assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotFound), + `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + }); + // HINT_FilenameHasDifferingCase it('should generate HINT_FilenameHasDifferingCase if a referenced file has differing case', async function() { From 5ef356a1949b0394b158c763966e1cbb44f54d11 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 1 Feb 2024 10:31:18 +0000 Subject: [PATCH 12/26] chore(developer): correct .kpj fixtures for ERROR_FileTypeNotFound BuildModelInfo tests --- .../error_file_type_not_found_mdl_kps.kpj | 15 ++------------- .../error_file_type_not_found_mdl_mdl.kpj | 15 ++------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_kps.kpj b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_kps.kpj index 4fabebfa76..3784422768 100644 --- a/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_kps.kpj +++ b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_kps.kpj @@ -5,22 +5,11 @@ False False False - keyboard + lexicalmodel - - error_file_type_not_found_mdl_kps_1 - error_file_type_not_found_mdl_kps.kmn - error_file_type_not_found_mdl_kps.kmn - 1.0 - .kmn -
- error_file_type_not_found_mdl_kps - Copyright (C) Keyman Team -
-
- error_file_type_not_found_mdl_kps_2 + error_file_type_not_found_mdl_kps_1 error_file_type_not_found_mdl_kps.model.ts error_file_type_not_found_mdl_kps.model.ts diff --git a/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_mdl.kpj b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_mdl.kpj index 0f17d70785..400028dfce 100644 --- a/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_mdl.kpj +++ b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_mdl.kpj @@ -5,23 +5,12 @@ False False False - keyboard + lexicalmodel - - error_file_type_not_found_mdl_mdl_1 - error_file_type_not_found_mdl_mdl.kmn - error_file_type_not_found_mdl_mdl.kmn - 1.0 - .kmn -
- error_file_type_not_found_mdl_mdl - Copyright (C) Keyman Team -
-
- error_file_type_not_found_mdl_mdl_3 + error_file_type_not_found_mdl_mdl_2 error_file_type_not_found_mdl_mdl.kps error_file_type_not_found_mdl_mdl.kps From 91524edfa9ad7413c7ff7a1830a7da210db56214 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 5 Feb 2024 11:07:42 +0000 Subject: [PATCH 13/26] chore(developer): add additional file type asserts to ERROR_FileTypeNotFound BuildModelInfo tests --- developer/src/kmc/test/test-infrastructureMessages.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 0079b65f0b..61984c275c 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -4,7 +4,7 @@ import { InfrastructureMessages } from '../src/messages/infrastructureMessages.j import { verifyCompilerMessagesObject } from '@keymanapp/developer-test-helpers'; import { makePathToFixture } from './helpers/index.js'; import { NodeCompilerCallbacks } from '../src/util/NodeCompilerCallbacks.js'; -import { CompilerErrorNamespace, CompilerEvent } from '@keymanapp/common-types'; +import { CompilerErrorNamespace, CompilerEvent, KeymanFileTypes } from '@keymanapp/common-types'; import { unitTestEndpoints } from '../src/commands/build.js'; import { KmnCompilerMessages } from '@keymanapp/kmc-kmn'; import { clearOptions } from '@keymanapp/developer-utils'; @@ -129,6 +129,8 @@ describe('InfrastructureMessages', function () { await buildModelInfo.build(projectPath, ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotFound), `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + assert.isTrue(nodeCompilerMessage(ncb, InfrastructureMessages.ERROR_FileTypeNotFound).includes(KeymanFileTypes.Source.Model), + KeymanFileTypes.Source.Model+` not found in the message`); }); // ERROR_FileTypeNotFound (BuildModelInfo; .kps) @@ -140,6 +142,8 @@ describe('InfrastructureMessages', function () { await buildModelInfo.build(projectPath, ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotFound), `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + assert.isTrue(nodeCompilerMessage(ncb, InfrastructureMessages.ERROR_FileTypeNotFound).includes(KeymanFileTypes.Source.Package), + KeymanFileTypes.Source.Package+` not found in the message`); }); // HINT_FilenameHasDifferingCase @@ -187,4 +191,8 @@ function assertMessagesEqual(actualMessages: CompilerEvent[], expectedMessages: assert.deepEqual(actualMessages.map(m => m.code), expectedMessages, `actual callbacks.messages:\n${JSON.stringify(actualMessages,null,2)}\n\n`+ `did not match expected:\n${JSON.stringify(expectedMessages,null,2)}\n\n`); +} + +function nodeCompilerMessage(ncb: NodeCompilerCallbacks, code: number): string { + return ncb.messages.find((item) => item.code == code).message ?? ''; } \ No newline at end of file From 9fa6d23a541db625d6f46d3bb20e83d0987c3f58 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Tue, 6 Feb 2024 10:25:36 +0000 Subject: [PATCH 14/26] chore(developer): change to reflect addition of outfile parameter to build methods --- developer/src/kmc/test/test-infrastructureMessages.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 61984c275c..7c581218c5 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -115,7 +115,7 @@ describe('InfrastructureMessages', function () { const buildKeyboardInfo = new BuildKeyboardInfo(); const projectPath = makePathToFixture('invalid-projects', 'error_file_type_not_found_kbd.kpj') const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); - await buildKeyboardInfo.build(projectPath, ncb, {}); + await buildKeyboardInfo.build(projectPath, '', ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotFound), `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); @@ -126,7 +126,7 @@ describe('InfrastructureMessages', function () { const buildModelInfo = new BuildModelInfo(); const projectPath = makePathToFixture('invalid-projects', 'error_file_type_not_found_mdl_mdl.kpj') const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); - await buildModelInfo.build(projectPath, ncb, {}); + await buildModelInfo.build(projectPath, '', ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotFound), `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); assert.isTrue(nodeCompilerMessage(ncb, InfrastructureMessages.ERROR_FileTypeNotFound).includes(KeymanFileTypes.Source.Model), @@ -139,7 +139,7 @@ describe('InfrastructureMessages', function () { const buildModelInfo = new BuildModelInfo(); const projectPath = makePathToFixture('invalid-projects', 'error_file_type_not_found_mdl_kps.kpj') const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); - await buildModelInfo.build(projectPath, ncb, {}); + await buildModelInfo.build(projectPath, '', ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotFound), `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); assert.isTrue(nodeCompilerMessage(ncb, InfrastructureMessages.ERROR_FileTypeNotFound).includes(KeymanFileTypes.Source.Package), From eb68475d35daf898693456204cbac92f157d851e Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Wed, 7 Feb 2024 17:13:59 +0000 Subject: [PATCH 15/26] chore(developer): correct error message in ERROR_UnknownFileFormat test --- developer/src/kmc/test/test-infrastructureMessages.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 7c581218c5..eda1f8dcdf 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -106,7 +106,7 @@ describe('InfrastructureMessages', function () { const options = {mappingFile: makePathToFixture('analyze', 'error_not_a_project_file.xxx')}; await analyzeUnitTestEndpoints.analyzeOskCharUse(ncb, [], options); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_UnknownFileFormat), - `ERROR_NotAProjectFile not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + `ERROR_UnknownFileFormat not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); // ERROR_FileTypeNotFound (BuildKeyboardInfo) From 1023c7c902cd416f4b04a458590707fa200e69d3 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 12 Feb 2024 10:27:34 +0000 Subject: [PATCH 16/26] chore(developer): add ERROR_InvalidProjectFolder (no source folder) unit test --- .../kmc/test/fixtures/empty-folder/.gitkeep | 0 .../kmc/test/test-infrastructureMessages.ts | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 developer/src/kmc/test/fixtures/empty-folder/.gitkeep diff --git a/developer/src/kmc/test/fixtures/empty-folder/.gitkeep b/developer/src/kmc/test/fixtures/empty-folder/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index eda1f8dcdf..bb8b15a755 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -146,6 +146,25 @@ describe('InfrastructureMessages', function () { KeymanFileTypes.Source.Package+` not found in the message`); }); + // ERROR_InvalidProjectFolder (no source folder) + it('should generate ERROR_InvalidProjectFolder if there is no source folder when generating a default project file', async function() { + const projectPath = makePathToFixture('empty-folder', 'error_invalid_project_folder.kpj') + const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); + loadProject(projectPath, ncb); + assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_InvalidProjectFolder), + `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + }); + + // ERROR_InvalidProjectFolder (invalid source folder) + + it('should generate ERROR_InvalidProjectFolder if there are no valid file types in the source folder when generating a default project file', async function() { + const projectPath = makePathToFixture('invalid-source-folder', 'error_invalid_project_folder.kpj') + const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); + loadProject(projectPath, ncb); + assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_InvalidProjectFolder), + `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + }); + // HINT_FilenameHasDifferingCase it('should generate HINT_FilenameHasDifferingCase if a referenced file has differing case', async function() { From ec8d2339a686537bec8377444e3387848fcdf5ff Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Mon, 12 Feb 2024 10:39:42 +0000 Subject: [PATCH 17/26] chore(developer): add ERROR_CannotCreateFolder infrastructure message unit test --- .../src/kmc/test/fixtures/invalid-projects/build | 1 + developer/src/kmc/test/test-infrastructureMessages.ts | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 developer/src/kmc/test/fixtures/invalid-projects/build diff --git a/developer/src/kmc/test/fixtures/invalid-projects/build b/developer/src/kmc/test/fixtures/invalid-projects/build new file mode 100644 index 0000000000..ce5a9fe3c0 --- /dev/null +++ b/developer/src/kmc/test/fixtures/invalid-projects/build @@ -0,0 +1 @@ +This is a file used to test the cannot create folder error (see test-infrastructureMessages.ts) \ No newline at end of file diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index bb8b15a755..c6f185acb5 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -165,6 +165,17 @@ describe('InfrastructureMessages', function () { `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); }); + // ERROR_CannotCreateFolder + + it('should generate ERROR_CannotCreateFolder if the output folder cannot be created', async function() { + const buildKeyboardInfo = new BuildKeyboardInfo(); + const targetFilename = makePathToFixture('invalid-projects', 'build', 'error_cannot create_folder.xxx') + const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); + buildKeyboardInfo['createOutputFolder'](targetFilename, ncb); // call private method + assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_CannotCreateFolder), + `ERROR_CannotCreateFolder not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + }); + // HINT_FilenameHasDifferingCase it('should generate HINT_FilenameHasDifferingCase if a referenced file has differing case', async function() { From f1fbb5a86a783e5861669a2f04093a3781d657ee Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 15 Feb 2024 09:43:28 +0000 Subject: [PATCH 18/26] chore(developer): change folder name in ERROR_InvalidProjectFolder (no source folder) test' --- developer/src/kmc/test/fixtures/empty-folder/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 developer/src/kmc/test/fixtures/empty-folder/.gitkeep diff --git a/developer/src/kmc/test/fixtures/empty-folder/.gitkeep b/developer/src/kmc/test/fixtures/empty-folder/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 From 1a53c9d0742a217309086ba0a4e4bef35db4d5fe Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 15 Feb 2024 09:50:14 +0000 Subject: [PATCH 19/26] chore(developer): rename fixture file in 'ERROR_FileTypeNotFound (BuildKeyboardInfo)' test --- .../error_file_type_not_found_kbd.kpj | 24 ------------------- .../kmc/test/test-infrastructureMessages.ts | 4 ++-- 2 files changed, 2 insertions(+), 26 deletions(-) delete mode 100644 developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_kbd.kpj diff --git a/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_kbd.kpj b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_kbd.kpj deleted file mode 100644 index dd35f982a1..0000000000 --- a/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_kbd.kpj +++ /dev/null @@ -1,24 +0,0 @@ - - - - $PROJECTPATH - False - False - False - keyboard - - - - error_file_type_not_found_kbd_1 - error_file_type_not_found_kbd.kmn - error_file_type_not_found_kbd.kmn - 1.0 - .kmn -
- error_file_type_not_found_kbd - Copyright (C) Keyman Team -
-
- -
-
diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index c6f185acb5..36728df188 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -113,7 +113,7 @@ describe('InfrastructureMessages', function () { it('should generate ERROR_FileTypeNotFound if a project file does not contain a .kps file entry (BuildKeyboardInfo)', async function() { const buildKeyboardInfo = new BuildKeyboardInfo(); - const projectPath = makePathToFixture('invalid-projects', 'error_file_type_not_found_kbd.kpj') + const projectPath = makePathToFixture('invalid-projects', 'error_file_type_not_found__keyboard.kpj') const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); await buildKeyboardInfo.build(projectPath, '', ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotFound), @@ -148,7 +148,7 @@ describe('InfrastructureMessages', function () { // ERROR_InvalidProjectFolder (no source folder) it('should generate ERROR_InvalidProjectFolder if there is no source folder when generating a default project file', async function() { - const projectPath = makePathToFixture('empty-folder', 'error_invalid_project_folder.kpj') + const projectPath = makePathToFixture('no-source-folder', 'error_invalid_project_folder.kpj') const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); loadProject(projectPath, ncb); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_InvalidProjectFolder), From 1e292c34dc63023ff2ee2c296dfd9d79e4534920 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 15 Feb 2024 09:54:03 +0000 Subject: [PATCH 20/26] chore(developer): rename fixture file in 'ERROR_FileTypeNotFound (BuildModelInfo; .kps)' test --- .../error_file_type_not_found_mdl_kps.kpj | 24 ------------------- .../kmc/test/test-infrastructureMessages.ts | 2 +- 2 files changed, 1 insertion(+), 25 deletions(-) delete mode 100644 developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_kps.kpj diff --git a/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_kps.kpj b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_kps.kpj deleted file mode 100644 index 3784422768..0000000000 --- a/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_kps.kpj +++ /dev/null @@ -1,24 +0,0 @@ - - - - $PROJECTPATH - False - False - False - lexicalmodel - - - - error_file_type_not_found_mdl_kps_1 - error_file_type_not_found_mdl_kps.model.ts - error_file_type_not_found_mdl_kps.model.ts - - .model.ts -
- error_file_type_not_found_mdl_kps - Copyright (C) Keyman Team -
-
- -
-
diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 36728df188..c315b5d221 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -137,7 +137,7 @@ describe('InfrastructureMessages', function () { it('should generate ERROR_FileTypeNotFound if a project file does not contain a .kps file entry (BuildModelInfo)', async function() { const buildModelInfo = new BuildModelInfo(); - const projectPath = makePathToFixture('invalid-projects', 'error_file_type_not_found_mdl_kps.kpj') + const projectPath = makePathToFixture('invalid-projects', 'error_file_type_not_found__model_kps.kpj') const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); await buildModelInfo.build(projectPath, '', ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotFound), From f4b1c968cc5f40f752c5bf550719d34d3c3a18f5 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 15 Feb 2024 10:07:50 +0000 Subject: [PATCH 21/26] chore(developer): changes to files that should have been added to previous commits --- .../error_file_type_not_found__keyboard.kpj | 24 +++++++++++++++++++ .../error_file_type_not_found__model_kps.kpj | 24 +++++++++++++++++++ .../test/fixtures/no-source-folder/.gitkeep | 0 3 files changed, 48 insertions(+) create mode 100644 developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found__keyboard.kpj create mode 100644 developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found__model_kps.kpj create mode 100644 developer/src/kmc/test/fixtures/no-source-folder/.gitkeep diff --git a/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found__keyboard.kpj b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found__keyboard.kpj new file mode 100644 index 0000000000..c810dc7c33 --- /dev/null +++ b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found__keyboard.kpj @@ -0,0 +1,24 @@ + + + + $PROJECTPATH + False + False + False + keyboard + + + + error_file_type_not_found_kbd_1 + error_file_type_not_found__keyboard.kmn + error_file_type_not_found__keyboard.kmn + 1.0 + .kmn +
+ error_file_type_not_found__keyboard + Copyright (C) Keyman Team +
+
+ +
+
diff --git a/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found__model_kps.kpj b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found__model_kps.kpj new file mode 100644 index 0000000000..aa1e55d9ae --- /dev/null +++ b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found__model_kps.kpj @@ -0,0 +1,24 @@ + + + + $PROJECTPATH + False + False + False + lexicalmodel + + + + error_file_type_not_found_mdl_kps_1 + error_file_type_not_found__model_kps.model.ts + error_file_type_not_found__model_kps.model.ts + + .model.ts +
+ error_file_type_not_found__model_kps + Copyright (C) Keyman Team +
+
+ +
+
diff --git a/developer/src/kmc/test/fixtures/no-source-folder/.gitkeep b/developer/src/kmc/test/fixtures/no-source-folder/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 From 62589599a084b9484a4014a043e250aa3a857477 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 15 Feb 2024 10:11:23 +0000 Subject: [PATCH 22/26] chore(developer): rename fixture file in 'ERROR_FileTypeNotFound (BuildModelInfo; .model.ts)' --- ..._mdl_mdl.kpj => error_file_type_not_found__model_ts.kpj} | 6 +++--- developer/src/kmc/test/test-infrastructureMessages.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename developer/src/kmc/test/fixtures/invalid-projects/{error_file_type_not_found_mdl_mdl.kpj => error_file_type_not_found__model_ts.kpj} (78%) diff --git a/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_mdl.kpj b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found__model_ts.kpj similarity index 78% rename from developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_mdl.kpj rename to developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found__model_ts.kpj index 400028dfce..3d69834913 100644 --- a/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found_mdl_mdl.kpj +++ b/developer/src/kmc/test/fixtures/invalid-projects/error_file_type_not_found__model_ts.kpj @@ -11,12 +11,12 @@ error_file_type_not_found_mdl_mdl_2 - error_file_type_not_found_mdl_mdl.kps - error_file_type_not_found_mdl_mdl.kps + error_file_type_not_found__model_ts.kps + error_file_type_not_found__model_ts.kps .kps
- error_file_type_not_found_mdl_mdl + error_file_type_not_found__model_ts Copyright (C) Keyman Team
diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index c315b5d221..8b55751dd1 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -124,7 +124,7 @@ describe('InfrastructureMessages', function () { it('should generate ERROR_FileTypeNotFound if a project file does not contain a .model.ts file entry (BuildModelInfo)', async function() { const buildModelInfo = new BuildModelInfo(); - const projectPath = makePathToFixture('invalid-projects', 'error_file_type_not_found_mdl_mdl.kpj') + const projectPath = makePathToFixture('invalid-projects', 'error_file_type_not_found__model_ts.kpj') const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); await buildModelInfo.build(projectPath, '', ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotFound), From 429cad07039ca6404d4cbe8ef91314aa53b83b68 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 15 Feb 2024 10:23:32 +0000 Subject: [PATCH 23/26] chore(developer): change unnecessary template literals to single quotes in tests --- .../kmc/test/test-infrastructureMessages.ts | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 8b55751dd1..9403f58745 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -46,7 +46,7 @@ describe('InfrastructureMessages', function () { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); await unitTestEndpoints.build(makePathToFixture('invalid-keyboards', 'Error_File_Does_Not_Exist.kmn'), '', ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileDoesNotExist), - `ERROR_FileDoesNotExist not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + 'ERROR_FileDoesNotExist not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); }); // ERROR_FileTypeNotRecognized @@ -55,7 +55,7 @@ describe('InfrastructureMessages', function () { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); await unitTestEndpoints.build(makePathToFixture('invalid-keyboards', 'error_file_type_not_recognized.xxx'), '', ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotRecognized), - `ERROR_FileTypeNotRecognized not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + 'ERROR_FileTypeNotRecognized not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); }); // ERROR_OutFileNotValidForProjects @@ -67,7 +67,7 @@ describe('InfrastructureMessages', function () { const options: CompilerOptions = {...defaultCompilerOptions}; await unitTestEndpoints.build(projectPath, outFilePath, ncb, options); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_OutFileNotValidForProjects), - `ERROR_OutFileNotValidForProjects not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + 'ERROR_OutFileNotValidForProjects not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); }); // ERROR_InvalidProjectFile @@ -76,7 +76,7 @@ describe('InfrastructureMessages', function () { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); await unitTestEndpoints.build(makePathToFixture('invalid-projects', 'error_invalid_project_file.kpj'), '', ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_InvalidProjectFile), - `ERROR_InvalidProjectFile not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + 'ERROR_InvalidProjectFile not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); }); // ERROR_InvalidProjectFolder (invalid source folder) @@ -96,7 +96,7 @@ describe('InfrastructureMessages', function () { const projectPath = makePathToFixture('invalid-projects', 'error_not_a_project_file.xxx') loadProject(projectPath, ncb); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_NotAProjectFile), - `ERROR_NotAProjectFile not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + 'ERROR_NotAProjectFile not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); }); // ERROR_UnknownFileFormat @@ -106,7 +106,7 @@ describe('InfrastructureMessages', function () { const options = {mappingFile: makePathToFixture('analyze', 'error_not_a_project_file.xxx')}; await analyzeUnitTestEndpoints.analyzeOskCharUse(ncb, [], options); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_UnknownFileFormat), - `ERROR_UnknownFileFormat not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + 'ERROR_UnknownFileFormat not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); }); // ERROR_FileTypeNotFound (BuildKeyboardInfo) @@ -117,7 +117,7 @@ describe('InfrastructureMessages', function () { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); await buildKeyboardInfo.build(projectPath, '', ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotFound), - `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + 'ERROR_FileTypeNotFound not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); }); // ERROR_FileTypeNotFound (BuildModelInfo; .model.ts) @@ -128,9 +128,9 @@ describe('InfrastructureMessages', function () { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); await buildModelInfo.build(projectPath, '', ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotFound), - `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + 'ERROR_FileTypeNotFound not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); assert.isTrue(nodeCompilerMessage(ncb, InfrastructureMessages.ERROR_FileTypeNotFound).includes(KeymanFileTypes.Source.Model), - KeymanFileTypes.Source.Model+` not found in the message`); + KeymanFileTypes.Source.Model+' not found in the message'); }); // ERROR_FileTypeNotFound (BuildModelInfo; .kps) @@ -141,9 +141,9 @@ describe('InfrastructureMessages', function () { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); await buildModelInfo.build(projectPath, '', ncb, {}); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_FileTypeNotFound), - `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + 'ERROR_FileTypeNotFound not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); assert.isTrue(nodeCompilerMessage(ncb, InfrastructureMessages.ERROR_FileTypeNotFound).includes(KeymanFileTypes.Source.Package), - KeymanFileTypes.Source.Package+` not found in the message`); + KeymanFileTypes.Source.Package+' not found in the message'); }); // ERROR_InvalidProjectFolder (no source folder) @@ -152,7 +152,7 @@ describe('InfrastructureMessages', function () { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); loadProject(projectPath, ncb); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_InvalidProjectFolder), - `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + 'ERROR_FileTypeNotFound not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); }); // ERROR_InvalidProjectFolder (invalid source folder) @@ -162,7 +162,7 @@ describe('InfrastructureMessages', function () { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); loadProject(projectPath, ncb); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_InvalidProjectFolder), - `ERROR_FileTypeNotFound not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + 'ERROR_FileTypeNotFound not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); }); // ERROR_CannotCreateFolder @@ -173,7 +173,7 @@ describe('InfrastructureMessages', function () { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); buildKeyboardInfo['createOutputFolder'](targetFilename, ncb); // call private method assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_CannotCreateFolder), - `ERROR_CannotCreateFolder not generated, instead got: `+JSON.stringify(ncb.messages,null,2)); + 'ERROR_CannotCreateFolder not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); }); // HINT_FilenameHasDifferingCase From eff01fb3a156daa801fac87bc77a6afc39b27ea6 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 15 Feb 2024 10:33:14 +0000 Subject: [PATCH 24/26] chore(developer): corrected filename in ERROR_UnknownFileFormat unit test --- developer/src/kmc/test/test-infrastructureMessages.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 9403f58745..6567b4e07d 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -103,7 +103,7 @@ describe('InfrastructureMessages', function () { it('should generate ERROR_UnknownFileFormat if an analyze osk-char-use mapping file is not the correct type', async function() { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); - const options = {mappingFile: makePathToFixture('analyze', 'error_not_a_project_file.xxx')}; + const options = {mappingFile: makePathToFixture('analyze', 'error_unknown_file_format.xxx')}; await analyzeUnitTestEndpoints.analyzeOskCharUse(ncb, [], options); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_UnknownFileFormat), 'ERROR_UnknownFileFormat not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); From dc5a6aabb4a41bf248874622b5afe5f4a7eac867 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 15 Feb 2024 10:42:26 +0000 Subject: [PATCH 25/26] chore(developer): added missing underscore in filename in ERROR_CannotCreateFolder test --- developer/src/kmc/test/test-infrastructureMessages.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 6567b4e07d..4eb08e454b 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -169,7 +169,7 @@ describe('InfrastructureMessages', function () { it('should generate ERROR_CannotCreateFolder if the output folder cannot be created', async function() { const buildKeyboardInfo = new BuildKeyboardInfo(); - const targetFilename = makePathToFixture('invalid-projects', 'build', 'error_cannot create_folder.xxx') + const targetFilename = makePathToFixture('invalid-projects', 'build', 'error_cannot_create_folder.xxx') const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); buildKeyboardInfo['createOutputFolder'](targetFilename, ncb); // call private method assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_CannotCreateFolder), From d670e471869588d7e003ebbbb398da333f9dd139 Mon Sep 17 00:00:00 2001 From: "Dr Mark C. Sinclair" Date: Thu, 15 Feb 2024 10:50:13 +0000 Subject: [PATCH 26/26] chore(developer): corrected assert message in both ERROR_InvalidProjectFolder tests --- developer/src/kmc/test/test-infrastructureMessages.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/developer/src/kmc/test/test-infrastructureMessages.ts b/developer/src/kmc/test/test-infrastructureMessages.ts index 4eb08e454b..6d8da21b31 100644 --- a/developer/src/kmc/test/test-infrastructureMessages.ts +++ b/developer/src/kmc/test/test-infrastructureMessages.ts @@ -152,7 +152,7 @@ describe('InfrastructureMessages', function () { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); loadProject(projectPath, ncb); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_InvalidProjectFolder), - 'ERROR_FileTypeNotFound not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); + 'ERROR_InvalidProjectFolder not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); }); // ERROR_InvalidProjectFolder (invalid source folder) @@ -162,7 +162,7 @@ describe('InfrastructureMessages', function () { const ncb = new NodeCompilerCallbacks({logLevel: 'silent'}); loadProject(projectPath, ncb); assert.isTrue(ncb.hasMessage(InfrastructureMessages.ERROR_InvalidProjectFolder), - 'ERROR_FileTypeNotFound not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); + 'ERROR_InvalidProjectFolder not generated, instead got: '+JSON.stringify(ncb.messages,null,2)); }); // ERROR_CannotCreateFolder