diff options
Diffstat (limited to 'tests')
68 files changed, 3303 insertions, 390 deletions
diff --git a/tests/auto/cplusplus/ast/tst_ast.cpp b/tests/auto/cplusplus/ast/tst_ast.cpp index eaac17ade3..603d8f908d 100644 --- a/tests/auto/cplusplus/ast/tst_ast.cpp +++ b/tests/auto/cplusplus/ast/tst_ast.cpp @@ -118,6 +118,8 @@ private slots: void crash_test_1(); void thread_local_1(); + void msvc_attributes_declspec(); + // expressions void simple_name_1(); void template_id_1(); @@ -141,6 +143,7 @@ private slots: void if_statement_2(); void if_statement_3(); void if_else_statement(); + void if_constexpr(); void while_statement(); void while_condition_statement(); void for_statement(); @@ -169,6 +172,8 @@ private slots: //! checks for both correct ellipsis tokens in //! "template<class ...Args> class T : Args... {};" void cpp11_variadic_inheritance(); + void cpp11_attributes(); + void variableTemplatesInExpression(); // Q_PROPERTY void cpp_qproperty(); @@ -281,6 +286,14 @@ void tst_AST::thread_local_1() QCOMPARE(Token::name(T___THREAD), "__thread"); } +void tst_AST::msvc_attributes_declspec() +{ + const char *inp = "class __declspec(novtable) Name{};"; + QSharedPointer<TranslationUnit> unit(parseDeclaration(inp)); + QVERIFY(unit->ast()); + QCOMPARE(diag.errorCount, 0); +} + void tst_AST::simple_declaration_1() { QSharedPointer<TranslationUnit> unit(parseStatement("\n" @@ -1322,6 +1335,56 @@ void tst_AST::cpp11_variadic_inheritance() QVERIFY(ba->ellipsis_token != 0); // important } +void tst_AST::cpp11_attributes() +{ + QSharedPointer<TranslationUnit> unit(parseDeclaration( + "[[noreturn]] void f() {throw \"error\";}", + false, false, true)); + AST *ast = unit->ast(); + QVERIFY(ast != nullptr); + + DeclarationAST *d = ast->asDeclaration(); + QVERIFY(d != nullptr); + + FunctionDefinitionAST *f = d->asFunctionDefinition(); + QVERIFY(f != nullptr); + QVERIFY(f->decl_specifier_list != nullptr); + QVERIFY(f->decl_specifier_list->value != nullptr); + + StdAttributeSpecifierAST *attr = f->decl_specifier_list->value->asStdAttributeSpecifier(); + QVERIFY(attr != nullptr); +} + +void tst_AST::variableTemplatesInExpression() +{ + QSharedPointer<TranslationUnit> unit(parseDeclaration("int i = t<int> + t<char>;", + false, false, true)); + AST *ast = unit->ast(); + QVERIFY(ast != nullptr); + + QCOMPARE(diag.errorCount, 0); + + DeclarationAST *d = ast->asDeclaration(); + QVERIFY(d != nullptr); +} + +void tst_AST::if_constexpr() +{ + QSharedPointer<TranslationUnit> unit(parseStatement("if constexpr (a) b;",true)); + + AST *ast = unit->ast(); + QVERIFY(ast != 0); + + IfStatementAST *stmt = ast->asIfStatement(); + QVERIFY(stmt != 0); + QCOMPARE(stmt->if_token, 1); + QCOMPARE(stmt->constexpr_token, 2); + QCOMPARE(stmt->lparen_token, 3); + QVERIFY(stmt->condition != 0); + QCOMPARE(stmt->rparen_token, 5); + QVERIFY(stmt->statement != 0); +} + void tst_AST::cpp_qproperty() { QFETCH(QByteArray, source); diff --git a/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp b/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp index f54816f9fe..0657e58786 100644 --- a/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp +++ b/tests/auto/cplusplus/codeformatter/tst_codeformatter.cpp @@ -125,6 +125,8 @@ private Q_SLOTS: void braceReturn(); void staticVarDeclWithTypeDecl(); void strings(); + void initializerWithinFunctionArg(); + void shiftWithinInitializer(); }; struct Line { @@ -1285,6 +1287,7 @@ void tst_CodeFormatter::functionReturnType() << Line("A::B::foo() {}") << Line("std::map<int,std::vector<int>> indent() {}") << Line("std::map<int,std::vector<int> > indent() {}") + << Line("auto indent() -> std::map<int,std::vector<int>>") << Line("") ; checkIndent(data); @@ -2170,6 +2173,29 @@ void tst_CodeFormatter::strings() checkIndent(data); } +void tst_CodeFormatter::initializerWithinFunctionArg() +{ + QList<Line> data; + data << Line("void f() {") + << Line(" g(foo,") + << Line(" { 1, 2});", 4, 2) + << Line("}") + ; + + checkIndent(data); +} + +void tst_CodeFormatter::shiftWithinInitializer() +{ + QList<Line> data; + data << Line("void f() {") + << Line(" list << A{1 << 1};") + << Line(" list;") // OK, same indentation/padding as above. + << Line("}") + ; + checkIndent(data); +} + QTEST_MAIN(tst_CodeFormatter) #include "tst_codeformatter.moc" diff --git a/tests/auto/cplusplus/cxx11/data/userDefinedLiterals.1.cpp b/tests/auto/cplusplus/cxx11/data/userDefinedLiterals.1.cpp index f194b3ed51..6352a82a28 100644 --- a/tests/auto/cplusplus/cxx11/data/userDefinedLiterals.1.cpp +++ b/tests/auto/cplusplus/cxx11/data/userDefinedLiterals.1.cpp @@ -3,5 +3,5 @@ constexpr long double operator"" _inv(long double value) { } int main() { auto foo = operator"" _inv(2.3); - return 12_km + 0.5_Pa + 'c'_X + "abd"_L + u"xyz"_M; + return 12_km + 0.5_Pa + 'c'_X + "abd"_L + u"xyz"_M + 10ms; } diff --git a/tests/auto/cplusplus/findusages/tst_findusages.cpp b/tests/auto/cplusplus/findusages/tst_findusages.cpp index d961cb449d..2dd9566021 100644 --- a/tests/auto/cplusplus/findusages/tst_findusages.cpp +++ b/tests/auto/cplusplus/findusages/tst_findusages.cpp @@ -84,6 +84,11 @@ private Q_SLOTS: void shadowedNames_2(); void staticVariables(); + void functionNameFoundInArguments(); + void memberFunctionFalsePositives_QTCREATORBUG2176(); + void resolveTemplateConstructor(); + void templateConstructorVsCallOperator(); + // Qt keywords void qproperty_1(); @@ -115,6 +120,19 @@ private Q_SLOTS: void inAlignas(); void memberAccessAsTemplate(); + + void variadicFunctionTemplate(); + void typeTemplateParameterWithDefault(); + void resolveOrder_for_templateFunction_vs_function(); + void templateArrowOperator_with_defaultType(); + void templateSpecialization_with_IntArgument(); + void templateSpecialization_with_BoolArgument(); + void templatePartialSpecialization(); + void templatePartialSpecialization_2(); + void template_SFINAE_1(); + void variableTemplateInExpression(); + + void variadicMacros(); }; void tst_FindUsages::dump(const QList<Usage> &usages) const @@ -339,6 +357,222 @@ void tst_FindUsages::staticVariables() QCOMPARE(findUsages.usages().size(), 5); } +void tst_FindUsages::functionNameFoundInArguments() +{ + const QByteArray src = + R"( +void bar(); // call find usages for bar from here. This is 1st result +void foo(int bar); // should not be found +void foo(int bar){} // should not be found +void foo2(int b=bar()); // 2nd result +void foo2(int b=bar()){} // 3rd result +)"; + + Document::Ptr doc = Document::create("functionNameFoundInArguments"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QVERIFY(doc->globalSymbolCount() >= 1); + + Symbol *s = doc->globalSymbolAt(0); + QCOMPARE(s->name()->identifier()->chars(), "bar"); + + Snapshot snapshot; + snapshot.insert(doc); + + FindUsages find(src, doc, snapshot); + find(s); + + QCOMPARE(find.usages().size(), 3); + + QCOMPARE(find.usages()[0].line, 1); + QCOMPARE(find.usages()[0].col, 5); + + QCOMPARE(find.usages()[1].line, 4); + QCOMPARE(find.usages()[1].col, 16); + + QCOMPARE(find.usages()[2].line, 5); + QCOMPARE(find.usages()[2].col, 16); +} + +void tst_FindUsages::memberFunctionFalsePositives_QTCREATORBUG2176() +{ + const QByteArray src = + R"( +void otherFunction(int value){} +struct Struct{ + static int foo(){return 1;} + int bar(){ + int foo=Struct::foo(); + otherFunction(foo); + } +}; +)"; + + Document::Ptr doc = Document::create("memberFunctionFalsePositives"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QCOMPARE(doc->globalSymbolCount(), 2); + + Class *s = doc->globalSymbolAt(1)->asClass(); + QVERIFY(s); + QCOMPARE(s->name()->identifier()->chars(), "Struct"); + QCOMPARE(s->memberCount(), 2); + + Symbol *memberFunctionFoo = s->memberAt(0); + QVERIFY(memberFunctionFoo); + QCOMPARE(memberFunctionFoo->name()->identifier()->chars(), "foo"); + QVERIFY(memberFunctionFoo->asFunction()); + + Function* bar = s->memberAt(1)->asFunction(); + QVERIFY(bar); + QCOMPARE(bar->name()->identifier()->chars(), "bar"); + QCOMPARE(bar->memberCount(), 1); + + Block* block = bar->memberAt(0)->asBlock(); + QVERIFY(block); + QCOMPARE(block->memberCount(), 1); + + Symbol *variableFoo = block->memberAt(0); + QVERIFY(variableFoo); + QCOMPARE(variableFoo->name()->identifier()->chars(), "foo"); + QVERIFY(variableFoo->asDeclaration()); + + Snapshot snapshot; + snapshot.insert(doc); + + FindUsages find(src, doc, snapshot); + + find(memberFunctionFoo); + QCOMPARE(find.usages().size(), 2); + + QCOMPARE(find.usages()[0].line, 3); + QCOMPARE(find.usages()[0].col, 15); + + QCOMPARE(find.usages()[1].line, 5); + QCOMPARE(find.usages()[1].col, 24); + + find(variableFoo); + QCOMPARE(find.usages().size(), 2); + + QCOMPARE(find.usages()[0].line, 5); + QCOMPARE(find.usages()[0].col, 12); + + QCOMPARE(find.usages()[1].line, 6); + QCOMPARE(find.usages()[1].col, 22); +} + +void tst_FindUsages::resolveTemplateConstructor() +{ + const QByteArray src = + R"( +struct MyStruct { int value; }; +template <class T> struct Tmp { + T str; +}; +template <class T> struct Tmp2 { + Tmp2(){} + T str; +}; +template <class T> struct Tmp3 { + Tmp3(int i){} + T str; +}; +int main() { + auto tmp = Tmp<MyStruct>(); + auto tmp2 = Tmp2<MyStruct>(); + auto tmp3 = Tmp3<MyStruct>(1); + tmp.str.value; + tmp2.str.value; + tmp3.str.value; + Tmp<MyStruct>().str.value; + Tmp2<MyStruct>().str.value; + Tmp3<MyStruct>(1).str.value; +} +)"; + + Document::Ptr doc = Document::create("resolveTemplateConstructor"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QVERIFY(doc->globalSymbolCount() == 5); + + Class *s = doc->globalSymbolAt(0)->asClass(); + QVERIFY(s); + QCOMPARE(s->name()->identifier()->chars(), "MyStruct"); + QCOMPARE(s->memberCount(), 1); + + Declaration *sv = s->memberAt(0)->asDeclaration(); + QVERIFY(sv); + QCOMPARE(sv->name()->identifier()->chars(), "value"); + + Snapshot snapshot; + snapshot.insert(doc); + + FindUsages find(src, doc, snapshot); + find(sv); + QCOMPARE(find.usages().size(), 7); +} + +void tst_FindUsages::templateConstructorVsCallOperator() +{ + const QByteArray src = + R"( +struct MyStruct { int value; }; +template<class T> struct Tmp { + T str; + MyStruct operator()() { return MyStruct(); } +}; +struct Simple { + MyStruct str; + MyStruct operator()() { return MyStruct(); } +}; +int main() +{ + Tmp<MyStruct>().str.value; + Tmp<MyStruct>()().value; + Tmp<MyStruct> t; + t().value; + + Simple().str.value; + Simple()().value; + Simple s; + s().value; +} +)"; + + Document::Ptr doc = Document::create("resolveTemplateConstructor"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QVERIFY(doc->globalSymbolCount() == 4); + + Class *s = doc->globalSymbolAt(0)->asClass(); + QVERIFY(s); + QCOMPARE(s->name()->identifier()->chars(), "MyStruct"); + QCOMPARE(s->memberCount(), 1); + + Declaration *sv = s->memberAt(0)->asDeclaration(); + QVERIFY(sv); + QCOMPARE(sv->name()->identifier()->chars(), "value"); + + Snapshot snapshot; + snapshot.insert(doc); + + FindUsages find(src, doc, snapshot); + find(sv); + QCOMPARE(find.usages().size(), 7); +} + #if 0 @interface Clazz {} +(void)method:(int)arg; @end @implementation Clazz +(void)method:(int)arg { @@ -1076,5 +1310,580 @@ void tst_FindUsages::memberAccessAsTemplate() } } +void tst_FindUsages::variadicFunctionTemplate() +{ + const QByteArray src = "struct S{int value;};\n" + "template<class ... Types> S foo(Types & ... args){return S();}\n" + "int main(){\n" + " foo().value;\n" + " foo(1).value;\n" + " foo(1,2).value;\n" + "}"; + + Document::Ptr doc = Document::create("variadicFunctionTemplate"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QVERIFY(doc->globalSymbolCount()>=1); + + Snapshot snapshot; + snapshot.insert(doc); + + { // Test "S::value" + Class *c = doc->globalSymbolAt(0)->asClass(); + QVERIFY(c); + QCOMPARE(c->name()->identifier()->chars(), "S"); + QCOMPARE(c->memberCount(), 1); + + Declaration *v = c->memberAt(0)->asDeclaration(); + QVERIFY(v); + QCOMPARE(v->name()->identifier()->chars(), "value"); + + FindUsages find(src, doc, snapshot); + find(v); + QCOMPARE(find.usages().size(), 4); + } +} + +void tst_FindUsages::typeTemplateParameterWithDefault() +{ + const QByteArray src = "struct X{int value;};\n" + "struct S{int value;};\n" + "template<class T = S> T foo(){return T();}\n" + "int main(){\n" + " foo<X>().value;\n" + " foo<S>().value;\n" + " foo().value;\n" // this is S.value + "}"; + + Document::Ptr doc = Document::create("typeTemplateParameterWithDefault"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QVERIFY(doc->globalSymbolCount()>=2); + + Snapshot snapshot; + snapshot.insert(doc); + + { // Test "S::value" + Class *x = doc->globalSymbolAt(0)->asClass(); + QVERIFY(x); + QCOMPARE(x->name()->identifier()->chars(), "X"); + QCOMPARE(x->memberCount(), 1); + + Class *s = doc->globalSymbolAt(1)->asClass(); + QVERIFY(s); + QCOMPARE(s->name()->identifier()->chars(), "S"); + QCOMPARE(s->memberCount(), 1); + + Declaration *xv = x->memberAt(0)->asDeclaration(); + QVERIFY(xv); + QCOMPARE(xv->name()->identifier()->chars(), "value"); + + Declaration *sv = s->memberAt(0)->asDeclaration(); + QVERIFY(sv); + QCOMPARE(sv->name()->identifier()->chars(), "value"); + + FindUsages find(src, doc, snapshot); + find(xv); + QCOMPARE(find.usages().size(), 2); + find(sv); + QCOMPARE(find.usages().size(), 3); + } +} + +void tst_FindUsages::resolveOrder_for_templateFunction_vs_function() +{ + const QByteArray src = "struct X{int value;};\n" + "struct S{int value;};\n" + "X foo(){return X();}\n" + "template<class T = S> T foo(){return T();}\n" + "int main(){\n" + " foo().value;\n" // this is X.value + "}"; + + Document::Ptr doc = Document::create("resolveOrder_for_templateFunction_vs_function"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QVERIFY(doc->globalSymbolCount()>=1); + + Snapshot snapshot; + snapshot.insert(doc); + + { // Test "S::value" + Class *x = doc->globalSymbolAt(0)->asClass(); + QVERIFY(x); + QCOMPARE(x->name()->identifier()->chars(), "X"); + QCOMPARE(x->memberCount(), 1); + + Declaration *xv = x->memberAt(0)->asDeclaration(); + QVERIFY(xv); + QCOMPARE(xv->name()->identifier()->chars(), "value"); + + FindUsages find(src, doc, snapshot); + find(xv); + QCOMPARE(find.usages().size(), 2); + } +} + +void tst_FindUsages::templateArrowOperator_with_defaultType() +{ + const QByteArray src = "struct S{int value;};\n" + "struct C{\n" + " S* s;\n" + " template<class T = S> \n" + " T* operator->(){return &s;}\n" + "};\n" + "int main(){\n" + " C().operator -> ()->value;\n" + " C()->value;\n" + "}\n"; + + Document::Ptr doc = Document::create("templateArrowOperator_with_defaultType"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QVERIFY(doc->globalSymbolCount()>=1); + + Snapshot snapshot; + snapshot.insert(doc); + + { // Test "S::value" + Class *s = doc->globalSymbolAt(0)->asClass(); + QVERIFY(s); + QCOMPARE(s->name()->identifier()->chars(), "S"); + QCOMPARE(s->memberCount(), 1); + + Declaration *sv = s->memberAt(0)->asDeclaration(); + QVERIFY(sv); + QCOMPARE(sv->name()->identifier()->chars(), "value"); + + FindUsages find(src, doc, snapshot); + find(sv); + QCOMPARE(find.usages().size(), 3); + } +} + +void tst_FindUsages::templateSpecialization_with_IntArgument() +{ + const QByteArray src = "\n" + "struct S0{ int value = 0; };\n" + "struct S1{ int value = 1; };\n" + "struct S2{ int value = 2; };\n" + "template<int N> struct S { S0 s; };\n" + "template<> struct S<1> { S1 s; };\n" + "template<> struct S<2> { S2 s; };\n" + "int main()\n" + "{\n" + " S<0> s0;\n" + " S<1> s1;\n" + " S<2> s2;\n" + " s0.s.value;\n" + " s1.s.value;\n" + " s2.s.value;\n" + "}\n"; + + Document::Ptr doc = Document::create("templateSpecialization_with_IntArgument"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QVERIFY(doc->globalSymbolCount()>=3); + + Snapshot snapshot; + snapshot.insert(doc); + + { + Class *s[3] = { + doc->globalSymbolAt(0)->asClass(), + doc->globalSymbolAt(1)->asClass(), + doc->globalSymbolAt(2)->asClass(), + }; + + QVERIFY(s[0]); + QVERIFY(s[1]); + QVERIFY(s[2]); + + QCOMPARE(s[0]->name()->identifier()->chars(), "S0"); + QCOMPARE(s[1]->name()->identifier()->chars(), "S1"); + QCOMPARE(s[2]->name()->identifier()->chars(), "S2"); + + QCOMPARE(s[0]->memberCount(), 1); + QCOMPARE(s[1]->memberCount(), 1); + QCOMPARE(s[2]->memberCount(), 1); + + Declaration *sv[3] = { + s[0]->memberAt(0)->asDeclaration(), + s[1]->memberAt(0)->asDeclaration(), + s[2]->memberAt(0)->asDeclaration(), + }; + + QVERIFY(sv[0]); + QVERIFY(sv[1]); + QVERIFY(sv[2]); + + QCOMPARE(sv[0]->name()->identifier()->chars(), "value"); + QCOMPARE(sv[1]->name()->identifier()->chars(), "value"); + QCOMPARE(sv[2]->name()->identifier()->chars(), "value"); + + FindUsages find(src, doc, snapshot); + + find(sv[0]); + QCOMPARE(find.usages().size(), 2); + + QCOMPARE(find.usages()[0].line, 1); + QCOMPARE(find.usages()[0].col, 15); + QCOMPARE(find.usages()[1].line, 12); + QCOMPARE(find.usages()[1].col, 9); + + find(sv[1]); + QCOMPARE(find.usages().size(), 2); + + QCOMPARE(find.usages()[0].line, 2); + QCOMPARE(find.usages()[0].col, 15); + QCOMPARE(find.usages()[1].line, 13); + QCOMPARE(find.usages()[1].col, 9); + + find(sv[2]); + QCOMPARE(find.usages().size(), 2); + + QCOMPARE(find.usages()[0].line, 3); + QCOMPARE(find.usages()[0].col, 15); + QCOMPARE(find.usages()[1].line, 14); + QCOMPARE(find.usages()[1].col, 9); + } +} + +void tst_FindUsages::templateSpecialization_with_BoolArgument() +{ + const QByteArray src = "\n" + "struct S0{ int value = 0; };\n" + "struct S1{ int value = 1; };\n" + "template<bool B> struct S { S0 s; };\n" + "template<> struct S<true> { S1 s; };\n" + "int main()\n" + "{\n" + " S<false> s0;\n" + " S<true> s1;\n" + " s0.s.value;\n" + " s1.s.value;\n" + "}\n"; + + Document::Ptr doc = Document::create("templateSpecialization_with_BoolArgument"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QVERIFY(doc->globalSymbolCount()>=3); + + Snapshot snapshot; + snapshot.insert(doc); + + { + Class *s[2] = { + doc->globalSymbolAt(0)->asClass(), + doc->globalSymbolAt(1)->asClass(), + }; + + QVERIFY(s[0]); + QVERIFY(s[1]); + + QCOMPARE(s[0]->name()->identifier()->chars(), "S0"); + QCOMPARE(s[1]->name()->identifier()->chars(), "S1"); + + QCOMPARE(s[0]->memberCount(), 1); + QCOMPARE(s[1]->memberCount(), 1); + + Declaration *sv[2] = { + s[0]->memberAt(0)->asDeclaration(), + s[1]->memberAt(0)->asDeclaration(), + }; + + QVERIFY(sv[0]); + QVERIFY(sv[1]); + + QCOMPARE(sv[0]->name()->identifier()->chars(), "value"); + QCOMPARE(sv[1]->name()->identifier()->chars(), "value"); + + FindUsages find(src, doc, snapshot); + + find(sv[0]); + QCOMPARE(find.usages().size(), 2); + + QCOMPARE(find.usages()[0].line, 1); + QCOMPARE(find.usages()[0].col, 15); + QCOMPARE(find.usages()[1].line, 9); + QCOMPARE(find.usages()[1].col, 9); + + find(sv[1]); + QCOMPARE(find.usages().size(), 2); + + QCOMPARE(find.usages()[0].line, 2); + QCOMPARE(find.usages()[0].col, 15); + QCOMPARE(find.usages()[1].line, 10); + QCOMPARE(find.usages()[1].col, 9); + } +} + +void tst_FindUsages::templatePartialSpecialization() +{ + const QByteArray src = "\n" + "struct S0{ int value = 0; };\n" + "struct S1{ int value = 1; };\n" + "template<class T, class U> struct S { S0 ss; };\n" + "template<class U> struct S<float, U> { S1 ss; };\n" + "int main()\n" + "{\n" + " S<int, int> s0;\n" + " S<float, int> s1;\n" + " s0.ss.value;\n" + " s1.ss.value;\n" + "}\n"; + + Document::Ptr doc = Document::create("templatePartialSpecialization"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QVERIFY(doc->globalSymbolCount()>=3); + + Snapshot snapshot; + snapshot.insert(doc); + + { + Class *s[2] = { + doc->globalSymbolAt(0)->asClass(), + doc->globalSymbolAt(1)->asClass(), + }; + + QVERIFY(s[0]); + QVERIFY(s[1]); + + QCOMPARE(s[0]->name()->identifier()->chars(), "S0"); + QCOMPARE(s[1]->name()->identifier()->chars(), "S1"); + + QCOMPARE(s[0]->memberCount(), 1); + QCOMPARE(s[1]->memberCount(), 1); + + Declaration *sv[2] = { + s[0]->memberAt(0)->asDeclaration(), + s[1]->memberAt(0)->asDeclaration(), + }; + + QVERIFY(sv[0]); + QVERIFY(sv[1]); + + QCOMPARE(sv[0]->name()->identifier()->chars(), "value"); + QCOMPARE(sv[1]->name()->identifier()->chars(), "value"); + + FindUsages find(src, doc, snapshot); + + find(sv[0]); + QCOMPARE(find.usages().size(), 2); + + QCOMPARE(find.usages()[0].line, 1); + QCOMPARE(find.usages()[0].col, 15); + QCOMPARE(find.usages()[1].line, 9); + QCOMPARE(find.usages()[1].col, 10); + + find(sv[1]); + QCOMPARE(find.usages().size(), 2); + + QCOMPARE(find.usages()[0].line, 2); + QCOMPARE(find.usages()[0].col, 15); + QCOMPARE(find.usages()[1].line, 10); + QCOMPARE(find.usages()[1].col, 10); + } +} + +void tst_FindUsages::templatePartialSpecialization_2() +{ + const QByteArray src = +R"( +struct S0{int value=0;}; +struct S1{int value=1;}; +struct S2{int value=2;}; +template<class T1, class T2> struct S{T1 ss;}; +template<class U> struct S<int, U>{ U ss; }; +template<class V> struct S<V*, int>{ V *ss; }; +int main() +{ + S<S0, float> s0; + s0.ss.value; + S<int, S1> s1; + s1.ss.value; + S<S2*, int> s2; + s2.ss->value; +} +)"; + + Document::Ptr doc = Document::create("templatePartialSpecialization_2"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QVERIFY(doc->globalSymbolCount()>=3); + + Snapshot snapshot; + snapshot.insert(doc); + + FindUsages find(src, doc, snapshot); + + Class *s[3]; + Declaration *sv[3]; + for (int i = 0; i < 3; i++) { + s[i] = doc->globalSymbolAt(i)->asClass(); + QVERIFY(s[i]); + QCOMPARE(s[i]->memberCount(), 1); + sv[i] = s[i]->memberAt(0)->asDeclaration(); + QVERIFY(sv[i]); + QCOMPARE(sv[i]->name()->identifier()->chars(), "value"); + } + QCOMPARE(s[0]->name()->identifier()->chars(), "S0"); + QCOMPARE(s[1]->name()->identifier()->chars(), "S1"); + QCOMPARE(s[2]->name()->identifier()->chars(), "S2"); + + find(sv[0]); + QCOMPARE(find.usages().size(), 2); + + find(sv[1]); + QCOMPARE(find.usages().size(), 2); + + find(sv[2]); + QCOMPARE(find.usages().size(), 2); +} + +void tst_FindUsages::template_SFINAE_1() +{ + const QByteArray src = +R"( +struct S{int value=1;}; +template<class, class> struct is_same {}; +template<class T> struct is_same<T, T> {using type = int;}; +template<class T = S, typename is_same<T, S>::type = 0> T* foo(){return new T();} +int main(){ + foo()->value; +} +)"; + + Document::Ptr doc = Document::create("template_SFINAE_1"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QVERIFY(doc->globalSymbolCount()>=1); + + Snapshot snapshot; + snapshot.insert(doc); + + Class *s = doc->globalSymbolAt(0)->asClass(); + QVERIFY(s); + QCOMPARE(s->name()->identifier()->chars(), "S"); + QCOMPARE(s->memberCount(), 1); + + Declaration *sv = s->memberAt(0)->asDeclaration(); + QVERIFY(sv); + QCOMPARE(sv->name()->identifier()->chars(), "value"); + + FindUsages find(src, doc, snapshot); + find(sv); + QCOMPARE(find.usages().size(), 2); +} + +void tst_FindUsages::variableTemplateInExpression() +{ + const QByteArray src = +R"( +struct S{int value;}; +template<class T> constexpr int foo = sizeof(T); +template<class T1, class T2> +struct pair{ + pair() noexcept(foo<T1> + foo<T2>){} + T1 first; + T2 second; +}; +int main(){ + pair<int, S> pair; + pair.second.value; +} +)"; + + Document::Ptr doc = Document::create("variableTemplateInExpression"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QVERIFY(doc->globalSymbolCount()>=1); + + Snapshot snapshot; + snapshot.insert(doc); + + Class *s = doc->globalSymbolAt(0)->asClass(); + QVERIFY(s); + QCOMPARE(s->name()->identifier()->chars(), "S"); + QCOMPARE(s->memberCount(), 1); + + Declaration *sv = s->memberAt(0)->asDeclaration(); + QVERIFY(sv); + QCOMPARE(sv->name()->identifier()->chars(), "value"); + + FindUsages find(src, doc, snapshot); + find(sv); + QCOMPARE(find.usages().size(), 2); +} + +void tst_FindUsages::variadicMacros() +{ + const QByteArray src = + R"( +struct MyStruct { int value; }; +#define FOO( ... ) int foo() +FOO(1) { + MyStruct s; + s.value; +} +int main(){} +)"; + + Document::Ptr doc = Document::create("variadicMacros"); + doc->setUtf8Source(src); + doc->parse(); + doc->check(); + + QVERIFY(doc->diagnosticMessages().isEmpty()); + QVERIFY(doc->globalSymbolCount() >= 1); + + Snapshot snapshot; + snapshot.insert(doc); + + Class *s = doc->globalSymbolAt(0)->asClass(); + QVERIFY(s); + QCOMPARE(s->name()->identifier()->chars(), "MyStruct"); + QCOMPARE(s->memberCount(), 1); + + Declaration *sv = s->memberAt(0)->asDeclaration(); + QVERIFY(sv); + QCOMPARE(sv->name()->identifier()->chars(), "value"); + + FindUsages find(src, doc, snapshot); + find(sv); + QCOMPARE(find.usages().size(), 2); +} + QTEST_APPLESS_MAIN(tst_FindUsages) #include "tst_findusages.moc" diff --git a/tests/auto/cplusplus/lexer/tst_lexer.cpp b/tests/auto/cplusplus/lexer/tst_lexer.cpp index 79548e6fd4..90a36c510c 100644 --- a/tests/auto/cplusplus/lexer/tst_lexer.cpp +++ b/tests/auto/cplusplus/lexer/tst_lexer.cpp @@ -619,6 +619,8 @@ void tst_SimpleLexer::user_defined_literals_data() << _("11_udl") << createToken(T_NUMERIC_LITERAL, 6, 6, true); QTest::newRow("numeric user-defined literal with decimal part") << _("11.1_udl") << createToken(T_NUMERIC_LITERAL, 8, 8, true); + QTest::newRow("numeric user-defined reserved literal") + << _("11ms") << createToken(T_NUMERIC_LITERAL, 4, 4, true); } static Token createToken(unsigned kind, unsigned byteOffset, unsigned bytes, diff --git a/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp b/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp index 005ea5c1fa..6801240368 100644 --- a/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp +++ b/tests/auto/cplusplus/preprocessor/tst_preprocessor.cpp @@ -405,6 +405,7 @@ private slots: void multi_byte_code_point_in_expansion(); void trigraph(); void nested_arguments_expansion(); + void preprocessorSymbolsAsMacroArguments(); }; // Remove all #... lines, and 'simplify' string, to allow easily comparing the result @@ -2099,6 +2100,20 @@ void tst_Preprocessor::nested_arguments_expansion() QVERIFY(prep.contains(output)); } +void tst_Preprocessor::preprocessorSymbolsAsMacroArguments() +{ + Environment env; + Preprocessor preprocess(nullptr, &env); + const QByteArray input = + "#define IFGEN(if, endif) if (1 == 0) endif\n" + "int main()\n" + "{\n" + "IFGEN(#if, #endif)\n" + "return 0;\n" + "}\n"; + QVERIFY(preprocess.run(QLatin1String("<stdin>"), input).startsWith("# 1 \"<stdin>\"\n")); +} + void tst_Preprocessor::excessive_nesting() { Environment env; diff --git a/tests/auto/cplusplus/semantic/tst_semantic.cpp b/tests/auto/cplusplus/semantic/tst_semantic.cpp index 51c1fadf7e..deda2aab2c 100644 --- a/tests/auto/cplusplus/semantic/tst_semantic.cpp +++ b/tests/auto/cplusplus/semantic/tst_semantic.cpp @@ -612,7 +612,7 @@ void tst_Semantic::template_instance_1() Declaration *decl = templ->memberAt(1)->asClass()->memberAt(0)->asDeclaration(); QVERIFY(decl); - FullySpecifiedType templArgs[] = {control->integerType(IntegerType::Int)}; + TemplateArgument templArgs[] = {FullySpecifiedType(control->integerType(IntegerType::Int))}; const Name *templId = control->templateNameId(control->identifier("QList"), false, templArgs, 1); FullySpecifiedType genTy = DeprecatedGenTemplateInstance::instantiate(templId, decl, control); diff --git a/tests/auto/cplusplus/typeprettyprinter/tst_typeprettyprinter.cpp b/tests/auto/cplusplus/typeprettyprinter/tst_typeprettyprinter.cpp index 04d9fc683d..742591d72c 100644 --- a/tests/auto/cplusplus/typeprettyprinter/tst_typeprettyprinter.cpp +++ b/tests/auto/cplusplus/typeprettyprinter/tst_typeprettyprinter.cpp @@ -189,7 +189,7 @@ void tst_TypePrettyPrinter::basic_data() QTest::addColumn<QString>("result"); // Define some often used flag combinations. - const Overview::StarBindFlags bindToNothing = 0; + const Overview::StarBindFlags bindToNothing({}); const Overview::StarBindFlags bindToBothSpecifiers = Overview::StarBindFlags(Overview::BindToLeftSpecifier | Overview::BindToRightSpecifier); const Overview::StarBindFlags bindToNameAndType diff --git a/tests/auto/debugger/CMakeLists.txt b/tests/auto/debugger/CMakeLists.txt index fb90869cde..367a0de393 100644 --- a/tests/auto/debugger/CMakeLists.txt +++ b/tests/auto/debugger/CMakeLists.txt @@ -7,8 +7,10 @@ add_qtc_test(tst_debugger_disassembler "${DEBUGGERDIR}/disassemblerlines.cpp" "${DEBUGGERDIR}/disassemblerlines.h" ) +option(WITH_DEBUGGER_DUMPERS "Include tests for debugger pretty printers" OFF) if (WITH_DEBUGGER_DUMPERS) add_qtc_test(tst_debugger_dumpers + TIMEOUT 0 DEPENDS Qt5::Network Utils DEFINES DUMPERDIR="${PROJECT_SOURCE_DIR}/share/qtcreator/debugger" INCLUDES diff --git a/tests/auto/debugger/README.txt b/tests/auto/debugger/README.txt index e3b550e8cc..ae522e2e0e 100644 --- a/tests/auto/debugger/README.txt +++ b/tests/auto/debugger/README.txt @@ -24,6 +24,8 @@ conditions by using environment variables as follows: (QTC_CDBEXT_PATH (optional) - path to the cdbextension defaults to IDE_BUILD_TREE/IDE_LIBRARY_BASENAME/qtcreatorcdbext64) + QTC_USE_CMAKE_FOR_TEST - Use cmake to build test cases (incomplete) + The tests should be used for automated testing, but can also be used for dumper development and fixing. diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index 9bbd10b266..3646f9eaac 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -28,11 +28,11 @@ #include "watchdata.h" #include "watchutils.h" +#include <utils/fileutils.h> #ifdef Q_OS_WIN #include <utils/environment.h> #ifdef Q_CC_MSVC #include <utils/qtcprocess.h> -#include <utils/fileutils.h> #include <utils/synchronousprocess.h> #endif // Q_CC_MSVC #endif // Q_OS_WIN @@ -45,6 +45,22 @@ using namespace Debugger; using namespace Internal; +enum class BuildSystem +{ + Qmake, + CMake, + Nim +}; + +enum class Language +{ + Cxx, + C, + ObjectiveCxx, + Nim, + Fortran90 +}; + #ifdef Q_CC_MSVC // Copied from msvctoolchain.cpp to avoid plugin dependency. @@ -220,6 +236,12 @@ struct BoostVersion : VersionBase {} }; +struct ConfigTest +{ + QString executable; + QStringList arguments; +}; + static QString noValue = "\001"; enum DebuggerEngine @@ -697,6 +719,7 @@ struct NetworkProfile {}; struct QmlProfile {}; struct QmlPrivateProfile {}; struct SqlProfile {}; +struct XmlProfile {}; struct NimProfile {}; @@ -838,6 +861,10 @@ public: { profileExtra += "QT += core\n"; + cmakelistsExtra += + "find_package(Qt5 COMPONENTS Core REQUIRED)\n" + "target_link_libraries(doit PRIVATE Qt5::Core)\n"; + useQt = true; useQHash = true; @@ -848,6 +875,10 @@ public: { profileExtra += "QT += core network\n"; + cmakelistsExtra += + "find_package(Qt5 COMPONENTS Core Network REQUIRED)\n" + "target_link_libraries(doit PRIVATE Qt5::Core Qt::Network)\n"; + useQt = true; useQHash = true; @@ -876,6 +907,10 @@ public: "QT += gui\n" "greaterThan(QT_MAJOR_VERSION, 4):QT *= widgets\n"; + cmakelistsExtra += + "find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)\n" + "target_link_libraries(doit PRIVATE Qt5::Core Qt5::Gui Qt::Widgets)\n"; + return *this; } @@ -900,6 +935,10 @@ public: " CONFIG += no_private_qt_headers_warning\n" "}"; + cmakelistsExtra += + //"find_package(Qt5 COMPONENTS Core Gui GuiPrivate REQUIRED)\n" + "target_link_libraries(doit PRIVATE Qt5::Core Qt5::Gui Qt5::GuiPrivate)\n"; + return *this; } @@ -923,6 +962,23 @@ public: " CONFIG += no_private_qt_headers_warning\n" "}"; + cmakelistsExtra += + "find_package(Qt5 COMPONENTS Core Gui Qml REQUIRED)\n" + "target_link_libraries(doit PRIVATE Qt5::Core Qt5::Qml Qt5::QmlPrivate)\n"; + + return *this; + } + + const Data &operator+(const XmlProfile &) const + { + this->operator+(CoreProfile()); + profileExtra += + " QT += xml\n"; + + cmakelistsExtra += + "find_package(Qt5 COMPONENTS Core Xml REQUIRED)\n" + "target_link_libraries(doit PRIVATE Qt5::Core Qt5::Xml)\n"; + return *this; } @@ -935,13 +991,13 @@ public: useQt = false; useQHash = false; - mainFile = "main.mm"; + language = Language::ObjectiveCxx; return *this; } const Data &operator+(const ForceC &) const { - mainFile = "main.c"; + language = Language::C; return *this; } @@ -962,16 +1018,15 @@ public: mutable BoostVersion neededBoostVersion; // DEC. 105400 for 1.54.0 mutable DwarfVersion neededDwarfVersion; // DEC. 105400 for 1.54.0 - mutable QString configTest; + mutable ConfigTest configTest; mutable QString allProfile; // Overrides anything below if not empty. mutable QString allCode; // Overrides anything below if not empty. - mutable QString mainFile = "main.cpp"; - mutable QString projectFile = "doit.pro"; - + mutable Language language = Language::Cxx; mutable QString dumperOptions; mutable QString profileExtra; + mutable QString cmakelistsExtra; mutable QString includes; mutable QString code; mutable QString unused; @@ -1015,9 +1070,11 @@ private slots: private: void disarm() { t->buildTemp.setAutoRemove(!keepTemp()); } bool keepTemp() const { return m_keepTemp || m_forceKeepTemp; } - TempStuff *t = 0; + TempStuff *t = nullptr; + BuildSystem m_buildSystem = BuildSystem::Qmake; QString m_debuggerBinary; QString m_qmakeBinary; + QString m_cmakeBinary{"cmake"}; QProcessEnvironment m_env; DebuggerEngine m_debuggerEngine; QString m_makeBinary; @@ -1056,7 +1113,11 @@ void tst_Dumpers::initTestCase() m_qmakeBinary = QDir::fromNativeSeparators(QString::fromLocal8Bit(qgetenv("QTC_QMAKE_PATH_FOR_TEST"))); if (m_qmakeBinary.isEmpty()) m_qmakeBinary = "qmake"; + if (qEnvironmentVariableIntValue("QTC_USE_CMAKE_FOR_TEST")) + m_buildSystem = BuildSystem::CMake; + qDebug() << "QMake : " << m_qmakeBinary; + qDebug() << "Use CMake : " << (m_buildSystem == BuildSystem::CMake) << int(m_buildSystem); m_useGLibCxxDebug = qgetenv("QTC_USE_GLIBCXXDEBUG_FOR_TEST").toInt(); qDebug() << "Use _GLIBCXX_DEBUG : " << m_useGLibCxxDebug; @@ -1288,44 +1349,109 @@ void tst_Dumpers::dumper() + QByteArray::number(data.neededMsvcVersion.max)); } - if (!data.configTest.isEmpty()) { + if (!data.configTest.executable.isEmpty()) { QProcess configTest; - configTest.start(data.configTest); + configTest.start(data.configTest.executable, data.configTest.arguments); QVERIFY(configTest.waitForFinished()); output = configTest.readAllStandardOutput(); error = configTest.readAllStandardError(); if (configTest.exitCode()) { - MSKIP_SINGLE("Configure test failed: '" - + data.configTest.toUtf8() + "' " + output + ' ' + error); + QString msg = "Configure test failed: '" + + data.configTest.executable + ' ' + + data.configTest.arguments.join(' ') + + "' " + output + ' ' + error; + MSKIP_SINGLE(msg.toUtf8()); } } - QFile proFile(t->buildPath + '/' + data.projectFile); - QVERIFY(proFile.open(QIODevice::ReadWrite)); - if (data.allProfile.isEmpty()) { - proFile.write("SOURCES = "); - proFile.write(data.mainFile.toUtf8()); - proFile.write("\nTARGET = doit\n"); - proFile.write("\nCONFIG -= app_bundle\n"); - proFile.write("\nmacos: CONFIG += sdk_no_version_check\n"); - proFile.write("\nCONFIG -= release\n"); - proFile.write("\nCONFIG += debug\n"); - proFile.write("\nCONFIG += console\n"); - if (data.useQt) - proFile.write("QT -= widgets gui\n"); - else - proFile.write("CONFIG -= qt\n"); - if (m_useGLibCxxDebug) - proFile.write("DEFINES += _GLIBCXX_DEBUG\n"); - if (m_debuggerEngine == GdbEngine && m_debuggerVersion < 70500) - proFile.write("QMAKE_CXXFLAGS += -gdwarf-3\n"); - proFile.write(data.profileExtra.toUtf8()); + QString mainFile; + QByteArray cmakeLanguage; + if (data.language == Language::C) { + mainFile = "main.c"; + cmakeLanguage = "C"; + } else if (data.language == Language::ObjectiveCxx) { + mainFile = "main.mm"; + cmakeLanguage = "CXX"; + } else if (data.language == Language::Nim) { + mainFile = "main.nim"; + cmakeLanguage = "CXX"; + } else if (data.language == Language::Fortran90) { + mainFile = "main.f90"; + cmakeLanguage = "Fortran"; } else { - proFile.write(data.allProfile.toUtf8()); + mainFile = "main.cpp"; + cmakeLanguage = "CXX"; } - proFile.close(); - QFile source(t->buildPath + '/' + data.mainFile); + QFile projectFile; + if (m_buildSystem == BuildSystem::CMake) { + projectFile.setFileName(t->buildPath + "/CMakeLists.txt"); + QVERIFY(projectFile.open(QIODevice::ReadWrite)); + if (data.allProfile.isEmpty()) { + projectFile.write("cmake_minimum_required(VERSION 3.5)\n\n"); + projectFile.write("project(doit LANGUAGES " + cmakeLanguage + ")\n\n"); + projectFile.write("set(CMAKE_INCLUDE_CURRENT_DIR ON)\n\n"); + + if (data.useQt) { + projectFile.write("set(CMAKE_AUTOUIC ON)\n"); + projectFile.write("set(CMAKE_AUTOMOC ON)\n"); + projectFile.write("set(CMAKE_AUTORCC ON)\n"); + } + + projectFile.write("set(CMAKE_CXX_STANDARD 11)\n"); + projectFile.write("set(CMAKE_CXX_STANDARD_REQUIRED ON)\n"); + + projectFile.write("add_executable(doit\n"); + projectFile.write(" " + mainFile.toUtf8() + "\n"); + projectFile.write(")\n\n"); + + //projectFile.write("target_link_libraries(doit PRIVATE Qt5::Widgets)\n"); + + //projectFile.write("\nmacos: CONFIG += sdk_no_version_check\n"); + //projectFile.write("\nCONFIG -= release\n"); + //projectFile.write("\nCONFIG += debug\n"); + //projectFile.write("\nCONFIG += console\n"); + + //if (m_useGLibCxxDebug) + // projectFile.write("DEFINES += _GLIBCXX_DEBUG\n"); + //if (m_debuggerEngine == GdbEngine && m_debuggerVersion < 70500) + // projectFile.write("QMAKE_CXXFLAGS += -gdwarf-3\n"); + projectFile.write(data.cmakelistsExtra.toUtf8()); + } else { + projectFile.write(data.allProfile.toUtf8()); + } + projectFile.close(); + } else { + projectFile.setFileName(t->buildPath + "/doit.pro"); + QVERIFY(projectFile.open(QIODevice::ReadWrite)); + if (data.allProfile.isEmpty()) { + projectFile.write("SOURCES = "); + projectFile.write(mainFile.toUtf8()); + projectFile.write("\nTARGET = doit\n"); + projectFile.write("\nCONFIG -= app_bundle\n"); + projectFile.write("\nmacos: CONFIG += sdk_no_version_check\n"); + projectFile.write("\nCONFIG -= release\n"); + projectFile.write("\nCONFIG += debug\n"); + projectFile.write("\nCONFIG += console\n"); + if (data.useQt) + projectFile.write("QT -= widgets gui\n"); + else + projectFile.write("CONFIG -= qt\n"); + if (m_useGLibCxxDebug) + projectFile.write("DEFINES += _GLIBCXX_DEBUG\n"); + if (m_debuggerEngine == GdbEngine && m_debuggerVersion < 70500) + projectFile.write("QMAKE_CXXFLAGS += -gdwarf-3\n"); + projectFile.write(data.profileExtra.toUtf8()); + } else { + projectFile.write(data.allProfile.toUtf8()); + } +#ifdef Q_OS_WIN + projectFile.write("TARGET = ../doit\n"); // avoid handling debug / release folder +#endif + projectFile.close(); + } + + QFile source(t->buildPath + '/' + mainFile); QVERIFY(source.open(QIODevice::ReadWrite)); QString unused; @@ -1411,23 +1537,47 @@ void tst_Dumpers::dumper() source.write(fullCode.toUtf8()); source.close(); - QProcess qmake; - qmake.setWorkingDirectory(t->buildPath); - //qDebug() << "Starting qmake: " << m_qmakeBinary; - QStringList options; -#ifdef Q_OS_MAC - if (m_qtVersion && m_qtVersion < 0x050000) - options << "-spec" << "unsupported/macx-clang"; -#endif - qmake.start(m_qmakeBinary, options); - QVERIFY(qmake.waitForFinished()); - output = qmake.readAllStandardOutput(); - error = qmake.readAllStandardError(); - //qDebug() << "stdout: " << output; + if (m_buildSystem == BuildSystem::CMake) { + QProcess cmake; + cmake.setWorkingDirectory(t->buildPath); + QDir dir = QFileInfo(m_qmakeBinary).dir(); // {Qt:QT_INSTALL_PREFIX} + dir.cdUp(); + QStringList options = { + "-DCMAKE_BUILD_TYPE=Debug", + "-DCMAKE_PREFIX_PATH=" + dir.absolutePath(), + "." + }; + //qDebug() << "Starting cmake: " << m_cmakeBinary << ' ' << qPrintable(options.join(' ')); + cmake.start(m_cmakeBinary, options); + QVERIFY(cmake.waitForFinished()); + output = cmake.readAllStandardOutput(); + error = cmake.readAllStandardError(); + //qDebug() << "stdout: " << output; + + if (data.allProfile.isEmpty()) { // Nim... + if (!error.isEmpty()) { + qDebug() << error; QVERIFY(false); + } + } + } else { + QProcess qmake; + qmake.setWorkingDirectory(t->buildPath); + //qDebug() << "Starting qmake: " << m_qmakeBinary; + QStringList options; + #ifdef Q_OS_MACOS + if (m_qtVersion && m_qtVersion < 0x050000) + options << "-spec" << "unsupported/macx-clang"; + #endif + qmake.start(m_qmakeBinary, options); + QVERIFY(qmake.waitForFinished()); + output = qmake.readAllStandardOutput(); + error = qmake.readAllStandardError(); + //qDebug() << "stdout: " << output; - if (data.allProfile.isEmpty()) { // Nim... - if (!error.isEmpty()) { - qDebug() << error; QVERIFY(false); + if (data.allProfile.isEmpty()) { // Nim... + if (!error.isEmpty()) { + qDebug() << error; QVERIFY(false); + } } } @@ -1445,7 +1595,7 @@ void tst_Dumpers::dumper() qDebug() << "\n------------------ CODE --------------------"; qDebug().noquote() << fullCode; qDebug() << "\n------------------ CODE --------------------"; - qDebug().noquote() << "Project file: " << proFile.fileName(); + qDebug().noquote() << "Project file: " << projectFile.fileName(); QCOMPARE(make.exitCode(), 0); } @@ -1487,7 +1637,7 @@ void tst_Dumpers::dumper() } }; collectExpandedINames(data.checks); - for (const auto checkset : qAsConst(data.checksets)) + for (const auto &checkset : qAsConst(data.checksets)) collectExpandedINames(checkset.checks); QString expanded; @@ -1518,12 +1668,7 @@ void tst_Dumpers::dumper() QByteArray nograb = "-nograb"; cmds = "set confirm off\n" -#ifdef Q_OS_WIN - "file debug/doit\n" -#else "file doit\n" -#endif - "set print object on\n" "set auto-load python-scripts off\n"; cmds += "python sys.path.insert(1, '" + dumperDir + "')\n" @@ -1547,7 +1692,7 @@ void tst_Dumpers::dumper() << "0x4000001f" << "-c" << "bm doit!qtcDebugBreakFunction;g" - << "debug\\doit.exe"; + << "doit.exe"; cmds += ".symopt+0x8000\n" "!qtcreatorcdbext.script sys.path.insert(1, '" + dumperDir + "')\n" "!qtcreatorcdbext.script from cdbbridge import *\n" @@ -2333,6 +2478,7 @@ void tst_Dumpers::dumper_data() "&l1, &l2, &l3, &l4, &l5, &l6") + CoreProfile() + + QtVersion(0, 0x5ffff) // QLinkedList was dropped in Qt 6 + Check("l0", "<0 items>", "@QLinkedList<float>") @@ -4267,8 +4413,7 @@ void tst_Dumpers::dumper_data() "atts.append(\"name3\", \"uri3\", \"localPart3\", \"value3\");", "&atts") - + CoreProfile() - + Profile("QT += xml\n") + + XmlProfile() + Check("atts", "<3 items>", "@QXmlAttributes") + Check("atts.0", "[0]", "", "@QXmlAttributes::Attribute") @@ -5857,7 +6002,7 @@ void tst_Dumpers::dumper_data() // + Check("c.r", "1", "int"); // // Manual: Toogle "Sort Member Alphabetically" in context menu -// // Manual: of "Locals and Expressions" view"); +// // Manual: of "Locals" and "Expressions" views"); // // Manual: Check that order of displayed members changes"); QTest::newRow("Typedef") @@ -5972,7 +6117,7 @@ void tst_Dumpers::dumper_data() // QTest::newRow("TypeFormats") // << Data( // "// These tests should result in properly displayed umlauts in the\n" -// "// Locals and Expressions view. It is only support on gdb with Python");\n" +// "// Locals and Expressions views. It is only support on gdb with Python");\n" // "const char *s = "aöa";\n" // "const wchar_t *w = L"aöa";\n" // "QString u;\n" @@ -7175,6 +7320,127 @@ void tst_Dumpers::dumper_data() + Check("p", "<5 items>", "@QGraphicsPolygonItem"); + QTest::newRow("QCbor") + << Data("#include <QString>\n" + "#if QT_VERSION >= 0x050c00\n" + "#include <QCborArray>\n" + "#include <QCborMap>\n" + "#include <QCborValue>\n" + "#include <QVariantMap>\n" + "#endif\n", + + "#if QT_VERSION >= 0x050c00\n" + "QCborMap ob0;\n" + "QCborMap ob = QCborMap::fromVariantMap({\n" + " {\"a\", 1},\n" + " {\"bb\", 2},\n" + " {\"ccc\", \"hallo\"},\n" + " {\"s\", \"ssss\"}\n" + "});\n" + "ob.insert(QLatin1String(\"d\"), QCborMap::fromVariantMap({{\"ddd\", 1234}}));\n" + "\n" + "QCborValue a0;\n" + "QCborValue a1(1);\n" + "QCborValue a2(\"asd\");\n" + "QCborValue a3(QString::fromUtf8(\"cöder\"));\n" + "QCborValue a4(1.4);\n" + "QCborValue a5(true);\n" + "QCborValue a6(QByteArray(\"cder\"));\n" + "\n" + "QCborArray aa;\n" + "QCborArray a;\n" + "a.append(a1);\n" + "a.append(a2);\n" + "a.append(a3);\n" + "a.append(a4);\n" + "a.append(a5);\n" + "a.append(a0);\n" + "a.append(ob);\n" + "\n" + "QCborArray b;\n" + "b.append(QCborValue(1));\n" + "b.append(a);\n" + "b.append(QCborValue(2));\n" + "\n" + "QCborArray c;\n" + "for (unsigned int i = 0; i < 32; ++i) {\n" + " c.append(QCborValue(qint64(1u << i) - 1));\n" + " c.append(QCborValue(qint64(1u << i)));\n" + " c.append(QCborValue(qint64(1u << i) + 1));\n" + "}\n" + "for (unsigned int i = 0; i < 32; ++i) {\n" + " c.append(QCborValue(-qint64(1u << i) + 1));\n" + " c.append(QCborValue(-qint64(1u << i)));\n" + " c.append(QCborValue(-qint64(1u << i) - 1));\n" + "}" + "unused(&b, &a, &aa);\n" + "#endif\n", + + "") + + + Cxx11Profile() + + CoreProfile() + + QtVersion(0x50f00) + + MsvcVersion(1900) + + + Check("a0", "Undefined", "QCborValue (Undefined)") + + Check("a1", "1", "QCborValue (Integer)") + + Check("a2", "\"asd\"", "QCborValue (String)") + + Check("a3", "\"cöder\"", "QCborValue (String)") + + Check("a4", "1.400000", "QCborValue (Double)") + + Check("a5", "True", "QCborValue (True)") + + Check("a6", "\"cder\"", "QCborValue (ByteArray)") + + Check("aa", "<0 items>", "@QCborArray") + + Check("a", "<7 items>", "@QCborArray") + + Check("a.0", "[0]", "1", "QCborValue (Integer)") + + Check("a.1", "[1]", "\"asd\"", "QCborValue (String)") + + Check("a.2", "[2]", "\"cöder\"", "QCborValue (String)") + + Check("a.3", "[3]", "1.400000", "QCborValue (Double)") + + Check("a.4", "[4]", "True", "QCborValue (True)") + + Check("a.5", "[5]", "Undefined", "QCborValue (Undefined)") + + Check("a.6", "[6]", "<5 items>", "QCborValue (Map)") + + Check("a.6.0", "[0] \"a\"", "1", "") + + Check("a.6.1", "[1] \"bb\"", "2", "") + + Check("a.6.2", "[2] \"ccc\"", "\"hallo\"", "") + + Check("a.6.3", "[3] \"s\"", "\"ssss\"", "") + + Check("a.6.4", "[4] \"d\"", "<1 items>", "") + + Check("b", "b", "<3 items>" , "@QCborArray") + + Check("b.0", "[0]", "1", "QCborValue (Integer)") + + Check("b.1", "[1]", "<7 items>", "QCborValue (Array)") + + Check("b.1.0", "[0]", "1", "QCborValue (Integer)") + + Check("b.1.1", "[1]", "\"asd\"", "QCborValue (String)") + + Check("b.1.2", "[2]", "\"cöder\"", "QCborValue (String)") + + Check("b.1.3", "[3]", "1.400000", "QCborValue (Double)") + + Check("b.1.4", "[4]", "True", "QCborValue (True)") + + Check("b.1.5", "[5]", "Undefined", "QCborValue (Undefined)") + + Check("b.1.6", "[6]", "<5 items>", "QCborValue (Map)") + + Check("b.2", "[2]", "2", "QCborValue (Integer)") + + Check("c", "c", "<192 items>", "@QCborArray") + + Check("c.0", "[0]", "0", "QCborValue (Integer)") + + Check("c.1", "[1]", "1", "QCborValue (Integer)") + + Check("c.78", "[78]", "67108863", "QCborValue (Integer)") + + Check("c.79", "[79]", "67108864", "QCborValue (Integer)") + + Check("c.94", "[94]", "2147483648", "QCborValue (Integer)") + + Check("c.95", "[95]", "2147483649", "QCborValue (Integer)") + + Check("c.96", "[96]", "0", "QCborValue (Integer)") + + Check("c.97", "[97]", "-1", "QCborValue (Integer)") + + Check("c.174", "[174]", "-67108863", "QCborValue (Integer)") + + Check("c.175", "[175]", "-67108864", "QCborValue (Integer)") + + Check("ob0", "ob0", "<0 items>", "@QCborMap") + + Check("ob", "ob", "<5 items>", "@QCborMap") + + Check("ob.0", "[0] \"a\"", "1", "") + + Check("ob.0.key", "key", "\"a\"", "QCborValue (String)") + + Check("ob.0.value", "value", "1", "QCborValue (Integer)") + + Check("ob.1", "[1] \"bb\"", "2", "") + + Check("ob.2", "[2] \"ccc\"", "\"hallo\"", "") + + Check("ob.3", "[3] \"s\"", "\"ssss\"", "") + + Check("ob.4", "[4] \"d\"", "<1 items>", "") + ; + + + const QtVersion jsonv1{0, 0x50e00}; + const QtVersion jsonv2{0x50e00}; + QTest::newRow("QJson") << Data("#include <QString>\n" "#if QT_VERSION >= 0x050000\n" @@ -7185,6 +7451,7 @@ void tst_Dumpers::dumper_data() "#endif\n", "#if QT_VERSION >= 0x050000\n" + "QJsonObject ob0;\n" "QJsonObject ob = QJsonObject::fromVariantMap({\n" " {\"a\", 1},\n" " {\"bb\", 2},\n" @@ -7193,6 +7460,7 @@ void tst_Dumpers::dumper_data() "});\n" "ob.insert(QLatin1String(\"d\"), QJsonObject::fromVariantMap({{\"ddd\", 1234}}));\n" "\n" + "QJsonArray aa;\n" "QJsonArray a;\n" "a.append(QJsonValue(1));\n" "a.append(QJsonValue(\"asd\"));\n" @@ -7217,7 +7485,7 @@ void tst_Dumpers::dumper_data() " c.append(QJsonValue(-qint64(1u << i)));\n" " c.append(QJsonValue(-qint64(1u << i) - 1));\n" "}" - "unused(&ob,&b,&a);\n" + "unused(&ob, &b, &a, &aa);\n" "#endif\n", "") @@ -7227,45 +7495,66 @@ void tst_Dumpers::dumper_data() + QtVersion(0x50000) + MsvcVersion(1900) + + Check("aa", "<0 items>", "@QJsonArray") + Check("a", "<6 items>", "@QJsonArray") + Check("a.0", "[0]", "1", "QJsonValue (Number)") + Check("a.1", "[1]", "\"asd\"", "QJsonValue (String)") + Check("a.2", "[2]", "\"cdfer\"", "QJsonValue (String)") - + Check("a.3", "[3]", "1.4", "QJsonValue (Number)") - + Check("a.4", "[4]", "true", "QJsonValue (Bool)") + + Check("a.3", "[3]", "1.4", "QJsonValue (Number)") % jsonv1 + + Check("a.3", "[3]", "1.400000", "QJsonValue (Number)") % jsonv2 + + Check("a.4", "[4]", "true", "QJsonValue (Bool)") % jsonv1 + + Check("a.4", "[4]", "True", "QJsonValue (Bool)") % jsonv2 + Check("a.5", "[5]", "<5 items>", "QJsonValue (Object)") - + Check("a.5.0", "\"a\"", "1", "QJsonValue (Number)") - + Check("a.5.1", "\"bb\"", "2", "QJsonValue (Number)") - + Check("a.5.2", "\"ccc\"", "\"hallo\"", "QJsonValue (String)") - + Check("a.5.3", "\"d\"", "<1 items>", "QJsonValue (Object)") - + Check("a.5.4", "\"s\"", "\"ssss\"", "QJsonValue (String)") + + Check("a.5.0", "\"a\"", "1", "QJsonValue (Number)") % jsonv1 + + Check("a.5.0", "[0] \"a\"", "1", "" ) % jsonv2 + + Check("a.5.1", "\"bb\"", "2", "QJsonValue (Number)") % jsonv1 + + Check("a.5.1", "[1] \"bb\"", "2", "" ) % jsonv2 + + Check("a.5.2", "\"ccc\"", "\"hallo\"", "QJsonValue (String)") % jsonv1 + + Check("a.5.2", "[2] \"ccc\"","\"hallo\"", "" ) % jsonv2 + + Check("a.5.3", "\"d\"", "<1 items>", "QJsonValue (Object)") % jsonv1 + + Check("a.5.3", "[3] \"d\"", "<1 items>", "" ) % jsonv2 + + Check("a.5.4", "\"s\"", "\"ssss\"", "QJsonValue (String)") % jsonv1 + + Check("a.5.4", "[4] \"s\"", "\"ssss\"", "" ) % jsonv2 + Check("b", "b", "<3 items>" , "@QJsonArray") + Check("b.0", "[0]", "1", "QJsonValue (Number)") + Check("b.1", "[1]", "<6 items>", "QJsonValue (Array)") - + Check("b.1.0", "[0]", "1", "QJsonValue (Number)") - + Check("b.1.1", "[1]", "\"asd\"", "QJsonValue (String)") - + Check("b.1.2", "[2]", "\"cdfer\"", "QJsonValue (String)") - + Check("b.1.3", "[3]", "1.4", "QJsonValue (Number)") - + Check("b.1.4", "[4]", "true", "QJsonValue (Bool)") - + Check("b.1.5", "[5]", "<5 items>", "QJsonValue (Object)") - + Check("b.2", "[2]", "2", "QJsonValue (Number)") + + Check("b.1.0", "[0]", "1", "QJsonValue (Number)") % jsonv2 + + Check("b.1.1", "[1]", "\"asd\"", "QJsonValue (String)") % jsonv2 + + Check("b.1.2", "[2]", "\"cdfer\"", "QJsonValue (String)") % jsonv2 + + Check("b.1.3", "[3]", "1.4", "QJsonValue (Number)") % jsonv1 + + Check("b.1.3", "[3]", "1.400000", "QJsonValue (Number)") % jsonv2 + + Check("b.1.4", "[4]", "true", "QJsonValue (Bool)") % jsonv1 + + Check("b.1.5", "[5]", "<5 items>", "QJsonValue (Object)") % jsonv2 + + Check("b.2", "[2]", "2", "QJsonValue (Number)") % jsonv2 + Check("c", "c", "<192 items>", "@QJsonArray") - + Check("c.0", "[0]", "0.0", "QJsonValue (Number)") + + Check("c.0", "[0]", "0.0", "QJsonValue (Number)") % jsonv1 + + Check("c.0", "[0]", "0", "QJsonValue (Number)") % jsonv2 + Check("c.1", "[1]", "1", "QJsonValue (Number)") + Check("c.78", "[78]", "67108863", "QJsonValue (Number)") - + Check("c.79", "[79]", "67108864.0", "QJsonValue (Number)") - + Check("c.94", "[94]", "2147483648.0", "QJsonValue (Number)") - + Check("c.95", "[95]", "2147483649.0", "QJsonValue (Number)") - + Check("c.96", "[96]", "0.0", "QJsonValue (Number)") + + Check("c.79", "[79]", "67108864.0", "QJsonValue (Number)") % jsonv1 + + Check("c.79", "[79]", "67108864", " QJsonValue (Number)") % jsonv2 + + Check("c.94", "[94]", "2147483648.0", "QJsonValue (Number)") % jsonv1 + + Check("c.94", "[94]", "2147483648", "QJsonValue (Number)") % jsonv2 + + Check("c.95", "[95]", "2147483649.0", "QJsonValue (Number)") % jsonv1 + + Check("c.95", "[95]", "2147483649", "QJsonValue (Number)") % jsonv2 + + Check("c.96", "[96]", "0.0", "QJsonValue (Number)") % jsonv1 + + Check("c.96", "[96]", "0", "QJsonValue (Number)") % jsonv2 + Check("c.97", "[97]", "-1", "QJsonValue (Number)") + Check("c.174", "[174]", "-67108863", "QJsonValue (Number)") - + Check("c.175", "[175]", "-67108864.0", "QJsonValue (Number)") + + Check("c.175", "[175]", "-67108864.0", "QJsonValue (Number)") % jsonv1 + + Check("c.175", "[175]", "-67108864", "QJsonValue (Number)") % jsonv2 + + Check("ob0", "ob0", "<0 items>", "@QJsonObject") + Check("ob", "ob", "<5 items>", "@QJsonObject") - + Check("ob.0", "\"a\"", "1", "QJsonValue (Number)") - + Check("ob.1", "\"bb\"", "2", "QJsonValue (Number)") - + Check("ob.2", "\"ccc\"", "\"hallo\"", "QJsonValue (String)") - + Check("ob.3", "\"d\"", "<1 items>", "QJsonValue (Object)") - + Check("ob.4", "\"s\"", "\"ssss\"", "QJsonValue (String)"); + + Check("ob.0", "\"a\"", "1", "QJsonValue (Number)") % jsonv1 + + Check("ob.0", "[0] \"a\"", "1", "" ) % jsonv2 + + Check("ob.1", "\"bb\"", "2", "QJsonValue (Number)") % jsonv1 + + Check("ob.1", "[1] \"bb\"", "2", "" ) % jsonv2 + + Check("ob.2", "\"ccc\"", "\"hallo\"", "QJsonValue (String)") % jsonv1 + + Check("ob.2", "[2] \"ccc\"", "\"hallo\"", "" ) % jsonv2 + + Check("ob.3", "\"d\"", "<1 items>", "QJsonValue (Object)") % jsonv1 + + Check("ob.3", "[3] \"d\"", "<1 items>", "" ) % jsonv2 + + Check("ob.4", "\"s\"", "\"ssss\"", "QJsonValue (String)") % jsonv1 + + Check("ob.4", "[4] \"s\"", "\"ssss\"", "" ) % jsonv2; QTest::newRow("Q&qstring_literal_temp,V4") @@ -7652,7 +7941,7 @@ void tst_Dumpers::dumper_data() #ifdef Q_OS_LINUX Data f90data; - f90data.configTest = "which f95"; + f90data.configTest = {"which", {"f95"}}; f90data.allProfile = "CONFIG -= qt\n" "SOURCES += main.f90\n" @@ -7675,7 +7964,7 @@ void tst_Dumpers::dumper_data() " i8 = i8 / 0\n" "end program\n"; - f90data.mainFile = "main.f90"; + f90data.language = Language::Fortran90; QTest::newRow("F90") << f90data @@ -7690,7 +7979,7 @@ void tst_Dumpers::dumper_data() // touch qt_tst_dumpers_Nim_.../dummy.nimproject // qtcreator qt_tst_dumpers_Nim_*/dummy.nimproject Data nimData; - nimData.configTest = "which nim"; + nimData.configTest = {"which", {"nim"}}; nimData.allProfile = "CONFIG -= qt\n" "SOURCES += main.nim\n" diff --git a/tests/auto/debugger/tst_offsets.cpp b/tests/auto/debugger/tst_offsets.cpp index 90d1cfa3ef..2309b5296a 100644 --- a/tests/auto/debugger/tst_offsets.cpp +++ b/tests/auto/debugger/tst_offsets.cpp @@ -226,11 +226,11 @@ void tst_offsets::offsets_data() OFFSET_TEST(QFilePrivate, fileName) << 140 << 232; #endif - OFFSET_TEST(QFileSystemEntry, m_filePath) << 0 << 0; - OFFSET_TEST(QFileInfoPrivate, fileEntry) << 4 << 8; + OFFSET_TEST(QFileSystemEntry, m_filePath) << 0 << 0; + OFFSET_TEST(QFileInfoPrivate, fileEntry) << 4 << 8; - QTest::newRow("sizeof(QObjectData)") << int(sizeof(QObjectData)) - << 28 << 48; // vptr + 3 ptr + 2 int + ptr + QTest::newRow("sizeof(QObjectData)") << int(sizeof(QObjectData)) + << 28 << 48; // vptr + 3 ptr + 2 int + ptr if (qtVersion >= 0x50000) OFFSET_TEST(QObjectPrivate, extraData) << 28 << 48; // sizeof(QObjectData) @@ -272,11 +272,16 @@ void tst_offsets::offsets_data() OFFSET_TEST(QDateTimePrivate, m_timeZone) << 20 << 24; OFFSET_TEST(QDateTimePrivate, m_status) << 24 << 32; # endif -#else +#elif QT_VERSION < 0x50e00 OFFSET_TEST(QDateTimePrivate, m_msecs) << 0 << 0; OFFSET_TEST(QDateTimePrivate, m_status) << 8 << 8; OFFSET_TEST(QDateTimePrivate, m_offsetFromUtc) << 12 << 12; OFFSET_TEST(QDateTimePrivate, m_timeZone) << 20 << 24; +#else + OFFSET_TEST(QDateTimePrivate, m_msecs) << 8 << 8; + OFFSET_TEST(QDateTimePrivate, m_status) << 4 << 4; + OFFSET_TEST(QDateTimePrivate, m_offsetFromUtc) << 16 << 16; + OFFSET_TEST(QDateTimePrivate, m_timeZone) << 20 << 24; #endif #ifdef HAS_BOOST diff --git a/tests/auto/filesearch/tst_filesearch.cpp b/tests/auto/filesearch/tst_filesearch.cpp index 29a19ba99d..eaea01badb 100644 --- a/tests/auto/filesearch/tst_filesearch.cpp +++ b/tests/auto/filesearch/tst_filesearch.cpp @@ -86,17 +86,17 @@ void tst_FileSearch::multipleResults() expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 2, QLatin1String("search to find multiple find results"), 10, 4, QStringList()); expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 2, QLatin1String("search to find multiple find results"), 24, 4, QStringList()); expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 4, QLatin1String("here you find another result"), 9, 4, QStringList()); - test_helper(expectedResults, QLatin1String("find"), QTextDocument::FindFlags(0)); + test_helper(expectedResults, QLatin1String("find"), QTextDocument::FindFlags()); expectedResults.clear(); expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 5, QLatin1String("aaaaaaaa this line has 2 results for four a in a row"), 0, 4, QStringList()); expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 5, QLatin1String("aaaaaaaa this line has 2 results for four a in a row"), 4, 4, QStringList()); - test_helper(expectedResults, QLatin1String("aaaa"), QTextDocument::FindFlags(0)); + test_helper(expectedResults, QLatin1String("aaaa"), QTextDocument::FindFlags()); expectedResults.clear(); expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 5, QLatin1String("aaaaaaaa this line has 2 results for four a in a row"), 0, 4, QStringList() << QLatin1String("aaaa")); expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 5, QLatin1String("aaaaaaaa this line has 2 results for four a in a row"), 4, 4, QStringList() << QLatin1String("aaaa")); - test_helper(expectedResults, QLatin1String("aaaa"), QTextDocument::FindFlags(0), RegExp); + test_helper(expectedResults, QLatin1String("aaaa"), QTextDocument::FindFlags(), RegExp); } void tst_FileSearch::caseSensitive() @@ -111,7 +111,7 @@ void tst_FileSearch::caseInSensitive() Utils::FileSearchResultList expectedResults; expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 3, QLatin1String("search CaseSensitively for casesensitive"), 7, 13, QStringList()); expectedResults << Utils::FileSearchResult(QLatin1String(FILENAME), 3, QLatin1String("search CaseSensitively for casesensitive"), 27, 13, QStringList()); - test_helper(expectedResults, QLatin1String("CaseSensitive"), QTextDocument::FindFlags(0)); + test_helper(expectedResults, QLatin1String("CaseSensitive"), QTextDocument::FindFlags()); } void tst_FileSearch::matchCaseReplacement() diff --git a/tests/auto/profilewriter/tst_profilewriter.cpp b/tests/auto/profilewriter/tst_profilewriter.cpp index 2abc7ccaa2..69ae2e86e7 100644 --- a/tests/auto/profilewriter/tst_profilewriter.cpp +++ b/tests/auto/profilewriter/tst_profilewriter.cpp @@ -686,25 +686,25 @@ void tst_ProFileWriter::multiVar() void tst_ProFileWriter::addFiles() { - QString input = QLatin1String( - "SOURCES = foo.cpp" - ); - QStringList lines = input.split(QLatin1Char('\n')); - QString output = QLatin1String( - "SOURCES = foo.cpp \\\n" - "\tsub/bar.cpp" - ); - - QMakeVfs vfs; - QMakeParser parser(0, &vfs, &parseHandler); - ProFile *proFile = parser.parsedProBlock(QStringRef(&input), 0, QLatin1String(BASE_DIR "/test.pro"), 1); - QVERIFY(proFile); - QmakeProjectManager::Internal::ProWriter::addFiles(proFile, &lines, - QStringList() << QString::fromLatin1(BASE_DIR "/sub/bar.cpp"), - QLatin1String("SOURCES"), "\t"); - proFile->deref(); - - QCOMPARE(lines.join(QLatin1Char('\n')), output); + const QStringList equivalentInputs = {"SOURCES = foo.cpp", "SOURCES = foo.cpp \\"}; + for (const QString &input : equivalentInputs) { + QStringList lines = input.split(QLatin1Char('\n')); + QString output = QLatin1String( + "SOURCES = foo.cpp \\\n" + "\tsub/bar.cpp" + ); + + QMakeVfs vfs; + QMakeParser parser(0, &vfs, &parseHandler); + ProFile *proFile = parser.parsedProBlock(QStringRef(&input), 0, BASE_DIR "/test.pro", 1); + QVERIFY(proFile); + QmakeProjectManager::Internal::ProWriter::addFiles(proFile, &lines, + QStringList(BASE_DIR "/sub/bar.cpp"), + QLatin1String("SOURCES"), "\t"); + proFile->deref(); + + QCOMPARE(lines.join(QLatin1Char('\n')), output); + } } void tst_ProFileWriter::removeFiles() diff --git a/tests/auto/qml/codemodel/importscheck/004_cppOnly copy/QtQuick.2/plugins.qmltypes b/tests/auto/qml/codemodel/importscheck/004_cppOnly copy/QtQuick.2/plugins.qmltypes index cadef10370..8a8bc257d7 100644 --- a/tests/auto/qml/codemodel/importscheck/004_cppOnly copy/QtQuick.2/plugins.qmltypes +++ b/tests/auto/qml/codemodel/importscheck/004_cppOnly copy/QtQuick.2/plugins.qmltypes @@ -4160,14 +4160,14 @@ Module { exportMetaObjectRevisions: [0] } Component { - name: "QRegExpValidator" + name: "QRegularExpressionValidator" prototype: "QValidator" - exports: ["QtQuick/RegExpValidator 2.0"] + exports: ["QtQuick/RegularExpressionValidator 2.14"] exportMetaObjectRevisions: [0] - Property { name: "regExp"; type: "QRegExp" } + Property { name: "regularExpression"; type: "QRegularExpression" } Signal { - name: "regExpChanged" - Parameter { name: "regExp"; type: "QRegExp" } + name: "regularExpressionChanged" + Parameter { name: "regularExpression"; type: "QRegularExpression" } } } Component { diff --git a/tests/auto/qml/codemodel/importscheck/base/QtQuick.2/plugins.qmltypes b/tests/auto/qml/codemodel/importscheck/base/QtQuick.2/plugins.qmltypes index cadef10370..8a8bc257d7 100644 --- a/tests/auto/qml/codemodel/importscheck/base/QtQuick.2/plugins.qmltypes +++ b/tests/auto/qml/codemodel/importscheck/base/QtQuick.2/plugins.qmltypes @@ -4160,14 +4160,14 @@ Module { exportMetaObjectRevisions: [0] } Component { - name: "QRegExpValidator" + name: "QRegularExpressionValidator" prototype: "QValidator" - exports: ["QtQuick/RegExpValidator 2.0"] + exports: ["QtQuick/RegularExpressionValidator 2.14"] exportMetaObjectRevisions: [0] - Property { name: "regExp"; type: "QRegExp" } + Property { name: "regularExpression"; type: "QRegularExpression" } Signal { - name: "regExpChanged" - Parameter { name: "regExp"; type: "QRegExp" } + name: "regularExpressionChanged" + Parameter { name: "regularExpression"; type: "QRegularExpression" } } } Component { diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/importQtQuick.qml b/tests/auto/qml/codemodel/importscheck/importTypes/importQtQuick.qml new file mode 100644 index 0000000000..68c21087cb --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/importQtQuick.qml @@ -0,0 +1,5 @@ +import QtQuick 2.15 + +Item { + +} diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQml/plugins.qmltypes b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQml/plugins.qmltypes new file mode 100644 index 0000000000..39cb4f3ccc --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQml/plugins.qmltypes @@ -0,0 +1,26 @@ +import QtQuick.tooling 1.1 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -nonrelocatable -builtins' + +Module { + Component { + name: "QObject" + exports: ["QtQml/QtObject 2.0"] + exportMetaObjectRevisions: [0] + Property { name: "objectName"; type: "string" } + Signal { + name: "objectNameChanged" + Parameter { name: "objectName"; type: "string" } + } + Method { name: "toString" } + Method { name: "destroy" } + Method { + name: "destroy" + Parameter { name: "delay"; type: "int" } + } + } +} diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQml/qmldir b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQml/qmldir new file mode 100644 index 0000000000..8175ebb1a1 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQml/qmldir @@ -0,0 +1,2 @@ +module QtQml +typeinfo plugins.qmltypes diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQuick.2/plugins.qmltypes b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQuick.2/plugins.qmltypes new file mode 100644 index 0000000000..b6a7fc5697 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQuick.2/plugins.qmltypes @@ -0,0 +1,175 @@ +import QtQuick.tooling 1.1 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -nonrelocatable -builtins' + +Module { + Component { + name: "IsQtQuickQmldirImport" + exports: ["QtQuick/IsQtQuickQmldirImport 2.0"] + exportMetaObjectRevisions: [0] + } + Component { + name: "QQuickBehavior" + defaultProperty: "animation" + prototype: "QObject" + exports: [ + "QtQuick/Behavior 2.0", + "QtQuick/Behavior 2.13", + "QtQuick/Behavior 2.15", + "QtQuick/Behavior 2.16" + ] + exportMetaObjectRevisions: [0, 13, 15, 16] + Property { name: "animation"; type: "QQuickAbstractAnimation"; isPointer: true } + Property { name: "enabled"; type: "bool" } + Property { name: "targetValue"; revision: 13; type: "QVariant"; isReadonly: true } + Property { name: "targetProperty"; revision: 15; type: "QQmlProperty"; isReadonly: true } + Method { name: "componentFinalized" } + } + Component { + name: "QQuickItem" + defaultProperty: "data" + prototype: "QObject" + exports: ["QtQuick/Item 2.0", "QtQuick/Item 2.1"] + exportMetaObjectRevisions: [0, 1] + Enum { + name: "TransformOrigin" + values: { + "TopLeft": 0, + "Top": 1, + "TopRight": 2, + "Left": 3, + "Center": 4, + "Right": 5, + "BottomLeft": 6, + "Bottom": 7, + "BottomRight": 8 + } + } + Property { name: "parent"; type: "QQuickItem"; isPointer: true } + Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "resources"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "children"; type: "QQuickItem"; isList: true; isReadonly: true } + Property { name: "x"; type: "double" } + Property { name: "y"; type: "double" } + Property { name: "z"; type: "double" } + Property { name: "width"; type: "double" } + Property { name: "height"; type: "double" } + Property { name: "opacity"; type: "double" } + Property { name: "enabled"; type: "bool" } + Property { name: "visible"; type: "bool" } + Property { name: "visibleChildren"; type: "QQuickItem"; isList: true; isReadonly: true } + Property { name: "states"; type: "QQuickState"; isList: true; isReadonly: true } + Property { name: "transitions"; type: "QQuickTransition"; isList: true; isReadonly: true } + Property { name: "state"; type: "string" } + Property { name: "childrenRect"; type: "QRectF"; isReadonly: true } + Property { name: "anchors"; type: "QQuickAnchors"; isReadonly: true; isPointer: true } + Property { name: "left"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "right"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "horizontalCenter"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "top"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "bottom"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "verticalCenter"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "baseline"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "baselineOffset"; type: "double" } + Property { name: "clip"; type: "bool" } + Property { name: "focus"; type: "bool" } + Property { name: "activeFocus"; type: "bool"; isReadonly: true } + Property { name: "activeFocusOnTab"; revision: 1; type: "bool" } + Property { name: "rotation"; type: "double" } + Property { name: "scale"; type: "double" } + Property { name: "transformOrigin"; type: "TransformOrigin" } + Property { name: "transformOriginPoint"; type: "QPointF"; isReadonly: true } + Property { name: "transform"; type: "QQuickTransform"; isList: true; isReadonly: true } + Property { name: "smooth"; type: "bool" } + Property { name: "antialiasing"; type: "bool" } + Property { name: "implicitWidth"; type: "double" } + Property { name: "implicitHeight"; type: "double" } + Property { name: "layer"; type: "QQuickItemLayer"; isReadonly: true; isPointer: true } + Signal { + name: "childrenRectChanged" + Parameter { type: "QRectF" } + } + Signal { + name: "baselineOffsetChanged" + Parameter { type: "double" } + } + Signal { + name: "stateChanged" + Parameter { type: "string" } + } + Signal { + name: "focusChanged" + Parameter { type: "bool" } + } + Signal { + name: "activeFocusChanged" + Parameter { type: "bool" } + } + Signal { + name: "activeFocusOnTabChanged" + revision: 1 + Parameter { type: "bool" } + } + Signal { + name: "parentChanged" + Parameter { type: "QQuickItem"; isPointer: true } + } + Signal { + name: "transformOriginChanged" + Parameter { type: "TransformOrigin" } + } + Signal { + name: "smoothChanged" + Parameter { type: "bool" } + } + Signal { + name: "antialiasingChanged" + Parameter { type: "bool" } + } + Signal { + name: "clipChanged" + Parameter { type: "bool" } + } + Signal { + name: "windowChanged" + revision: 1 + Parameter { name: "window"; type: "QQuickWindow"; isPointer: true } + } + Method { name: "update" } + Method { + name: "contains" + type: "bool" + Parameter { name: "point"; type: "QPointF" } + } + Method { + name: "mapFromItem" + Parameter { type: "QQmlV4Function"; isPointer: true } + } + Method { + name: "mapToItem" + Parameter { type: "QQmlV4Function"; isPointer: true } + } + Method { name: "forceActiveFocus" } + Method { + name: "forceActiveFocus" + Parameter { name: "reason"; type: "Qt::FocusReason" } + } + Method { + name: "nextItemInFocusChain" + revision: 1 + type: "QQuickItem*" + Parameter { name: "forward"; type: "bool" } + } + Method { name: "nextItemInFocusChain"; revision: 1; type: "QQuickItem*" } + Method { + name: "childAt" + type: "QQuickItem*" + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + } +} diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQuick.2/qmldir b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQuick.2/qmldir new file mode 100644 index 0000000000..4bdfa4feb3 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-qmldir-import/QtQuick.2/qmldir @@ -0,0 +1,5 @@ +module QtQuick +plugin qtquick2plugin +classname QtQuick2Plugin +typeinfo plugins.qmltypes +import QtQml diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-simple/QtQuick.2/plugins.qmltypes b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-simple/QtQuick.2/plugins.qmltypes new file mode 100644 index 0000000000..8771dbec91 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-simple/QtQuick.2/plugins.qmltypes @@ -0,0 +1,174 @@ +import QtQuick.tooling 1.1 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -nonrelocatable -builtins' + +Module { + Component { + name: "IsQtQuickSimple" + exports: ["QtQuick/IsQtQuickSimple 2.0"] + exportMetaObjectRevisions: [0] + } + Component { + name: "QObject" + exports: ["QtQml/QtObject 2.0", "QtQuick/QtObject 2.0"] + exportMetaObjectRevisions: [0, 0] + Property { name: "objectName"; type: "string" } + Signal { + name: "objectNameChanged" + Parameter { name: "objectName"; type: "string" } + } + Method { name: "toString" } + Method { name: "destroy" } + Method { + name: "destroy" + Parameter { name: "delay"; type: "int" } + } + } + Component { + name: "QQuickItem" + defaultProperty: "data" + prototype: "QObject" + exports: ["QtQuick/Item 2.0", "QtQuick/Item 2.1"] + exportMetaObjectRevisions: [0, 1] + Enum { + name: "TransformOrigin" + values: { + "TopLeft": 0, + "Top": 1, + "TopRight": 2, + "Left": 3, + "Center": 4, + "Right": 5, + "BottomLeft": 6, + "Bottom": 7, + "BottomRight": 8 + } + } + Property { name: "parent"; type: "QQuickItem"; isPointer: true } + Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "resources"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "children"; type: "QQuickItem"; isList: true; isReadonly: true } + Property { name: "x"; type: "double" } + Property { name: "y"; type: "double" } + Property { name: "z"; type: "double" } + Property { name: "width"; type: "double" } + Property { name: "height"; type: "double" } + Property { name: "opacity"; type: "double" } + Property { name: "enabled"; type: "bool" } + Property { name: "visible"; type: "bool" } + Property { name: "visibleChildren"; type: "QQuickItem"; isList: true; isReadonly: true } + Property { name: "states"; type: "QQuickState"; isList: true; isReadonly: true } + Property { name: "transitions"; type: "QQuickTransition"; isList: true; isReadonly: true } + Property { name: "state"; type: "string" } + Property { name: "childrenRect"; type: "QRectF"; isReadonly: true } + Property { name: "anchors"; type: "QQuickAnchors"; isReadonly: true; isPointer: true } + Property { name: "left"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "right"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "horizontalCenter"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "top"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "bottom"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "verticalCenter"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "baseline"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "baselineOffset"; type: "double" } + Property { name: "clip"; type: "bool" } + Property { name: "focus"; type: "bool" } + Property { name: "activeFocus"; type: "bool"; isReadonly: true } + Property { name: "activeFocusOnTab"; revision: 1; type: "bool" } + Property { name: "rotation"; type: "double" } + Property { name: "scale"; type: "double" } + Property { name: "transformOrigin"; type: "TransformOrigin" } + Property { name: "transformOriginPoint"; type: "QPointF"; isReadonly: true } + Property { name: "transform"; type: "QQuickTransform"; isList: true; isReadonly: true } + Property { name: "smooth"; type: "bool" } + Property { name: "antialiasing"; type: "bool" } + Property { name: "implicitWidth"; type: "double" } + Property { name: "implicitHeight"; type: "double" } + Property { name: "layer"; type: "QQuickItemLayer"; isReadonly: true; isPointer: true } + Signal { + name: "childrenRectChanged" + Parameter { type: "QRectF" } + } + Signal { + name: "baselineOffsetChanged" + Parameter { type: "double" } + } + Signal { + name: "stateChanged" + Parameter { type: "string" } + } + Signal { + name: "focusChanged" + Parameter { type: "bool" } + } + Signal { + name: "activeFocusChanged" + Parameter { type: "bool" } + } + Signal { + name: "activeFocusOnTabChanged" + revision: 1 + Parameter { type: "bool" } + } + Signal { + name: "parentChanged" + Parameter { type: "QQuickItem"; isPointer: true } + } + Signal { + name: "transformOriginChanged" + Parameter { type: "TransformOrigin" } + } + Signal { + name: "smoothChanged" + Parameter { type: "bool" } + } + Signal { + name: "antialiasingChanged" + Parameter { type: "bool" } + } + Signal { + name: "clipChanged" + Parameter { type: "bool" } + } + Signal { + name: "windowChanged" + revision: 1 + Parameter { name: "window"; type: "QQuickWindow"; isPointer: true } + } + Method { name: "update" } + Method { + name: "contains" + type: "bool" + Parameter { name: "point"; type: "QPointF" } + } + Method { + name: "mapFromItem" + Parameter { type: "QQmlV4Function"; isPointer: true } + } + Method { + name: "mapToItem" + Parameter { type: "QQmlV4Function"; isPointer: true } + } + Method { name: "forceActiveFocus" } + Method { + name: "forceActiveFocus" + Parameter { name: "reason"; type: "Qt::FocusReason" } + } + Method { + name: "nextItemInFocusChain" + revision: 1 + type: "QQuickItem*" + Parameter { name: "forward"; type: "bool" } + } + Method { name: "nextItemInFocusChain"; revision: 1; type: "QQuickItem*" } + Method { + name: "childAt" + type: "QQuickItem*" + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + } +} diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-simple/QtQuick.2/qmldir b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-simple/QtQuick.2/qmldir new file mode 100644 index 0000000000..4a79c82e76 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-simple/QtQuick.2/qmldir @@ -0,0 +1,4 @@ +module QtQuick +plugin qtquick2plugin +classname QtQuick2Plugin +typeinfo plugins.qmltypes diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQml/plugins.qmltypes b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQml/plugins.qmltypes new file mode 100644 index 0000000000..39cb4f3ccc --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQml/plugins.qmltypes @@ -0,0 +1,26 @@ +import QtQuick.tooling 1.1 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -nonrelocatable -builtins' + +Module { + Component { + name: "QObject" + exports: ["QtQml/QtObject 2.0"] + exportMetaObjectRevisions: [0] + Property { name: "objectName"; type: "string" } + Signal { + name: "objectNameChanged" + Parameter { name: "objectName"; type: "string" } + } + Method { name: "toString" } + Method { name: "destroy" } + Method { + name: "destroy" + Parameter { name: "delay"; type: "int" } + } + } +} diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQml/qmldir b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQml/qmldir new file mode 100644 index 0000000000..8175ebb1a1 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQml/qmldir @@ -0,0 +1,2 @@ +module QtQml +typeinfo plugins.qmltypes diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQuick.2/plugins.qmltypes b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQuick.2/plugins.qmltypes new file mode 100644 index 0000000000..25d6c402a6 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQuick.2/plugins.qmltypes @@ -0,0 +1,174 @@ +import QtQuick.tooling 1.1 + +// This file describes the plugin-supplied types contained in the library. +// It is used for QML tooling purposes only. +// +// This file was auto-generated by: +// 'qmlplugindump -nonrelocatable -builtins' + +Module { + Component { + name: "IsQtQuickWorkaround" + exports: ["QtQuick/IsQtQuickWorkaround 2.0"] + exportMetaObjectRevisions: [0] + } + Component { + name: "QQuickBehavior" + defaultProperty: "animation" + prototype: "QObject" + exports: [ + "QtQuick/Behavior 2.0", + "QtQuick/Behavior 2.13", + "QtQuick/Behavior 2.15" + ] + exportMetaObjectRevisions: [0, 13, 15] + Property { name: "animation"; type: "QQuickAbstractAnimation"; isPointer: true } + Property { name: "enabled"; type: "bool" } + Property { name: "targetValue"; revision: 13; type: "QVariant"; isReadonly: true } + Property { name: "targetProperty"; revision: 15; type: "QQmlProperty"; isReadonly: true } + Method { name: "componentFinalized" } + } + Component { + name: "QQuickItem" + defaultProperty: "data" + prototype: "QObject" + exports: ["QtQuick/Item 2.0", "QtQuick/Item 2.1"] + exportMetaObjectRevisions: [0, 1] + Enum { + name: "TransformOrigin" + values: { + "TopLeft": 0, + "Top": 1, + "TopRight": 2, + "Left": 3, + "Center": 4, + "Right": 5, + "BottomLeft": 6, + "Bottom": 7, + "BottomRight": 8 + } + } + Property { name: "parent"; type: "QQuickItem"; isPointer: true } + Property { name: "data"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "resources"; type: "QObject"; isList: true; isReadonly: true } + Property { name: "children"; type: "QQuickItem"; isList: true; isReadonly: true } + Property { name: "x"; type: "double" } + Property { name: "y"; type: "double" } + Property { name: "z"; type: "double" } + Property { name: "width"; type: "double" } + Property { name: "height"; type: "double" } + Property { name: "opacity"; type: "double" } + Property { name: "enabled"; type: "bool" } + Property { name: "visible"; type: "bool" } + Property { name: "visibleChildren"; type: "QQuickItem"; isList: true; isReadonly: true } + Property { name: "states"; type: "QQuickState"; isList: true; isReadonly: true } + Property { name: "transitions"; type: "QQuickTransition"; isList: true; isReadonly: true } + Property { name: "state"; type: "string" } + Property { name: "childrenRect"; type: "QRectF"; isReadonly: true } + Property { name: "anchors"; type: "QQuickAnchors"; isReadonly: true; isPointer: true } + Property { name: "left"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "right"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "horizontalCenter"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "top"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "bottom"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "verticalCenter"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "baseline"; type: "QQuickAnchorLine"; isReadonly: true } + Property { name: "baselineOffset"; type: "double" } + Property { name: "clip"; type: "bool" } + Property { name: "focus"; type: "bool" } + Property { name: "activeFocus"; type: "bool"; isReadonly: true } + Property { name: "activeFocusOnTab"; revision: 1; type: "bool" } + Property { name: "rotation"; type: "double" } + Property { name: "scale"; type: "double" } + Property { name: "transformOrigin"; type: "TransformOrigin" } + Property { name: "transformOriginPoint"; type: "QPointF"; isReadonly: true } + Property { name: "transform"; type: "QQuickTransform"; isList: true; isReadonly: true } + Property { name: "smooth"; type: "bool" } + Property { name: "antialiasing"; type: "bool" } + Property { name: "implicitWidth"; type: "double" } + Property { name: "implicitHeight"; type: "double" } + Property { name: "layer"; type: "QQuickItemLayer"; isReadonly: true; isPointer: true } + Signal { + name: "childrenRectChanged" + Parameter { type: "QRectF" } + } + Signal { + name: "baselineOffsetChanged" + Parameter { type: "double" } + } + Signal { + name: "stateChanged" + Parameter { type: "string" } + } + Signal { + name: "focusChanged" + Parameter { type: "bool" } + } + Signal { + name: "activeFocusChanged" + Parameter { type: "bool" } + } + Signal { + name: "activeFocusOnTabChanged" + revision: 1 + Parameter { type: "bool" } + } + Signal { + name: "parentChanged" + Parameter { type: "QQuickItem"; isPointer: true } + } + Signal { + name: "transformOriginChanged" + Parameter { type: "TransformOrigin" } + } + Signal { + name: "smoothChanged" + Parameter { type: "bool" } + } + Signal { + name: "antialiasingChanged" + Parameter { type: "bool" } + } + Signal { + name: "clipChanged" + Parameter { type: "bool" } + } + Signal { + name: "windowChanged" + revision: 1 + Parameter { name: "window"; type: "QQuickWindow"; isPointer: true } + } + Method { name: "update" } + Method { + name: "contains" + type: "bool" + Parameter { name: "point"; type: "QPointF" } + } + Method { + name: "mapFromItem" + Parameter { type: "QQmlV4Function"; isPointer: true } + } + Method { + name: "mapToItem" + Parameter { type: "QQmlV4Function"; isPointer: true } + } + Method { name: "forceActiveFocus" } + Method { + name: "forceActiveFocus" + Parameter { name: "reason"; type: "Qt::FocusReason" } + } + Method { + name: "nextItemInFocusChain" + revision: 1 + type: "QQuickItem*" + Parameter { name: "forward"; type: "bool" } + } + Method { name: "nextItemInFocusChain"; revision: 1; type: "QQuickItem*" } + Method { + name: "childAt" + type: "QQuickItem*" + Parameter { name: "x"; type: "double" } + Parameter { name: "y"; type: "double" } + } + } +} diff --git a/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQuick.2/qmldir b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQuick.2/qmldir new file mode 100644 index 0000000000..4a79c82e76 --- /dev/null +++ b/tests/auto/qml/codemodel/importscheck/importTypes/imports-QtQuick-workaround-QtQml/QtQuick.2/qmldir @@ -0,0 +1,4 @@ +module QtQuick +plugin qtquick2plugin +classname QtQuick2Plugin +typeinfo plugins.qmltypes diff --git a/tests/auto/qml/codemodel/importscheck/tst_importscheck.cpp b/tests/auto/qml/codemodel/importscheck/tst_importscheck.cpp index f6126b73af..2496f7341d 100644 --- a/tests/auto/qml/codemodel/importscheck/tst_importscheck.cpp +++ b/tests/auto/qml/codemodel/importscheck/tst_importscheck.cpp @@ -58,6 +58,9 @@ private slots: void test(); void test_data(); + void importTypes_data(); + void importTypes(); + void initTestCase(); private: QStringList m_basePaths; @@ -191,10 +194,12 @@ void tst_ImportCheck::test() QStringList detectedFiles; foreach (const ImportKey &importK, iDeps->libraryImports(vCtx)) detectedLibraries << importK.toString(); - foreach (const QString &path, paths) + foreach (const QString &path, paths) { foreach (const ImportKey &importK, iDeps->subdirImports(ImportKey(ImportType::Directory, - path), vCtx)) - detectedFiles << QFileInfo(importK.toString()).canonicalFilePath(); + path), vCtx)) { + detectedFiles << QFileInfo(importK.toString()).canonicalFilePath(); + } + } expectedLibraries.sort(); expectedFiles.sort(); @@ -204,6 +209,92 @@ void tst_ImportCheck::test() QCOMPARE(expectedFiles, detectedFiles); } +class MyModelManager : public ModelManagerInterface +{ +public: + using ModelManagerInterface::setDefaultProject; + using ModelManagerInterface::updateImportPaths; +}; + +void tst_ImportCheck::importTypes_data() +{ + QTest::addColumn<QString>("qmlFile"); + QTest::addColumn<QString>("importPath"); + QTest::addColumn<QStringList>("expectedTypes"); + + QTest::newRow("base") + << QString(TESTSRCDIR "/importTypes/importQtQuick.qml") + << QString(TESTSRCDIR "/base") + << QStringList({ "Item", "Rectangle", "QtObject" }); + + // simple case, with everything in QtQuick/plugins.qmltypes + QTest::newRow("QtQuick-simple") + << QString(TESTSRCDIR "/importTypes/importQtQuick.qml") + << QString(TESTSRCDIR "/importTypes/imports-QtQuick-simple") + << QStringList({ "Item", "QtObject", "IsQtQuickSimple" }); + + // QtQuick/ and QtQml/ with an implicit dependency + // Seen in Qt 5.15.0. + QTest::newRow("QtQuick-workaround-QtQml") + << QString(TESTSRCDIR "/importTypes/importQtQuick.qml") + << QString(TESTSRCDIR "/importTypes/imports-QtQuick-workaround-QtQml") + << QStringList({ "Item", "QtObject", "IsQtQuickWorkaround" }); + + // QtQuick/ and QtQml/ with an "import" in the qmldir file + // Seen in Qt 6. + QTest::newRow("QtQuick-qmldir-import") + << QString(TESTSRCDIR "/importTypes/importQtQuick.qml") + << QString(TESTSRCDIR "/importTypes/imports-QtQuick-qmldir-import") + << QStringList({ "Item", "QtObject", "IsQtQuickQmldirImport" }); +} + +void tst_ImportCheck::importTypes() +{ + QFETCH(QString, qmlFile); + QFETCH(QString, importPath); + QFETCH(QStringList, expectedTypes); + + // full reset + delete ModelManagerInterface::instance(); + MyModelManager *modelManager = new MyModelManager; + + // the default qtQmlPath is based on the Qt version in use otherwise + ModelManagerInterface::ProjectInfo defaultProject; + defaultProject.qtQmlPath = importPath; + modelManager->setDefaultProject(defaultProject, nullptr); + modelManager->activateScan(); + + modelManager->updateSourceFiles(QStringList(qmlFile), false); + modelManager->test_joinAllThreads(); + + Snapshot snapshot = modelManager->newestSnapshot(); + Document::Ptr doc = snapshot.document(qmlFile); + + // It's unfortunate, but nowadays linking can trigger async module loads, + // so do it once to start the process, then do it again for real once the + // dependencies are available. + const auto getContext = [&]() { + Link link(snapshot, modelManager->defaultVContext(doc->language(), doc), + modelManager->builtins(doc)); + return link(); + }; + getContext(); + modelManager->test_joinAllThreads(); + snapshot = modelManager->newestSnapshot(); + doc = snapshot.document(qmlFile); + + ContextPtr context = getContext(); + + bool allFound = true; + for (const auto &expected : expectedTypes) { + if (!context->lookupType(doc.data(), QStringList(expected))) { + allFound = false; + qWarning() << "Type '" << expected << "' not found"; + } + } + QVERIFY(allFound); +} + #ifdef MANUAL_IMPORT_SCANNER int main(int argc, char *argv[]) diff --git a/tests/auto/qml/qmldesigner/coretests/coretests.pro b/tests/auto/qml/qmldesigner/coretests/coretests.pro index dd0f071b0e..7afb0fda2e 100644 --- a/tests/auto/qml/qmldesigner/coretests/coretests.pro +++ b/tests/auto/qml/qmldesigner/coretests/coretests.pro @@ -12,7 +12,8 @@ QTC_LIB_DEPENDS += \ QTC_PLUGIN_DEPENDS += \ coreplugin \ qmljseditor \ - qmakeprojectmanager + qmakeprojectmanager \ + qmlprojectmanager CONFIG -= qtquickcompiler diff --git a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp index 52fa6f519f..fc5d9dcfa9 100644 --- a/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp +++ b/tests/auto/qml/qmldesigner/coretests/tst_testcore.cpp @@ -4255,7 +4255,7 @@ void tst_TestCore::testMetaInfoSimpleType() QCOMPARE(itemMetaInfo.superClasses().size(), 2); // Item, QtQuick.QtObject QVERIFY(itemMetaInfo.isSubclassOf("QtQuick.Item", -1, -1)); QVERIFY(itemMetaInfo.isSubclassOf("<cpp>.QObject", -1, -1)); - QVERIFY(itemMetaInfo.isSubclassOf("QtQuick.QtObject", -1, -1)); + QVERIFY(itemMetaInfo.isSubclassOf("QtQml.QtObject", -1, -1)); // availableInVersion QVERIFY(itemMetaInfo.availableInVersion(2, 2)); diff --git a/tests/auto/treeviewfind/tst_treeviewfind.cpp b/tests/auto/treeviewfind/tst_treeviewfind.cpp index d23de377e6..cfe60c6c6e 100644 --- a/tests/auto/treeviewfind/tst_treeviewfind.cpp +++ b/tests/auto/treeviewfind/tst_treeviewfind.cpp @@ -70,7 +70,7 @@ void tst_treeviewfind::wrapping() QCOMPARE(tree->currentItem()->text(0), QString::fromLatin1("FOO2")); // forward - findSupport->findStep(QLatin1String("FOO"), 0); + findSupport->findStep(QLatin1String("FOO"), Core::FindFlags()); QCOMPARE(tree->currentItem(), toplevelitems.at(0)->child(0)); // backward @@ -115,19 +115,19 @@ void tst_treeviewfind::columns() QCOMPARE(tree->currentItem()->text(0), QString::fromLatin1("HEADER1")); // find in first column - findSupport->findStep(QLatin1String("FOO"), 0); + findSupport->findStep(QLatin1String("FOO"), Core::FindFlags()); QCOMPARE(tree->currentItem(), toplevelitems.at(0)->child(0)); // find in second column of node with children - findSupport->findStep(QLatin1String("FOO"), 0); + findSupport->findStep(QLatin1String("FOO"), Core::FindFlags()); QCOMPARE(tree->currentItem(), toplevelitems.at(1)); // again find in first column - findSupport->findStep(QLatin1String("FOO"), 0); + findSupport->findStep(QLatin1String("FOO"), Core::FindFlags()); QCOMPARE(tree->currentItem(), toplevelitems.at(1)->child(0)); // don't stay in item if multiple columns match, and find in second column - findSupport->findStep(QLatin1String("FOO"), 0); + findSupport->findStep(QLatin1String("FOO"), Core::FindFlags()); QCOMPARE(tree->currentItem(), toplevelitems.at(2)->child(0)); // wrap - findSupport->findStep(QLatin1String("FOO"), 0); + findSupport->findStep(QLatin1String("FOO"), Core::FindFlags()); QCOMPARE(tree->currentItem(), toplevelitems.at(0)->child(0)); // backwards diff --git a/tests/manual/debugger/gui/mainwindow.cpp b/tests/manual/debugger/gui/mainwindow.cpp index 37545d7c5f..723a0b67c9 100644 --- a/tests/manual/debugger/gui/mainwindow.cpp +++ b/tests/manual/debugger/gui/mainwindow.cpp @@ -46,7 +46,6 @@ #include <QFileInfo> #include <QSharedPointer> #include <QDir> -#include <QLinkedList> #include <QStandardItemModel> struct TestClass { @@ -306,8 +305,6 @@ void MainWindow::on_actionExtTypes_triggered() qDebug() << hidden; } - QLinkedList<QString> lls; - lls << "link1" << "link2"; QStandardItemModel *model =new QStandardItemModel; model->appendRow(new QStandardItem("i1")); diff --git a/tests/manual/debugger/simple/simple_test_app.cpp b/tests/manual/debugger/simple/simple_test_app.cpp index 20734abede..bffb755c74 100644 --- a/tests/manual/debugger/simple/simple_test_app.cpp +++ b/tests/manual/debugger/simple/simple_test_app.cpp @@ -154,7 +154,6 @@ void dummyStatement(...) {} #include <QDir> #include <QHash> #include <QLibrary> -#include <QLinkedList> #include <QList> #include <QMap> #include <QPointer> @@ -1163,111 +1162,6 @@ namespace painting { } // namespace painting -namespace qlinkedlist { - - void testQLinkedListInt() - { - QLinkedList<int> list; - list.append(101); - list.append(102); - BREAK_HERE; - // Expand list. - // Check list <2 items> QLinkedList<int>. - // Check list.0 101 int. - // Check list.1 102 int. - // Continue. - dummyStatement(&list); - } - - void testQLinkedListUInt() - { - QLinkedList<uint> list; - list.append(103); - list.append(104); - BREAK_HERE; - // Expand list. - // Check list <2 items> QLinkedList<unsigned int>. - // Check list.0 103 unsigned int. - // Check list.1 104 unsigned int. - // Continue. - dummyStatement(&list); - } - - void testQLinkedListFooStar() - { - QLinkedList<Foo *> list; - list.append(new Foo(1)); - list.append(0); - list.append(new Foo(3)); - BREAK_HERE; - // Expand list list.0 list.2. - // Check list <3 items> QLinkedList<Foo*>. - // CheckType list.0 Foo. - // Check list.0.a 1 int. - // Check list.1 0x0 Foo *. - // CheckType list.2 Foo. - // Check list.2.a 3 int. - // Continue. - dummyStatement(&list); - } - - void testQLinkedListULongLong() - { - QLinkedList<qulonglong> list; - list.append(42); - list.append(43); - BREAK_HERE; - // Expand list. - // Check list <2 items> QLinkedList<unsigned long long>. - // Check list.0 42 unsigned long long. - // Check list.1 43 unsigned long long. - // Continue. - dummyStatement(&list); - } - - void testQLinkedListFoo() - { - QLinkedList<Foo> list; - list.append(Foo(1)); - list.append(Foo(2)); - BREAK_HERE; - // Expand list list.0 list.1. - // Check list <2 items> QLinkedList<Foo>. - // CheckType list.0 Foo. - // Check list.0.a 1 int. - // CheckType list.1 Foo. - // Check list.1.a 2 int. - // Continue. - dummyStatement(&list); - } - - void testQLinkedListStdString() - { - QLinkedList<std::string> list; - list.push_back("aa"); - list.push_back("bb"); - BREAK_HERE; - // Expand list. - // Check list <2 items> QLinkedList<std::string>. - // Check list.0 "aa" std::string. - // Check list.1 "bb" std::string. - // Continue. - dummyStatement(&list); - } - - void testQLinkedList() - { - testQLinkedListInt(); - testQLinkedListUInt(); - testQLinkedListFooStar(); - testQLinkedListULongLong(); - testQLinkedListFoo(); - testQLinkedListStdString(); - } - -} // namespace qlinkedlist - - namespace qlist { void testQListInt() @@ -5304,7 +5198,7 @@ namespace basic { // Continue. // Manual: Toogle "Sort Member Alphabetically" in context menu - // Manual: of "Locals and Expressions" view. + // Manual: of "Locals" and "Expressions" views. // Manual: Check that order of displayed members changes. dummyStatement(&c); } @@ -5436,7 +5330,7 @@ namespace basic { void testTypeFormats() { // These tests should result in properly displayed umlauts in the - // Locals and Expressions view. It is only support on gdb with Python. + // Locals and Expressions views. It is only support on gdb with Python. const char *s = "aöa"; const char cs[] = "aöa"; @@ -7290,7 +7184,6 @@ int main(int argc, char *argv[]) qdir::testQDir(); qfileinfo::testQFileInfo(); qhash::testQHash(); - qlinkedlist::testQLinkedList(); qlist::testQList(); qlocale::testQLocale(); qmap::testQMap(); diff --git a/tests/manual/meson/mesonsampleproject/main.cpp b/tests/manual/meson/mesonsampleproject/main.cpp new file mode 100644 index 0000000000..6dcfef8e8e --- /dev/null +++ b/tests/manual/meson/mesonsampleproject/main.cpp @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Alexis Jeandet. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ +#include "mesonsampleproject.h" + +#include <QApplication> +#include <QTranslator> + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + QTranslator translator; + translator.load("mesonsampleproject_" + QLocale::system().name()); + a.installTranslator(&translator); + MesonSampleProject w; + w.show(); + return a.exec(); +} diff --git a/tests/manual/meson/mesonsampleproject/meson.build b/tests/manual/meson/mesonsampleproject/meson.build new file mode 100644 index 0000000000..901285a587 --- /dev/null +++ b/tests/manual/meson/mesonsampleproject/meson.build @@ -0,0 +1,19 @@ +project('mesonsampleproject', 'cpp',default_options : ['cpp_std=c++11']) + +# Documentation: https://mesonbuild.com/Qt5-module.html +qt5 = import('qt5') +qt5dep = dependency('qt5', modules : ['Core', 'Widgets']) + +translations = qt5.compile_translations(ts_files : 'mesonsampleproject_fr_FR.ts', build_by_default : true) + +generated_files = qt5.preprocess( + moc_headers : 'mesonsampleproject.h', + ui_files : 'mesonsampleproject.ui', + dependencies: [qt5dep]) + +executable('mesonsampleproject' + , 'main.cpp' + , 'mesonsampleproject.cpp' + , generated_files + , dependencies : [qt5dep] + , install : true) diff --git a/tests/manual/meson/mesonsampleproject/mesonsampleproject.cpp b/tests/manual/meson/mesonsampleproject/mesonsampleproject.cpp new file mode 100644 index 0000000000..9840775622 --- /dev/null +++ b/tests/manual/meson/mesonsampleproject/mesonsampleproject.cpp @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Alexis Jeandet. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ +#include "mesonsampleproject.h" +#include "ui_mesonsampleproject.h" + +MesonSampleProject::MesonSampleProject(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MesonSampleProject) +{ + ui->setupUi(this); +} + +MesonSampleProject::~MesonSampleProject() +{ + delete ui; +} + diff --git a/tests/manual/meson/mesonsampleproject/mesonsampleproject.h b/tests/manual/meson/mesonsampleproject/mesonsampleproject.h new file mode 100644 index 0000000000..b02897e0a4 --- /dev/null +++ b/tests/manual/meson/mesonsampleproject/mesonsampleproject.h @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2020 Alexis Jeandet. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ +#ifndef MESONSAMPLEPROJECT_H +#define MESONSAMPLEPROJECT_H + +#include <QMainWindow> + +QT_BEGIN_NAMESPACE +namespace Ui { class MesonSampleProject; } +QT_END_NAMESPACE + +class MesonSampleProject : public QMainWindow +{ + Q_OBJECT + +public: + MesonSampleProject(QWidget *parent = nullptr); + ~MesonSampleProject(); + +private: + Ui::MesonSampleProject *ui; +}; +#endif // MESONSAMPLEPROJECT_H diff --git a/tests/manual/meson/mesonsampleproject/mesonsampleproject.ui b/tests/manual/meson/mesonsampleproject/mesonsampleproject.ui new file mode 100644 index 0000000000..51e51e1248 --- /dev/null +++ b/tests/manual/meson/mesonsampleproject/mesonsampleproject.ui @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MesonSampleProject</class> + <widget class="QMainWindow" name="MesonSampleProject"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>600</height> + </rect> + </property> + <property name="windowTitle"> + <string>MesonSampleProject</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>This is a sample meson project</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>29</height> + </rect> + </property> + </widget> + <widget class="QStatusBar" name="statusbar"/> + </widget> + <resources/> + <connections/> +</ui> diff --git a/tests/manual/meson/mesonsampleproject/mesonsampleproject_fr_FR.ts b/tests/manual/meson/mesonsampleproject/mesonsampleproject_fr_FR.ts new file mode 100644 index 0000000000..1b4f705da2 --- /dev/null +++ b/tests/manual/meson/mesonsampleproject/mesonsampleproject_fr_FR.ts @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.1" language="fr_FR"> +<context> + <name>MesonSampleProject</name> + <message> + <location filename="mesonsampleproject.ui" line="14"/> + <source>MesonSampleProject</source> + <translation>Projet de démonstration Meson</translation> + </message> + <message> + <location filename="mesonsampleproject.ui" line="34"/> + <source>This is a sample meson project</source> + <translation>Ceci est un projet de démonstration pour Meson</translation> + </message> +</context> +</TS> diff --git a/tests/system/shared/project.py b/tests/system/shared/project.py index 96b79a5c4a..6c0c9c52b4 100644 --- a/tests/system/shared/project.py +++ b/tests/system/shared/project.py @@ -617,7 +617,7 @@ def addCPlusPlusFile(name, template, projectName, forceOverwrite=False, addToVCS if name == None: test.fatal("File must have a name - got None.") return - __createProjectOrFileSelectType__(" C++", template, isProject=False) + __createProjectOrFileSelectType__(" C/C++", template, isProject=False) window = "{type='ProjectExplorer::JsonWizard' unnamed='1' visible='1'}" basePathEdit = waitForObject("{type='Utils::FancyLineEdit' unnamed='1' visible='1' " "window=%s}" % window) diff --git a/tests/system/shared/utils.py b/tests/system/shared/utils.py index 6501f738a2..26afa78c8a 100644 --- a/tests/system/shared/utils.py +++ b/tests/system/shared/utils.py @@ -652,11 +652,11 @@ def openVcsLog(): waitForObject("{text='Version Control' type='QLabel' unnamed='1' visible='1' " "window=':Qt Creator_Core::Internal::MainWindow'}", 2000) except: - invokeMenuItem("Window", "Output Panes", "Version Control") + invokeMenuItem("View", "Output Panes", "Version Control") def openGeneralMessages(): if not object.exists(":Qt Creator_Core::OutputWindow"): - invokeMenuItem("Window", "Output Panes", "General Messages") + invokeMenuItem("View", "Output Panes", "General Messages") # function that retrieves a specific child object by its class # this is sometimes the best way to avoid using waitForObject() on objects that diff --git a/tests/system/suite_QMLS/tst_QMLS02/test.py b/tests/system/suite_QMLS/tst_QMLS02/test.py index 752bf3a05e..a89be4d032 100644 --- a/tests/system/suite_QMLS/tst_QMLS02/test.py +++ b/tests/system/suite_QMLS/tst_QMLS02/test.py @@ -40,10 +40,14 @@ def main(): testingCodeLine = 'Color : "blue"' type(editorArea, "<Return>") type(editorArea, testingCodeLine) + + invokeMenuItem("View", "Output Panes", "Issues") + issuesView = waitForObject(":Qt Creator.Issues_QListView") + clickButton(waitForObject(":*Qt Creator.Clear_QToolButton")) + # invoke QML parsing invokeMenuItem("Tools", "QML/JS", "Run Checks") # verify that error properly reported - issuesView = waitForObject(":Qt Creator.Issues_QListView") test.verify(checkSyntaxError(issuesView, ['Invalid property name "Color". (M16)'], True), "Verifying if error is properly reported") # repair error - go to written line diff --git a/tests/system/suite_debugger/tst_qml_js_console/test.py b/tests/system/suite_debugger/tst_qml_js_console/test.py index c7d9df09f2..040ceed705 100644 --- a/tests/system/suite_debugger/tst_qml_js_console/test.py +++ b/tests/system/suite_debugger/tst_qml_js_console/test.py @@ -149,7 +149,7 @@ def main(): mainRect = getQModelIndexStr("text='Rectangle'", rootIndex) doubleClick(waitForObject(mainRect)) if not object.exists(":DebugModeWidget_Debugger::Internal::ConsoleView"): - invokeMenuItem("Window", "Output Panes", "QML Debugger Console") + invokeMenuItem("View", "Output Panes", "QML Debugger Console") # Window might be too small to show Locals, so close what we don't need for view in ("Stack", "Breakpoints", "Expressions"): invokeMenuItem("Window", "Views", view) diff --git a/tests/system/suite_editors/tst_rename_macros/test.py b/tests/system/suite_editors/tst_rename_macros/test.py index 24c4c22813..491cc3bd20 100644 --- a/tests/system/suite_editors/tst_rename_macros/test.py +++ b/tests/system/suite_editors/tst_rename_macros/test.py @@ -42,11 +42,10 @@ def main(): if not testRenameMacroAfterSourceModification(): return headerName = "anothertestfile.h" - addCPlusPlusFile(headerName, "C++ Header File", "testfiles.pro", + addCPlusPlusFile(headerName, "C/C++ Header File", "testfiles.pro", expectedHeaderName=headerName) if not testRenameMacroAfterSourceMoving(): return - invokeMenuItem("File", "Save All") invokeMenuItem("File", "Exit") def testRenameMacroAfterSourceModification(): diff --git a/tests/system/suite_general/tst_opencreator_qbs/testdata/projecttree_creator.tsv b/tests/system/suite_general/tst_opencreator_qbs/testdata/projecttree_creator.tsv index fb41cd7373..93dfff235b 100644 --- a/tests/system/suite_general/tst_opencreator_qbs/testdata/projecttree_creator.tsv +++ b/tests/system/suite_general/tst_opencreator_qbs/testdata/projecttree_creator.tsv @@ -5720,33 +5720,6 @@ "clangcodemodel.qbs:112" "4" "data" "4" "clangtestdata.qrc" "5" -"/unittests/ClangCodeModel" "6" -"exampleIncludeDir" "7" -"mylib" "8" -"mylib.h" "9" -"file.h" "8" -"otherFile.h" "8" -"qt-widgets-app" "7" -"main.cpp" "8" -"mainwindow.cpp" "8" -"mainwindow.h" "8" -"mainwindow.ui" "8" -"qt-widgets-app.pro" "8" -"completionWithProject.cpp" "7" -"constructorCompletion.cpp" "7" -"dotToArrowCorrection.cpp" "7" -"doxygenKeywordsCompletion.cpp" "7" -"functionCompletion.cpp" "7" -"globalCompletion.cpp" "7" -"includeDirectiveCompletion.cpp" "7" -"memberCompletion.cpp" "7" -"myheader.h" "7" -"mysource.cpp" "7" -"noDotToArrowCorrectionForFloats.cpp" "7" -"objc_messages_1.mm" "7" -"objc_messages_2.mm" "7" -"objc_messages_3.mm" "7" -"preprocessorKeywordsCompletion.cpp" "7" "clangautomationutils.cpp" "4" "clangautomationutils.h" "4" "clangbatchfileprocessor.cpp" "4" @@ -5975,36 +5948,6 @@ "clangtoolsunittests.cpp" "4" "clangtoolsunittests.h" "4" "clangtoolsunittests.qrc" "4" -"/" "5" -"unit-tests" "6" -"clangtidy_clazy" "7" -"clangtidy_clazy.pro" "8" -"clazy_example.cpp" "8" -"tidy_example.cpp" "8" -"qt-essential-includes" "7" -"main.cpp" "8" -"qt-essential-includes.pro" "8" -"qt-essential-includes.qbs" "8" -"qt-widgets-app" "7" -"main.cpp" "8" -"mainwindow.cpp" "8" -"mainwindow.h" "8" -"mainwindow.ui" "8" -"qt-widgets-app.pro" "8" -"qt-widgets-app.qbs" "8" -"simple" "7" -"main.cpp" "8" -"simple.pro" "8" -"simple.qbs" "8" -"simple-library" "7" -"simple-library.cpp" "8" -"simple-library.h" "8" -"simple-library.pro" "8" -"simple-library.qbs" "8" -"stdc++11-includes" "7" -"main.cpp" "8" -"stdc++11-includes.pro" "8" -"stdc++11-includes.qbs" "8" "clangfileinfo.h" "3" "clangfixitsrefactoringchanges.cpp" "3" "clangfixitsrefactoringchanges.h" "3" diff --git a/tests/system/suite_qtquick/tst_qml_outline/test.py b/tests/system/suite_qtquick/tst_qml_outline/test.py index b0cd8df316..220735a53b 100644 --- a/tests/system/suite_qtquick/tst_qml_outline/test.py +++ b/tests/system/suite_qtquick/tst_qml_outline/test.py @@ -140,12 +140,8 @@ def verifyOutline(outlinePseudoTree, datasetFileName): return for counter, (expectedItem, foundItem) in enumerate(zip(expected, outlinePseudoTree)): if expectedItem != foundItem: - if JIRA.isBugStillOpen(21335) and expectedItem[:-1] == foundItem[:-1]: - test.xfail("Mismatch in element number %d for '%s'" % (counter + 1, fileName), - "%s != %s" % (str(expectedItem), str(foundItem))) - else: - test.fail("Mismatch in element number %d for '%s'" % (counter + 1, fileName), - "%s != %s" % (str(expectedItem), str(foundItem))) + test.fail("Mismatch in element number %d for '%s'" % (counter + 1, fileName), + "%s != %s" % (str(expectedItem), str(foundItem))) return test.passes("All nodes (%d) inside outline match expected nodes for '%s'." % (len(expected), fileName)) diff --git a/tests/system/suite_tools/tst_codepasting/test.py b/tests/system/suite_tools/tst_codepasting/test.py index 0915f02fcc..e2686d25b6 100644 --- a/tests/system/suite_tools/tst_codepasting/test.py +++ b/tests/system/suite_tools/tst_codepasting/test.py @@ -35,6 +35,7 @@ def __platformToBeRunToday__(): skipPastingToPastebinCom = platform.system() not in __platformToBeRunToday__() NAME_PBCOM = "Pastebin.Com" +NAME_DPCOM = "DPaste.Com" serverProblems = "Server side problems." @@ -90,8 +91,8 @@ def pasteFile(sourceFile, protocol): clickButton(waitForObject(":Send to Codepaster.Paste_QPushButton")) try: outputWindow = waitForObject(":Qt Creator_Core::OutputWindow") - waitFor("'https://' in str(outputWindow.plainText)", 20000) - output = str(outputWindow.plainText).splitlines()[-1] + waitFor("re.search('^https?://', str(outputWindow.plainText)) is not None", 20000) + output = filter(lambda x: len(x), str(outputWindow.plainText).splitlines())[-1] except: output = "" if closeHTTPStatusAndPasterDialog(protocol, ':Send to Codepaster_CodePaster::PasteView'): @@ -127,8 +128,17 @@ def fetchSnippet(protocol, description, pasteId, skippedPasting): except: closeHTTPStatusAndPasterDialog(protocol, ':PasteSelectDialog_CodePaster::PasteSelectDialog') return -1 - waitFor("pasteModel.rowCount() > 1", 20000) - if (protocol != NAME_PBCOM and not skippedPasting and not any(map(lambda str:pasteId in str, dumpItems(pasteModel)))): + + condition = "pasteModel.rowCount() > 1" + if protocol == NAME_DPCOM: # no list support + condition = "pasteModel.rowCount() == 1" + waitFor(condition, 20000) + + if protocol == NAME_DPCOM: + items = dumpItems(pasteModel) + test.compare(items, ["This protocol does not support listing"], "Check expected message.") + elif (protocol != NAME_PBCOM and not skippedPasting + and not any(map(lambda str:pasteId in str, dumpItems(pasteModel)))): test.warning("Fetching too fast for server of %s - waiting 3s and trying to refresh." % protocol) snooze(3) clickButton("{text='Refresh' type='QPushButton' unnamed='1' visible='1' " @@ -154,8 +164,8 @@ def fetchSnippet(protocol, description, pasteId, skippedPasting): message = "Could not find id '%s' in list of pastes from %s" % (pasteId, protocol) if protocol == NAME_PBCOM: test.xfail(message, "pastebin.com does not show pastes in list anymore") - else: - test.fail(message) + elif protocol != NAME_DPCOM: # does not happen now, but kept to avoid forgetting to + test.fail(message) # re-add when protocols change again foundSnippet = False replaceEditorContent(waitForObject(":PasteSelectDialog.pasteEdit_QLineEdit"), pasteId) if foundSnippet: @@ -168,7 +178,7 @@ def main(): startQC() if not startedWithoutPluginError(): return - protocolsToTest = [NAME_PBCOM] + protocolsToTest = [NAME_PBCOM, NAME_DPCOM] sourceFile = os.path.join(os.getcwd(), "testdata", "main.cpp") # make sure General Messages is open openGeneralMessages() diff --git a/tests/system/suite_tools/tst_git_local/test.py b/tests/system/suite_tools/tst_git_local/test.py index d5f99f6ea6..9703e450e8 100644 --- a/tests/system/suite_tools/tst_git_local/test.py +++ b/tests/system/suite_tools/tst_git_local/test.py @@ -87,7 +87,7 @@ def __clickCommit__(count): # find commit try: # Commits are listed in reverse chronologic order, so we have to invert count - line = filter(lambda line: line.startswith("commit"), content.splitlines())[-count] + line = filter(lambda line: line.startswith("commit"), content.splitlines())[-count].strip() commit = line.split(" ", 1)[1] except: test.fail("Could not find the %d. commit - leaving test" % count) @@ -176,7 +176,7 @@ def main(): commitMessages = [commit("Initial Commit", "Committed 6 files.")] clickButton(waitForObject(":*Qt Creator.Clear_QToolButton")) headerName = "pointless_header.h" - addCPlusPlusFile(headerName, "C++ Header File", projectName + ".pro", + addCPlusPlusFile(headerName, "C/C++ Header File", projectName + ".pro", addToVCS="Git", expectedHeaderName=headerName) commitMessages.insert(0, commit("Added pointless header file", "Committed 2 files.")) readmeName = "README.txt" diff --git a/tests/tests.qbs b/tests/tests.qbs index 0b475afde5..4e04ae57d8 100644 --- a/tests/tests.qbs +++ b/tests/tests.qbs @@ -2,5 +2,8 @@ import qbs Project { name: "Tests" - references: ["auto/auto.qbs"] + references: [ + "auto/auto.qbs", + "unit/unit.qbs", + ] } diff --git a/tests/unit/echoserver/echoserver.qbs b/tests/unit/echoserver/echoserver.qbs new file mode 100644 index 0000000000..77df73a6d6 --- /dev/null +++ b/tests/unit/echoserver/echoserver.qbs @@ -0,0 +1,30 @@ +import qbs.FileInfo + +QtcProduct { + name: "echoserver" + type: "application" + targetName: "echo" + consoleApplication: true + destinationDirectory: FileInfo.joinPaths(project.buildDirectory, + FileInfo.relativePath(project.ide_source_tree, sourceDirectory)) + install: false + + Depends { name: "qtc" } + Depends { name: "ClangSupport" } + Depends { name: "Sqlite" } + Depends { name: "Utils" } + Depends { name: "Qt.network" } + + cpp.defines: ["CLANGSUPPORT_TESTS", "DONT_CHECK_MESSAGE_COUNTER"] + cpp.dynamicLibraries: qbs.targetOS.contains("unix:") ? ["dl"] : [] + cpp.rpaths: [ + FileInfo.joinPaths(project.buildDirectory, qtc.ide_library_path), + FileInfo.joinPaths(project.buildDirectory, qtc.ide_plugin_path) + ] + + files: [ + "echoclangcodemodelserver.cpp", + "echoclangcodemodelserver.h", + "echoserverprocessmain.cpp", + ] +} diff --git a/tests/unit/echoserver/echoserverprocessmain.cpp b/tests/unit/echoserver/echoserverprocessmain.cpp index 07010b0b91..5225007617 100644 --- a/tests/unit/echoserver/echoserverprocessmain.cpp +++ b/tests/unit/echoserver/echoserverprocessmain.cpp @@ -43,12 +43,9 @@ int main(int argc, char *argv[]) QCoreApplication application(argc, argv); - if (application.arguments().count() < 2) return 1; - else if (application.arguments().count() == 3) - *(int*)0 = 0; - else if (application.arguments().contains("connectionName")) + if (application.arguments().contains("connectionName")) return 0; EchoClangCodeModelServer echoClangCodeModelServer; diff --git a/tests/unit/unit.qbs b/tests/unit/unit.qbs new file mode 100644 index 0000000000..cf73b27036 --- /dev/null +++ b/tests/unit/unit.qbs @@ -0,0 +1,7 @@ +Project { + name: "C++ unit tests" + references: [ + "echoserver/echoserver.qbs", + "unittest/unittest.qbs", + ] +} diff --git a/tests/unit/unittest/CMakeLists.txt b/tests/unit/unittest/CMakeLists.txt index d42337155d..9ae0b9c9a9 100644 --- a/tests/unit/unittest/CMakeLists.txt +++ b/tests/unit/unittest/CMakeLists.txt @@ -20,8 +20,10 @@ add_qtc_test(unittest GTEST Qt5::Xml Qt5::Concurrent Qt5::Qml Qt5::Gui Googletest clangrefactoringbackend_lib clangbackend_lib clangpchmanagerbackend_lib - CPlusPlus Sqlite Utils + CPlusPlus Utils DEFINES + QT_NO_CAST_TO_ASCII + QT_RESTRICTED_CAST_FROM_ASCII UNIT_TESTS DONT_CHECK_MESSAGE_COUNTER QTC_RESOURCE_DIR="${PROJECT_SOURCE_DIR}/share/qtcreator" @@ -175,6 +177,13 @@ add_qtc_test(unittest GTEST sqlitevalue-test.cpp ) +extend_qtc_test(unittest + DEFINES + $<TARGET_PROPERTY:Sqlite,INTERFACE_COMPILE_DEFINITIONS> + SOURCES + ../../../src/libs/3rdparty/sqlite/sqlite3.c +) + # Do not work on the source directory data add_custom_command(TARGET unittest POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_directory @@ -192,8 +201,11 @@ string(REPLACE "$$QTCREATOR_COPYRIGHT_YEAR" "${IDE_COPYRIGHT_YEAR}" plugin_json_ string(REPLACE "$$dependencyList" "\"Dependencies\" : []" plugin_json_in ${plugin_json_in}) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CppTools.json" ${plugin_json_in}}) -if (TARGET libclang) - target_sources(unittest PRIVATE +extend_qtc_test(unittest + CONDITION TARGET libclang + INCLUDES "${CLANG_INCLUDE_DIRS}" + DEPENDS libclang + SOURCES activationsequencecontextprocessor-test.cpp activationsequenceprocessor-test.cpp chunksreportedmonitor.cpp @@ -245,14 +257,13 @@ if (TARGET libclang) clangasyncjob-base.h clangcompareoperators.h diagnosticcontainer-matcher.h - ) - target_include_directories(unittest PRIVATE "${CLANG_INCLUDE_DIRS}") - target_link_libraries(unittest PRIVATE libclang) -endif() +) -if (TARGET clangTooling) - target_compile_definitions(unittest PRIVATE CLANG_UNIT_TESTS) - target_sources(unittest PRIVATE +extend_qtc_test(unittest + CONDITION TARGET clangTooling + DEFINES CLANG_UNIT_TESTS + DEPENDS clangTooling clangIndex clangQuery + SOURCES gtest-llvm-printing.cpp clangquerygatherer-test.cpp clangqueryprojectfindfilter-test.cpp @@ -272,37 +283,35 @@ if (TARGET clangTooling) builddependencycollector-test.cpp mockrefactoringclient.h mockrefactoringserver.h - ) - target_link_libraries(unittest - PRIVATE clangTooling clangIndex clangQuery) -endif() +) -if (TARGET clangFormat) - target_sources(unittest PRIVATE +extend_qtc_test(unittest + CONDITION TARGET clangFormat + DEPENDS clangFormat + SOURCES clangformat-test.cpp - ) - target_link_libraries(unittest PRIVATE clangFormat) -endif() +) -if (TARGET GoogleBenchmark) - target_sources(unittest PRIVATE +extend_qtc_test(unittest + CONDITION TARGET GoogleBenchmark + DEPENDS GoogleBenchmark + SOURCES smallstring-benchmark.cpp - ) - target_link_libraries(unittest PRIVATE GoogleBenchmark) -endif() +) -finalize_qtc_gtest(unittest) +finalize_qtc_gtest(unittest ".c$") # Path needs to be before CppTools target_include_directories(unittest PRIVATE BEFORE $<TARGET_PROPERTY:clangrefactoringbackend_lib,INTERFACE_INCLUDE_DIRECTORIES> - BEFORE $<TARGET_PROPERTY:ClangRefactoring,INTERFACE_INCLUDE_DIRECTORIES> + BEFORE ../../../src/plugins/clangrefactoring + BEFORE ../../../src/plugins ) get_target_property(ClangSupportSources ClangSupport SOURCES) get_target_property(ClangSupportSourcesDir ClangSupport SOURCES_DIR) -extend_qtc_target(unittest +extend_qtc_test(unittest SOURCES_PREFIX "${ClangSupportSourcesDir}" SOURCES ${ClangSupportSources} DEFINES @@ -313,7 +322,7 @@ extend_qtc_target(unittest ) get_target_property(ClangCodeModelSourcesDir ClangCodeModel SOURCES_DIR) -extend_qtc_target(unittest +extend_qtc_test(unittest SOURCES_PREFIX "${ClangCodeModelSourcesDir}" SOURCES clangactivationsequencecontextprocessor.cpp clangactivationsequencecontextprocessor.h @@ -328,25 +337,25 @@ extend_qtc_target(unittest ) get_target_property(CompilationDatabasePMSourcesDir CompilationDatabaseProjectManager SOURCES_DIR) -extend_qtc_target(unittest +extend_qtc_test(unittest SOURCES_PREFIX "${CompilationDatabasePMSourcesDir}" SOURCES compilationdatabaseutils.cpp compilationdatabaseutils.h ) get_target_property(CoreSourcesDir Core SOURCES_DIR) -extend_qtc_target(unittest +extend_qtc_test(unittest SOURCES_PREFIX "${CoreSourcesDir}" DEFINES CORE_STATIC_LIBRARY SOURCES coreicons.cpp coreicons.h - id.cpp id.h + id.h find/ifindfilter.cpp find/ifindfilter.h locator/ilocatorfilter.cpp locator/ilocatorfilter.h ) get_target_property(CppToolsSourcesDir CppTools SOURCES_DIR) -extend_qtc_target(unittest +extend_qtc_test(unittest SOURCES_PREFIX "${CppToolsSourcesDir}" DEFINES CPPTOOLS_STATIC_LIBRARY SOURCES @@ -362,16 +371,15 @@ extend_qtc_target(unittest ) get_target_property(ProjectExplorerSourcesDir ProjectExplorer SOURCES_DIR) -extend_qtc_target(unittest +extend_qtc_test(unittest SOURCES_PREFIX "${ProjectExplorerSourcesDir}" DEFINES PROJECTEXPLORER_STATIC_LIBRARY SOURCES projectmacro.cpp projectmacro.h ) -get_target_property(ClangRefactoringSourcesDir ClangRefactoring SOURCES_DIR) -extend_qtc_target(unittest - SOURCES_PREFIX "${ClangRefactoringSourcesDir}" +extend_qtc_test(unittest + SOURCES_PREFIX ../../../src/plugins/clangrefactoring SOURCES clangqueryexamplehighlighter.cpp clangqueryexamplehighlighter.h clangqueryexamplehighlightmarker.h @@ -393,9 +401,8 @@ extend_qtc_target(unittest locatorfilter.cpp locatorfilter.h ) -get_target_property(ClangPchManagerSourcesDir ClangPchManager SOURCES_DIR) -extend_qtc_target(unittest - SOURCES_PREFIX "${ClangPchManagerSourcesDir}" +extend_qtc_test(unittest + SOURCES_PREFIX ../../../src/plugins/clangpchmanager DEFINES CLANGPCHMANAGER_STATIC_LIB SOURCES clangindexingprojectsettings.cpp clangindexingprojectsettings.h @@ -412,7 +419,7 @@ extend_qtc_target(unittest ) get_target_property(ClangFormatSourcesDir ClangFormat SOURCES_DIR) -extend_qtc_target(unittest +extend_qtc_test(unittest SOURCES_PREFIX "${ClangFormatSourcesDir}" DEFINES CLANGPCHMANAGER_STATIC_LIB SOURCES diff --git a/tests/unit/unittest/clangformat-test.cpp b/tests/unit/unittest/clangformat-test.cpp index 172afb64c8..822f4b76d2 100644 --- a/tests/unit/unittest/clangformat-test.cpp +++ b/tests/unit/unittest/clangformat-test.cpp @@ -198,7 +198,14 @@ TEST_F(ClangFormat, IndentLambdaWithReturnType) "}")); } -TEST_F(ClangFormat, IndentFunctionArgumentLambdaWithNextLineScope) +#ifndef KEEP_LINE_BREAKS_FOR_NON_EMPTY_LINES_BACKPORTED +# define DISABLED_FOR_VANILLA_CLANG(x) DISABLED_##x +#else +# define DISABLED_FOR_VANILLA_CLANG(x) x +#endif + +// This test requires the custom clang patch https://code.qt.io/cgit/clang/llvm-project.git/commit/?h=release_100-based&id=9b992a0f7f160dd6c75f20a4dcfcf7c60a4894df +TEST_F(ClangFormat, DISABLED_FOR_VANILLA_CLANG(IndentFunctionArgumentLambdaWithNextLineScope)) { insertLines({"foo([]()", "{", diff --git a/tests/unit/unittest/clangsupportivetranslationunitinitializer-test.cpp b/tests/unit/unittest/clangsupportivetranslationunitinitializer-test.cpp index 9e79cd744d..c62b803a71 100644 --- a/tests/unit/unittest/clangsupportivetranslationunitinitializer-test.cpp +++ b/tests/unit/unittest/clangsupportivetranslationunitinitializer-test.cpp @@ -31,7 +31,7 @@ #include <clangbackend_global.h> #include <clangdocuments.h> #include <clangexceptions.h> -#include <clangsupportivetranslationunitinitializer.cpp> +#include <clangsupportivetranslationunitinitializer.h> #include <clangtranslationunit.h> #include <clangtranslationunits.h> #include <utf8string.h> diff --git a/tests/unit/unittest/clangtooltipinfo-test.cpp b/tests/unit/unittest/clangtooltipinfo-test.cpp index fb630e2aa3..26b6596cc5 100644 --- a/tests/unit/unittest/clangtooltipinfo-test.cpp +++ b/tests/unit/unittest/clangtooltipinfo-test.cpp @@ -385,6 +385,15 @@ TEST_F(ToolTipInfo, SizeForUnion) ASSERT_THAT(actual.sizeInBytes, Utf8StringLiteral("1")); } +TEST_F(ToolTipInfo, constexprValue) +{ + // CLANG-UPGRADE-CHECK: Adapt the values below + ASSERT_THAT(tooltip(204, 12).value.toInt(), 4); + ASSERT_THAT(tooltip(204, 27).value.toInt(), 4); // 3 in clang 11 + ASSERT_THAT(tooltip(204, 30).value.toInt(), 4); + ASSERT_THAT(tooltip(204, 32).value.toInt(), 4); // 1 in clang 11 +} + TEST_F(ToolTipInfo, Namespace) { ::ToolTipInfo expected(Utf8StringLiteral("X")); diff --git a/tests/unit/unittest/codecompleter-test.cpp b/tests/unit/unittest/codecompleter-test.cpp index ec865aacbd..be84bad99e 100644 --- a/tests/unit/unittest/codecompleter-test.cpp +++ b/tests/unit/unittest/codecompleter-test.cpp @@ -530,7 +530,9 @@ TEST_F(CodeCompleterSlowTest, NoDotArrowCorrectionForColonColon) ASSERT_THAT(completions, Not(Contains(HasFixIts()))); } -TEST_F(CodeCompleterSlowTest, NoGlobalCompletionAfterForwardDeclaredClassPointer) +// Our workaround is not applicable with LLVM/Clang 10 anymore, so disable this test for that version. +// Luckily, the workaround is not needed anymore with LLVM/Clang 11. +TEST_F(CodeCompleterSlowTest, DISABLED_FOR_CLANG_10(NoGlobalCompletionAfterForwardDeclaredClassPointer)) { auto myCompleter = setupCompleter(globalCompletionAfterForwardDeclaredClassPointer); const ClangBackEnd::CodeCompletions completions = myCompleter.complete(5, 10); @@ -605,14 +607,11 @@ TEST_F(CodeCompleterSlowTest, FunctionOverloadsNoParametersOrder) auto myCompleter = setupCompleter(completionsOrder); const ClangBackEnd::CodeCompletions completions = myCompleter.complete(27, 7); - int firstIndex = Utils::indexOf(completions, [](const CodeCompletion &codeCompletion) { + const int fooCount = Utils::count(completions, [](const CodeCompletion &codeCompletion) { return codeCompletion.text == "foo"; }); - int secondIndex = Utils::indexOf(completions, [i = 0, firstIndex](const CodeCompletion &codeCompletion) mutable { - return (i++) > firstIndex && codeCompletion.text == "foo"; - }); - ASSERT_THAT(abs(firstIndex - secondIndex), 1); + ASSERT_THAT(fooCount, 1); } TEST_F(CodeCompleterSlowTest, FunctionOverloadsWithParametersOrder) @@ -645,6 +644,26 @@ TEST_F(CodeCompleterSlowTest, FunctionOverloadsWithoutDotOrArrowOrder) ASSERT_THAT(abs(firstIndex - secondIndex), 1); } +TEST_F(CodeCompleterSlowTest, LexicographicalSorting) +{ + auto myCompleter = setupCompleter(completionsOrder); + const ClangBackEnd::CodeCompletions completions = myCompleter.complete(40, 18); + + const int funcAIndex = Utils::indexOf(completions, [](const CodeCompletion &codeCompletion) { + return codeCompletion.text == "memberFuncAAA"; + }); + const int funcBIndex = Utils::indexOf(completions, [](const CodeCompletion &codeCompletion) { + return codeCompletion.text == "memberFuncBB"; + }); + const int funcCIndex = Utils::indexOf(completions, [](const CodeCompletion &codeCompletion) { + return codeCompletion.text == "memberFuncC"; + }); + + ASSERT_NE(funcAIndex, -1); + ASSERT_EQ(funcBIndex, funcAIndex + 1); + ASSERT_EQ(funcCIndex, funcAIndex + 2); +} + ClangBackEnd::CodeCompleter CodeCompleter::setupCompleter( const ClangBackEnd::FileContainer &fileContainer) { diff --git a/tests/unit/unittest/conditionally-disabled-tests.h b/tests/unit/unittest/conditionally-disabled-tests.h index 128520a881..91b2541fe9 100644 --- a/tests/unit/unittest/conditionally-disabled-tests.h +++ b/tests/unit/unittest/conditionally-disabled-tests.h @@ -25,6 +25,14 @@ #include <QtGlobal> +#include <clang-c/Index.h> + +#if CINDEX_VERSION_MAJOR == 0 && CINDEX_VERSION_MINOR == 59 +# define DISABLED_FOR_CLANG_10(x) DISABLED_##x +#else +# define DISABLED_FOR_CLANG_10(x) x +#endif + #ifdef Q_OS_WIN # define DISABLED_ON_WINDOWS(x) DISABLED_##x #else diff --git a/tests/unit/unittest/data/completions_order.cpp b/tests/unit/unittest/data/completions_order.cpp index 6c363a6c50..3812225ad7 100644 --- a/tests/unit/unittest/data/completions_order.cpp +++ b/tests/unit/unittest/data/completions_order.cpp @@ -26,3 +26,16 @@ void testPriorities() { DifferentPriorities d; d. } + +class LexicographicalSorting +{ +public: + void memberFuncBB(); + void memberFuncC(); + void memberFuncAAA() const; +}; + +void testLexicographicalSorting() { + LexicographicalSorting ls; + ls.memberFunc +} diff --git a/tests/unit/unittest/data/tooltipinfo.cpp b/tests/unit/unittest/data/tooltipinfo.cpp index bfad1fdd0f..6844a823cc 100644 --- a/tests/unit/unittest/data/tooltipinfo.cpp +++ b/tests/unit/unittest/data/tooltipinfo.cpp @@ -199,3 +199,6 @@ Nuu **pointers(Nuu **p1) { return p1; } + +static constexpr int calcValue() { return 1 + 2; } +const auto val = calcValue() + sizeof(char); diff --git a/tests/unit/unittest/diagnostic-test.cpp b/tests/unit/unittest/diagnostic-test.cpp index 3ab382c46b..adfc503d3e 100644 --- a/tests/unit/unittest/diagnostic-test.cpp +++ b/tests/unit/unittest/diagnostic-test.cpp @@ -123,7 +123,11 @@ TEST_F(DiagnosticSlowTest, MoveSelfAssigment) TEST_F(DiagnosticSlowTest, Text) { +#if CINDEX_VERSION_MAJOR == 0 && CINDEX_VERSION_MINOR >= 59 // >= LLVM/Clang 10 + ASSERT_THAT(diagnostic.text(), Utf8StringLiteral("warning: non-void function does not return a value")); +#else ASSERT_THAT(diagnostic.text(), Utf8StringLiteral("warning: control reaches end of non-void function")); +#endif } TEST_F(DiagnosticSlowTest, Category) diff --git a/tests/unit/unittest/gtest-clang-printing.cpp b/tests/unit/unittest/gtest-clang-printing.cpp index 727273d2bf..217114ab9e 100644 --- a/tests/unit/unittest/gtest-clang-printing.cpp +++ b/tests/unit/unittest/gtest-clang-printing.cpp @@ -32,6 +32,7 @@ #include <clangdocumentsuspenderresumer.h> #include <clangreferencescollector.h> +#include <filepathview.h> #include <fulltokeninfo.h> #include <tokenprocessor.h> diff --git a/tests/unit/unittest/gtest-creator-printing.cpp b/tests/unit/unittest/gtest-creator-printing.cpp index 20e44154d9..13fbe94130 100644 --- a/tests/unit/unittest/gtest-creator-printing.cpp +++ b/tests/unit/unittest/gtest-creator-printing.cpp @@ -1440,6 +1440,7 @@ std::ostream &operator<<(std::ostream &out, const ExplainingStep &step) std::ostream &operator<<(std::ostream &out, const Diagnostic &diag) { return out << "(" + << diag.name << ", " << diag.description << ", " << diag.category << ", " << diag.type << ", " diff --git a/tests/unit/unittest/readexporteddiagnostics-test.cpp b/tests/unit/unittest/readexporteddiagnostics-test.cpp index 368c868233..cc52c51450 100644 --- a/tests/unit/unittest/readexporteddiagnostics-test.cpp +++ b/tests/unit/unittest/readexporteddiagnostics-test.cpp @@ -106,6 +106,7 @@ TEST_F(ReadExportedDiagnostics, Tidy) const QString sourceFile = TESTDATA "tidy.modernize-use-nullptr.cpp"; const QString exportedFile = createFile(TESTDATA "tidy.modernize-use-nullptr.yaml", sourceFile); Diagnostic expectedDiag; + expectedDiag.name = "modernize-use-nullptr"; expectedDiag.location = {sourceFile, 2, 25}; expectedDiag.description = "use nullptr [modernize-use-nullptr]"; expectedDiag.type = "warning"; @@ -143,6 +144,7 @@ TEST_F(ReadExportedDiagnostics, Tidy_Clang) const QString sourceFile = TESTDATA "clang.unused-parameter.cpp"; const QString exportedFile = createFile(TESTDATA "clang.unused-parameter.yaml", sourceFile); Diagnostic expectedDiag; + expectedDiag.name = "clang-diagnostic-unused-parameter"; expectedDiag.location = {sourceFile, 4, 12}; expectedDiag.description = "unused parameter 'g' [clang-diagnostic-unused-parameter]"; expectedDiag.type = "warning"; @@ -162,6 +164,7 @@ TEST_F(ReadExportedDiagnostics, Tidy_ClangAnalyzer) const QString sourceFile = TESTDATA "clang-analyzer.dividezero.cpp"; const QString exportedFile = createFile(TESTDATA "clang-analyzer.dividezero.yaml", sourceFile); Diagnostic expectedDiag; + expectedDiag.name = "clang-analyzer-core.DivideZero"; expectedDiag.location = {sourceFile, 4, 15}; expectedDiag.description = "Division by zero [clang-analyzer-core.DivideZero]"; expectedDiag.type = "warning"; @@ -197,6 +200,7 @@ TEST_F(ReadExportedDiagnostics, Clazy) const QString sourceFile = TESTDATA "clazy.qgetenv.cpp"; const QString exportedFile = createFile(TESTDATA "clazy.qgetenv.yaml", sourceFile); Diagnostic expectedDiag; + expectedDiag.name = "clazy-qgetenv"; expectedDiag.location = {sourceFile, 7, 5}; expectedDiag.description = "qgetenv().isEmpty() allocates. Use qEnvironmentVariableIsEmpty() instead [clazy-qgetenv]"; expectedDiag.type = "warning"; diff --git a/tests/unit/unittest/skippedsourceranges-test.cpp b/tests/unit/unittest/skippedsourceranges-test.cpp index c91f726437..6a2d80d852 100644 --- a/tests/unit/unittest/skippedsourceranges-test.cpp +++ b/tests/unit/unittest/skippedsourceranges-test.cpp @@ -141,7 +141,7 @@ TEST_F(SkippedSourceRanges, DISABLED_ON_WINDOWS(RangeOne)) { auto ranges = skippedSourceRanges.sourceRanges(); - ASSERT_THAT(ranges[0].start(), IsSourceLocation(filePath, 1, 1, 0)); + ASSERT_THAT(ranges[0].start(), IsSourceLocation(filePath, 2, 1, 6)); ASSERT_THAT(ranges[0].end(), IsSourceLocation(filePath, 5, 1, 18)); } @@ -149,7 +149,7 @@ TEST_F(SkippedSourceRanges, DISABLED_ON_WINDOWS(RangeTwo)) { auto ranges = skippedSourceRanges.sourceRanges(); - ASSERT_THAT(ranges[1].start(), IsSourceLocation(filePath, 7, 1, 26)); + ASSERT_THAT(ranges[1].start(), IsSourceLocation(filePath, 8, 1, 39)); ASSERT_THAT(ranges[1].end(), IsSourceLocation(filePath, 12, 1, 57)); } diff --git a/tests/unit/unittest/sqlstatementbuilder-test.cpp b/tests/unit/unittest/sqlstatementbuilder-test.cpp index ef3a66e1da..654439fbcd 100644 --- a/tests/unit/unittest/sqlstatementbuilder-test.cpp +++ b/tests/unit/unittest/sqlstatementbuilder-test.cpp @@ -141,6 +141,7 @@ TEST(SqlStatementBuilder, ColumnType) ASSERT_THAT(SqlStatementBuilder::columnTypeToString(ColumnType::Integer), "INTEGER"); ASSERT_THAT(SqlStatementBuilder::columnTypeToString(ColumnType::Real), "REAL"); ASSERT_THAT(SqlStatementBuilder::columnTypeToString(ColumnType::Text), "TEXT"); + ASSERT_THAT(SqlStatementBuilder::columnTypeToString(ColumnType::Blob), "BLOB"); ASSERT_TRUE(SqlStatementBuilder::columnTypeToString(ColumnType::None).isEmpty()); } diff --git a/tests/unit/unittest/translationunitupdater-test.cpp b/tests/unit/unittest/translationunitupdater-test.cpp index eecc06b8a7..ea71070351 100644 --- a/tests/unit/unittest/translationunitupdater-test.cpp +++ b/tests/unit/unittest/translationunitupdater-test.cpp @@ -124,6 +124,7 @@ TEST_F(TranslationUnitUpdaterSlowTest, UpdatesDependentOnFilesOnParse) void TranslationUnitUpdater::TearDown() { + clang_disposeTranslationUnit(cxTranslationUnit); clang_disposeIndex(cxIndex); } diff --git a/tests/unit/unittest/unittest.qbs b/tests/unit/unittest/unittest.qbs new file mode 100644 index 0000000000..d00ec93b26 --- /dev/null +++ b/tests/unit/unittest/unittest.qbs @@ -0,0 +1,828 @@ +import qbs.File +import qbs.FileInfo + +CppApplication { + condition: gtest.present && gmock.present + type: base.concat(["autotest", "json_copy"]) + consoleApplication: true + destinationDirectory: FileInfo.joinPaths(project.buildDirectory, + FileInfo.relativePath(project.ide_source_tree, sourceDirectory)) + + Depends { name: "echoserver" } + Depends { name: "pluginjson" } + Depends { name: "libclang"; required: false } + Depends { name: "clang_defines" } + + Depends { name: "sqlite_sources" } + Depends { name: "Core" } + Depends { name: "CPlusPlus" } + Depends { name: "yaml-cpp" } + + Depends { name: "Qt"; submodules: ["network", "widgets", "testlib"] } + + Depends { name: "pkgconfig"; required: false } + Depends { name: "benchmark"; required: false } + Depends { name: "gtest"; required: false } + Depends { name: "gmock"; required: false } + + sqlite_sources.buildSharedLib: false + + cpp.defines: { + var defines = [ + "QT_NO_CAST_TO_ASCII", + "QT_RESTRICTED_CAST_FROM_ASCII", + "QT_USE_FAST_OPERATOR_PLUS", + "QT_USE_FAST_CONCATENATION", + "CLANG_UNIT_TESTS", + "UNIT_TESTS", + "DONT_CHECK_MESSAGE_COUNTER", + 'QTC_RESOURCE_DIR="' + path + "/../../../share/qtcreator" + '"', + 'TESTDATA_DIR="' + FileInfo.joinPaths(sourceDirectory, "data") + '"', + 'ECHOSERVER="' + FileInfo.joinPaths(project.buildDirectory, "tests", "unit", + "echoserver", "echo") + '"', + 'RELATIVE_DATA_PATH="' + FileInfo.relativePath(destinationDirectory, + FileInfo.joinPaths(project.sourceDirectory, "share", "qtcreator")) + '"', + 'CPPTOOLS_JSON="' + FileInfo.joinPaths(destinationDirectory, "CppTools.json") + '"', + ]; + if (libclang.present && libclang.toolingEnabled) + defines = defines.concat(libclang.llvmToolingDefines); + return defines; + } + cpp.cxxFlags: { + var flags = []; + if (qbs.toolchain.contains("msvc")) + flags.push("-w34100", "/bigobj", "/wd4267", "/wd4141", "/wd4146"); + if (qbs.toolchain.contains("gcc") && !qbs.toolchain.contains("clang")) + flags.push("-Wno-noexcept-type"); + if (qbs.toolchain.contains("clang")) { + flags.push("-Wno-inconsistent-missing-override", "-Wno-self-move", + "-Wno-self-assign-overloaded"); + flags.push("-Wno-unused-command-line-argument"); // gtest puts -lpthread on compiler command line + if (!qbs.hostOS.contains("darwin") + && Utilities.versionCompare(cpp.compilerVersion, "10") >= 0) { + flags.push("-Wno-deprecated-copy", "-Wno-constant-logical-operand"); + } + } + if (qbs.toolchain.contains("gcc")) + flags.push("-Wno-unused-parameter"); + if (libclang.present && libclang.toolingEnabled) + flags = flags.concat(libclang.llvmToolingCxxFlags); + return flags; + } + cpp.cxxLanguageVersion: "c++14" + cpp.dynamicLibraries: { + var libs = []; + if (libclang.present) { + libs = libs.concat(libclang.llvmLibs); + if (libclang.toolingEnabled) + libs = libs.concat(libclang.llvmToolingLibs); + if (libclang.llvmFormattingLibs.length + && (!qbs.targetOS.contains("windows") || libclang.llvmBuildModeMatches)) { + libs = libs.concat(libclang.llvmFormattingLibs); + } + } + return libs; + } + cpp.includePaths: { + var paths = [ + ".", + "../mockup", + "../../../src/libs", + "../../../src/libs/3rdparty", + "../../../src/libs/clangsupport", + "../../../src/plugins", + "../../../src/plugins/clangcodemodel", + "../../../src/plugins/clangpchmanager", + "../../../src/plugins/clangrefactoring", + "../../../src/tools/clangbackend/source", + "../../../src/tools/clangpchmanagerbackend/source", + "../../../src/tools/clangrefactoringbackend/source", + ]; + if (libclang.present) { + paths.push(libclang.llvmIncludeDir); + if (libclang.toolingEnabled) + paths = paths.concat(libclang.llvmToolingIncludes); + } + return paths; + } + cpp.libraryPaths: { + var paths = []; + if (libclang.present) + paths.push(libclang.llvmLibDir); + return paths; + } + cpp.rpaths: { + var paths = [ + FileInfo.joinPaths(project.buildDirectory, qtc.ide_library_path), + FileInfo.joinPaths(project.buildDirectory, qtc.ide_plugin_path) + ]; + if (libclang.present) + paths.push(libclang.llvmLibDir); + return paths; + } + + files: [ + "builddependenciesprovider-test.cpp", + "builddependenciesstorage-test.cpp", + "clangindexingsettingsmanager-test.cpp", + "clangpathwatcher-test.cpp", + "clangqueryexamplehighlightmarker-test.cpp", + "clangqueryhighlightmarker-test.cpp", + "clientserverinprocess-test.cpp", + "clientserveroutsideprocess-test.cpp", + "commandlinebuilder-test.cpp", + "compare-operators.h", + "compilationdatabaseutils-test.cpp", + "compileroptionsbuilder-test.cpp", + "conditionally-disabled-tests.h", + "cppprojectfilecategorizer-test.cpp", + "cppprojectinfogenerator-test.cpp", + "cppprojectpartchooser-test.cpp", + "createtablesqlstatementbuilder-test.cpp", + "directorypathcompressor-test.cpp", + "dummyclangipcclient.h", + "dynamicastmatcherdiagnosticcontainer-matcher.h", + "eventspy.cpp", + "eventspy.h", + "fakeprocess.cpp", + "fakeprocess.h", + "filepath-test.cpp", + "filepathcache-test.cpp", + "filepathstorage-test.cpp", + "filepathstoragesqlitestatementfactory-test.cpp", + "filepathview-test.cpp", + "filestatuscache-test.cpp", + "filesystem-utilities.h", + "generatedfiles-test.cpp", + "google-using-declarations.h", + "googletest.h", + "gtest-creator-printing.cpp", + "gtest-creator-printing.h", + "gtest-llvm-printing.h", + "gtest-qt-printing.cpp", + "gtest-qt-printing.h", + "headerpathfilter-test.cpp", + "lineprefixer-test.cpp", + "locatorfilter-test.cpp", + "matchingtext-test.cpp", + "mimedatabase-utilities.cpp", + "mimedatabase-utilities.h", + "mockbuilddependenciesprovider.h", + "mockbuilddependenciesstorage.h", + "mockbuilddependencygenerator.h", + "mockclangcodemodelclient.h", + "mockclangcodemodelserver.h", + "mockclangpathwatcher.h", + "mockclangpathwatchernotifier.h", + "mockcppmodelmanager.h", + "mockeditormanager.h", + "mockfilepathcaching.h", + "mockfilepathstorage.h", + "mockfilesystem.h", + "mockfutureinterface.h", + "mockgeneratedfiles.h", + "mockmodifiedtimechecker.h", + "mockmutex.h", + "mockpchcreator.h", + "mockpchmanagerclient.h", + "mockpchmanagernotifier.h", + "mockpchmanagerserver.h", + "mockpchtaskgenerator.h", + "mockpchtaskqueue.h", + "mockpchtasksmerger.h", + "mockprecompiledheaderstorage.h", + "mockprocessor.h", + "mockprocessormanager.h", + "mockprogressmanager.h", + "mockprojectpartprovider.h", + "mockprojectpartqueue.h", + "mockprojectpartsmanager.h", + "mockprojectpartsstorage.h", + "mockqfilesystemwatcher.h", + "mockqueue.h", + "mocksearch.h", + "mocksearchhandle.h", + "mocksearchresult.h", + "mocksqlitedatabase.h", + "mocksqlitereadstatement.cpp", + "mocksqlitereadstatement.h", + "mocksqlitestatement.h", + "mocksqlitetransactionbackend.h", + "mocksqlitewritestatement.h", + "mocksymbolindexertaskqueue.h", + "mocksymbolindexing.h", + "mocksymbolquery.h", + "mocksymbolscollector.h", + "mocksymbolstorage.h", + "mocksyntaxhighligher.h", + "mocktaskscheduler.h", + "mocktimer.cpp", + "mocktimer.h", + "modifiedtimechecker-test.cpp", + "nativefilepath-test.cpp", + "nativefilepathview-test.cpp", + "pchmanagerclient-test.cpp", + "pchmanagerclientserverinprocess-test.cpp", + "pchmanagerserver-test.cpp", + "pchtaskgenerator-test.cpp", + "pchtaskqueue-test.cpp", + "pchtasksmerger-test.cpp", + "precompiledheaderstorage-test.cpp", + "preprocessormacrocollector-test.cpp", + "processcreator-test.cpp", + "processevents-utilities.cpp", + "processevents-utilities.h", + "processormanager-test.cpp", + "progresscounter-test.cpp", + "projectpartartefact-test.cpp", + "projectpartsmanager-test.cpp", + "projectpartsstorage-test.cpp", + "projectupdater-test.cpp", + "readandwritemessageblock-test.cpp", + "refactoringdatabaseinitializer-test.cpp", + "refactoringprojectupdater-test.cpp", + "rundocumentparse-utility.h", + "sizedarray-test.cpp", + "smallstring-test.cpp", + "sourcerangecontainer-matcher.h", + "sourcerangefilter-test.cpp", + "sourcesmanager-test.cpp", + "spydummy.cpp", + "spydummy.h", + "sqlitecolumn-test.cpp", + "sqlitedatabase-test.cpp", + "sqlitedatabasebackend-test.cpp", + "sqliteindex-test.cpp", + "sqlitestatement-test.cpp", + "sqlitetable-test.cpp", + "sqliteteststatement.h", + "sqlitetransaction-test.cpp", + "sqlitevalue-test.cpp", + "sqlstatementbuilder-test.cpp", + "stringcache-test.cpp", + "symbolindexer-test.cpp", + "symbolindexertaskqueue-test.cpp", + "symbolquery-test.cpp", + "symbolsfindfilter-test.cpp", + "symbolstorage-test.cpp", + "task.cpp", + "taskscheduler-test.cpp", + "testenvironment.h", + "toolchainargumentscache-test.cpp", + "unittest-utility-functions.h", + "unittests-main.cpp", + "usedmacrofilter-test.cpp", + "utf8-test.cpp", + ] + + Group { + name: "libclang tests" + condition: libclang.present + files: [ + "activationsequencecontextprocessor-test.cpp", + "activationsequenceprocessor-test.cpp", + "chunksreportedmonitor.cpp", + "chunksreportedmonitor.h", + "clangasyncjob-base.cpp", + "clangasyncjob-base.h", + "clangcodecompleteresults-test.cpp", + "clangcodemodelserver-test.cpp", + "clangcompareoperators.h", + "clangcompletecodejob-test.cpp", + "clangcompletioncontextanalyzer-test.cpp", + "clangdiagnosticfilter-test.cpp", + "clangdocument-test.cpp", + "clangdocumentprocessor-test.cpp", + "clangdocumentprocessors-test.cpp", + "clangdocuments-test.cpp", + "clangfixitoperation-test.cpp", + "clangfollowsymbol-test.cpp", + "clangisdiagnosticrelatedtolocation-test.cpp", + "clangjobqueue-test.cpp", + "clangjobs-test.cpp", + "clangparsesupportivetranslationunitjob-test.cpp", + "clangrequestannotationsjob-test.cpp", + "clangrequestreferencesjob-test.cpp", + "clangresumedocumentjob-test.cpp", + "clangstring-test.cpp", + "clangsupportivetranslationunitinitializer-test.cpp", + "clangsuspenddocumentjob-test.cpp", + "clangtooltipinfo-test.cpp", + "clangtranslationunit-test.cpp", + "clangtranslationunits-test.cpp", + "clangupdateannotationsjob-test.cpp", + "codecompleter-test.cpp", + "codecompletionsextractor-test.cpp", + "completionchunkstotextconverter-test.cpp", + "cursor-test.cpp", + "diagnostic-test.cpp", + "diagnosticcontainer-matcher.h", + "diagnosticset-test.cpp", + "fixit-test.cpp", + "highlightingresultreporter-test.cpp", + "readexporteddiagnostics-test.cpp", + "senddocumenttracker-test.cpp", + "skippedsourceranges-test.cpp", + "sourcelocation-test.cpp", + "sourcerange-test.cpp", + "token-test.cpp", + "translationunitupdater-test.cpp", + "unsavedfile-test.cpp", + "unsavedfiles-test.cpp", + "utf8positionfromlinecolumn-test.cpp", + ] + } + + Group { + name: "clang tooling tests" + condition: libclang.present && libclang.toolingEnabled + files: [ + "builddependencycollector-test.cpp", + "clangdocumentsuspenderresumer-test.cpp", + "clangquery-test.cpp", + "clangquerygatherer-test.cpp", + "clangqueryprojectfindfilter-test.cpp", + "clangreferencescollector-test.cpp", + "gtest-clang-printing.cpp", + "gtest-clang-printing.h", + "gtest-llvm-printing.cpp", + "mockrefactoringclient.h", + "mockrefactoringserver.h", + "pchcreator-test.cpp", + "refactoringclient-test.cpp", + "refactoringclientserverinprocess-test.cpp", + "refactoringcompilationdatabase-test.cpp", + "refactoringengine-test.cpp", + "refactoringserver-test.cpp", + "sourcerangeextractor-test.cpp", + "symbolindexing-test.cpp", + "symbolscollector-test.cpp", + "testclangtool.cpp", + "testclangtool.h", + "tokenprocessor-test.cpp", + "usedmacrocollector-test.cpp", + ] + } + + Group { + name: "ClangFormat tests" + condition: libclang.present + && libclang.llvmFormattingLibs.length + && (!qbs.targetOS.contains("windows") || libclang.llvmBuildModeMatches) + files: "clangformat-test.cpp" + } + + Group { + name: "benchmark test" + condition: benchmark.present + files: "smallstring-benchmark.cpp" + } + + Group { + name: "data" + files: [ + "data/*", + "data/include/*", + ] + fileTags: [] + } + + Group { + name: "json.in file" + files: "../../../src/plugins/cpptools/CppTools.json.in" + fileTags: "pluginJsonIn" + } + + Group { + name: "sources from pchmanager" + prefix: "../../../src/plugins/clangpchmanager/" + cpp.defines: outer.concat("CLANGPCHMANAGER_STATIC_LIB") + files: [ + "clangindexingprojectsettings.cpp", + "clangindexingprojectsettings.h", + "clangindexingsettingsmanager.cpp", + "clangindexingsettingsmanager.h", + "clangpchmanager_global.h", + "pchmanagerclient.cpp", + "pchmanagerclient.h", + "pchmanagerconnectionclient.cpp", + "pchmanagerconnectionclient.h", + "pchmanagernotifierinterface.cpp", + "pchmanagernotifierinterface.h", + "pchmanagerprojectupdater.cpp", + "pchmanagerprojectupdater.h", + "preprocessormacrocollector.cpp", + "preprocessormacrocollector.h", + "progressmanager.h", + "progressmanagerinterface.h", + "projectupdater.cpp", + "projectupdater.h", + ] + } + + Group { + name: "sources from pchmanager backend" + prefix: "../../../src/tools/clangpchmanagerbackend/source/" + files: [ + "builddependenciesprovider.cpp", + "builddependenciesprovider.h", + "builddependenciesproviderinterface.h", + "builddependenciesstorage.h", + "builddependenciesstorageinterface.h", + "builddependency.h", + "builddependencygeneratorinterface.h", + "clangpchmanagerbackend_global.h", + "generatepchactionfactory.h", + "pchcreatorinterface.h", + "pchmanagerserver.cpp", + "pchmanagerserver.h", + "pchnotcreatederror.h", + "pchtask.h", + "pchtaskgenerator.cpp", + "pchtaskgenerator.h", + "pchtaskgeneratorinterface.h", + "pchtaskqueue.cpp", + "pchtaskqueue.h", + "pchtaskqueueinterface.h", + "pchtasksmerger.cpp", + "pchtasksmerger.h", + "pchtasksmergerinterface.h", + "precompiledheaderstorage.h", + "precompiledheaderstorageinterface.h", + "processorinterface.h", + "processormanagerinterface.h", + "projectpartsmanager.cpp", + "projectpartsmanager.h", + "projectpartsmanagerinterface.h", + "queueinterface.h", + "taskscheduler.h", + "taskschedulerinterface.h", + "toolchainargumentscache.h", + "usedmacrofilter.h", + ] + + Group { + name: "tooling sources from pchmanager backend" + condition: libclang.toolingEnabled + files: [ + "builddependencycollector.cpp", + "builddependencycollector.h", + "collectbuilddependencyaction.h", + "collectbuilddependencypreprocessorcallbacks.h", + "collectbuilddependencytoolaction.h", + "collectusedmacroactionfactory.h", + "collectusedmacrosaction.h", + "collectusedmacrosandsourcespreprocessorcallbacks.h", + "pchcreator.cpp", + "pchcreator.h", + "processormanager.h", + "usedmacrosandsourcescollector.cpp", + "usedmacrosandsourcescollector.h", + ] + } + } + + Group { + name: "sources from clangrefactoring backend" + prefix: "../../../src/tools/clangrefactoringbackend/source/" + files: [ + "clangrefactoringbackend_global.h", + "collectmacrospreprocessorcallbacks.h", + "projectpartentry.h", + "sourcedependency.h", + "sourcelocationentry.h", + "sourcerangefilter.cpp", + "sourcerangefilter.h", + "sourcesmanager.h", + "symbolentry.h", + "symbolindexer.cpp", + "symbolindexer.h", + "symbolindexertask.h", + "symbolindexertaskqueue.h", + "symbolindexertaskqueueinterface.h", + "symbolindexing.h", + "symbolindexinginterface.h", + "symbolscollectorinterface.h", + "symbolstorage.h", + "symbolstorageinterface.h", + "usedmacro.h", + ] + + Group { + name: "tooling sources from clangrefactoring backend" + condition: libclang.toolingEnabled + files: [ + "clangquery.cpp", + "clangquery.h", + "clangquerygatherer.cpp", + "clangquerygatherer.h", + "clangtool.cpp", + "clangtool.h", + "collectmacrossourcefilecallbacks.cpp", + "collectmacrossourcefilecallbacks.h", + "collectsymbolsaction.cpp", + "collectsymbolsaction.h", + "indexdataconsumer.cpp", + "indexdataconsumer.h", + "locationsourcefilecallbacks.cpp", + "locationsourcefilecallbacks.h", + "macropreprocessorcallbacks.cpp", + "macropreprocessorcallbacks.h", + "refactoringcompilationdatabase.cpp", + "refactoringcompilationdatabase.h", + "refactoringserver.cpp", + "refactoringserver.h", + "sourcelocationsutils.h", + "sourcerangeextractor.cpp", + "sourcerangeextractor.h", + "symbolindexing.cpp", + "symbolscollector.cpp", + "symbolscollector.h", + "symbolsvisitorbase.h", + ] + } + } + + Group { + name: "sources from clangbackend" + condition: libclang.present + prefix: "../../../src/tools/clangbackend/source/" + files: [ + "clangasyncjob.h", + "clangbackend_global.h", + "clangclock.h", + "clangcodecompleteresults.cpp", + "clangcodecompleteresults.h", + "clangcodemodelserver.cpp", + "clangcodemodelserver.h", + "clangcompletecodejob.cpp", + "clangcompletecodejob.h", + "clangdocument.cpp", + "clangdocument.h", + "clangdocumentjob.h", + "clangdocumentprocessor.cpp", + "clangdocumentprocessor.h", + "clangdocumentprocessors.cpp", + "clangdocumentprocessors.h", + "clangdocuments.cpp", + "clangdocuments.h", + "clangdocumentsuspenderresumer.cpp", + "clangdocumentsuspenderresumer.h", + "clangexceptions.cpp", + "clangexceptions.h", + "clangfilepath.cpp", + "clangfilepath.h", + "clangfilesystemwatcher.cpp", + "clangfilesystemwatcher.h", + "clangfollowsymbol.cpp", + "clangfollowsymbol.h", + "clangfollowsymboljob.cpp", + "clangfollowsymboljob.h", + "clangiasyncjob.cpp", + "clangiasyncjob.h", + "clangjobcontext.cpp", + "clangjobcontext.h", + "clangjobqueue.cpp", + "clangjobqueue.h", + "clangjobrequest.cpp", + "clangjobrequest.h", + "clangjobs.cpp", + "clangjobs.h", + "clangparsesupportivetranslationunitjob.cpp", + "clangparsesupportivetranslationunitjob.h", + "clangreferencescollector.cpp", + "clangreferencescollector.h", + "clangrequestannotationsjob.cpp", + "clangrequestannotationsjob.h", + "clangrequestreferencesjob.cpp", + "clangrequestreferencesjob.h", + "clangrequesttooltipjob.cpp", + "clangrequesttooltipjob.h", + "clangresumedocumentjob.cpp", + "clangresumedocumentjob.h", + "clangstring.h", + "clangsupportivetranslationunitinitializer.cpp", + "clangsupportivetranslationunitinitializer.h", + "clangsuspenddocumentjob.cpp", + "clangsuspenddocumentjob.h", + "clangtooltipinfocollector.cpp", + "clangtooltipinfocollector.h", + "clangtranslationunit.cpp", + "clangtranslationunit.h", + "clangtranslationunits.cpp", + "clangtranslationunits.h", + "clangtranslationunitupdater.cpp", + "clangtranslationunitupdater.h", + "clangtype.cpp", + "clangtype.h", + "clangunsavedfilesshallowarguments.cpp", + "clangunsavedfilesshallowarguments.h", + "clangupdateannotationsjob.cpp", + "clangupdateannotationsjob.h", + "clangupdateextraannotationsjob.cpp", + "clangupdateextraannotationsjob.h", + "codecompleter.cpp", + "codecompleter.h", + "codecompletionchunkconverter.cpp", + "codecompletionchunkconverter.h", + "codecompletionsextractor.cpp", + "codecompletionsextractor.h", + "commandlinearguments.cpp", + "commandlinearguments.h", + "cursor.cpp", + "cursor.h", + "diagnostic.cpp", + "diagnostic.h", + "diagnosticset.cpp", + "diagnosticset.h", + "diagnosticsetiterator.h", + "fixit.cpp", + "fixit.h", + "fulltokeninfo.cpp", + "fulltokeninfo.h", + "skippedsourceranges.cpp", + "skippedsourceranges.h", + "sourcelocation.cpp", + "sourcelocation.h", + "sourcerange.cpp", + "sourcerange.h", + "token.cpp", + "token.h", + "tokeninfo.cpp", + "tokeninfo.h", + "tokenprocessor.h", + "tokenprocessoriterator.h", + "unsavedfile.cpp", + "unsavedfile.h", + "unsavedfiles.cpp", + "unsavedfiles.h", + "utf8positionfromlinecolumn.cpp", + "utf8positionfromlinecolumn.h", + ] + } + + Group { + name: "sources from clangsupport" + prefix: "../../../src/libs/clangsupport/" + cpp.defines: outer.concat("CLANGSUPPORT_STATIC_LIB") + files: [ + "*.cpp", + "*.h", + ] + } + + Group { + name: "sources from clangcodemodel" + prefix: "../../../src/plugins/clangcodemodel/" + files: [ + "clangactivationsequencecontextprocessor.cpp", + "clangactivationsequencecontextprocessor.h", + "clangactivationsequenceprocessor.cpp", + "clangactivationsequenceprocessor.h", + "clangcompletionchunkstotextconverter.cpp", + "clangcompletionchunkstotextconverter.h", + "clangcompletioncontextanalyzer.cpp", + "clangcompletioncontextanalyzer.h", + "clangdiagnosticfilter.cpp", + "clangdiagnosticfilter.h", + "clangfixitoperation.cpp", + "clangfixitoperation.h", + "clanghighlightingresultreporter.cpp", + "clanghighlightingresultreporter.h", + "clangisdiagnosticrelatedtolocation.h", + "clanguiheaderondiskmanager.cpp", + "clanguiheaderondiskmanager.h", + ] + } + + Group { + name: "sources from cpptools" + prefix: "../../../src/plugins/cpptools/" + cpp.defines: outer.concat("CPPTOOLS_STATIC_LIBRARY") + files: [ + "compileroptionsbuilder.cpp", + "compileroptionsbuilder.h", + "cppprojectfile.cpp", + "cppprojectfile.h", + "cppprojectfilecategorizer.cpp", + "cppprojectfilecategorizer.h", + "cppprojectinfogenerator.cpp", + "cppprojectpartchooser.cpp", + "cppprojectpartchooser.h", + "headerpathfilter.cpp", + "headerpathfilter.h", + "projectinfo.cpp", + "projectinfo.h", + "projectpart.cpp", + "projectpart.h", + "senddocumenttracker.cpp", + "senddocumenttracker.h", + ] + } + + Group { + name: "sources from clangtools" + condition: libclang.present + prefix: "../../../src/plugins/clangtools/" + cpp.defines: outer.concat("CLANGTOOLS_STATIC_LIBRARY") + files: [ + "clangtoolsdiagnostic.cpp", + "clangtoolsdiagnostic.h", + "clangtoolslogfilereader.cpp", + "clangtoolslogfilereader.h", + ] + } + + Group { + name: "sources from clangdbpm" + prefix: "../../../src/plugins/compilationdatabaseprojectmanager/" + files: [ + "compilationdatabaseutils.cpp", + "compilationdatabaseutils.h", + ] + } + + Group { + name: "sources from ProjectExplorer" + prefix: "../../../src/plugins/projectexplorer/" + cpp.defines: base.concat("PROJECTEXPLORER_STATIC_LIBRARY") + files: [ + "projectmacro.cpp", + "projectmacro.h", + ] + } + + Group { + name: "sources from ClangRefactoring" + prefix: "../../../src/plugins/clangrefactoring/" + files: [ + "clangqueryexamplehighlighter.cpp", + "clangqueryexamplehighlighter.h", + "clangqueryexamplehighlightmarker.h", + "clangqueryhighlighter.cpp", + "clangqueryhighlighter.h", + "clangqueryhighlightmarker.h", + "clangqueryprojectsfindfilter.cpp", + "clangqueryprojectsfindfilter.h", + "clangsymbolsfindfilter.cpp", + "clangsymbolsfindfilter.h", + "editormanagerinterface.h", + "locatorfilter.cpp", + "locatorfilter.h", + "projectpartproviderinterface.h", + "projectpartutilities.cpp", + "projectpartutilities.h", + "refactoringclient.cpp", + "refactoringclient.h", + "refactoringconnectionclient.cpp", + "refactoringconnectionclient.h", + "refactoringengine.cpp", + "refactoringengine.h", + "refactoringprojectupdater.cpp", + "refactoringprojectupdater.h", + "searchhandle.cpp", + "searchhandle.h", + "searchinterface.h", + "symbol.h", + "symbolqueryinterface.h", + ] + } + + Group { + name: "sources from ClangFormat" + prefix: "../../../src/plugins/clangformat/" + condition: libclang.present + && libclang.llvmFormattingLibs.length + && (!qbs.targetOS.contains("windows") || libclang.llvmBuildModeMatches) + files: [ + "clangformatbaseindenter.cpp", + "clangformatbaseindenter.h", + "clangformatconstants.h", + ] + } + + Group { + name: "sources from Debugger" + prefix: "../../../src/plugins/debugger/analyzer/" + cpp.defines: outer.concat("DEBUGGER_STATIC_LIBRARY") + files: [ + "diagnosticlocation.cpp", + "diagnosticlocation.h", + ] + } + + Rule { + inputs: "qt_plugin_metadata" + Artifact { + filePath: FileInfo.joinPaths(product.destinationDirectory, "CppTools.json") + fileTags: "json_copy" + } + prepare: { + var cmd = new JavaScriptCommand; + cmd.description = "copying " + input.fileName; + cmd.sourceCode = function() { File.copy(input.filePath, output.filePath); }; + return cmd; + } + } + +} |