TestConfiguration *QuickTestTreeItem::testConfiguration() const { ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); QTC_ASSERT(project, return 0); QuickTestConfiguration *config = 0; switch (type()) { case TestCase: { QStringList testFunctions; for (int row = 0, count = childCount(); row < count; ++row) testFunctions << name() + QLatin1String("::") + childItem(row)->name(); config = new QuickTestConfiguration; config->setTestCases(testFunctions); config->setProFile(proFile()); config->setProject(project); break; } case TestFunctionOrSet: { TestTreeItem *parent = parentItem(); QStringList testFunction(parent->name() + QLatin1String("::") + name()); config = new QuickTestConfiguration; config->setTestCases(testFunction); config->setProFile(parent->proFile()); config->setProject(project); break; } default: return 0; } return config; }
bool CentralWidget::setProFile(const QString &proFilePath) { if(m_proFileWidget == NULL) { if(!QFile::exists(proFilePath)) { return false; } QFile proFile(proFilePath); if(!proFile.open(QIODevice::ReadOnly)) { return false; } QFileInfo fileInfo(proFilePath); QString fileName = fileInfo.fileName(); m_proFileWidget = new QPlainTextEdit(this); m_proFileWidget->setReadOnly(true); QFont font = m_proFileWidget->font(); font.setPixelSize(20); m_proFileWidget->setFont(font); this->addTab(m_proFileWidget, fileName); QString text = proFile.readAll().data(); m_proFileWidget->setPlainText(text); proFile.close(); initTmpPlotAndGL(); } return true; }
TestConfiguration *AutoTestTreeItem::testConfiguration() const { ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject(); QTC_ASSERT(project, return 0); QtTestConfiguration *config = 0; switch (type()) { case TestCase: config = new QtTestConfiguration; config->setTestCaseCount(childCount()); config->setProFile(proFile()); config->setProject(project); config->setDisplayName(TestUtils::getCMakeDisplayNameIfNecessary(filePath(), proFile())); break; case TestFunctionOrSet: { TestTreeItem *parent = parentItem(); config = new QtTestConfiguration(); config->setTestCases(QStringList(name())); config->setProFile(parent->proFile()); config->setProject(project); config->setDisplayName( TestUtils::getCMakeDisplayNameIfNecessary(filePath(), parent->proFile())); break; } case TestDataTag:{ const TestTreeItem *function = parentItem(); const TestTreeItem *parent = function ? function->parentItem() : 0; if (!parent) return 0; const QString functionWithTag = function->name() + QLatin1Char(':') + name(); config = new QtTestConfiguration(); config->setTestCases(QStringList(functionWithTag)); config->setProFile(parent->proFile()); config->setProject(project); config->setDisplayName(TestUtils::getCMakeDisplayNameIfNecessary(filePath(), parent->proFile())); break; } default: return 0; } return config; }
QByteArray AbstractMobileApp::generateProFile(QString *errorMessage) const { const QChar comment = QLatin1Char('#'); QFile proFile(path(AppProOrigin)); if (!proFile.open(QIODevice::ReadOnly)) { *errorMessage = QCoreApplication::translate("Qt4ProjectManager::AbstractMobileApp", "Could not open project file template '%1'.") .arg(proFile.fileName()); return QByteArray(); } QTextStream in(&proFile); QByteArray proFileContent; QTextStream out(&proFileContent, QIODevice::WriteOnly); QString valueOnNextLine; bool commentOutNextLine = false; QString line; while (!(line = in.readLine()).isNull()) { if (line.contains(QLatin1String("# TARGETUID3"))) { valueOnNextLine = symbianTargetUid(); } else if (line.contains(QLatin1String("# NETWORKACCESS")) && !networkEnabled()) { commentOutNextLine = true; } else if (line.contains(QLatin1String("# DEPLOYMENTFOLDERS"))) { // Eat lines QString nextLine; while (!(nextLine = in.readLine()).isNull() && !nextLine.contains(QLatin1String("# DEPLOYMENTFOLDERS_END"))) { } if (nextLine.isNull()) continue; int foldersCount = 0; QStringList folders; foreach (const DeploymentFolder &folder, deploymentFolders()) { foldersCount++; const QString folderName = QString::fromLatin1("folder_%1").arg(foldersCount, 2, 10, QLatin1Char('0')); out << folderName << ".source = " << folder.first << endl; if (!folder.second.isEmpty()) out << folderName << ".target = " << folder.second << endl; folders.append(folderName); } if (foldersCount > 0) out << "DEPLOYMENTFOLDERS = " << folders.join(QLatin1String(" ")) << endl; } else {
void TestRunner::compile() { // Check when is the last time that the test source has been modified const QString filePath = inDir_.filePath(fileName_); const QFileInfo fileInfo(filePath); const QDateTime lastModified = fileInfo.lastModified(); // Compile if necessary Status s = status(); bool notCompiledYet = (s == Status::NotCompiledYet) || (s == Status::CompileError); bool modified = (lastCompiled_ < lastModified); bool processing = (s == Status::Compiling) || (s == Status::Running); if (notCompiledYet || (modified && !processing)) { setStatus_(Status::Compiling); compileOutput_.clear(); lastCompiled_ = lastModified; // -------- Go to folder where to compile test -------- QString compileDirPath = outDir_.absoluteFilePath(testName_); compileDir_ = outDir_; if (!compileDir_.cd(testName_)) { // Create folder since it doesn't exist if (!outDir_.mkdir(testName_)) { failCompilation_("Can't create build folder " + compileDirPath); return; } // Go to folder where to compile test // This is hard to reach (if we manage to create the folder, surely // we can cd to it), but doesn't hurt to check. if (!compileDir_.cd(testName_)) { failCompilation_("Can't create build folder " + compileDirPath); return; } } // -------- Open all files for reading or writing -------- const QString hFileName = testName_ + ".gen.h"; const QString cppFileName = testName_ + ".gen.cpp"; const QString proFileName = testName_ + ".gen.pro"; const QString hFilePath = compileDir_.filePath(hFileName); const QString cppFilePath = compileDir_.filePath(cppFileName); const QString proFilePath = compileDir_.filePath(proFileName); QFile sourceFile(filePath); QFile hFile(hFilePath); QFile cppFile(cppFilePath); QFile proFile(proFilePath); if (!sourceFile.open(QFile::ReadOnly | QFile::Text)) { failCompilation_("Can't open " + filePath); return; } if (!hFile.open(QFile::WriteOnly | QFile::Text)) { failCompilation_("Can't write " + hFilePath); return; } if (!cppFile.open(QFile::WriteOnly | QFile::Text)) { failCompilation_("Can't write " + cppFilePath); return; } if (!proFile.open(QFile::WriteOnly | QFile::Text)) { failCompilation_("Can't write " + proFilePath); return; } // -------- Read source file -------- QTextStream sourceStream(&sourceFile); const QString testSource = sourceStream.readAll(); // -------- Generate and write test gen files -------- QTextStream hStream(&hFile); QTextStream cppStream(&cppFile); QTextStream proStream(&proFile); hStream << generateH(testName_, testSource); cppStream << generateCpp(testName_, testSource); proStream << generatePro(testName_, testSource); // -------- Run qmake -------- QString program = QMAKE_QMAKE_QMAKE; QStringList arguments; arguments << "-spec" << QMAKE_QMAKESPEC << proFilePath; compileOutput_ += getCurrentTime() + ": Starting: \"" + program + "\" " + arguments.join(' ') + "\n"; process_->setWorkingDirectory(compileDirPath); connect(process_, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, &TestRunner::compile_onQmakeFinished_); emit outputChanged(); process_->start(program, arguments); // -> go read qMakeFinished_(int exitCode) now. } else { emit compileFinished(true); } }