From: Jerome St-Louis Date: Fri, 11 May 2018 10:31:44 +0000 (-0400) Subject: TestingSuite: Long overdue revival. X-Git-Url: http://ecere.com/cgi-bin/gitweb.cgi?p=testingSuite;a=commitdiff_plain;h=ccf5a81e34693a3dc19f792f6700999225ca14d4 TestingSuite: Long overdue revival. - Previously uncommitted and new fixes --- diff --git a/testSuite.ec b/testSuite.ec index d678b95..29129fd 100644 --- a/testSuite.ec +++ b/testSuite.ec @@ -3,6 +3,16 @@ import "EDA" import "md5" import "Project" +IDESettings ideSettings; + +IDESettingsContainer settingsContainer +{ + dataOwner = &ideSettings; + dataClass = class(IDESettings); +}; + +IDEConfigHolder ideConfig { }; + Test dummy; // FIXME ugly hack GlobalSettings globalSettings { }; @@ -23,7 +33,7 @@ struct MD5Digest {Color {digest[9] , digest[10], digest[11]}, 0.6f}, {Color {digest[12], digest[13], digest[14]}, 0.8f}, {Color {digest[15], digest[0] , digest[1] }, 1.0f}}; - + surface.Gradient(keys, 6, 0, horizontal, x+1, y+1, x+34, y+14); surface.Rectangle(x+1,y+1,x+34,y+14); } @@ -36,7 +46,7 @@ struct MD5Digest { channel.ReadData(digest,16); } - property TestRun + property TestRun { set { TempFile hashTemp { }; @@ -60,7 +70,7 @@ struct MD5Digest uint size; MD5_CTX ctx; MD5Init(&ctx); - size = hashTemp.GetSize(); + size = (uint)hashTemp.GetSize(); MD5Update(&ctx, hashTemp.buffer, size); MD5Final(digest, &ctx); } @@ -69,7 +79,7 @@ struct MD5Digest delete files; } // TOFIX: When this is commented out, no warning at conversion but conversion not acting as such!! - get { } + get { return 0; } } }; @@ -88,13 +98,13 @@ void CreateMakefile(String epjPath, String makePath) } else { - char * compiler = getenv("COMPILER"); + const char * compiler = getenv("COMPILER"); if(!compiler) compiler = "Default"; // TODO: Command line option to choose between the two -// or a command line option to not use global settings +// or a command line option to not use global settings //defaultCompiler = MakeDefaultCompiler(); - defaultCompiler = ideSettings.GetCompilerConfig(compiler); + defaultCompiler = ideConfig.compilers.GetCompilerConfig(compiler); // possible TODO: use the workspace to select the active compiler // TODO: option to specify compiler name when using global settings } @@ -153,9 +163,9 @@ void CreateMakefile(String epjPath, String makePath) if(!releaseConfig) { - printf("Error: There are no Project configurations.\n", configName); + printf("Error: There are no Project configurations.\n"); valid = false; - // we don't need to create a config to compile a config-less project, do we? + // we don't need to create a config to compile a config-less project, do we? /* char targetName[MAX_FILENAME]; GetLastDirectory(epjPath, targetName); @@ -181,8 +191,8 @@ void CreateMakefile(String epjPath, String makePath) } if(valid) { - project.GenerateCrossPlatformMk(); - project.GenerateCompilerCf(defaultCompiler); + project.GenerateCrossPlatformMk(null); + project.GenerateCompilerCf(defaultCompiler, true); project.GenerateMakefile(makePath, false, null, project.config); } @@ -224,7 +234,7 @@ dbtable "Runs" TestRun { TestRun id "id"; File makeOutput "makeOutput"; - bool makeReturnValue "makeReturnValue"; + int makeReturnValue "makeReturnValue"; Test test "test"; TimeStamp time "time"; bool save "save"; @@ -284,9 +294,10 @@ class TestSuiteGlobalSettings : GlobalAppSettings { Load(); } - void Load() + public SettingsIOResult Load() { - if(GlobalAppSettings::Load()) + SettingsIOResult result = GlobalAppSettings::Load(); + if(result == success) { delete diffTool; delete testDB_file; @@ -294,15 +305,19 @@ class TestSuiteGlobalSettings : GlobalAppSettings GetGlobalValue("Tests","list", singleString, &testDB_file); CloseAndMonitor(); } + return result; } - void Save() + + public SettingsIOResult Save() { - if(GlobalAppSettings::Save()) + SettingsIOResult result = GlobalAppSettings::Save(); + if(result == success) { PutGlobalValue("Tools","diff", singleString, diffTool); PutGlobalValue("Tests","list", singleString, testDB_file); CloseAndMonitor(); } + return result; } } @@ -310,7 +325,7 @@ class DiffThread : Thread { char origDir[MAX_LOCATION]; char newDir[MAX_LOCATION]; - + uint Main() { DualPipe diff; @@ -325,12 +340,12 @@ class DiffThread : Thread { DeleteFile(flOrig.path); } - rmdir(origDir); + RemoveDir(origDir); while(flNew.Find()) { DeleteFile(flNew.path); } - rmdir(newDir); + RemoveDir(newDir); delete diff; return 0; } @@ -338,8 +353,6 @@ class DiffThread : Thread { //char origDir[MAX_LOCATION]; //char newDir[MAX_LOCATION]; - char tmpname[MAX_LOCATION]; - CreateTemporaryDir(origDir, "TestSuiteOrigDir"); CreateTemporaryDir(newDir,"TestSuiteNewDir"); @@ -375,23 +388,23 @@ class BuildTool { int GenerateMakefile(Test t) { - DualPipe epj2makePipe; + //DualPipe epj2makePipe; char testFolder[MAX_LOCATION]; char makefileOut[MAX_LOCATION]; char epjName[MAX_LOCATION]; char * filePath = t.filePath; - + /* StripLastDirectory(filePath, testFolder); PathCat(testFolder, "release"); MakeDir(testFolder); */ - + StripLastDirectory(filePath, testFolder); GetLastDirectory(filePath, epjName); strcpy(makefileOut, testFolder); PathCat(makefileOut, "project-testingSuite.Makefile"); - + // epj2makePipe = DualPipeOpenf({ output = true },"epj2make -l /usr/ecere/lib -o %s %s > /dev/null", makefileOut, t.filePath); //epj2makePipe = DualPipeOpenf({ output = true },"epj2make -cpp cpp -l /usr/ecere/lib -o %s %s", makefileOut, filePath); //epj2makePipe.Wait(); @@ -401,7 +414,7 @@ class BuildTool //return epj2makePipe.GetExitCode(); return 0; } - + char* Copy2Temp(File f, String tmpPath) { File tmp; @@ -409,9 +422,9 @@ class BuildTool tmp = CreateTemporaryFile(tmpFilename, tmpPath); CopyFile(f, tmp); tmp.Flush(); - return tmpFilename; + return CopyString(tmpFilename); } - + int BuildTest(TestRun run) { DualPipe makePipe; @@ -424,7 +437,7 @@ class BuildTool GetWorkingDir(oldDir, sizeof(oldDir)); ChangeWorkingDir(makefileOut); PathCat(makefileOut, "project-testingSuite.Makefile"); - + //Execute("make -f %s clean", makefileOut); makePipe = DualPipeOpenf({ output = true },"%s -f %s clean", defaultCompiler.makeCommand, makefileOut); @@ -432,7 +445,6 @@ class BuildTool { TempFile f { }; char makeBuffer[1024]; - int size=1024; uint count; while(!makePipe.Eof()) { @@ -448,7 +460,6 @@ class BuildTool { TempFile f { }; char makeBuffer[1024]; - int size=1024; uint count; while(!makePipe.Eof()) { @@ -473,7 +484,7 @@ class BuildTool // TODO: Get from config PathCat(testFolder, "obj/release.win32"); - + fl = { testFolder, extensions = "c, ec, sym, imp" }; // ["c", "ec", "sym", "imp"] perhaps? while(fl.Find()) { @@ -482,7 +493,7 @@ class BuildTool char extension[MAX_LOCATION]; DateTime rightNow { }; f = FileOpen(fl.path, read); - + of.Add(); of.id = of.sysID; of.outputFile = f; @@ -523,18 +534,18 @@ void CopyFile(File input, File output) uint count = input.Read(buffer, 1, sizeof(buffer)); if(count) { - int yo = output.Write(buffer, 1, count); + output.Write(buffer, 1, count); } } } class RelativeTimeStamp : TimeStamp { - char * OnGetString(char * tempString, void * fieldData, bool * needClass) + const char * OnGetString(char * tempString, void * fieldData, bool * needClass) { int64 count; int days; - String units; + const String units; DateTime dt { }; TimeStamp rightNow; dt.GetLocalTime(); @@ -607,7 +618,7 @@ enum BuildStatus success, failure; void OnDisplay(Surface surface, int x, int y, int width, - TrumpDialog trumpDialog, + void * unused, Alignment alignment, DataDisplayFlags flags) { @@ -637,12 +648,12 @@ class TestSuiteWindow : Window BitmapResource makeSuccess { ":check.png" , window = this }; BitmapResource makeFailure { ":x.png", window = this }; - + TestSuiteWindow() { testListBox.AddField(fieldName); testListBox.AddField(fieldActive); - + runsListBox.AddField(fieldBuildStatus); runsListBox.AddField(fieldAuraColor); runsListBox.AddField(fieldRun); @@ -677,7 +688,7 @@ class TestSuiteWindow : Window } }; - void NewTest(RowTests tRow, char* testName, char* testFilePath) + void NewTest(RowTests tRow, const char * testName, const char * testFilePath) { tRow.Add(); tRow.id = tRow.sysID; @@ -701,7 +712,7 @@ class TestSuiteWindow : Window { // do we also delete all runs and files associated with this test? RowTests tRow { }; - tRow.sysID=row.tag; + tRow.sysID=(uint)row.tag; tRow.Delete(); delete tRow; // won't be needed in the (distant?) future :-) testListBox.DeleteRow(row); @@ -716,7 +727,7 @@ class TestSuiteWindow : Window } delete tRow; } - + DataField fieldName { width = 140, header = "Name" , dataType = class(char*), editable = true }; DataField fieldActive { width = 40, header = "Active", dataType = class(bool) }; @@ -729,7 +740,7 @@ class TestSuiteWindow : Window bool NotifyChanged(ListBox testListBox, DataRow row) { RowTests tRow { }; - tRow.sysID=row.tag; + tRow.sysID=(uint)row.tag; tRow.name = row.GetData(fieldName); tRow.active = row.GetData(fieldActive); delete tRow; @@ -775,9 +786,8 @@ class TestSuiteWindow : Window { // show test runs Test t; Array runs; - AccessMacros amacs{ }; t = (Test)row.tag; - runs = amacs.allTestRuns(t); + runs = AccessMacros::allTestRuns(t); runsListBox.Clear(); for(tr : runs) { @@ -798,7 +808,7 @@ class TestSuiteWindow : Window return true; } }; - + DataField fieldBuildStatus { width = 40, dataType = class(BuildStatus), header = "Make" }; DataField fieldAuraColor { width = 40, dataType = class(MD5Digest), header = "Aura" }; DataField fieldRun { width = 120, dataType = class(RelativeTimeStamp), header = "Run" }; @@ -860,7 +870,7 @@ class TestSuiteWindow : Window { testListBox.SelectRow(row); } - } + } } delete f; //Refocus(); @@ -887,7 +897,6 @@ class TestSuiteWindow : Window else { BuildTool bt { }; - DiffThread dt { }; DateTime rightNow { }; RowRuns runs { }; TestRun run; @@ -947,7 +956,8 @@ class TestSuiteWindow : Window } return true; } - } + }; + bool OnCreate() { globalSettings.Load(); @@ -988,9 +998,7 @@ class TestSuiteApp : GuiApplication if(!run.save) { if(t.reference == run) - { - t.reference = null; - } + t.reference = 0; files = AccessMacros::allOutputFiles(run); for(file : files) { @@ -1012,6 +1020,7 @@ class TestSuiteApp : GuiApplication bool Init() { settingsContainer.Load(); + ideConfig.compilers.read(settingsContainer); delete settingsContainer; return true; } diff --git a/testSuite.epj b/testSuite.epj index c87dd35..c9811f8 100644 --- a/testSuite.epj +++ b/testSuite.epj @@ -40,25 +40,24 @@ { "Folder" : "project", "Files" : [ - "/sdk/ide/src/project/Project.ec", - "/sdk/ide/src/project/ProjectConfig.ec", - "/sdk/ide/src/project/ProjectNode.ec" + "$(ECERE_SDK_SRC)/ide/src/project/Project.ec", + "$(ECERE_SDK_SRC)/ide/src/project/ProjectConfig.ec", + "$(ECERE_SDK_SRC)/ide/src/project/ProjectNode.ec" ] }, - "/sdk/extras/md5.ec", - "../../sdk/ide/src/IDESettings.ec", - "../../sdk/extras/gui/controls/StringsBox.ec", - "../../sdk/ide/src/OldIDESettings.ec", - "../../sdk/extras/types/DynamicString.ec" + "$(ECERE_SDK_SRC)/extras/md5.ec", + "$(ECERE_SDK_SRC)/ide/src/IDESettings.ec", + "$(ECERE_SDK_SRC)/extras/gui/controls/StringsBox.ec", + "$(ECERE_SDK_SRC)/ide/src/OldIDESettings.ec", + "$(ECERE_SDK_SRC)/extras/types/DynamicString.ec" ] }, - "testSuite.ec", - "TODO.txt" + "testSuite.ec" ], "ResourcesPath" : "", "Resources" : [ "res/check.png", "res/x.png", - "../../sdk/crossplatform.mk" + "$(ECERE_SDK_SRC)/crossplatform.mk" ] }