X-Git-Url: http://ecere.com/cgi-bin/gitweb.cgi?p=testingSuite;a=blobdiff_plain;f=testSuite.ec;h=29129fdf088cbc2fec34d464e579a671a6ad8bba;hp=4f08ac1dfb5babbe78f39bdf53f7f81e0d260ef2;hb=HEAD;hpb=731c2c262ebc08d95f917a60520f2936e1bed003 diff --git a/testSuite.ec b/testSuite.ec index 4f08ac1..29129fd 100644 --- a/testSuite.ec +++ b/testSuite.ec @@ -2,7 +2,16 @@ import "ecere" import "EDA" import "md5" import "Project" -import "PathBox" + +IDESettings ideSettings; + +IDESettingsContainer settingsContainer +{ + dataOwner = &ideSettings; + dataClass = class(IDESettings); +}; + +IDEConfigHolder ideConfig { }; Test dummy; // FIXME ugly hack @@ -24,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); } @@ -37,7 +46,7 @@ struct MD5Digest { channel.ReadData(digest,16); } - property TestRun + property TestRun { set { TempFile hashTemp { }; @@ -61,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); } @@ -70,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; } } }; @@ -82,7 +91,23 @@ void CreateMakefile(String epjPath, String makePath) bool valid = true; char* configName = null;//"release"; - defaultCompiler = MakeDefaultCompiler("Default", true); + if(false) //noGlobalSettings) + { + defaultCompiler = MakeDefaultCompiler("Default", true); + delete ideSettings; + } + else + { + 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 +//defaultCompiler = MakeDefaultCompiler(); + 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 + } defaultCompiler.eccCommand = "ecc -nolinenumbers"; if(FileExists(epjPath).isFile) @@ -92,7 +117,7 @@ void CreateMakefile(String epjPath, String makePath) strlwr(extension); if(!strcmp(extension, ProjectExtension)) { - project = LoadProject(epjPath); + project = LoadProject(epjPath, "Debug"); if(project) { ProjectConfig defaultConfig = null; @@ -138,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); @@ -165,7 +190,11 @@ void CreateMakefile(String epjPath, String makePath) } } if(valid) - project.GenerateMakefile(makePath, false, ""); + { + project.GenerateCrossPlatformMk(null); + project.GenerateCompilerCf(defaultCompiler, true); + project.GenerateMakefile(makePath, false, null, project.config); + } delete defaultConfig; delete project; @@ -205,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"; @@ -231,7 +260,7 @@ class AccessMacros { Array runs { }; Row tRow { tbl = dbindex("Runs",testAndTime) }; - for(tRow.Find(dbfield("Runs",test),middle,nil,t); !tRow.nil; tRow.Next()) + for(tRow.Find(dbfield("Runs",test),middle,nil,t); !tRow.nil; tRow.Find(dbfield("Runs", test), next, nil, t)) //Next()) runs.Add(tRow.sysID); delete tRow; return runs; @@ -240,7 +269,7 @@ class AccessMacros { Array files { }; RowOutputFiles tRow { tbl = dbindex("OutputFiles",run) }; - for(tRow.Find(dbfield("OutputFiles",run),middle,nil,t); !tRow.nil; tRow.Next()) + for(tRow.Find(dbfield("OutputFiles",run),middle,nil,t); !tRow.nil; tRow.Find(dbfield("OutputFiles", run), next, nil, t)) //tRow.Next()) { if(t != tRow.run) break; @@ -251,51 +280,6 @@ class AccessMacros } } -class TestSuiteApp : GuiApplication -{ - DataSource ds { driver = /*"SQLite"*/"EDB" }; - TestSuiteApp() - { - db = database_open(ds, "TestSuite"); - } - ~TestSuiteApp() - { - Array files; - Array runs; - RowTests tests { }; - RowRuns rRuns { }; - RowOutputFiles rFiles { }; - while(tests.Next()) - { - Test t = (Test)tests.id; - runs = AccessMacros::allTestRuns(t); - for(run : runs) - { - if(!run.save) - { - if(t.reference == run) - { - t.reference = null; - } - files = AccessMacros::allOutputFiles(run); - for(file : files) - { - rFiles.sysID=file; - rFiles.Delete(); - } - rRuns.sysID=run; - rRuns.Delete(); - } - } - } - delete tests; - delete rRuns; - delete rFiles; - delete db; - delete ds; - } -} - class TestSuiteGlobalSettings : GlobalAppSettings { settingsName = "testSuite"; @@ -310,25 +294,30 @@ class TestSuiteGlobalSettings : GlobalAppSettings { Load(); } - void Load() + public SettingsIOResult Load() { - if(GlobalAppSettings::Load()) + SettingsIOResult result = GlobalAppSettings::Load(); + if(result == success) { delete diffTool; delete testDB_file; GetGlobalValue("Tools","diff", singleString, &diffTool); - GetGlobalValue("Tests","list", singleString, $testDB_file); + 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; } } @@ -336,7 +325,7 @@ class DiffThread : Thread { char origDir[MAX_LOCATION]; char newDir[MAX_LOCATION]; - + uint Main() { DualPipe diff; @@ -351,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; } @@ -364,8 +353,6 @@ class DiffThread : Thread { //char origDir[MAX_LOCATION]; //char newDir[MAX_LOCATION]; - char tmpname[MAX_LOCATION]; - CreateTemporaryDir(origDir, "TestSuiteOrigDir"); CreateTemporaryDir(newDir,"TestSuiteNewDir"); @@ -401,21 +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, "makefile.test"); - + 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(); @@ -425,7 +414,7 @@ class BuildTool //return epj2makePipe.GetExitCode(); return 0; } - + char* Copy2Temp(File f, String tmpPath) { File tmp; @@ -433,13 +422,13 @@ class BuildTool tmp = CreateTemporaryFile(tmpFilename, tmpPath); CopyFile(f, tmp); tmp.Flush(); - return tmpFilename; + return CopyString(tmpFilename); } - + int BuildTest(TestRun run) { DualPipe makePipe; - int makeSuccess; + int makeSuccess = -1; char makefileOut[MAX_LOCATION]; char * filePath = run.test.filePath; char oldDir[MAX_LOCATION]; @@ -447,15 +436,15 @@ class BuildTool GetWorkingDir(oldDir, sizeof(oldDir)); ChangeWorkingDir(makefileOut); - PathCat(makefileOut, "makefile.test"); - + PathCat(makefileOut, "project-testingSuite.Makefile"); + //Execute("make -f %s clean", makefileOut); - makePipe = DualPipeOpenf({ output = true },"make -f %s clean", makefileOut); + makePipe = DualPipeOpenf({ output = true },"%s -f %s clean", defaultCompiler.makeCommand, makefileOut); + if(makePipe) { TempFile f { }; char makeBuffer[1024]; - int size=1024; uint count; while(!makePipe.Eof()) { @@ -463,14 +452,14 @@ class BuildTool f.Write(makeBuffer, 1, count); } run.makeOutput = f; + delete makePipe; } - delete makePipe; - makePipe = DualPipeOpenf({ output = true },"make -f %s", makefileOut); + makePipe = DualPipeOpenf({ output = true },"%s -f %s", defaultCompiler.makeCommand, makefileOut); + if(makePipe) { TempFile f { }; char makeBuffer[1024]; - int size=1024; uint count; while(!makePipe.Eof()) { @@ -478,11 +467,12 @@ class BuildTool f.Write(makeBuffer, 1, count); } run.makeOutput = f; + //makePipe.Wait(); + ChangeWorkingDir(oldDir); + makeSuccess = makePipe.GetExitCode(); + run.makeReturnValue = makeSuccess; + delete makePipe; } - //makePipe.Wait(); - ChangeWorkingDir(oldDir); - makeSuccess = makePipe.GetExitCode(); - run.makeReturnValue = makeSuccess; return makeSuccess; } void AddOutputFiles(TestRun run) @@ -491,8 +481,10 @@ class BuildTool FileListing fl; char * filePath = run.test.filePath; StripLastDirectory(filePath, testFolder); - PathCat(testFolder, "release"); - + + // TODO: Get from config + PathCat(testFolder, "obj/release.win32"); + fl = { testFolder, extensions = "c, ec, sym, imp" }; // ["c", "ec", "sym", "imp"] perhaps? while(fl.Find()) { @@ -501,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; @@ -542,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(); @@ -626,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) { @@ -656,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); @@ -696,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; @@ -720,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); @@ -735,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) }; @@ -748,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; @@ -794,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) { @@ -817,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" }; @@ -879,7 +870,7 @@ class TestSuiteWindow : Window { testListBox.SelectRow(row); } - } + } } delete f; //Refocus(); @@ -906,7 +897,6 @@ class TestSuiteWindow : Window else { BuildTool bt { }; - DiffThread dt { }; DateTime rightNow { }; RowRuns runs { }; TestRun run; @@ -932,7 +922,7 @@ class TestSuiteWindow : Window dt.DiffDir(outputsReference, outputsLatest); } } - testListBox.NotifySelect(this, testListBox, testListBox.currentRow, mods); + testListBox.NotifySelect(this, testListBox, testListBox.currentRow, mods); } return true; } @@ -966,7 +956,8 @@ class TestSuiteWindow : Window } return true; } - } + }; + bool OnCreate() { globalSettings.Load(); @@ -981,3 +972,56 @@ class TestSuiteWindow : Window TestSuiteWindow theTestSuiteWindow { }; TestSuiteGlobalSettings theGlobalSettings { }; + +class TestSuiteApp : GuiApplication +{ + DataSource ds { driver = /*"SQLite" */"EDB" }; + TestSuiteApp() + { + //File f { }; + //f.OnSerialize(0); + db = database_open(ds, "TestSuite"); + } + ~TestSuiteApp() + { + Array files; + Array runs; + RowTests tests { }; + RowRuns rRuns { }; + RowOutputFiles rFiles { }; + while(tests.Next()) + { + Test t = (Test)tests.id; + runs = AccessMacros::allTestRuns(t); + for(run : runs) + { + if(!run.save) + { + if(t.reference == run) + t.reference = 0; + files = AccessMacros::allOutputFiles(run); + for(file : files) + { + rFiles.sysID=file; + rFiles.Delete(); + } + rRuns.sysID=run; + rRuns.Delete(); + } + } + } + delete tests; + delete rRuns; + delete rFiles; + delete db; + delete ds; + } + + bool Init() + { + settingsContainer.Load(); + ideConfig.compilers.read(settingsContainer); + delete settingsContainer; + return true; + } +}