Changeset 800 for mcbuilder/trunk/tests/TestBuilder.cpp
- Timestamp:
- 08/10/08 13:20:07 (5 months ago)
- Files:
-
- 1 modified
-
mcbuilder/trunk/tests/TestBuilder.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mcbuilder/trunk/tests/TestBuilder.cpp
r799 r800 17 17 18 18 #include "TestBuilder.h" 19 #include "ProjectInfo.h"20 19 21 20 #define TEST_PROJECT "resources/examples/Input-Output/AinToServo" … … 40 39 void TestBuilder::initTestCase() 41 40 { 41 window->openProject(currentProjectPath()); 42 42 builder = window->builder; 43 builder->currentProjectPath = currentProjectPath();44 43 } 45 44 … … 85 84 86 85 QStringList makeFiles; // list of files in the Makefile 86 QStringList makeFileDirs; // list of include dirs in the Makefile 87 87 QVERIFY(makefile.open(QFile::ReadOnly | QFile::Text)); 88 88 QTextStream in(&makefile); … … 90 90 static const int BEGIN = 0; 91 91 static const int FILES = 1; 92 static const int DIRS = 2; 92 93 int state = BEGIN; 93 94 while(!makeLine.isNull()) … … 101 102 case FILES: 102 103 if(makeLine.startsWith("INCLUDEDIRS")) 104 state = DIRS; 105 else if(!makeLine.isEmpty() && !makeLine.startsWith("ARM_SRC")) 106 makeFiles << makeLine.remove("\\").trimmed(); 107 break; 108 case DIRS: 109 if(makeLine.startsWith("CC")) 103 110 state = BEGIN; 104 else 105 { 106 if(!makeLine.isEmpty() && !makeLine.startsWith("ARM_SRC")) 107 makeFiles.append(makeLine.remove("\\").trimmed()); 108 } 109 break; 111 else if(!makeLine.isEmpty()) 112 makeFileDirs << makeLine.remove("\\").remove("-I").trimmed(); 110 113 } 111 114 makeLine = in.readLine(); 112 115 } 113 116 QVERIFY(makeFiles.size()); // make sure we got something 117 QVERIFY(makeFileDirs.size()); 114 118 115 119 // now, let's compare our lists … … 128 132 //qDebug("makefiles: %d, projectfiles: %d, matches: %d", makeFiles.size(), projectFiles.size(), matches); 129 133 QVERIFY( matches == (makeFiles.size() - libraryFiles)); 134 135 // now check that the appropriate include directories have been added 136 QDomNodeList dirs = projectDoc.elementsByTagName("include_dirs").at(0).childNodes(); 137 QStringList includeDirs; 138 for(int i = 0; i < dirs.count(); i++) 139 includeDirs.append(builder->filteredPath(dirs.at(i).toElement().text())); 140 QVERIFY(includeDirs.size()); // make sure we got something 141 142 matches = 0; 143 int libraryDirs = 0; 144 foreach( QString dir, makeFileDirs ) 145 { 146 if(includeDirs.contains(dir)) 147 matches++; 148 else if(dir.contains("cores/makecontroller/libraries")) 149 libraryDirs++; 150 } 151 //qDebug("makefile dirs: %d, project file dirs: %d, matches: %d, library dirs: %d", 152 // makeFileDirs.size(), includeDirs.size(), matches, libraryDirs); 153 154 // one additional difference is that the Makefile should include the project dir itself as an include dir 155 // whereas this is not specificed in the project file 156 QVERIFY(matches == (makeFileDirs.size() - libraryDirs - 1)); 157 } 158 159 /* 160 Create a config file. 161 Make sure it includes the appropriate elements, based on the 162 ProjectInfo. 163 */ 164 void TestBuilder::testConfigFile() 165 { 166 QDir projDir(currentProjectPath()); 167 QFile configFile(projDir.filePath("config.h")); 168 169 if( configFile.exists() ) 170 projDir.remove("config.h"); // get rid of the file, so we can test creating it 171 172 builder->createConfigFile(currentProjectPath()); 173 // we haven't changed anything in the file yet, so this should return false 174 QVERIFY( builder->compareConfigFile(currentProjectPath()) == false ); 175 176 // now let's change a few things in the config file, and confirm that we need to update it 177 // QVERIFY(configFile.open(QFile::Text)); 178 // QTextStream in(&configFile); 179 // 180 // configFile.close(); 130 181 } 131 182
