mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-21 07:07:39 +00:00
chore(developer): move package version unit tests into Typescript
This commit is contained in:
parent
7dc8743cd3
commit
5a6758d12e
23 changed files with 47 additions and 1378 deletions
1
developer/src/kmc-package/test/fixtures/versioning/test-1.0/test.js
vendored
Normal file
1
developer/src/kmc-package/test/fixtures/versioning/test-1.0/test.js
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
KeymanWeb.KR(new Keyboard_test());function Keyboard_test(){this._v=(typeof keyman!="undefined"&&typeof keyman.version=="string")?parseInt(keyman.version,10):9;this.KI="Keyboard_test";this.KN="Keyboard Version Test";this.KMINVER="9.0";this.KV=null;this.KDU=0;this.KH='';this.KM=0;this.KBVER="1.0";this.KMBM=0x0;this.KVER="17.0.159.0";this.KVS=[];this.gs=function(t,e) {return this.g0(t,e);};this.gs=function(t,e) {return this.g0(t,e);};this.g0=function(t,e) {var k=KeymanWeb,r=0,m=0;return r;};}
|
||||
BIN
developer/src/kmc-package/test/fixtures/versioning/test-1.0/test.kmx
vendored
Normal file
BIN
developer/src/kmc-package/test/fixtures/versioning/test-1.0/test.kmx
vendored
Normal file
Binary file not shown.
1
developer/src/kmc-package/test/fixtures/versioning/test-2.0/test.js
vendored
Normal file
1
developer/src/kmc-package/test/fixtures/versioning/test-2.0/test.js
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
KeymanWeb.KR(new Keyboard_test());function Keyboard_test(){this._v=(typeof keyman!="undefined"&&typeof keyman.version=="string")?parseInt(keyman.version,10):9;this.KI="Keyboard_test";this.KN="Keyboard Version Test";this.KMINVER="9.0";this.KV=null;this.KDU=0;this.KH='';this.KM=0;this.KBVER="2.0";this.KMBM=0x0;this.KVER="17.0.159.0";this.KVS=[];this.gs=function(t,e) {return this.g0(t,e);};this.gs=function(t,e) {return this.g0(t,e);};this.g0=function(t,e) {var k=KeymanWeb,r=0,m=0;return r;};}
|
||||
BIN
developer/src/kmc-package/test/fixtures/versioning/test-2.0/test.kmx
vendored
Normal file
BIN
developer/src/kmc-package/test/fixtures/versioning/test-2.0/test.kmx
vendored
Normal file
Binary file not shown.
42
developer/src/kmc-package/test/test-versioning.ts
Normal file
42
developer/src/kmc-package/test/test-versioning.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import 'mocha';
|
||||
import { assert } from 'chai';
|
||||
import { TestCompilerCallbacks } from '@keymanapp/developer-test-helpers';
|
||||
import { makePathToFixture } from './helpers/index.js';
|
||||
import { KmpCompiler } from '../src/compiler/kmp-compiler.js';
|
||||
import { KmpJsonFile } from '@keymanapp/common-types';
|
||||
|
||||
// This unit test was translated from a Delphi test
|
||||
// Keyman.Test.System.CompilePackageVersioningTest, but note the difference in
|
||||
// test results documented below.
|
||||
|
||||
describe('package versioning', function () {
|
||||
|
||||
const cases: [string,string][] = [
|
||||
['test-single-version-1-package', 'test1.kps'],
|
||||
['test-single-version-2-package', 'test2.kps'],
|
||||
|
||||
// The test result for the following two packages has changed in Keyman 17,
|
||||
// in commit 92c8c6497e987a0583c62c91515884e6e36ece23, to 'shouldPass':
|
||||
//
|
||||
// `WARN_KeyboardVersionsDoNotMatchPackageVersion` has been removed, because
|
||||
// it did not really make sense; if 'FollowKeyboardVersion' is set, it could
|
||||
// not be raised, and otherwise, the author may wish to have separate
|
||||
// keyboard + package versions anyway.
|
||||
|
||||
['test-version-2-1-mismatch', 'test2-1.kps'],
|
||||
['test-version-1-2-mismatch', 'test1-2.kps'],
|
||||
|
||||
['test-keyboard-1-package-2', 'test-keyboard-1-vs-package-2.kps'],
|
||||
['test-package-1-keyboard-2', 'test-package-1-vs-keyboard-2.kps'],
|
||||
];
|
||||
|
||||
for(const [ caseTitle, filename ] of cases) {
|
||||
it(caseTitle, async function () {
|
||||
const callbacks = new TestCompilerCallbacks();
|
||||
const kmpCompiler = new KmpCompiler(callbacks);
|
||||
const kpsPath = makePathToFixture('versioning', filename);
|
||||
const kmpJson: KmpJsonFile.KmpJsonFile = kmpCompiler.transformKpsToKmpObject(kpsPath);
|
||||
assert.isTrue(kmpJson !== null);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -16,7 +16,6 @@ test:
|
|||
developer-tests: \
|
||||
compile-supplementary-support \
|
||||
keyboard-js-info \
|
||||
keyboard-package-versions \
|
||||
kmcomp \
|
||||
kmcomp-x64-structures \
|
||||
kmconvert \
|
||||
|
|
@ -44,10 +43,6 @@ kmx-file-languages: .virtual
|
|||
cd $(DEVELOPER_ROOT)\src\test\auto\kmx-file-languages
|
||||
$(MAKE) $(TARGET)
|
||||
|
||||
keyboard-package-versions: .virtual
|
||||
cd $(DEVELOPER_ROOT)\src\test\auto\keyboard-package-versions
|
||||
$(MAKE) $(TARGET)
|
||||
|
||||
kmcomp: .virtual
|
||||
cd $(DEVELOPER_ROOT)\src\test\auto\kmcomp
|
||||
$(MAKE) $(TARGET)
|
||||
|
|
|
|||
|
|
@ -6,9 +6,6 @@
|
|||
<Projects Include="keyboard-js-info\KeyboardJSInfoTestSuite.dproj">
|
||||
<Dependencies/>
|
||||
</Projects>
|
||||
<Projects Include="keyboard-package-versions\KeyboardPackageVersionsTestSuite.dproj">
|
||||
<Dependencies/>
|
||||
</Projects>
|
||||
<Projects Include="kmcomp-x64-structures\passtructsize\passtructsize.dproj">
|
||||
<Dependencies/>
|
||||
</Projects>
|
||||
|
|
@ -41,15 +38,6 @@
|
|||
<Target Name="KeyboardJSInfoTestSuite:Make">
|
||||
<MSBuild Projects="keyboard-js-info\KeyboardJSInfoTestSuite.dproj" Targets="Make"/>
|
||||
</Target>
|
||||
<Target Name="KeyboardPackageVersionsTestSuite">
|
||||
<MSBuild Projects="keyboard-package-versions\KeyboardPackageVersionsTestSuite.dproj"/>
|
||||
</Target>
|
||||
<Target Name="KeyboardPackageVersionsTestSuite:Clean">
|
||||
<MSBuild Projects="keyboard-package-versions\KeyboardPackageVersionsTestSuite.dproj" Targets="Clean"/>
|
||||
</Target>
|
||||
<Target Name="KeyboardPackageVersionsTestSuite:Make">
|
||||
<MSBuild Projects="keyboard-package-versions\KeyboardPackageVersionsTestSuite.dproj" Targets="Make"/>
|
||||
</Target>
|
||||
<Target Name="passtructsize">
|
||||
<MSBuild Projects="kmcomp-x64-structures\passtructsize\passtructsize.dproj"/>
|
||||
</Target>
|
||||
|
|
@ -96,13 +84,13 @@
|
|||
<MSBuild Projects="package-info\PackageInfoTestSuite.dproj" Targets="Make"/>
|
||||
</Target>
|
||||
<Target Name="Build">
|
||||
<CallTarget Targets="KeyboardJSInfoTestSuite;KeyboardPackageVersionsTestSuite;passtructsize;kmconverttest;KMXFileLanguagesTestSuite;ModelTsParserTest;PackageInfoTestSuite"/>
|
||||
<CallTarget Targets="KeyboardJSInfoTestSuite;passtructsize;kmconverttest;KMXFileLanguagesTestSuite;ModelTsParserTest;PackageInfoTestSuite"/>
|
||||
</Target>
|
||||
<Target Name="Clean">
|
||||
<CallTarget Targets="KeyboardJSInfoTestSuite:Clean;KeyboardPackageVersionsTestSuite:Clean;passtructsize:Clean;kmconverttest:Clean;KMXFileLanguagesTestSuite:Clean;ModelTsParserTest:Clean;PackageInfoTestSuite:Clean"/>
|
||||
<CallTarget Targets="KeyboardJSInfoTestSuite:Clean;Clean;passtructsize:Clean;kmconverttest:Clean;KMXFileLanguagesTestSuite:Clean;ModelTsParserTest:Clean;PackageInfoTestSuite:Clean"/>
|
||||
</Target>
|
||||
<Target Name="Make">
|
||||
<CallTarget Targets="KeyboardJSInfoTestSuite:Make;KeyboardPackageVersionsTestSuite:Make;passtructsize:Make;kmconverttest:Make;KMXFileLanguagesTestSuite:Make;ModelTsParserTest:Make;PackageInfoTestSuite:Make"/>
|
||||
<CallTarget Targets="KeyboardJSInfoTestSuite:Make;Make;passtructsize:Make;kmconverttest:Make;KMXFileLanguagesTestSuite:Make;ModelTsParserTest:Make;PackageInfoTestSuite:Make"/>
|
||||
</Target>
|
||||
<Import Project="$(BDS)\Bin\CodeGear.Group.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')"/>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
*.kmp
|
||||
test-?.0/*.js
|
||||
test-?.0/*.kmx
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
program KeyboardPackageVersionsTestSuite;
|
||||
|
||||
{$IFNDEF TESTINSIGHT}
|
||||
{$APPTYPE CONSOLE}
|
||||
{$ENDIF}{$STRONGLINKTYPES ON}
|
||||
uses
|
||||
System.SysUtils,
|
||||
{$IFDEF TESTINSIGHT}
|
||||
TestInsight.DUnitX,
|
||||
{$ENDIF }
|
||||
DUnitX.Loggers.Console,
|
||||
DUnitX.Loggers.Xml.NUnit,
|
||||
DUnitX.TestFramework,
|
||||
Keyman.Test.System.CompilePackageVersioningTest in 'Keyman.Test.System.CompilePackageVersioningTest.pas',
|
||||
CompilePackage in '..\..\..\common\delphi\compiler\CompilePackage.pas',
|
||||
VisualKeyboard in '..\..\..\..\..\common\windows\delphi\visualkeyboard\VisualKeyboard.pas',
|
||||
kmpinffile in '..\..\..\..\..\common\windows\delphi\packages\kmpinffile.pas',
|
||||
kpsfile in '..\..\..\common\delphi\packages\kpsfile.pas',
|
||||
PackageFileFormats in '..\..\..\..\..\common\windows\delphi\packages\PackageFileFormats.pas',
|
||||
PackageInfo in '..\..\..\..\..\common\windows\delphi\packages\PackageInfo.pas',
|
||||
utilfiletypes in '..\..\..\..\..\common\windows\delphi\general\utilfiletypes.pas',
|
||||
StockFileNames in '..\..\..\..\..\common\windows\delphi\general\StockFileNames.pas',
|
||||
utilstr in '..\..\..\..\..\common\windows\delphi\general\utilstr.pas',
|
||||
Unicode in '..\..\..\..\..\common\windows\delphi\general\Unicode.pas',
|
||||
JsonUtil in '..\..\..\..\..\common\windows\delphi\general\JsonUtil.pas',
|
||||
KeymanVersion in '..\..\..\..\..\common\windows\delphi\general\KeymanVersion.pas',
|
||||
utildir in '..\..\..\..\..\common\windows\delphi\general\utildir.pas',
|
||||
utilsystem in '..\..\..\..\..\common\windows\delphi\general\utilsystem.pas',
|
||||
RegistryKeys in '..\..\..\..\..\common\windows\delphi\general\RegistryKeys.pas',
|
||||
utilexecute in '..\..\..\..\..\common\windows\delphi\general\utilexecute.pas',
|
||||
GetOsVersion in '..\..\..\..\..\common\windows\delphi\general\GetOsVersion.pas',
|
||||
VersionInfo in '..\..\..\..\..\common\windows\delphi\general\VersionInfo.pas',
|
||||
ExtShiftState in '..\..\..\..\..\common\windows\delphi\visualkeyboard\ExtShiftState.pas',
|
||||
VisualKeyboardLoaderBinary in '..\..\..\..\..\common\windows\delphi\visualkeyboard\VisualKeyboardLoaderBinary.pas',
|
||||
VisualKeyboardLoaderXML in '..\..\..\..\..\common\windows\delphi\visualkeyboard\VisualKeyboardLoaderXML.pas',
|
||||
VisualKeyboardSaverBinary in '..\..\..\..\..\common\windows\delphi\visualkeyboard\VisualKeyboardSaverBinary.pas',
|
||||
VisualKeyboardSaverXML in '..\..\..\..\..\common\windows\delphi\visualkeyboard\VisualKeyboardSaverXML.pas',
|
||||
VKeyChars in '..\..\..\..\..\common\windows\delphi\general\VKeyChars.pas',
|
||||
VKeys in '..\..\..\..\..\common\windows\delphi\general\VKeys.pas',
|
||||
ErrorControlledRegistry in '..\..\..\..\..\common\windows\delphi\vcl\ErrorControlledRegistry.pas',
|
||||
kmxfile in '..\..\..\..\..\common\windows\delphi\keyboards\kmxfile.pas',
|
||||
KeyNames in '..\..\..\..\..\common\windows\delphi\general\KeyNames.pas',
|
||||
KeymanDeveloperOptions in '..\..\..\tike\main\KeymanDeveloperOptions.pas',
|
||||
Keyman.System.PackageInfoRefreshKeyboards in '..\..\..\common\delphi\packages\Keyman.System.PackageInfoRefreshKeyboards.pas',
|
||||
Keyman.System.KeyboardJSInfo in '..\..\..\common\delphi\keyboards\Keyman.System.KeyboardJSInfo.pas',
|
||||
Keyman.System.KeyboardUtils in '..\..\..\common\delphi\keyboards\Keyman.System.KeyboardUtils.pas',
|
||||
Keyman.System.KMXFileLanguages in '..\..\..\common\delphi\keyboards\Keyman.System.KMXFileLanguages.pas',
|
||||
Keyman.System.Standards.ISO6393ToBCP47Registry in '..\..\..\..\..\common\windows\delphi\standards\Keyman.System.Standards.ISO6393ToBCP47Registry.pas',
|
||||
Keyman.System.Standards.LCIDToBCP47Registry in '..\..\..\..\..\common\windows\delphi\standards\Keyman.System.Standards.LCIDToBCP47Registry.pas',
|
||||
TempFileManager in '..\..\..\..\..\common\windows\delphi\general\TempFileManager.pas',
|
||||
RedistFiles in '..\..\..\tike\main\RedistFiles.pas',
|
||||
DebugPaths in '..\..\..\..\..\common\windows\delphi\general\DebugPaths.pas',
|
||||
Upload_Settings in '..\..\..\..\..\common\windows\delphi\general\Upload_Settings.pas',
|
||||
klog in '..\..\..\..\..\common\windows\delphi\general\klog.pas',
|
||||
compile in '..\..\..\common\delphi\compiler\compile.pas',
|
||||
Keyman.Developer.System.Project.kmnProjectFile in '..\..\..\tike\project\Keyman.Developer.System.Project.kmnProjectFile.pas',
|
||||
Keyman.Developer.System.Project.kmnProjectFileAction in '..\..\..\tike\project\Keyman.Developer.System.Project.kmnProjectFileAction.pas',
|
||||
Keyman.Developer.System.Project.Project in '..\..\..\tike\project\Keyman.Developer.System.Project.Project.pas',
|
||||
Keyman.Developer.System.Project.ProjectFile in '..\..\..\tike\project\Keyman.Developer.System.Project.ProjectFile.pas',
|
||||
Keyman.Developer.System.Project.ProjectFiles in '..\..\..\tike\project\Keyman.Developer.System.Project.ProjectFiles.pas',
|
||||
Keyman.Developer.System.Project.ProjectFileType in '..\..\..\tike\project\Keyman.Developer.System.Project.ProjectFileType.pas',
|
||||
mrulist in '..\..\..\tike\main\mrulist.pas',
|
||||
kmxfileconsts in '..\..\..\..\..\common\windows\delphi\keyboards\kmxfileconsts.pas',
|
||||
Keyman.Developer.System.Project.ProjectLoader in '..\..\..\tike\project\Keyman.Developer.System.Project.ProjectLoader.pas',
|
||||
Keyman.Developer.System.Project.ProjectLog in '..\..\..\tike\project\Keyman.Developer.System.Project.ProjectLog.pas',
|
||||
Keyman.Developer.System.Project.ProjectSaver in '..\..\..\tike\project\Keyman.Developer.System.Project.ProjectSaver.pas',
|
||||
UKeymanTargets in '..\..\..\common\delphi\general\UKeymanTargets.pas',
|
||||
CompileErrorCodes in '..\..\..\common\delphi\compiler\CompileErrorCodes.pas',
|
||||
KeyboardParser in '..\..\..\tike\main\KeyboardParser.pas',
|
||||
WindowsLanguages in '..\..\..\common\delphi\general\WindowsLanguages.pas',
|
||||
KeymanWebKeyCodes in '..\..\..\tike\compile\KeymanWebKeyCodes.pas',
|
||||
kmxfileutils in '..\..\..\..\..\common\windows\delphi\keyboards\kmxfileutils.pas',
|
||||
TouchLayoutDefinitions in '..\..\..\tike\oskbuilder\TouchLayoutDefinitions.pas',
|
||||
TouchLayout in '..\..\..\tike\oskbuilder\TouchLayout.pas',
|
||||
KeyboardFonts in '..\..\..\common\delphi\general\KeyboardFonts.pas',
|
||||
Keyman.Developer.System.Project.kpsProjectFile in '..\..\..\tike\project\Keyman.Developer.System.Project.kpsProjectFile.pas',
|
||||
Keyman.Developer.System.Project.kpsProjectFileAction in '..\..\..\tike\project\Keyman.Developer.System.Project.kpsProjectFileAction.pas',
|
||||
CompilePackageInstaller in '..\..\..\common\delphi\compiler\CompilePackageInstaller.pas',
|
||||
utilhttp in '..\..\..\..\..\common\windows\delphi\general\utilhttp.pas',
|
||||
Keyman.System.LanguageCodeUtils in '..\..\..\..\..\common\windows\delphi\general\Keyman.System.LanguageCodeUtils.pas',
|
||||
Keyman.System.RegExGroupHelperRSP19902 in '..\..\..\..\..\common\windows\delphi\vcl\Keyman.System.RegExGroupHelperRSP19902.pas',
|
||||
DUnitX.Loggers.TeamCity in '..\..\..\..\..\common\windows\delphi\general\DUnitX.Loggers.TeamCity.pas',
|
||||
BCP47Tag in '..\..\..\..\..\common\windows\delphi\general\BCP47Tag.pas',
|
||||
Keyman.System.Standards.BCP47SubtagRegistry in '..\..\..\..\..\common\windows\delphi\standards\Keyman.System.Standards.BCP47SubtagRegistry.pas',
|
||||
Keyman.System.Standards.BCP47SuppressScriptRegistry in '..\..\..\..\..\common\windows\delphi\standards\Keyman.System.Standards.BCP47SuppressScriptRegistry.pas',
|
||||
Keyman.System.CanonicalLanguageCodeUtils in '..\..\..\..\..\common\windows\delphi\general\Keyman.System.CanonicalLanguageCodeUtils.pas',
|
||||
TextFileFormat in '..\..\..\common\delphi\general\TextFileFormat.pas',
|
||||
Keyman.System.LexicalModelUtils in '..\..\..\common\delphi\lexicalmodels\Keyman.System.LexicalModelUtils.pas',
|
||||
Keyman.System.PackageInfoRefreshLexicalModels in '..\..\..\common\delphi\packages\Keyman.System.PackageInfoRefreshLexicalModels.pas',
|
||||
Keyman.System.Standards.LangTagsRegistry in '..\..\..\..\..\common\windows\delphi\standards\Keyman.System.Standards.LangTagsRegistry.pas',
|
||||
Keyman.Developer.System.Project.UrlRenderer in '..\..\..\tike\project\Keyman.Developer.System.Project.UrlRenderer.pas',
|
||||
KeymanPaths in '..\..\..\..\..\common\windows\delphi\general\KeymanPaths.pas',
|
||||
Keyman.Developer.System.ValidateKpsFile in '..\..\..\common\delphi\compiler\Keyman.Developer.System.ValidateKpsFile.pas',
|
||||
Keyman.Developer.System.KeymanDeveloperPaths in '..\..\..\tike\main\Keyman.Developer.System.KeymanDeveloperPaths.pas',
|
||||
Keyman.Developer.System.KmcWrapper in '..\..\..\tike\compile\Keyman.Developer.System.KmcWrapper.pas';
|
||||
|
||||
var
|
||||
runner : ITestRunner;
|
||||
results : IRunResults;
|
||||
logger : ITestLogger;
|
||||
nunitLogger : ITestLogger;
|
||||
begin
|
||||
{$IFDEF TESTINSIGHT}
|
||||
TestInsight.DUnitX.RunRegisteredTests;
|
||||
exit;
|
||||
{$ENDIF}
|
||||
try
|
||||
//Check command line options, will exit if invalid
|
||||
TDUnitX.CheckCommandLine;
|
||||
//Create the test runner
|
||||
runner := TDUnitX.CreateRunner;
|
||||
//Tell the runner to use RTTI to find Fixtures
|
||||
runner.UseRTTI := True;
|
||||
//tell the runner how we will log things
|
||||
//Log to the console window
|
||||
logger := TDUnitXConsoleLogger.Create(true);
|
||||
runner.AddLogger(logger);
|
||||
//Generate an NUnit compatible XML File
|
||||
nunitLogger := TDUnitXXMLNUnitFileLogger.Create(TDUnitX.Options.XMLOutputFile);
|
||||
runner.AddLogger(nunitLogger);
|
||||
runner.FailsOnNoAsserts := False; //When true, Assertions must be made during tests;
|
||||
|
||||
//Run tests
|
||||
results := runner.Execute;
|
||||
if not results.AllPassed then
|
||||
System.ExitCode := EXIT_ERRORS;
|
||||
|
||||
{$IFNDEF CI}
|
||||
//We don't want this happening when running under CI.
|
||||
if TDUnitX.Options.ExitBehavior = TDUnitXExitBehavior.Pause then
|
||||
begin
|
||||
System.Write('Done.. press <Enter> key to quit.');
|
||||
System.Readln;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
DUnitX.Loggers.TeamCity.ReportToTeamCity;
|
||||
except
|
||||
on E: Exception do
|
||||
System.Writeln(E.ClassName, ': ', E.Message);
|
||||
end;
|
||||
end.
|
||||
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
|
@ -1,155 +0,0 @@
|
|||
unit Keyman.Test.System.CompilePackageVersioningTest;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
DUnitX.TestFramework,
|
||||
Keyman.Developer.System.Project.ProjectLog;
|
||||
|
||||
type
|
||||
|
||||
[TestFixture]
|
||||
TCompilePackageVersioningTest = class(TObject)
|
||||
private
|
||||
FRoot: string;
|
||||
procedure PackageMessage(Sender: TObject; msg: string;
|
||||
State: TProjectLogState);
|
||||
public
|
||||
[Setup]
|
||||
procedure Setup;
|
||||
[TearDown]
|
||||
procedure TearDown;
|
||||
// Sample Methods
|
||||
// Simple single Test
|
||||
// Test with TestCase Attribute to supply parameters.
|
||||
[Test]
|
||||
[TestCase('test-single-version-1-package', 'test1.kps,False')]
|
||||
[TestCase('test-single-version-2-package', 'test2.kps,False')]
|
||||
[TestCase('test-version-2-1-mismatch', 'test2-1.kps,True')]
|
||||
[TestCase('test-version-1-2-mismatch', 'test1-2.kps,True')]
|
||||
[TestCase('test-keyboard-1-package-2', 'test-keyboard-1-vs-package-2.kps,False')]
|
||||
[TestCase('test-package-1-keyboard-2', 'test-package-1-vs-keyboard-2.kps,False')]
|
||||
procedure TestPackageCompile(Path: string; ExpectError: Boolean);
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
System.SysUtils,
|
||||
Winapi.ActiveX,
|
||||
|
||||
compile,
|
||||
CompilePackage,
|
||||
Keyman.Developer.System.Project.kmnProjectFileAction,
|
||||
Keyman.Developer.System.Project.ProjectFile,
|
||||
kpsfile;
|
||||
|
||||
type
|
||||
TProjectConsole = class(TProject)
|
||||
private
|
||||
FSilent: Boolean;
|
||||
FFullySilent: Boolean;
|
||||
public
|
||||
procedure Log(AState: TProjectLogState; Filename: string; Msg: string; MsgCode, line: Integer); override; // I4706
|
||||
function Save: Boolean; override; // I4709
|
||||
|
||||
property Silent: Boolean read FSilent write FSilent;
|
||||
property FullySilent: Boolean read FFullySilent write FFullySilent;
|
||||
end;
|
||||
|
||||
procedure TCompilePackageVersioningTest.Setup;
|
||||
var
|
||||
p: TProjectConsole;
|
||||
i: Integer;
|
||||
begin
|
||||
Assert.IgnoreCaseDefault := False;
|
||||
|
||||
FRoot := ExtractFileDir(ExtractFileDir(ExtractFileDir(ExtractFileDir(ParamStr(0)))));
|
||||
|
||||
p := TProjectConsole.Create(ptUnknown, FRoot+'\test-1.0\test-1.0.kpj', False);
|
||||
try
|
||||
for i := 0 to p.Files.Count - 1 do
|
||||
if p.Files[i] is TkmnProjectFileAction then
|
||||
Assert.IsTrue((p.Files[i] as TkmnProjectFileAction).CompileKeyboard, 'Could not compile keyboard');
|
||||
finally
|
||||
p.Free;
|
||||
end;
|
||||
|
||||
p := TProjectConsole.Create(ptUnknown, FRoot+'\test-2.0\test-2.0.kpj', False);
|
||||
try
|
||||
for i := 0 to p.Files.Count - 1 do
|
||||
if p.Files[i] is TkmnProjectFileAction then
|
||||
Assert.IsTrue((p.Files[i] as TkmnProjectFileAction).CompileKeyboard, 'Could not compile keyboard');
|
||||
finally
|
||||
p.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCompilePackageVersioningTest.TearDown;
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TCompilePackageVersioningTest.PackageMessage(Sender: TObject; msg: string; State: TProjectLogState);
|
||||
const
|
||||
Map: array[TProjectLogState] of TLogLevel = (
|
||||
{plsInfo} TLogLevel.Information,
|
||||
{plsHint} TLogLevel.Information,
|
||||
{plsWarning} TLogLevel.Warning,
|
||||
{plsError} TLogLevel.Error,
|
||||
{plsFatal} TLogLevel.Error,
|
||||
{plsSuccess} TLogLevel.Information,
|
||||
{plsFailure} TLogLevel.Error
|
||||
);
|
||||
begin
|
||||
Log(Map[State], msg);
|
||||
end;
|
||||
|
||||
procedure TCompilePackageVersioningTest.TestPackageCompile(Path: string; ExpectError: Boolean);
|
||||
var
|
||||
pack: TKPSFile;
|
||||
res: Boolean;
|
||||
begin
|
||||
pack := TKPSFile.Create;
|
||||
try
|
||||
pack.FileName := FRoot+'\'+Path;
|
||||
pack.LoadXML;
|
||||
res := DoCompilePackage(pack, PackageMessage, False, False, FRoot+'\'+ChangeFileExt(Path,'.kmp'));
|
||||
Assert.AreEqual(not ExpectError, res);
|
||||
finally
|
||||
pack.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TProjectConsole.Log(AState: TProjectLogState; Filename, Msg: string; MsgCode, line: Integer); // I4706
|
||||
begin
|
||||
{$IFDEF DEBUG_PROJECT}
|
||||
case AState of
|
||||
plsInfo,
|
||||
plsSuccess,
|
||||
plsFailure:
|
||||
if not FSilent then
|
||||
writeln(ExtractFileName(Filename)+': '+Msg);
|
||||
plsWarning:
|
||||
if not FFullySilent then
|
||||
writeln(ExtractFileName(Filename)+': Warning: '+Msg);
|
||||
plsError:
|
||||
if not FFullySilent then
|
||||
writeln(ExtractFileName(Filename)+': Error: '+Msg);
|
||||
plsFatal:
|
||||
writeln(ExtractFileName(Filename)+': Fatal error: '+Msg);
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TProjectConsole.Save: Boolean; // I4709
|
||||
begin
|
||||
// We don't modify the project file in the console
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
initialization
|
||||
CoInitializeEx(nil, COINIT_APARTMENTTHREADED);
|
||||
TDUnitX.RegisterTestFixture(TCompilePackageVersioningTest);
|
||||
finalization
|
||||
CoUninitialize;
|
||||
end.
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
#
|
||||
# Test that package compiler manages keyboard and package versions correctly
|
||||
#
|
||||
# NOTE: The .dproj needs $(CI) added to the Delphi Compiler/Conditional defines (All
|
||||
# configurations - all platforms) section in order for the CI flag to be passed in.
|
||||
# (It's best to make this change in Delphi IDE).
|
||||
#
|
||||
|
||||
!include ..\..\..\Defines.mak
|
||||
|
||||
test: build
|
||||
$(WIN32_TARGET_PATH)\keyboardpackageversionstestsuite.exe -b -exit:continue
|
||||
|
||||
build:
|
||||
$(DELPHI_MSBUILD) "/p:CI=CI" keyboardpackageversionstestsuite.dproj
|
||||
|
||||
clean: def-clean
|
||||
-del *.kmp
|
||||
-del test-1.0\*.kmx
|
||||
-del test-2.0\*.kmx
|
||||
-del test-1.0\*.js
|
||||
-del test-2.0\*.js
|
||||
|
||||
!include ..\..\..\Target.mak
|
||||
Loading…
Add table
Reference in a new issue