Esempio n. 1
0
Case* CaseBuilder::construct()
{
    Q_ASSERT(m_executable);
    QFileInfo exeLocation(m_executable->location().toLocalFile());

    QString cazeName = m_executable->name();
    if (!m_suite.isEmpty() && cazeName.startsWith(m_suite + '-')) {
        QStringList spl = cazeName.split('-');
        Q_ASSERT(spl.count() > 1);
        spl.removeFirst();
        cazeName = spl.join("-");
    }

    Case* caze = new Case(cazeName, exeLocation);
    caze->setExecutable( m_executable );
    Executable* exe = m_executable;
    //exe->setLocation(KUrl(exeLocation.absoluteFilePath()));
    m_executable->setCase(caze);
    exe->setOutputParser( new OutputParser);
    QStringList exeFunctionOut = m_executable->fetchFunctions();
    bool success = false;
    foreach(QString line, exeFunctionOut) { //krazy:exclude=foreach
        if (line.endsWith(QLatin1String("()")) &&
                !line.contains(QLatin1String(" "))) {
            // recognize this as a legit qtest function output line
            line.chop(2); // remove "()"
            Command* foo = new Command(line, caze);
            caze->addChild(foo);
            success = true;
        } else { // garbage
            if (!line.isEmpty()) {
                kDebug() << "Garbage line:\n" << line;
            }
        }
    }
    if (success) {
        return caze;
    } else {
        delete caze;
        return 0;
    }
}