Changeset View
Changeset View
Standalone View
Standalone View
autotests/testhighlighter.cpp
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | 96 | private Q_SLOTS: | |||
---|---|---|---|---|---|
104 | void cleanupTestCase() | 104 | void cleanupTestCase() | ||
105 | { | 105 | { | ||
106 | QFile coveredList(QLatin1String(TESTBUILDDIR "/covered-definitions.txt")); | 106 | QFile coveredList(QLatin1String(TESTBUILDDIR "/covered-definitions.txt")); | ||
107 | QFile uncoveredList(QLatin1String(TESTBUILDDIR "/uncovered-definition.txt")); | 107 | QFile uncoveredList(QLatin1String(TESTBUILDDIR "/uncovered-definition.txt")); | ||
108 | QVERIFY(coveredList.open(QFile::WriteOnly)); | 108 | QVERIFY(coveredList.open(QFile::WriteOnly)); | ||
109 | QVERIFY(uncoveredList.open(QFile::WriteOnly)); | 109 | QVERIFY(uncoveredList.open(QFile::WriteOnly)); | ||
110 | 110 | | |||
111 | int count = 0; | 111 | int count = 0; | ||
112 | foreach (const auto &def, m_repo->definitions()) { | 112 | for (const auto &def : m_repo->definitions()) { | ||
113 | if (def.isHidden() || !def.isValid()) | 113 | if (def.isHidden() || !def.isValid()) | ||
114 | continue; | 114 | continue; | ||
115 | ++count; | 115 | ++count; | ||
116 | if (m_coveredDefinitions.contains(def.name())) | 116 | if (m_coveredDefinitions.contains(def.name())) | ||
117 | coveredList.write(def.name().toUtf8() + '\n'); | 117 | coveredList.write(def.name().toUtf8() + '\n'); | ||
118 | else | 118 | else | ||
119 | uncoveredList.write(def.name().toUtf8() + '\n'); | 119 | uncoveredList.write(def.name().toUtf8() + '\n'); | ||
120 | } | 120 | } | ||
121 | 121 | | |||
122 | qDebug() << "Syntax definitions with test coverage:" << ((float)m_coveredDefinitions.size() * 100.0f / (float)count) << "%"; | 122 | qDebug() << "Syntax definitions with test coverage:" << ((float)m_coveredDefinitions.size() * 100.0f / (float)count) << "%"; | ||
123 | 123 | | |||
124 | delete m_repo; | 124 | delete m_repo; | ||
125 | m_repo = nullptr; | 125 | m_repo = nullptr; | ||
126 | } | 126 | } | ||
127 | 127 | | |||
128 | void testHighlight_data() | 128 | void testHighlight_data() | ||
129 | { | 129 | { | ||
130 | QTest::addColumn<QString>("inFile"); | 130 | QTest::addColumn<QString>("inFile"); | ||
131 | QTest::addColumn<QString>("outFile"); | 131 | QTest::addColumn<QString>("outFile"); | ||
132 | QTest::addColumn<QString>("refFile"); | 132 | QTest::addColumn<QString>("refFile"); | ||
133 | QTest::addColumn<QString>("syntax"); | 133 | QTest::addColumn<QString>("syntax"); | ||
134 | 134 | | |||
135 | const QDir dir(QStringLiteral(TESTSRCDIR "/input")); | 135 | const QDir dir(QStringLiteral(TESTSRCDIR "/input")); | ||
136 | foreach (const auto &fileName, dir.entryList(QDir::Files | QDir::NoSymLinks | QDir::Readable, QDir::Name)) { | 136 | for (const auto &fileName : dir.entryList(QDir::Files | QDir::NoSymLinks | QDir::Readable, QDir::Name)) { | ||
137 | const auto inFile = dir.absoluteFilePath(fileName); | 137 | const auto inFile = dir.absoluteFilePath(fileName); | ||
138 | if (inFile.endsWith(QLatin1String(".syntax"))) | 138 | if (inFile.endsWith(QLatin1String(".syntax"))) | ||
139 | continue; | 139 | continue; | ||
140 | 140 | | |||
141 | QString syntax; | 141 | QString syntax; | ||
142 | QFile syntaxOverride(inFile + QStringLiteral(".syntax")); | 142 | QFile syntaxOverride(inFile + QStringLiteral(".syntax")); | ||
143 | if (syntaxOverride.exists() && syntaxOverride.open(QFile::ReadOnly)) | 143 | if (syntaxOverride.exists() && syntaxOverride.open(QFile::ReadOnly)) | ||
144 | syntax = QString::fromUtf8(syntaxOverride.readAll()).trimmed(); | 144 | syntax = QString::fromUtf8(syntaxOverride.readAll()).trimmed(); | ||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |