~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to projectmanagers/cmake/tests/cmakecompliance.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* KDevelop CMake Support
 
2
 *
 
3
 * Copyright 2007 Aleix Pol Gonzalez <aleixpol@gmail.com>
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License
 
7
 * as published by the Free Software Foundation; either version 2
 
8
 * of the License, or (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
18
 * 02110-1301, USA.
 
19
 */
 
20
 
 
21
#include "cmakecompliance.h"
 
22
#include "cmakeast.h"
 
23
#include "cmakeprojectvisitor.h"
 
24
#include "astfactory.h"
 
25
 
 
26
#include <KDebug>
 
27
#include <KProcess>
 
28
#include <QFile>
 
29
#include <KStandardDirs>
 
30
 
 
31
QTEST_MAIN( CMakeCompliance )
 
32
 
 
33
//Copied from CMakeManager
 
34
QString executeProcess(const QString& execName, const QStringList& args=QStringList())
 
35
{
 
36
    KProcess p;
 
37
    p.setOutputChannelMode(KProcess::MergedChannels);
 
38
    p.setProgram(execName, args);
 
39
    p.start();
 
40
 
 
41
    if(!p.waitForFinished())
 
42
    {
 
43
        kDebug(9032) << "failed to execute:" << execName;
 
44
    }
 
45
 
 
46
    QByteArray b = p.readAllStandardOutput();
 
47
    QString t;
 
48
    t.prepend(b.trimmed());
 
49
 
 
50
    return t;
 
51
}
 
52
 
 
53
void CMakeCompliance::testEnumerate()
 
54
{
 
55
    QFETCH( QString, exe);
 
56
    
 
57
    QStringList commands=executeProcess(exe, QStringList("--help-command-list")).split("\n");
 
58
    commands.erase(commands.begin());
 
59
    commands.sort();
 
60
    foreach(const QString& cmd, commands)
 
61
    {
 
62
        if(cmd.toLower().startsWith("end") || cmd.toLower()=="else" || cmd.toLower()=="elseif")
 
63
            continue;
 
64
        CMakeAst* element = AstFactory::self()->createAst(cmd);
 
65
        if(!element)
 
66
            qDebug() << cmd << "is not supported";
 
67
        delete element;
 
68
    }
 
69
}
 
70
 
 
71
void CMakeCompliance::testEnumerate_data()
 
72
{
 
73
    QTest::addColumn<QString>( "exe" );
 
74
    QStringList cmakes;
 
75
    KStandardDirs::findAllExe(cmakes, "cmake");
 
76
    
 
77
    foreach(const QString& path, cmakes)
 
78
    {
 
79
        QTest::newRow( qPrintable(path) ) << (path);
 
80
    }
 
81
}
 
82
 
 
83
#include "cmakecompliance.moc"