1
#include "cmakeast_test.h"
4
#include "cmakelistsparser.h"
5
#include <astfactory.h>
7
QTEST_MAIN( CMakeAstTest )
9
void CMakeAstTest::testAddExecutableGoodParse()
11
QFETCH( CMakeFunctionDesc, function );
12
CMakeAst* ast = AstFactory::self()->createAst("add_executable");
13
QVERIFY( ast->parseFunctionInfo( function ) == true );
17
void CMakeAstTest::testAddExecutableGoodParse_data()
19
CMakeFunctionDesc func;
20
func.name = "add_executable";
22
argList << "foo" << "bar.c";
23
func.addArguments( argList );
25
CMakeFunctionDesc func2;
26
func2.name = "add_executable";
28
argList2 << "foo" << "WIN32" << "${mysrcs_SRCS}";
29
func2.addArguments( argList2 );
31
CMakeFunctionDesc func3;
32
func3.name = "ADD_EXECUTABLE";
34
argList3 << "foo" << "MACOSX_BUNDLE" << "${mysrcs_SRCS}";
35
func3.addArguments( argList3 );
37
CMakeFunctionDesc func4;
38
func4.name = "add_executable";
40
argList4 << "foo" << "EXCLUDE_FROM_ALL" << "${mysrcs_SRCS}";
41
func4.addArguments( argList4 );
43
CMakeFunctionDesc func5;
44
func5.name = "add_executable";
46
argList5 << "foo" << "WIN32" << "MACOSX_BUNDLE" << "EXCLUDE_FROM_ALL"
48
func5.addArguments( argList5 );
50
CMakeFunctionDesc func6;
51
func5.name = "add_executable";
52
QStringList argList6=QString("KDE4__kconfig_compiler IMPORTED").split(' ');
53
func5.addArguments( argList6 );
55
QTest::addColumn<CMakeFunctionDesc>( "function" );
56
QTest::newRow( "only sources" ) << func;
57
QTest::newRow( "win 32 app" ) << func2;
58
QTest::newRow( "mac os bundle" ) << func3;
59
QTest::newRow( "exclude from all" ) << func4;
60
QTest::newRow( "all" ) << func5;
63
void CMakeAstTest::testAddExecutableBadParse()
65
QFETCH( CMakeFunctionDesc, function );
66
CMakeAst* ast = AstFactory::self()->createAst("add_executable");
67
QVERIFY( ast->parseFunctionInfo( function ) == false );
71
void CMakeAstTest::testAddExecutableBadParse_data()
73
CMakeFunctionDesc func;
74
func.name = "add_executable";
77
func.addArguments( argList );
79
CMakeFunctionDesc func2;
80
func2.name = "addexecutable";
82
argList2 << "foo" << "${mysrcs_SRCS}";
83
func2.addArguments( argList2 );
85
CMakeFunctionDesc func3;
86
func3.name = "add_executable";
88
func3.addArguments( argList3 );
90
QTest::addColumn<CMakeFunctionDesc>( "function" );
91
QTest::newRow( "no sources" ) << func;
92
QTest::newRow( "wrong name" ) << func2;
93
QTest::newRow( "no arguments" ) << func3;
106
void CMakeAstTest::testAddLibraryGoodParse()
108
QFETCH( CMakeFunctionDesc, function );
109
CMakeAst* ast = AstFactory::self()->createAst("add_library");
110
QVERIFY( ast->parseFunctionInfo( function ) == true );
114
void CMakeAstTest::testAddLibraryGoodParse_data()
116
CMakeFunctionDesc func, func2, func3, func4, func5;
117
QStringList argList, argList2, argList3, argList4;
119
func.name = func2.name = func3.name = func4.name = func5.name = "add_library";
120
argList << "foo" << "${SRCS}";
121
func.addArguments( argList );
123
argList2 << "foo2" << "SHARED" << "${SRCS}";
124
func2.addArguments( argList2 );
126
argList3 << "foo3" << "EXCLUDE_FROM_ALL" << "${SRCS}";
127
func3.addArguments( argList3 );
129
argList4 << "foo4" << "MODULE" << "EXCLUDE_FROM_ALL" << "foo.c" << "bar.c" << "baz.c";
130
func4.addArguments( argList4 );
132
func5.addArguments( QString("krossui SHARED IMPORTED").split(' ') );
134
QTest::addColumn<CMakeFunctionDesc>( "function" );
135
QTest::newRow( "simple" ) << func;
136
QTest::newRow( "shared" ) << func2;
137
QTest::newRow( "exclude" ) << func3;
138
QTest::newRow( "full" ) << func4;
139
QTest::newRow( "imported" ) << func5;
142
void CMakeAstTest::testAddLibraryBadParse()
144
QFETCH( CMakeFunctionDesc, function );
145
CMakeAst* ast = AstFactory::self()->createAst("add_library");
146
QVERIFY( ast->parseFunctionInfo( function ) == false );
150
void CMakeAstTest::testAddLibraryBadParse_data()
152
CMakeFunctionDesc func, func2, func3;
153
QStringList argList, argList2, argList3;
155
func.name = func2.name = func3.name = "add_library";
156
func.name = "wrong_name";
157
argList << "foo" << "${SRCS}";
158
func.addArguments( argList );
160
func2.addArguments( argList2 );
162
argList3 << "no-sources" << "EXCLUDE_FROM_ALL";
163
func3.addArguments( argList3 );
165
QTest::addColumn<CMakeFunctionDesc>( "function" );
166
QTest::newRow( "wrong name" ) << func;
167
QTest::newRow( "no args" ) << func2;
168
QTest::newRow( "no sources" ) << func3;
179
void CMakeAstTest::testAddSubdirectoryGoodParse()
181
QFETCH( CMakeFunctionDesc, function );
182
CMakeAst* ast = AstFactory::self()->createAst("add_subdirectory");
183
QVERIFY( ast->parseFunctionInfo( function ) == true );
187
void CMakeAstTest::testAddSubdirectoryGoodParse_data()
189
CMakeFunctionDesc func, func2, func3, func4;
190
func.name = "ADD_SUBDIRECTORY";
191
func.addArguments( QStringList( "foodir" ) );
193
func2.name = "add_subdirectory";
194
func2.addArguments( QStringList( "foodir" ) );
196
func3.name = "add_subdirectory";
197
QStringList argList3;
198
argList3 << "foodir" << "binary_foo_dir" << "EXCLUDE_FROM_ALL";
199
func3.addArguments( argList3 );
201
func4.name = "add_subdirectory";
202
QStringList argList4;
203
argList4 << "foodri" << "binary_foo_dir";
204
func4.addArguments( argList4 );
206
QTest::addColumn<CMakeFunctionDesc>( "function" );
207
QTest::newRow( "good lowercase" ) << func;
208
QTest::newRow( "good uppercase" ) << func2;
209
QTest::newRow( "good all args" ) << func3;
210
QTest::newRow( "good binary dir only" ) << func4;
213
void CMakeAstTest::testAddSubdirectoryBadParse()
215
QFETCH( CMakeFunctionDesc, function );
216
CMakeAst* ast = AstFactory::self()->createAst("add_subdirectory");
217
QVERIFY( ast->parseFunctionInfo( function ) == false );
221
void CMakeAstTest::testAddSubdirectoryBadParse_data()
223
CMakeFunctionDesc func, func2;
224
func.name = "ADD_SUBDIRECTORY";
225
func2.name = "foobar";
227
func2.addArguments( QStringList( "foodir" ) );
229
QTest::addColumn<CMakeFunctionDesc>( "function" );
230
QTest::newRow( "good lowercase" ) << func;
231
QTest::newRow( "good uppercase" ) << func2;
234
void CMakeAstTest::testAddTestGoodParse()
236
QFETCH( CMakeFunctionDesc, function );
237
CMakeAst* ast = AstFactory::self()->createAst("add_test");
238
QVERIFY( ast->parseFunctionInfo( function ) == true );
242
void CMakeAstTest::testAddTestGoodParse_data()
244
CMakeFunctionDesc func1, func2;
245
func1.name = "ADD_TEST";
246
func2.name = "add_test";
248
QStringList argList1, argList2;
249
argList1 << "test_name" << "exec_name";
250
argList2 << "test_name" << "exec_name" << "arg1";
252
func1.addArguments( argList1 );
253
func2.addArguments( argList2 );
255
QTest::addColumn<CMakeFunctionDesc>( "function" );
256
QTest::newRow( "good req args" ) << func1;
257
QTest::newRow( "good opt args" ) << func2;
260
void CMakeAstTest::testAddTestBadParse()
262
QFETCH( CMakeFunctionDesc, function );
263
CMakeAst* ast = AstFactory::self()->createAst("add_test");
264
QVERIFY( ast->parseFunctionInfo( function ) == false );
268
void CMakeAstTest::testAddTestBadParse_data()
270
CMakeFunctionDesc func1, func2, func3;
271
func1.name = "wrong_name";
272
func2.name = func3.name = "add_test";
274
QStringList argList1, argList2, argList3;
275
argList1 << "some" << "args";
276
argList2 << "one arg";
278
func1.addArguments( argList1 );
279
func2.addArguments( argList2 );
280
func3.addArguments( argList3 );
282
QTest::addColumn<CMakeFunctionDesc>( "function" );
283
QTest::newRow( "wrong name" ) << func1;
284
QTest::newRow( "not enough args" ) << func2;
285
QTest::newRow( "no args" ) << func3;
298
void CMakeAstTest::testAuxSourceDirectoryGoodParse()
300
QFETCH( CMakeFunctionDesc, function );
301
CMakeAst* ast = AstFactory::self()->createAst("aux_source_directory");
302
QVERIFY( ast->parseFunctionInfo( function ) == true );
306
void CMakeAstTest::testAuxSourceDirectoryGoodParse_data()
308
CMakeFunctionDesc func1, func2;
309
func1.name = "AUX_SOURCE_DIRECTORY";
310
func2.name = "aux_source_directory";
313
argList << "foo1" << "foo2";
315
func1.addArguments( argList );
316
func2.addArguments( argList );
318
QTest::addColumn<CMakeFunctionDesc>( "function" );
319
QTest::newRow( "good uppercase" ) << func1;
320
QTest::newRow( "good lowercase" ) << func2;
323
void CMakeAstTest::testAuxSourceDirectoryBadParse()
325
QFETCH( CMakeFunctionDesc, function );
326
CMakeAst* ast = AstFactory::self()->createAst("aux_source_directory");
327
QVERIFY( ast->parseFunctionInfo( function ) == false );
331
void CMakeAstTest::testAuxSourceDirectoryBadParse_data()
333
CMakeFunctionDesc func1, func2;
334
func1.name = "AUX_SOURCE_DIRECTORY";
335
func2.name = "wrong name";
338
argList << "foo1" << "foo2";
340
func2.addArguments( argList );
342
QTest::addColumn<CMakeFunctionDesc>( "function" );
343
QTest::newRow( "bad no args" ) << func1;
344
QTest::newRow( "bad wrong name" ) << func2;
347
void CMakeAstTest::testBreakGoodParse()
349
QFETCH( CMakeFunctionDesc, function );
350
CMakeAst* ast = AstFactory::self()->createAst("break");
351
QVERIFY( ast->parseFunctionInfo( function ) == true );
355
void CMakeAstTest::testBreakGoodParse_data()
357
CMakeFunctionDesc func1, func2;
358
func1.name = "break";
360
func2.addArguments( QStringList() );
362
QTest::addColumn<CMakeFunctionDesc>( "function" );
363
QTest::newRow( "good" ) << func1;
366
void CMakeAstTest::testBreakBadParse()
368
QFETCH( CMakeFunctionDesc, function );
369
CMakeAst* ast = AstFactory::self()->createAst("break");
370
QVERIFY( ast->parseFunctionInfo( function ) == false );
374
void CMakeAstTest::testBreakBadParse_data()
376
CMakeFunctionDesc func1, func2;
377
func1.name = "break";
378
func2.name = "wrong name";
381
argList << "foo1" << "foo2";
383
func1.addArguments( argList );
385
QTest::addColumn<CMakeFunctionDesc>( "function" );
386
QTest::newRow( "bad with args" ) << func1;
387
QTest::newRow( "bad wrong name" ) << func2;
390
void CMakeAstTest::testBuildCommandGoodParse()
392
QFETCH( CMakeFunctionDesc, function );
393
CMakeAst* ast = AstFactory::self()->createAst("build_command");
394
QVERIFY( ast->parseFunctionInfo( function ) == true );
398
void CMakeAstTest::testBuildCommandGoodParse_data()
400
CMakeFunctionDesc func1, func2;
401
func1.name = "build_command";
402
func2.name = func1.name.toUpper();
405
argList << "mybuildtool" << "my_cool_build";
406
func1.addArguments( argList );
407
func2.arguments = func1.arguments;
409
QTest::addColumn<CMakeFunctionDesc>( "function" );
410
QTest::newRow( "good lower" ) << func1;
411
QTest::newRow( "good upper" ) << func2;
414
void CMakeAstTest::testBuildCommandBadParse()
416
QFETCH( CMakeFunctionDesc, function );
417
CMakeAst* ast = AstFactory::self()->createAst("build_command");
418
QVERIFY( ast->parseFunctionInfo( function ) == false );
422
void CMakeAstTest::testBuildCommandBadParse_data()
424
CMakeFunctionDesc func1, func2, func3;
425
func1.name = "build_command";
426
func2.name = "some_other_foo";
427
func3.name = func1.name;
429
QStringList argList, argList2;
430
argList << "mymake" << "unsermake";
431
argList2 << "single argument";
432
func2.addArguments( argList );
433
func3.addArguments( argList2 );
435
QTest::addColumn<CMakeFunctionDesc>( "function" );
436
QTest::newRow( "bad no args" ) << func1;
437
QTest::newRow( "bad wrong name" ) << func2;
438
QTest::newRow( "bad not enough args" ) << func3;
450
void CMakeAstTest::testBuildNameGoodParse()
452
QFETCH( CMakeFunctionDesc, function );
453
CMakeAst* ast = AstFactory::self()->createAst("build_name");
454
QVERIFY( ast->parseFunctionInfo( function ) == true );
458
void CMakeAstTest::testBuildNameGoodParse_data()
460
CMakeFunctionDesc func1, func2;
461
func1.name = "build_name";
462
func2.name = func1.name.toUpper();
465
argList << "my_cool_build";
466
func1.addArguments( argList );
467
func2.arguments = func1.arguments;
469
QTest::addColumn<CMakeFunctionDesc>( "function" );
470
QTest::newRow( "good lower" ) << func1;
471
QTest::newRow( "good upper" ) << func2;
474
void CMakeAstTest::testBuildNameBadParse()
476
QFETCH( CMakeFunctionDesc, function );
477
CMakeAst* ast = AstFactory::self()->createAst("build_name");
478
QVERIFY( ast->parseFunctionInfo( function ) == false );
482
void CMakeAstTest::testBuildNameBadParse_data()
484
CMakeFunctionDesc func1, func2;
485
func1.name = "build_name";
486
func2.name = "wrong_func_name";
489
argList << "my_cool_build";
490
func2.arguments = func1.arguments;
492
QTest::addColumn<CMakeFunctionDesc>( "function" );
493
QTest::newRow( "bad no args" ) << func1;
494
QTest::newRow( "ban wrong name" ) << func2;
497
void CMakeAstTest::testCMakeMinimumRequiredGoodParse()
499
QFETCH( CMakeFunctionDesc, function );
500
CMakeAst* ast = AstFactory::self()->createAst("cmake_minimum_required");
501
QVERIFY( ast->parseFunctionInfo( function ) == true );
505
void CMakeAstTest::testCMakeMinimumRequiredGoodParse_data()
507
CMakeFunctionDesc func1, func2, func3;
508
func1.name = "CMAKE_MINIMUM_REQUIRED";
509
func2.name = func3.name = func1.name.toLower();
510
QStringList argList1, argList2, argList3;
512
argList1 << "VERSION" << "2.4";
514
argList2 << "FATAL_ERROR";
516
func1.addArguments( argList1 );
517
func2.addArguments( argList1 );
518
func3.addArguments( argList2 );
520
QTest::addColumn<CMakeFunctionDesc>( "function" );
521
QTest::newRow( "good upper case" ) << func1;
522
QTest::newRow( "good lower case" ) << func2;
523
QTest::newRow( "good all args" ) << func3;
526
void CMakeAstTest::testCMakeMinimumRequiredBadParse()
528
QFETCH( CMakeFunctionDesc, function );
529
CMakeAst* ast = AstFactory::self()->createAst("cmake_minimum_required");
530
QVERIFY( ast->parseFunctionInfo( function ) == false );
534
void CMakeAstTest::testCMakeMinimumRequiredBadParse_data()
536
CMakeFunctionDesc func1, func2, func3, func4;
537
func1.name = "wrong_name";
538
func2.name = func3.name = "cmake_required_version";
539
func4.name = func3.name;
540
QStringList argList1, argList2, argList3, argList4;
542
argList1 << "VERSION" << "2.4";
543
argList2 << "VERSION";
544
argList3 << "VERSION" << "FATAL_ERROR";
547
func1.addArguments( argList1 );
548
func2.addArguments( argList1 );
549
func3.addArguments( argList3 );
551
QTest::addColumn<CMakeFunctionDesc>( "function" );
552
QTest::newRow( "wrong name" ) << func1;
553
QTest::newRow( "no version number 1" ) << func2;
554
QTest::newRow( "no version number 2" ) << func3;
555
QTest::newRow( "no arguments" ) << func4;
558
void CMakeAstTest::testCMakePolicyGoodParse()
560
QFETCH( CMakeFunctionDesc, function );
561
CMakeAst* ast = AstFactory::self()->createAst("cmake_policy");
562
QVERIFY( ast->parseFunctionInfo( function ) == true );
566
void CMakeAstTest::testCMakePolicyGoodParse_data()
568
CMakeFunctionDesc func[4];
569
func[0].name = "CMAKE_POLICY";
570
func[1].name = func[2].name = func[3].name = func[0].name.toLower();
571
QStringList argList[4];
573
argList[0] << "VERSION" << "2.4";
574
argList[1] << "SET" << "CMP333" << "NEW";
576
argList[3] << "PUSH";
578
func[0].addArguments( argList[0] );
579
func[1].addArguments( argList[1] );
580
func[2].addArguments( argList[2] );
581
func[3].addArguments( argList[3] );
583
QTest::addColumn<CMakeFunctionDesc>( "function" );
584
QTest::newRow( "good version" ) << func[0];
585
QTest::newRow( "good cmpset" ) << func[1];
586
QTest::newRow( "good pop" ) << func[2];
587
QTest::newRow( "good push" ) << func[3];
590
void CMakeAstTest::testCMakePolicyBadParse()
592
QFETCH( CMakeFunctionDesc, function );
593
CMakeAst* ast = AstFactory::self()->createAst("cmake_policy");
594
QVERIFY( ast->parseFunctionInfo( function ) == false );
598
void CMakeAstTest::testCMakePolicyBadParse_data()
600
CMakeFunctionDesc func[6];
601
func[0].name = "iamwrong";
602
func[1].name = func[2].name = func[3].name = func[4].name = func[5].name = "cmake_policy";
603
QStringList argList[5];
605
argList[0] << "VERSION" << "AB";
606
argList[1] << "SET" << "CMP123" << "NOTNEW";
607
argList[2] << "POP" << "33";
608
argList[3] << "PUSH" << "44";
609
argList[4] << "BUTTERFLY" << "44";
611
func[0].addArguments( argList[0] );
612
func[1].addArguments( argList[0] );
613
func[2].addArguments( argList[1] );
614
func[3].addArguments( argList[2] );
615
func[4].addArguments( argList[3] );
616
func[5].addArguments( argList[4] );
618
QTest::addColumn<CMakeFunctionDesc>( "function" );
619
QTest::newRow( "bad name" ) << func[0];
620
QTest::newRow( "bad version" ) << func[1];
621
QTest::newRow( "bad cmpset" ) << func[2];
622
QTest::newRow( "bad pop" ) << func[3];
623
QTest::newRow( "bad push" ) << func[4];
624
QTest::newRow( "bad parameter" ) << func[4];
628
void CMakeAstTest::testConfigureFileGoodParse()
630
QFETCH( CMakeFunctionDesc, function );
631
CMakeAst* ast = AstFactory::self()->createAst("configure_file");
632
QVERIFY( ast->parseFunctionInfo( function ) == true );
636
void CMakeAstTest::testConfigureFileGoodParse_data()
638
CMakeFunctionDesc func1, func2, func3, func4, func5;
639
func1.name = "CONFIGURE_FILE";
640
func2.name = func1.name.toLower();
641
func3.name = func4.name = func5.name = func2.name;
643
QStringList argList1, argList2, argList3, argList4;
644
argList1 << "inputfile" << "outputfile";
645
argList2 = argList1 << "COPYONLY";
646
argList3 = argList2 << "ESCAPE_QUOTES";
647
argList4 = argList3 << "@ONLY";
649
func1.addArguments( argList1 );
650
func2.addArguments( argList1 );
651
func3.addArguments( argList2 );
652
func4.addArguments( argList3 );
653
func5.addArguments( argList4 );
655
QTest::addColumn<CMakeFunctionDesc>( "function" );
656
QTest::newRow( "good uppercase min args" ) << func1;
657
QTest::newRow( "good lowercase min args" ) << func2;
658
QTest::newRow( "good lowercase 3 args" ) << func3;
659
QTest::newRow( "good lowercase 4 args" ) << func4;
660
QTest::newRow( "good lowercase 5 args" ) << func5;
663
void CMakeAstTest::testConfigureFileBadParse()
665
QFETCH( CMakeFunctionDesc, function );
666
CMakeAst* ast = AstFactory::self()->createAst("configure_file");
667
QVERIFY( ast->parseFunctionInfo( function ) == false );
671
void CMakeAstTest::testConfigureFileBadParse_data()
673
CMakeFunctionDesc func1, func2, func3;
674
func1.name = "wrong_func_name";
675
func2.name = func3.name = "configure_file";
677
QStringList argList1, argList2, argList3;
678
argList1 << "sourcefile" << "outputfile";
679
argList2 << "only_one";
681
func1.addArguments( argList1 );
682
func2.addArguments( argList2 );
683
func3.addArguments( argList3 );
685
QTest::addColumn<CMakeFunctionDesc>( "function" );
686
QTest::newRow( "bad wrong name" ) << func1;
687
QTest::newRow( "bad only one arg" ) << func2;
688
QTest::newRow( "bad no args" ) << func3;
691
void CMakeAstTest::testCreateTestSourcelistGoodParse()
693
QFETCH( CMakeFunctionDesc, function );
694
CMakeAst* ast = AstFactory::self()->createAst("create_test_sourcelist");
695
QVERIFY( ast->parseFunctionInfo( function ) == true );
699
void CMakeAstTest::testCreateTestSourcelistGoodParse_data()
701
CMakeFunctionDesc func1, func2, func3, func4;
702
func1.name = "create_test_sourcelist";
703
func2.name = func1.name;
704
func3.name = func2.name.toUpper();
705
func4.name = func3.name;
707
QStringList argList1, argList2, argList3, argList4;
708
argList1 << "$(TESTDRIVER_SRCS)" << "test_driver" << "$(TEST_SRCS)";
710
argList2 << "EXTRA_INCLUDE" << "include.h";
712
argList3 << "FUNCTION" << "function";
714
argList4 << "EXTRA_INCLUDE" << "include.h";
715
argList4 << "FUNCTION" << "function";
717
func1.addArguments( argList1 );
718
func2.addArguments( argList2 );
719
func3.addArguments( argList3 );
720
func4.addArguments( argList4 );
722
QTest::addColumn<CMakeFunctionDesc>( "function" );
723
QTest::newRow( "good min lower case" ) << func1;
724
QTest::newRow( "good lower case extra include" ) << func2;
725
QTest::newRow( "good upper extra function" ) << func3;
726
QTest::newRow( "good upper all args" ) << func4;
729
void CMakeAstTest::testCreateTestSourcelistBadParse()
731
QFETCH( CMakeFunctionDesc, function );
732
CMakeAst* ast = AstFactory::self()->createAst("create_test_sourcelist");
733
QVERIFY( ast->parseFunctionInfo( function ) == false );
737
void CMakeAstTest::testCreateTestSourcelistBadParse_data()
739
CMakeFunctionDesc func1, func2, func3, func4;
740
func1.name = "create_test_sourcelists";
741
func2.name = "create_test_sourcelist";
742
func3.name = func2.name.toUpper();
743
func4.name = func3.name;
745
QStringList argList1, argList2, argList3, argList4;
746
argList1 << "$(TESTDRIVER_SRCS) test_driver $(TEST_SRCS)";
748
argList2 << "EXTRA_INCLUDE";
750
argList3 << "FUNCTION";
751
argList4 << "foo bar";
753
func1.addArguments( argList1 );
754
func2.addArguments( argList2 );
755
func3.addArguments( argList3 );
756
func4.addArguments( argList4 );
758
QTest::addColumn<CMakeFunctionDesc>( "function" );
759
QTest::newRow( "bad name lower case" ) << func1;
760
QTest::newRow( "bad extra include not enough args" ) << func2;
761
QTest::newRow( "bad extra function not enough args" ) << func3;
762
QTest::newRow( "bad upper need at least 3 args" ) << func4;
774
void CMakeAstTest::testEnableLanguageGoodParse()
776
QFETCH( CMakeFunctionDesc, function );
777
CMakeAst* ast = AstFactory::self()->createAst("enable_language");
778
QVERIFY( ast->parseFunctionInfo( function ) == true );
782
void CMakeAstTest::testEnableLanguageGoodParse_data()
784
CMakeFunctionDesc func1, func2;
785
func1.name = "ENABLE_LANGUAGE";
786
func2.name = "enable_language";
788
QStringList argList1, argList2;
792
func1.addArguments( argList1 );
793
func2.addArguments( argList2 );
795
QTest::addColumn<CMakeFunctionDesc>( "function" );
796
QTest::newRow( "good uppercase" ) << func1;
797
QTest::newRow( "good lowercase" ) << func2;
800
void CMakeAstTest::testEnableLanguageBadParse()
802
QFETCH( CMakeFunctionDesc, function );
803
CMakeAst* ast = AstFactory::self()->createAst("enable_language");
804
QVERIFY( ast->parseFunctionInfo( function ) == false );
808
void CMakeAstTest::testEnableLanguageBadParse_data()
810
CMakeFunctionDesc func1, func2;
811
func1.name = "ENABLE_LANGUAGES";
812
func2.name = "enable_language";
814
QStringList argList1, argList2;
817
func1.addArguments( argList1 );
818
func2.addArguments( argList2 );
820
QTest::addColumn<CMakeFunctionDesc>( "function" );
821
QTest::newRow( "bad uppercase" ) << func1;
822
QTest::newRow( "bad lowercase. no param" ) << func2;
834
void CMakeAstTest::testEnableTestingGoodParse()
836
QFETCH( CMakeFunctionDesc, function );
837
CMakeAst* ast = AstFactory::self()->createAst("enable_testing");
838
QVERIFY( ast->parseFunctionInfo( function ) == true );
842
void CMakeAstTest::testEnableTestingGoodParse_data()
844
CMakeFunctionDesc func1, func2;
845
func1.name = "ENABLE_TESTING";
846
func2.name = "enable_testing";
848
QTest::addColumn<CMakeFunctionDesc>( "function" );
849
QTest::newRow( "good upper" ) << func1;
850
QTest::newRow( "good lower" ) << func2;
854
void CMakeAstTest::testEnableTestingBadParse()
856
QFETCH( CMakeFunctionDesc, function );
857
CMakeAst* ast = AstFactory::self()->createAst("enable_testing");
858
QVERIFY( ast->parseFunctionInfo( function ) == false );
862
void CMakeAstTest::testEnableTestingBadParse_data()
864
CMakeFunctionDesc func1, func2;
865
func1.name = "bad_func_name";
866
func2.name = "enable_testing";
871
func2.addArguments( argList );
873
QTest::addColumn<CMakeFunctionDesc>( "function" );
874
QTest::newRow( "bad wrong name" ) << func1;
875
QTest::newRow( "bad has args" ) << func2;
888
void CMakeAstTest::testExecProgramGoodParse()
890
QFETCH( CMakeFunctionDesc, function );
891
CMakeAst* ast = AstFactory::self()->createAst("exec_program");
892
QVERIFY( ast->parseFunctionInfo( function ) == true );
896
void CMakeAstTest::testExecProgramGoodParse_data()
898
CMakeFunctionDesc func1, func2, func3, func4;
899
func1.name = "exec_program";
900
func2.name = func1.name.toUpper();
901
func3.name = func4.name = func1.name;
903
QStringList argList1, argList2, argList3, argList4;
904
argList1 << "myExec";
906
argList2 << "myRunDir";
908
argList3 << "ARGS" << "arg1" << "arg2";
910
argList4 << "RETURN_VALUE" << "myReturnVar";
912
func1.addArguments( argList1 );
913
func2.addArguments( argList2 );
914
func3.addArguments( argList3 );
915
func4.addArguments( argList4 );
917
QTest::addColumn<CMakeFunctionDesc>( "function" );
918
QTest::newRow( "good 1" ) << func1;
919
QTest::newRow( "good 2" ) << func2;
920
QTest::newRow( "good 3" ) << func3;
921
QTest::newRow( "good 4" ) << func4;
925
void CMakeAstTest::testExecProgramBadParse()
927
QFETCH( CMakeFunctionDesc, function );
928
CMakeAst* ast = AstFactory::self()->createAst("exec_program");
929
QVERIFY( ast->parseFunctionInfo( function ) == false );
933
void CMakeAstTest::testExecProgramBadParse_data()
935
CMakeFunctionDesc func1, func2;
936
func1.name = "wrong_name_here";
937
func2.name = "exec_program";
939
QStringList argList1;
940
argList1 << "myExec";
942
func1.addArguments( argList1 );
944
QTest::addColumn<CMakeFunctionDesc>( "function" );
945
QTest::newRow( "bad 1" ) << func1;
946
QTest::newRow( "bad 2" ) << func2;
956
#define TDD_TODO QSKIP("No data available yet", SkipSingle)
957
#define TDD_TOIMPL QSKIP("Command not implemented yet", SkipSingle)
959
void CMakeAstTest::testExecuteProcessGoodParse()
962
QFETCH( CMakeFunctionDesc, function );
963
CMakeAst* ast = AstFactory::self()->createAst("execute_process");
964
QVERIFY( ast->parseFunctionInfo( function ) == true );
968
void CMakeAstTest::testExecuteProcessGoodParse_data()
972
void CMakeAstTest::testExecuteProcessBadParse()
975
QFETCH( CMakeFunctionDesc, function );
976
CMakeAst* ast = AstFactory::self()->createAst("execute_process");
977
QVERIFY( ast->parseFunctionInfo( function ) == false );
981
void CMakeAstTest::testExecuteProcessBadParse_data()
985
void CMakeAstTest::testExportGoodParse()
988
QFETCH( CMakeFunctionDesc, function );
989
CMakeAst* ast = AstFactory::self()->createAst("export");
990
QVERIFY( ast->parseFunctionInfo( function ) == true );
994
void CMakeAstTest::testExportGoodParse_data()
998
void CMakeAstTest::testExportBadParse()
1001
QFETCH( CMakeFunctionDesc, function );
1002
CMakeAst* ast = AstFactory::self()->createAst("export");
1003
QVERIFY( ast->parseFunctionInfo( function ) == false );
1007
void CMakeAstTest::testExportBadParse_data()
1020
void CMakeAstTest::testExportLibraryDepsGoodParse()
1022
QFETCH( CMakeFunctionDesc, function );
1023
CMakeAst* ast = AstFactory::self()->createAst("export_library_dependencies");
1024
QVERIFY( ast->parseFunctionInfo( function ) == true );
1028
void CMakeAstTest::testExportLibraryDepsGoodParse_data()
1030
CMakeFunctionDesc func1, func2;
1031
func1.name = func2.name = "export_library_dependencies";
1033
QStringList argList1, argList2;
1034
argList1 << "dep_file";
1035
argList2 = argList1;
1036
argList2 << "APPEND";
1038
func1.addArguments( argList1 );
1039
func2.addArguments( argList2 );
1041
QTest::addColumn<CMakeFunctionDesc>( "function" );
1042
QTest::newRow( "good 1" ) << func1;
1043
QTest::newRow( "good 2" ) << func2;
1046
void CMakeAstTest::testExportLibraryDepsBadParse()
1048
QFETCH( CMakeFunctionDesc, function );
1049
CMakeAst* ast = AstFactory::self()->createAst("export_library_dependencies");
1050
QVERIFY( ast->parseFunctionInfo( function ) == false );
1054
void CMakeAstTest::testExportLibraryDepsBadParse_data()
1056
CMakeFunctionDesc func1, func2;
1057
func1.name = "export_library_dependencies";
1058
func2.name = "foo_foo_bar";
1060
QStringList argList1, argList2;
1061
argList1 << "dep_file" << "lalala";
1062
argList2 << "dep_file";
1064
func1.addArguments( argList1 );
1065
func2.addArguments( argList2 );
1067
QTest::addColumn<CMakeFunctionDesc>( "function" );
1068
QTest::newRow( "bad 1" ) << func1;
1069
QTest::newRow( "bad 2" ) << func2;
1081
void CMakeAstTest::testFileGoodParse()
1083
QFETCH( CMakeFunctionDesc, function );
1084
CMakeAst* ast = AstFactory::self()->createAst("file");
1085
QVERIFY( ast->parseFunctionInfo( function ) == true );
1089
void CMakeAstTest::testFileGoodParse_data()
1091
const int NUM_TESTDATA = 13;
1092
CMakeFunctionDesc funcs[NUM_TESTDATA];
1093
QStringList args[NUM_TESTDATA];
1095
for ( int i = 0; i < NUM_TESTDATA; i++ )
1096
funcs[i].name = "FILE";
1098
//write file command
1099
args[0] << "WRITE" << "somefile.cpp" << "\"the things to write\"";
1101
//append file command
1102
args[1] << "APPEND" << "somefile.cpp" << "\"the things to append\"";
1105
args[2] << "READ" << "somefile.cpp" << "MY_VAR";
1107
//glob files command. does not search in files only for a pattern
1108
args[3] << "GLOB" << "MY_VAR" << "*.cpp";
1109
args[4] << "GLOB" << "MY_VAR" << "RELATIVE" << "/path/to/something"
1110
<< "*.cpp"; //RELATIVE is optional
1113
args[5] << "GLOB_RECURSE" << "MY_VAR" << "*.cpp";
1114
args[6] << "GLOB_RECURSE" << "MY_VAR" << "RELATIVE" << "/path/to/something"
1115
<< "*.cpp"; //RELATIVE is optional
1118
args[7] << "REMOVE" << "/path/to/file/to/remove.cpp";
1121
args[8] << "REMOVE_RECURSE" << "/path/to/dir/to/remove/files";
1124
args[9] << "MAKE_DIRECTORY" << "/path/to/dir/to/create";
1126
//get a relative path
1127
args[10] << "RELATIVE_PATH" << "MY_VAR" << "/path/to/foo"
1128
<< "/path/to/file/to/get/path/for.cpp";
1130
//get the cmake native path
1131
args[11] << "TO_CMAKE_PATH" << "/path/to/file.cpp" << "MY_CMAKE_PATH";
1133
//get the platform native path
1134
args[12] << "TO_NATIVE_PATH" << "/path/to/file.cpp" << "MY_NATIVE_PATH";
1137
QTest::addColumn<CMakeFunctionDesc>( "function" );
1139
for ( int i = 0; i < NUM_TESTDATA; i++)
1141
funcs[i].addArguments( args[i] );
1142
QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
1147
void CMakeAstTest::testFileBadParse()
1149
QFETCH( CMakeFunctionDesc, function );
1150
CMakeAst* ast = AstFactory::self()->createAst("file");
1151
QVERIFY( ast->parseFunctionInfo( function ) == false );
1155
void CMakeAstTest::testFileBadParse_data()
1158
const int NUM_TESTDATA = 35;
1159
CMakeFunctionDesc funcs[NUM_TESTDATA];
1160
QStringList args[NUM_TESTDATA];
1162
for ( int i = 0; i < NUM_TESTDATA; i++ )
1163
funcs[i].name = "FILE";
1165
funcs[NUM_TESTDATA - 1].name = "foo";
1167
//write file command
1168
args[0] << "WRITE" << "somefile.cpp"; //nothing to write
1169
args[1] << "WRITE"; //no file
1170
args[2] << "write" << "somefile.cpp" << "thing to write"; //uppercase required
1172
//append file command
1173
args[3] << "APPEND" << "somefile.cpp"; //nothing to append
1174
args[4] << "APPEND"; //no file
1175
args[5] << "append" << "somefile.cpp" << "thing to append"; //uppercase required
1178
args[6] << "READ" << "somefile.cpp"; //no variable
1179
args[7] << "READ"; //no file
1180
args[8] << "read" << "somefile.cpp" << "MY_VAR"; //uppercase required
1182
//glob files command. does not search in files only for a pattern
1183
args[9] << "GLOB"; //no variable
1184
args[10] << "GLOB" << "MY_VAR" << "RELATIVE"; //no path
1186
args[11] << "glob" << "MY_VAR" << "*.cpp"; //uppercase required
1189
args[13] << "GLOB_RECURSE"; //no variable
1190
args[14] << "GLOB_RECURSE" << "MY_VAR" << "RELATIVE"; //no path
1192
args[15] << "glob_recurse" << "MY_VAR" << "*.cpp"; //uppercase required
1195
args[17] << "REMOVE"; //nothing to remove
1196
args[18] << "remove" << "/path/to/file/to/remove.cpp";
1199
args[19] << "REMOVE_RECURSE"; //nothing to remove
1200
args[20] << "remove_recurse" << "/path/to/dir"; //uppercase required
1203
args[21] << "MAKE_DIRECTORY"; //nothing to create
1204
args[22] << "make_directory" << "/path/to/dir"; //uppercase required
1206
//get a relative path
1207
args[23] << "RELATIVE_PATH" << "MY_VAR" << "/path/to/foo"; //no file
1208
args[24] << "RELATIVE_PATH" << "MY_VAR"; //no path and no file
1209
args[25] << "RELATIVE_PATH"; //no variable, path, or file
1210
args[26] << "relative_path" << "MY_VAR" << "/path/to/foo"
1211
<< "/path/to/file/to/get/full/path/for.cpp"; // uppercase required
1213
//get the cmake native path
1214
args[27] << "TO_CMAKE_PATH" << "/path/to/file.cpp"; // no variable
1215
args[28] << "TO_CMAKE_PATH"; //no path or variable
1216
args[29] << "to_cmake_path" << "/path/to/file.cpp" << "MY_VAR"; //uppercase required
1218
//get the platform native path
1219
args[30] << "TO_NATIVE_PATH" << "/path/to/file.cpp"; //no variable
1220
args[31] << "TO_NATIVE_PATH"; //no path or variable
1221
args[32] << "to_native_path" << "/path/to/file.cpp" << "MY_VAR"; //uppercase required
1223
args[34] << "TO_NATIVE_PATH" << "/path/to/file.cpp" << "MY_VAR"; //correct args. wrong name
1225
QTest::addColumn<CMakeFunctionDesc>( "function" );
1227
for ( int i = 0; i < NUM_TESTDATA; i++)
1229
funcs[i].addArguments( args[i] );
1230
QTest::newRow( qPrintable(QString("%1. %2").arg(i).arg(args[i].isEmpty() ? "?" : args[i].first())) ) << funcs[i];
1244
void CMakeAstTest::testFindFileGoodParse()
1247
QFETCH( CMakeFunctionDesc, function );
1248
CMakeAst* ast = AstFactory::self()->createAst("find_file");
1249
QVERIFY( ast->parseFunctionInfo( function ) == true );
1253
void CMakeAstTest::testFindFileGoodParse_data()
1257
void CMakeAstTest::testFindFileBadParse()
1260
QFETCH( CMakeFunctionDesc, function );
1261
CMakeAst* ast = AstFactory::self()->createAst("find_file");
1262
QVERIFY( ast->parseFunctionInfo( function ) == false );
1266
void CMakeAstTest::testFindFileBadParse_data()
1279
void CMakeAstTest::testFindLibraryGoodParse()
1281
QFETCH( CMakeFunctionDesc, function );
1282
CMakeAst* ast = AstFactory::self()->createAst("find_library");
1283
QVERIFY( ast->parseFunctionInfo( function ) == true );
1287
void CMakeAstTest::testFindLibraryGoodParse_data()
1289
QTest::addColumn<CMakeFunctionDesc>("function");
1291
CMakeFunctionDesc l;
1292
l.name = "find_library";
1293
l.addArguments(QString("DEST_VAR name").split(' '));
1294
QTest::newRow("findlib with name") << l;
1296
l.arguments.clear();
1297
l.addArguments(QString("DEST_VAR name /path/to/lib").split(' '));
1298
QTest::newRow("findlib with name and path") << l;
1301
void CMakeAstTest::testFindLibraryBadParse()
1303
QFETCH( CMakeFunctionDesc, function );
1304
CMakeAst* ast = AstFactory::self()->createAst("find_library");
1305
QVERIFY( ast->parseFunctionInfo( function ) == false );
1309
void CMakeAstTest::testFindLibraryBadParse_data()
1311
QTest::addColumn<CMakeFunctionDesc>("function");
1313
CMakeFunctionDesc l;
1315
l.addArguments(QString("DEST_VAR name").split(' '));
1316
QTest::newRow("findlib with name") << l;
1328
void CMakeAstTest::testFindPackageGoodParse()
1331
QFETCH( CMakeFunctionDesc, function );
1332
CMakeAst* ast = AstFactory::self()->createAst("find_package");
1333
QVERIFY( ast->parseFunctionInfo( function ) == true );
1337
void CMakeAstTest::testFindPackageGoodParse_data()
1341
void CMakeAstTest::testFindPackageBadParse()
1344
QFETCH( CMakeFunctionDesc, function );
1345
CMakeAst* ast = AstFactory::self()->createAst("find_package");
1346
QVERIFY( ast->parseFunctionInfo( function ) == false );
1350
void CMakeAstTest::testFindPackageBadParse_data()
1363
void CMakeAstTest::testFindPathGoodParse()
1366
QFETCH( CMakeFunctionDesc, function );
1367
CMakeAst* ast = AstFactory::self()->createAst("find_path");
1368
QVERIFY( ast->parseFunctionInfo( function ) == true );
1372
void CMakeAstTest::testFindPathGoodParse_data()
1376
void CMakeAstTest::testFindPathBadParse()
1379
QFETCH( CMakeFunctionDesc, function );
1380
CMakeAst* ast = AstFactory::self()->createAst("find_path");
1381
QVERIFY( ast->parseFunctionInfo( function ) == false );
1385
void CMakeAstTest::testFindPathBadParse_data()
1398
void CMakeAstTest::testFindProgramGoodParse()
1400
QFETCH( CMakeFunctionDesc, function );
1401
CMakeAst* ast = AstFactory::self()->createAst("find_program");
1402
QVERIFY( ast->parseFunctionInfo( function ) == true );
1406
void CMakeAstTest::testFindProgramGoodParse_data()
1408
QTest::addColumn<CMakeFunctionDesc>("function");
1410
CMakeFunctionDesc l;
1411
l.name = "find_program";
1412
l.addArguments(QStringList() << "MY_VAR" << "file" << "location");
1413
QTest::newRow("normal use") << l;
1415
l.arguments.clear();
1416
l.addArguments(QStringList() << "MY_VAR" << "NAMES" << "file1" << "file2" << "PATHS" << "location1" << "location2");
1417
QTest::newRow("advanced use") << l;
1419
l.arguments.clear();
1420
l.addArguments(QStringList() << "MY_VAR" << "NAMES" << "file1" << "file2"
1421
<< "PATHS" << "location1" << "location2" << "DOC" << "I am documenting"
1422
<< "PATH_SUFFIXES" << "modules" << "NO_CMAKE_PATH");
1423
QTest::newRow("strange use") << l;
1426
void CMakeAstTest::testFindProgramBadParse()
1428
QFETCH( CMakeFunctionDesc, function );
1429
CMakeAst* ast = AstFactory::self()->createAst("find_program");
1430
QVERIFY( ast->parseFunctionInfo( function ) == false );
1434
void CMakeAstTest::testFindProgramBadParse_data()
1437
QTest::addColumn<CMakeFunctionDesc>("function");
1439
CMakeFunctionDesc l;
1441
l.addArguments(QStringList() << "MY_VAR" << "file");
1442
QTest::newRow ("no function name") << l;
1444
l.arguments.clear();
1445
l.name = "find_program";
1446
l.addArguments(QStringList() << "MY_VAR" << "NAMES" << "PATHS" << "location1" << "location2");
1447
QTest::newRow("no names") << l;
1459
void CMakeAstTest::testFltkWrapUiGoodParse()
1462
QFETCH( CMakeFunctionDesc, function );
1463
CMakeAst* ast = AstFactory::self()->createAst("fltk_wrap_ui");
1464
QVERIFY( ast->parseFunctionInfo( function ) == true );
1468
void CMakeAstTest::testFltkWrapUiGoodParse_data()
1472
void CMakeAstTest::testFltkWrapUiBadParse()
1475
QFETCH( CMakeFunctionDesc, function );
1476
CMakeAst* ast = AstFactory::self()->createAst("fltk_wrap_ui");
1477
QVERIFY( ast->parseFunctionInfo( function ) == false );
1481
void CMakeAstTest::testFltkWrapUiBadParse_data()
1494
void CMakeAstTest::testForeachGoodParse()
1497
QFETCH( CMakeFunctionDesc, function );
1498
CMakeAst* ast = AstFactory::self()->createAst("foreach");
1499
QVERIFY( ast->parseFunctionInfo( function ) == true );
1503
void CMakeAstTest::testForeachGoodParse_data()
1507
void CMakeAstTest::testForeachBadParse()
1510
QFETCH( CMakeFunctionDesc, function );
1511
CMakeAst* ast = AstFactory::self()->createAst("foreach");
1512
QVERIFY( ast->parseFunctionInfo( function ) == false );
1516
void CMakeAstTest::testForeachBadParse_data()
1530
void CMakeAstTest::testGetCMakePropertyGoodParse()
1533
QFETCH( CMakeFunctionDesc, function );
1534
CMakeAst* ast = AstFactory::self()->createAst("get_cmake_property");
1535
QVERIFY( ast->parseFunctionInfo( function ) == true );
1539
void CMakeAstTest::testGetCMakePropertyGoodParse_data()
1543
void CMakeAstTest::testGetCMakePropertyBadParse()
1546
QFETCH( CMakeFunctionDesc, function );
1547
CMakeAst* ast = AstFactory::self()->createAst("get_cmake_property");
1548
QVERIFY( ast->parseFunctionInfo( function ) == false );
1552
void CMakeAstTest::testGetCMakePropertyBadParse_data()
1565
void CMakeAstTest::testGetDirPropertyGoodParse()
1568
QFETCH( CMakeFunctionDesc, function );
1569
CMakeAst* ast = AstFactory::self()->createAst("get_directory_property");
1570
QVERIFY( ast->parseFunctionInfo( function ) == true );
1574
void CMakeAstTest::testGetDirPropertyGoodParse_data()
1578
void CMakeAstTest::testGetDirPropertyBadParse()
1581
QFETCH( CMakeFunctionDesc, function );
1582
CMakeAst* ast = AstFactory::self()->createAst("get_directory_property");
1583
QVERIFY( ast->parseFunctionInfo( function ) == false );
1587
void CMakeAstTest::testGetDirPropertyBadParse_data()
1600
void CMakeAstTest::testGetFilenameComponentGoodParse()
1603
QFETCH( CMakeFunctionDesc, function );
1604
CMakeAst* ast = AstFactory::self()->createAst("get_filename_component");
1605
QVERIFY( ast->parseFunctionInfo( function ) == true );
1609
void CMakeAstTest::testGetFilenameComponentGoodParse_data()
1613
void CMakeAstTest::testGetFilenameComponentBadParse()
1616
QFETCH( CMakeFunctionDesc, function );
1617
CMakeAst* ast = AstFactory::self()->createAst("get_filename_component");
1618
QVERIFY( ast->parseFunctionInfo( function ) == false );
1622
void CMakeAstTest::testGetFilenameComponentBadParse_data()
1635
void CMakeAstTest::testGetSourceFilePropGoodParse()
1638
QFETCH( CMakeFunctionDesc, function );
1639
CMakeAst* ast = AstFactory::self()->createAst("get_sourcefile_property");
1640
QVERIFY( ast->parseFunctionInfo( function ) == true );
1644
void CMakeAstTest::testGetSourceFilePropGoodParse_data()
1648
void CMakeAstTest::testGetSourceFilePropBadParse()
1651
QFETCH( CMakeFunctionDesc, function );
1652
CMakeAst* ast = AstFactory::self()->createAst("get_sourcefile_property");
1653
QVERIFY( ast->parseFunctionInfo( function ) == false );
1657
void CMakeAstTest::testGetSourceFilePropBadParse_data()
1670
void CMakeAstTest::testGetTargetPropGoodParse()
1673
QFETCH( CMakeFunctionDesc, function );
1674
CMakeAst* ast = AstFactory::self()->createAst("get_target_property");
1675
QVERIFY( ast->parseFunctionInfo( function ) == true );
1679
void CMakeAstTest::testGetTargetPropGoodParse_data()
1683
void CMakeAstTest::testGetTargetPropBadParse()
1686
QFETCH( CMakeFunctionDesc, function );
1687
CMakeAst* ast = AstFactory::self()->createAst("get_target_property");
1688
QVERIFY( ast->parseFunctionInfo( function ) == false );
1692
void CMakeAstTest::testGetTargetPropBadParse_data()
1705
void CMakeAstTest::testGetTestPropGoodParse()
1708
QFETCH( CMakeFunctionDesc, function );
1709
CMakeAst* ast = AstFactory::self()->createAst("get_test_property");
1710
QVERIFY( ast->parseFunctionInfo( function ) == true );
1714
void CMakeAstTest::testGetTestPropGoodParse_data()
1718
void CMakeAstTest::testGetTestPropBadParse()
1721
QFETCH( CMakeFunctionDesc, function );
1722
CMakeAst* ast = AstFactory::self()->createAst("get_test_property");
1723
QVERIFY( ast->parseFunctionInfo( function ) == false );
1727
void CMakeAstTest::testGetTestPropBadParse_data()
1740
void CMakeAstTest::testIfGoodParse()
1743
QFETCH( CMakeFunctionDesc, function );
1744
CMakeAst* ast = AstFactory::self()->createAst("if");
1745
QVERIFY( ast->parseFunctionInfo( function ) == true );
1749
void CMakeAstTest::testIfGoodParse_data()
1753
void CMakeAstTest::testIfBadParse()
1756
QFETCH( CMakeFunctionDesc, function );
1757
CMakeAst* ast = AstFactory::self()->createAst("if");
1758
QVERIFY( ast->parseFunctionInfo( function ) == false );
1762
void CMakeAstTest::testIfBadParse_data()
1775
void CMakeAstTest::testIncludeGoodParse()
1777
QFETCH( CMakeFunctionDesc, function );
1778
CMakeAst* ast = AstFactory::self()->createAst("include");
1779
QVERIFY( ast->parseFunctionInfo( function ) == true );
1783
void CMakeAstTest::testIncludeGoodParse_data()
1785
CMakeFunctionDesc func1, func2, func3, func4, func5;
1786
func1.name = "INCLUDE";
1787
func2.name = func3.name = func4.name = func5.name = func1.name.toLower();
1789
QStringList argList1, argList2, argList3, argList4;
1790
argList1 << "SomeFile";
1791
argList2 << "SomeFile" << "OPTIONAL";
1792
argList3 << "SomeFile" << "RESULT_VARIABLE" << "output";
1793
argList4 << "SomeFile" << "OPTIONAL" << "RESULT_VARIABLE" << "output";
1795
func1.addArguments( argList1 );
1796
func2.addArguments( argList1 );
1797
func3.addArguments( argList2 );
1798
func4.addArguments( argList3 );
1799
func5.addArguments( argList4 );
1801
QTest::addColumn<CMakeFunctionDesc>( "function" );
1802
QTest::newRow( "good upper" ) << func1;
1803
QTest::newRow( "good lower" ) << func2;
1804
QTest::newRow( "good optional" ) << func3;
1805
QTest::newRow( "good result" ) << func4;
1806
QTest::newRow( "good all args" ) << func5;
1809
void CMakeAstTest::testIncludeBadParse()
1811
QFETCH( CMakeFunctionDesc, function );
1812
CMakeAst* ast = AstFactory::self()->createAst("include");
1813
QVERIFY( ast->parseFunctionInfo( function ) == false );
1817
void CMakeAstTest::testIncludeBadParse_data()
1819
CMakeFunctionDesc func1, func2;
1820
func1.name = "WrongFuncName";
1821
func2.name = "include";
1823
QStringList argList1, argList2;
1824
argList1 << "SomeFile";
1826
func1.addArguments( argList1 );
1827
func2.addArguments( argList2 );
1829
QTest::addColumn<CMakeFunctionDesc>( "function" );
1830
QTest::newRow( "bad wrong name" ) << func1;
1831
QTest::newRow( "bad no args" ) << func2;
1844
void CMakeAstTest::testIncludeDirectoriesGoodParse()
1846
QFETCH( CMakeFunctionDesc, function );
1847
CMakeAst* ast = AstFactory::self()->createAst("include_directories");
1848
QVERIFY( ast->parseFunctionInfo( function ) == true );
1852
void CMakeAstTest::testIncludeDirectoriesGoodParse_data()
1854
QTest::addColumn<CMakeFunctionDesc>("function");
1856
CMakeFunctionDesc l;
1857
l.name = "include_directories";
1858
l.addArguments(QStringList() << "../g4u");
1859
QTest::newRow("a normal include_directories") << l;
1861
l.arguments.clear();
1862
l.addArguments(QStringList() << "AFTER" << "boost/");
1863
QTest::newRow("a include_directories with AFTER parameter") << l;
1865
l.arguments.clear();
1866
l.addArguments(QStringList() << "SYSTEM" << "~/kdelibs");
1867
QTest::newRow("a include_directories with SYSTEM paremeter") << l;
1870
void CMakeAstTest::testIncludeDirectoriesBadParse()
1872
QFETCH( CMakeFunctionDesc, function );
1873
CMakeAst* ast = AstFactory::self()->createAst("include_directories");
1874
QVERIFY( ast->parseFunctionInfo( function ) == false );
1878
void CMakeAstTest::testIncludeDirectoriesBadParse_data()
1880
QTest::addColumn<CMakeFunctionDesc>("function");
1882
CMakeFunctionDesc l;
1883
l.name = "include_directories";
1884
l.addArguments(QStringList() << "AFTER" << "BEFORE" << "lol");
1885
QTest::newRow("can't have after and before in include_directories") << l;
1897
void CMakeAstTest::testIncludeExternalMsProjectGoodParse()
1900
QFETCH( CMakeFunctionDesc, function );
1901
CMakeAst* ast = AstFactory::self()->createAst("include_external_msproject");
1902
QVERIFY( ast->parseFunctionInfo( function ) == true );
1906
void CMakeAstTest::testIncludeExternalMsProjectGoodParse_data()
1910
void CMakeAstTest::testIncludeExternalMsProjectBadParse()
1913
QFETCH( CMakeFunctionDesc, function );
1914
CMakeAst* ast = AstFactory::self()->createAst("include_external_msproject");
1915
QVERIFY( ast->parseFunctionInfo( function ) == false );
1919
void CMakeAstTest::testIncludeExternalMsProjectBadParse_data()
1932
void CMakeAstTest::testIncludeRegularExpressionGoodParse()
1935
QFETCH( CMakeFunctionDesc, function );
1936
CMakeAst* ast = AstFactory::self()->createAst("include_regular_expression");
1937
QVERIFY( ast->parseFunctionInfo( function ) == true );
1941
void CMakeAstTest::testIncludeRegularExpressionGoodParse_data()
1945
void CMakeAstTest::testIncludeRegularExpressionBadParse()
1948
QFETCH( CMakeFunctionDesc, function );
1949
CMakeAst* ast = AstFactory::self()->createAst("include_regular_expression");
1950
QVERIFY( ast->parseFunctionInfo( function ) == false );
1954
void CMakeAstTest::testIncludeRegularExpressionBadParse_data()
1967
void CMakeAstTest::testInstallGoodParse()
1970
QFETCH( CMakeFunctionDesc, function );
1971
CMakeAst* ast = AstFactory::self()->createAst("install");
1972
QVERIFY( ast->parseFunctionInfo( function ) == true );
1976
void CMakeAstTest::testInstallGoodParse_data()
1980
void CMakeAstTest::testInstallBadParse()
1983
QFETCH( CMakeFunctionDesc, function );
1984
CMakeAst* ast = AstFactory::self()->createAst("install");
1985
QVERIFY( ast->parseFunctionInfo( function ) == false );
1989
void CMakeAstTest::testInstallBadParse_data()
2002
void CMakeAstTest::testInstallFilesGoodParse()
2005
QFETCH( CMakeFunctionDesc, function );
2006
CMakeAst* ast = AstFactory::self()->createAst("install_files");
2007
QVERIFY( ast->parseFunctionInfo( function ) == true );
2011
void CMakeAstTest::testInstallFilesGoodParse_data()
2015
void CMakeAstTest::testInstallFilesBadParse()
2018
QFETCH( CMakeFunctionDesc, function );
2019
CMakeAst* ast = AstFactory::self()->createAst("install_files");
2020
QVERIFY( ast->parseFunctionInfo( function ) == false );
2024
void CMakeAstTest::testInstallFilesBadParse_data()
2037
void CMakeAstTest::testInstallProgramsGoodParse()
2040
QFETCH( CMakeFunctionDesc, function );
2041
CMakeAst* ast = AstFactory::self()->createAst("install_programs");
2042
QVERIFY( ast->parseFunctionInfo( function ) == true );
2046
void CMakeAstTest::testInstallProgramsGoodParse_data()
2050
void CMakeAstTest::testInstallProgramsBadParse()
2053
QFETCH( CMakeFunctionDesc, function );
2054
CMakeAst* ast = AstFactory::self()->createAst("install_programs");
2055
QVERIFY( ast->parseFunctionInfo( function ) == false );
2059
void CMakeAstTest::testInstallProgramsBadParse_data()
2072
void CMakeAstTest::testInstallTargetsGoodParse()
2075
QFETCH( CMakeFunctionDesc, function );
2076
CMakeAst* ast = AstFactory::self()->createAst("install_targets");
2077
QVERIFY( ast->parseFunctionInfo( function ) == true );
2081
void CMakeAstTest::testInstallTargetsGoodParse_data()
2085
void CMakeAstTest::testInstallTargetsBadParse()
2088
QFETCH( CMakeFunctionDesc, function );
2089
CMakeAst* ast = AstFactory::self()->createAst("install_targets");
2090
QVERIFY( ast->parseFunctionInfo( function ) == false );
2094
void CMakeAstTest::testInstallTargetsBadParse_data()
2107
void CMakeAstTest::testLinkDirectoriesGoodParse()
2110
QFETCH( CMakeFunctionDesc, function );
2111
CMakeAst* ast = AstFactory::self()->createAst("link_directories");
2112
QVERIFY( ast->parseFunctionInfo( function ) == true );
2116
void CMakeAstTest::testLinkDirectoriesGoodParse_data()
2120
void CMakeAstTest::testLinkDirectoriesBadParse()
2123
QFETCH( CMakeFunctionDesc, function );
2124
CMakeAst* ast = AstFactory::self()->createAst("link_directories");
2125
QVERIFY( ast->parseFunctionInfo( function ) == false );
2129
void CMakeAstTest::testLinkDirectoriesBadParse_data()
2142
void CMakeAstTest::testLinkLibrariesGoodParse()
2145
QFETCH( CMakeFunctionDesc, function );
2146
CMakeAst* ast = AstFactory::self()->createAst("link_libraries");
2147
QVERIFY( ast->parseFunctionInfo( function ) == true );
2151
void CMakeAstTest::testLinkLibrariesGoodParse_data()
2155
void CMakeAstTest::testLinkLibrariesBadParse()
2158
QFETCH( CMakeFunctionDesc, function );
2159
CMakeAst* ast = AstFactory::self()->createAst("link_libraries");
2160
QVERIFY( ast->parseFunctionInfo( function ) == false );
2164
void CMakeAstTest::testLinkLibrariesBadParse_data()
2177
void CMakeAstTest::testListGoodParse()
2180
QFETCH( CMakeFunctionDesc, function );
2181
CMakeAst* ast = AstFactory::self()->createAst("list");
2182
QVERIFY( ast->parseFunctionInfo( function ) == true );
2186
void CMakeAstTest::testListGoodParse_data()
2190
void CMakeAstTest::testListBadParse()
2193
QFETCH( CMakeFunctionDesc, function );
2194
CMakeAst* ast = AstFactory::self()->createAst("list");
2195
QVERIFY( ast->parseFunctionInfo( function ) == false );
2199
void CMakeAstTest::testListBadParse_data()
2212
void CMakeAstTest::testLoadCacheGoodParse()
2215
QFETCH( CMakeFunctionDesc, function );
2216
CMakeAst* ast = AstFactory::self()->createAst("load_cache");
2217
QVERIFY( ast->parseFunctionInfo( function ) == true );
2221
void CMakeAstTest::testLoadCacheGoodParse_data()
2225
void CMakeAstTest::testLoadCacheBadParse()
2228
QFETCH( CMakeFunctionDesc, function );
2229
CMakeAst* ast = AstFactory::self()->createAst("load_cache");
2230
QVERIFY( ast->parseFunctionInfo( function ) == false );
2234
void CMakeAstTest::testLoadCacheBadParse_data()
2247
void CMakeAstTest::testLoadCommandGoodParse()
2250
QFETCH( CMakeFunctionDesc, function );
2251
CMakeAst* ast = AstFactory::self()->createAst("load_command");
2252
QVERIFY( ast->parseFunctionInfo( function ) == true );
2256
void CMakeAstTest::testLoadCommandGoodParse_data()
2260
void CMakeAstTest::testLoadCommandBadParse()
2263
QFETCH( CMakeFunctionDesc, function );
2264
CMakeAst* ast = AstFactory::self()->createAst("load_command");
2265
QVERIFY( ast->parseFunctionInfo( function ) == false );
2269
void CMakeAstTest::testLoadCommandBadParse_data()
2282
void CMakeAstTest::testMacroGoodParse()
2284
QFETCH( CMakeFunctionDesc, function );
2285
CMakeAst* ast = AstFactory::self()->createAst("macro");
2286
QVERIFY( ast->parseFunctionInfo( function ) == true );
2290
void CMakeAstTest::testMacroGoodParse_data()
2292
CMakeFunctionDesc func1, func2, func3;
2293
func1.name = "MACRO";
2294
func2.name = func3.name = func1.name.toLower();
2296
QStringList argList1, argList2;
2297
argList1 << "MY_NEATO_MACRO";
2298
argList2 << "MY_NEATO_MACRO" << "one_arg" << "second_arg";
2300
func1.addArguments( argList1 );
2301
func2.addArguments( argList1 );
2302
func3.addArguments( argList2 );
2304
QTest::addColumn<CMakeFunctionDesc>( "function" );
2305
QTest::newRow( "good upper" ) << func1;
2306
QTest::newRow( "good lower" ) << func2;
2307
QTest::newRow( "good with args" ) << func3;
2310
void CMakeAstTest::testMacroBadParse()
2312
QFETCH( CMakeFunctionDesc, function );
2313
CMakeAst* ast = AstFactory::self()->createAst("macro");
2314
QVERIFY( ast->parseFunctionInfo( function ) == false );
2318
void CMakeAstTest::testMacroBadParse_data()
2320
CMakeFunctionDesc func1, func2;
2321
func1.name = "MACRO";
2322
func2.name = "wrong_function";
2324
QStringList argList1, argList2;
2325
argList2 << "MY_NEATO_MACRO" << "one_arg" << "second_arg";
2327
func1.addArguments( argList1 );
2328
func2.addArguments( argList2 );
2330
QTest::addColumn<CMakeFunctionDesc>( "function" );
2331
QTest::newRow( "bad no args" ) << func1;
2332
QTest::newRow( "bad wrong name" ) << func2;
2335
void CMakeAstTest::testFunctionGoodParse()
2337
QFETCH( CMakeFunctionDesc, function );
2338
CMakeAst* ast = AstFactory::self()->createAst("function");
2339
QVERIFY( ast->parseFunctionInfo( function ) == true );
2343
void CMakeAstTest::testFunctionGoodParse_data()
2345
CMakeFunctionDesc func1, func2, func3;
2346
func1.name = "FUNCTION";
2347
func2.name = func3.name = func1.name.toLower();
2349
QStringList argList1, argList2;
2350
argList1 << "MY_NEATO_MACRO";
2351
argList2 << "MY_NEATO_MACRO" << "one_arg" << "second_arg";
2353
func1.addArguments( argList1 );
2354
func2.addArguments( argList1 );
2355
func3.addArguments( argList2 );
2357
QTest::addColumn<CMakeFunctionDesc>( "function" );
2358
QTest::newRow( "good upper" ) << func1;
2359
QTest::newRow( "good lower" ) << func2;
2360
QTest::newRow( "good with args" ) << func3;
2363
void CMakeAstTest::testFunctionBadParse()
2365
QFETCH( CMakeFunctionDesc, function );
2366
CMakeAst* ast = AstFactory::self()->createAst("macro");
2367
QVERIFY( ast->parseFunctionInfo( function ) == false );
2371
void CMakeAstTest::testFunctionBadParse_data()
2373
CMakeFunctionDesc func1, func2;
2374
func1.name = "FUNCTION";
2375
func2.name = "wrong_function";
2377
QStringList argList1, argList2;
2378
argList2 << "MY_NEATO_MACRO" << "one_arg" << "second_arg";
2380
func1.addArguments( argList1 );
2381
func2.addArguments( argList2 );
2383
QTest::addColumn<CMakeFunctionDesc>( "function" );
2384
QTest::newRow( "bad no args" ) << func1;
2385
QTest::newRow( "bad wrong name" ) << func2;
2397
void CMakeAstTest::testMakeDirectoryGoodParse()
2400
QFETCH( CMakeFunctionDesc, function );
2401
CMakeAst* ast = AstFactory::self()->createAst("make_directory");
2402
QVERIFY( ast->parseFunctionInfo( function ) == true );
2406
void CMakeAstTest::testMakeDirectoryGoodParse_data()
2410
void CMakeAstTest::testMakeDirectoryBadParse()
2413
QFETCH( CMakeFunctionDesc, function );
2414
CMakeAst* ast = AstFactory::self()->createAst("make_directory");
2415
QVERIFY( ast->parseFunctionInfo( function ) == false );
2419
void CMakeAstTest::testMakeDirectoryBadParse_data()
2432
void CMakeAstTest::testMarkAsAdvancedGoodParse()
2434
QFETCH( CMakeFunctionDesc, function );
2435
CMakeAst* ast = AstFactory::self()->createAst("mark_as_advanced");
2436
QCOMPARE( ast->parseFunctionInfo( function ), true );
2440
void CMakeAstTest::testMarkAsAdvancedGoodParse_data()
2442
QTest::addColumn<CMakeFunctionDesc>("function");
2444
CMakeFunctionDesc l;
2445
l.name = "mark_as_advanced";
2446
l.addArguments(QStringList() << "FORCE" << "My_LIBRARY" << "My_INCLUDES");
2447
QTest::newRow("a forced mark_as_advanced") << l;
2449
l.arguments.clear();
2450
l.addArguments(QStringList() << "CLEAR" << "My_LIB");
2451
QTest::newRow("a clear mark_as_advanced") << l;
2453
l.arguments.clear();
2454
l.addArguments(QStringList() << "My_LIB");
2455
QTest::newRow("a normal mark_as_advanced") << l;
2458
void CMakeAstTest::testMarkAsAdvancedBadParse()
2460
QFETCH( CMakeFunctionDesc, function );
2461
CMakeAst* ast = AstFactory::self()->createAst("mark_as_advanced");
2462
QCOMPARE( ast->parseFunctionInfo( function ), false );
2466
void CMakeAstTest::testMarkAsAdvancedBadParse_data()
2468
QTest::addColumn<CMakeFunctionDesc>("function");
2470
CMakeFunctionDesc l;
2471
l.name = "mark_as_advanced";
2472
QTest::newRow("a mark_as_advanced without parameters") << l;
2474
l.arguments.clear();
2475
l.addArguments(QStringList() << "CLEAR");
2476
QTest::newRow("a clear mark_as_advanced without parameters") << l;
2488
void CMakeAstTest::testMathGoodParse()
2491
QFETCH( CMakeFunctionDesc, function );
2492
CMakeAst* ast = AstFactory::self()->createAst("math");
2493
QVERIFY( ast->parseFunctionInfo( function ) == true );
2497
void CMakeAstTest::testMathGoodParse_data()
2501
void CMakeAstTest::testMathBadParse()
2504
QFETCH( CMakeFunctionDesc, function );
2505
CMakeAst* ast = AstFactory::self()->createAst("math");
2506
QVERIFY( ast->parseFunctionInfo( function ) == false );
2510
void CMakeAstTest::testMathBadParse_data()
2524
void CMakeAstTest::testMessageGoodParse()
2527
QFETCH( CMakeFunctionDesc, function );
2528
CMakeAst* ast = AstFactory::self()->createAst("message");
2529
QVERIFY( ast->parseFunctionInfo( function ) == true );
2533
void CMakeAstTest::testMessageGoodParse_data()
2537
void CMakeAstTest::testMessageBadParse()
2540
QFETCH( CMakeFunctionDesc, function );
2541
CMakeAst* ast = AstFactory::self()->createAst("message");
2542
QVERIFY( ast->parseFunctionInfo( function ) == false );
2546
void CMakeAstTest::testMessageBadParse_data()
2559
void CMakeAstTest::testOptionGoodParse()
2562
QFETCH( CMakeFunctionDesc, function );
2563
CMakeAst* ast = AstFactory::self()->createAst("option");
2564
QVERIFY( ast->parseFunctionInfo( function ) == true );
2568
void CMakeAstTest::testOptionGoodParse_data()
2572
void CMakeAstTest::testOptionBadParse()
2575
QFETCH( CMakeFunctionDesc, function );
2576
CMakeAst* ast = AstFactory::self()->createAst("option");
2577
QVERIFY( ast->parseFunctionInfo( function ) == false );
2581
void CMakeAstTest::testOptionBadParse_data()
2594
void CMakeAstTest::testOutputRequiredFilesGoodParse()
2597
QFETCH( CMakeFunctionDesc, function );
2598
CMakeAst* ast = AstFactory::self()->createAst("output_required_files");
2599
QVERIFY( ast->parseFunctionInfo( function ) == true );
2603
void CMakeAstTest::testOutputRequiredFilesGoodParse_data()
2607
void CMakeAstTest::testOutputRequiredFilesBadParse()
2610
QFETCH( CMakeFunctionDesc, function );
2611
CMakeAst* ast = AstFactory::self()->createAst("output_required_files");
2612
QVERIFY( ast->parseFunctionInfo( function ) == false );
2616
void CMakeAstTest::testOutputRequiredFilesBadParse_data()
2629
void CMakeAstTest::testProjectGoodParse()
2631
QFETCH( CMakeFunctionDesc, function );
2632
CMakeAst* ast = AstFactory::self()->createAst("project");
2633
QVERIFY( ast->parseFunctionInfo( function ) == true );
2637
void CMakeAstTest::testProjectGoodParse_data()
2639
CMakeFunctionDesc func1, func2, func3, func4, func5, func6;
2640
func1.name = "PROJECT";
2641
func2.name = func3.name = func4.name = func5.name = func6.name = func1.name.toLower();
2643
QStringList argList1, argList2, argList3, argList4, argList5;
2644
argList1 << "myproject";
2645
argList2 << "myproject" << "C";
2646
argList3 << "myproject" << "CXX";
2647
argList4 << "myproject" << "Java";
2648
argList5 << "myproject" << "C" << "CXX" << "Java";
2650
func1.addArguments( argList1 );
2651
func2.addArguments( argList1 );
2652
func3.addArguments( argList2 );
2653
func4.addArguments( argList3 );
2654
func5.addArguments( argList4 );
2655
func6.addArguments( argList5 );
2657
QTest::addColumn<CMakeFunctionDesc>( "function" );
2658
QTest::newRow( "good 1" ) << func1;
2659
QTest::newRow( "good 2" ) << func2;
2660
QTest::newRow( "good 3" ) << func3;
2661
QTest::newRow( "good 4" ) << func4;
2662
QTest::newRow( "good 5" ) << func5;
2663
QTest::newRow( "good 6" ) << func6;
2667
void CMakeAstTest::testProjectBadParse()
2669
QFETCH( CMakeFunctionDesc, function );
2670
CMakeAst* ast = AstFactory::self()->createAst("project");
2671
QVERIFY( ast->parseFunctionInfo( function ) == false );
2675
void CMakeAstTest::testProjectBadParse_data()
2677
CMakeFunctionDesc func1, func2, func3;
2678
func1.name = "wrongname";
2679
func2.name = func3.name = "PROJECT";
2681
QStringList argList1, argList2;
2682
argList1 << "myproject" << "C" << "CXX" << "Java";
2683
argList2 << "myproject" << "C" << "CXX" << "Java" << "foo";
2685
func1.addArguments( argList1 );
2686
func3.addArguments( argList2 );
2688
QTest::addColumn<CMakeFunctionDesc>( "function" );
2689
QTest::newRow("wrong name") << func1;
2690
QTest::newRow("no args") << func2;
2691
QTest::newRow("wrong lang args") << func3;
2703
void CMakeAstTest::testQtWrapCppGoodParse()
2706
QFETCH( CMakeFunctionDesc, function );
2707
CMakeAst* ast = AstFactory::self()->createAst("qt_wrap_cpp");
2708
QVERIFY( ast->parseFunctionInfo( function ) == true );
2712
void CMakeAstTest::testQtWrapCppGoodParse_data()
2716
void CMakeAstTest::testQtWrapCppBadParse()
2719
QFETCH( CMakeFunctionDesc, function );
2720
CMakeAst* ast = AstFactory::self()->createAst("qt_wrap_cpp");
2721
QVERIFY( ast->parseFunctionInfo( function ) == false );
2725
void CMakeAstTest::testQtWrapCppBadParse_data()
2738
void CMakeAstTest::testQtWrapUiGoodParse()
2741
QFETCH( CMakeFunctionDesc, function );
2742
CMakeAst* ast = AstFactory::self()->createAst("qt_wrap_ui");
2743
QVERIFY( ast->parseFunctionInfo( function ) == true );
2747
void CMakeAstTest::testQtWrapUiGoodParse_data()
2751
void CMakeAstTest::testQtWrapUiBadParse()
2754
QFETCH( CMakeFunctionDesc, function );
2755
CMakeAst* ast = AstFactory::self()->createAst("qt_wrap_ui");
2756
QVERIFY( ast->parseFunctionInfo( function ) == false );
2760
void CMakeAstTest::testQtWrapUiBadParse_data()
2773
void CMakeAstTest::testRemoveGoodParse()
2776
QFETCH( CMakeFunctionDesc, function );
2777
CMakeAst* ast = AstFactory::self()->createAst("remove");
2778
QVERIFY( ast->parseFunctionInfo( function ) == true );
2782
void CMakeAstTest::testRemoveGoodParse_data()
2786
void CMakeAstTest::testRemoveBadParse()
2789
QFETCH( CMakeFunctionDesc, function );
2790
CMakeAst* ast = AstFactory::self()->createAst("remove");
2791
QVERIFY( ast->parseFunctionInfo( function ) == false );
2795
void CMakeAstTest::testRemoveBadParse_data()
2808
void CMakeAstTest::testRemoveDefinitionsGoodParse()
2811
QFETCH( CMakeFunctionDesc, function );
2812
CMakeAst* ast = AstFactory::self()->createAst("remove_definitions");
2813
QVERIFY( ast->parseFunctionInfo( function ) == true );
2817
void CMakeAstTest::testRemoveDefinitionsGoodParse_data()
2821
void CMakeAstTest::testRemoveDefinitionsBadParse()
2824
QFETCH( CMakeFunctionDesc, function );
2825
CMakeAst* ast = AstFactory::self()->createAst("remove_definitions");
2826
QVERIFY( ast->parseFunctionInfo( function ) == false );
2830
void CMakeAstTest::testRemoveDefinitionsBadParse_data()
2843
void CMakeAstTest::testReturnGoodParse()
2846
QFETCH( CMakeFunctionDesc, function );
2847
CMakeAst* ast = AstFactory::self()->createAst("return");
2848
QVERIFY( ast->parseFunctionInfo( function ) == true );
2852
void CMakeAstTest::testReturnGoodParse_data()
2856
void CMakeAstTest::testReturnBadParse()
2859
QFETCH( CMakeFunctionDesc, function );
2860
CMakeAst* ast = AstFactory::self()->createAst("return");
2861
QVERIFY( ast->parseFunctionInfo( function ) == false );
2865
void CMakeAstTest::testReturnBadParse_data()
2878
void CMakeAstTest::testSeparateArgumentsGoodParse()
2881
QFETCH( CMakeFunctionDesc, function );
2882
CMakeAst* ast = AstFactory::self()->createAst("separate_arguments");
2883
QVERIFY( ast->parseFunctionInfo( function ) == true );
2887
void CMakeAstTest::testSeparateArgumentsGoodParse_data()
2891
void CMakeAstTest::testSeparateArgumentsBadParse()
2894
QFETCH( CMakeFunctionDesc, function );
2895
CMakeAst* ast = AstFactory::self()->createAst("separate_arguments");
2896
QVERIFY( ast->parseFunctionInfo( function ) == false );
2900
void CMakeAstTest::testSeparateArgumentsBadParse_data()
2913
void CMakeAstTest::testSetGoodParse()
2915
QFETCH( CMakeFunctionDesc, function );
2916
CMakeAst* ast = AstFactory::self()->createAst("set");
2917
QVERIFY( ast->parseFunctionInfo( function ) == true );
2921
void CMakeAstTest::testSetGoodParse_data()
2923
CMakeFunctionDesc func1, func2, func3, func4, func5;
2925
func2.name = func3.name = func4.name = func5.name = func1.name.toLower();
2927
QStringList argList1, argList2, argList3, argList4, argList5;
2928
argList1 << "MYVAR";
2929
argList2 << "MYVAR" << "value1";
2930
argList3 << "MYVAR" << "CACHE" << "FILEPATH" << "docu";
2931
argList4 << "MYVAR" << "value1" << "CACHE" << "STRING" << "docu" << "FORCE";
2932
argList5 << "MYVAR" << "value1" << "PARENT_SCOPE";
2934
func1.addArguments( argList1 );
2935
func2.addArguments( argList2 );
2936
func3.addArguments( argList3 );
2937
func4.addArguments( argList4 );
2938
func5.addArguments( argList5 );
2940
QTest::addColumn<CMakeFunctionDesc>( "function" );
2941
QTest::newRow( "good delete value" ) << func1;
2942
QTest::newRow( "good set value" ) << func2;
2943
QTest::newRow( "good set cache value" ) << func3;
2944
QTest::newRow( "good set cache value forced" ) << func4;
2945
QTest::newRow( "good set parent_scope" ) << func5;
2949
void CMakeAstTest::testSetBadParse()
2951
QFETCH( CMakeFunctionDesc, function );
2952
CMakeAst* ast = AstFactory::self()->createAst("set");
2953
QCOMPARE( ast->parseFunctionInfo( function ), false );
2957
void CMakeAstTest::testSetBadParse_data()
2959
CMakeFunctionDesc func1, func2, func3, func4, func5, func6;
2960
func1.name = "foobar_set";
2961
func2.name = func3.name = func4.name = func5.name = func6.name = "set";
2963
QStringList argList1, argList2, argList3, argList4, argList5, argList6;
2964
argList1 << "MYVAR" << "value1" << "CACHE" << "STRING" << "docu" << "FORCE";
2965
argList3 << "MYVAR" << "CACHE";
2966
argList4 << "MYVAR" << "FORCE";
2967
argList5 << "MYVAR" << "CACHE" << "STRING";
2968
argList6 << "MYVAR" << "value1" << "CACHE" << "STRING" << "docu" << "PARENT_SCOPE";
2970
func1.addArguments( argList1 );
2971
// func2.addArguments( argList2 );
2972
func3.addArguments( argList3 );
2973
func4.addArguments( argList4 );
2974
func5.addArguments( argList5 );
2975
func6.addArguments( argList6 );
2977
qDebug() << func2.arguments.count();
2979
QTest::addColumn<CMakeFunctionDesc>( "function" );
2980
QTest::newRow( "bad wrong name" ) << func1;
2981
QTest::newRow( "bad no args" ) << func2;
2982
QTest::newRow( "bad wrong cache use" ) << func3;
2983
QTest::newRow( "bad wrong force use" ) << func4;
2984
QTest::newRow( "bad wrong cache use 2" ) << func5;
2985
QTest::newRow( "bad cache + parent_scope" ) << func6;
2993
void CMakeAstTest::testSetPropertyGoodParse()
2996
QFETCH( CMakeFunctionDesc, function );
2997
CMakeAst* ast = AstFactory::self()->createAst("set_property");
2998
QVERIFY( ast->parseFunctionInfo( function ) == true );
3002
void CMakeAstTest::testSetPropertyGoodParse_data()
3006
void CMakeAstTest::testSetPropertyBadParse()
3009
QFETCH( CMakeFunctionDesc, function );
3010
CMakeAst* ast = AstFactory::self()->createAst("set_property");
3011
QVERIFY( ast->parseFunctionInfo( function ) == false );
3015
void CMakeAstTest::testSetPropertyBadParse_data()
3025
void CMakeAstTest::testGetPropertyGoodParse()
3027
QFETCH( CMakeFunctionDesc, function );
3028
CMakeAst* ast = AstFactory::self()->createAst("get_property");
3029
QVERIFY( ast->parseFunctionInfo( function ) == true );
3033
void CMakeAstTest::testGetPropertyGoodParse_data()
3035
CMakeFunctionDesc func1;
3036
func1.name = "get_property";
3038
QStringList argList1;
3039
argList1=QString("_CTEST_TARGETS_ADDED GLOBAL PROPERTY CTEST_TARGETS_ADDED").split(" ");
3041
func1.addArguments( argList1 );
3043
QTest::addColumn<CMakeFunctionDesc>( "function" );
3044
QTest::newRow( "good get" ) << func1;
3047
void CMakeAstTest::testGetPropertyBadParse()
3050
QFETCH( CMakeFunctionDesc, function );
3051
CMakeAst* ast = AstFactory::self()->createAst("get_property");
3052
QVERIFY( ast->parseFunctionInfo( function ) == false );
3056
void CMakeAstTest::testGetPropertyBadParse_data()
3066
void CMakeAstTest::testSetDirectoryPropsGoodParse()
3069
QFETCH( CMakeFunctionDesc, function );
3070
CMakeAst* ast = AstFactory::self()->createAst("set_directory_properties");
3071
QVERIFY( ast->parseFunctionInfo( function ) == true );
3075
void CMakeAstTest::testSetDirectoryPropsGoodParse_data()
3079
void CMakeAstTest::testSetDirectoryPropsBadParse()
3082
QFETCH( CMakeFunctionDesc, function );
3083
CMakeAst* ast = AstFactory::self()->createAst("set_directory_properties");
3084
QVERIFY( ast->parseFunctionInfo( function ) == false );
3088
void CMakeAstTest::testSetDirectoryPropsBadParse_data()
3101
void CMakeAstTest::testSetSourceFilesPropsGoodParse()
3104
QFETCH( CMakeFunctionDesc, function );
3105
CMakeAst* ast = AstFactory::self()->createAst("set_source_files_properties");
3106
QVERIFY( ast->parseFunctionInfo( function ) == true );
3110
void CMakeAstTest::testSetSourceFilesPropsGoodParse_data()
3114
void CMakeAstTest::testSetSourceFilesPropsBadParse()
3117
QFETCH( CMakeFunctionDesc, function );
3118
CMakeAst* ast = AstFactory::self()->createAst("set_source_files_properties");
3119
QVERIFY( ast->parseFunctionInfo( function ) == false );
3123
void CMakeAstTest::testSetSourceFilesPropsBadParse_data()
3136
void CMakeAstTest::testSetTargetPropsGoodParse()
3139
QFETCH( CMakeFunctionDesc, function );
3140
CMakeAst* ast = AstFactory::self()->createAst("set_target_properties");
3141
QVERIFY( ast->parseFunctionInfo( function ) == true );
3145
void CMakeAstTest::testSetTargetPropsGoodParse_data()
3149
void CMakeAstTest::testSetTargetPropsBadParse()
3152
QFETCH( CMakeFunctionDesc, function );
3153
CMakeAst* ast = AstFactory::self()->createAst("set_target_properties");
3154
QVERIFY( ast->parseFunctionInfo( function ) == false );
3158
void CMakeAstTest::testSetTargetPropsBadParse_data()
3171
void CMakeAstTest::testSetTestsPropsGoodParse()
3174
QFETCH( CMakeFunctionDesc, function );
3175
CMakeAst* ast = AstFactory::self()->createAst("set_tests_properties");
3176
QVERIFY( ast->parseFunctionInfo( function ) == true );
3180
void CMakeAstTest::testSetTestsPropsGoodParse_data()
3184
void CMakeAstTest::testSetTestsPropsBadParse()
3187
QFETCH( CMakeFunctionDesc, function );
3188
CMakeAst* ast = AstFactory::self()->createAst("set_tests_properties");
3189
QVERIFY( ast->parseFunctionInfo( function ) == false );
3193
void CMakeAstTest::testSetTestsPropsBadParse_data()
3206
void CMakeAstTest::testSiteNameGoodParse()
3209
QFETCH( CMakeFunctionDesc, function );
3210
CMakeAst* ast = AstFactory::self()->createAst("site_name");
3211
QVERIFY( ast->parseFunctionInfo( function ) == true );
3215
void CMakeAstTest::testSiteNameGoodParse_data()
3219
void CMakeAstTest::testSiteNameBadParse()
3222
QFETCH( CMakeFunctionDesc, function );
3223
CMakeAst* ast = AstFactory::self()->createAst("site_name");
3224
QVERIFY( ast->parseFunctionInfo( function ) == false );
3228
void CMakeAstTest::testSiteNameBadParse_data()
3241
void CMakeAstTest::testSourceGroupGoodParse()
3244
QFETCH( CMakeFunctionDesc, function );
3245
CMakeAst* ast = AstFactory::self()->createAst("source_group");
3246
QVERIFY( ast->parseFunctionInfo( function ) == true );
3250
void CMakeAstTest::testSourceGroupGoodParse_data()
3254
void CMakeAstTest::testSourceGroupBadParse()
3257
QFETCH( CMakeFunctionDesc, function );
3258
CMakeAst* ast = AstFactory::self()->createAst("source_group");
3259
QVERIFY( ast->parseFunctionInfo( function ) == false );
3263
void CMakeAstTest::testSourceGroupBadParse_data()
3276
void CMakeAstTest::testStringGoodParse()
3278
QFETCH( CMakeFunctionDesc, function );
3279
CMakeAst* ast = AstFactory::self()->createAst("string");
3280
QVERIFY( ast->parseFunctionInfo( function ) == true );
3284
void CMakeAstTest::testStringGoodParse_data()
3287
cases << "string STRIP string output";
3288
cases << "string RANDOM output";
3289
cases << "stRing RANDOM LENGTH 3 output";
3290
cases << "string RANDOM ALPHABET abcd output";
3291
cases << "string RANDOM output LENGTH 3 ALPHABET abcd";
3292
QTest::addColumn<CMakeFunctionDesc>( "function" );
3294
foreach(const QString& acase, cases)
3296
QStringList splitted=acase.split(" ");
3297
CMakeFunctionDesc func;
3298
func.name = splitted.takeFirst();
3299
func.addArguments(splitted);
3300
QTest::newRow( qPrintable(acase) ) << func;
3304
void CMakeAstTest::testStringBadParse()
3307
QFETCH( CMakeFunctionDesc, function );
3308
CMakeAst* ast = AstFactory::self()->createAst("string");
3309
QVERIFY( ast->parseFunctionInfo( function ) == false );
3313
void CMakeAstTest::testStringBadParse_data()
3318
void CMakeAstTest::testSubdirDependsGoodParse()
3321
QFETCH( CMakeFunctionDesc, function );
3322
CMakeAst* ast = AstFactory::self()->createAst("subdir_depends");
3323
QVERIFY( ast->parseFunctionInfo( function ) == true );
3327
void CMakeAstTest::testSubdirDependsGoodParse_data()
3331
void CMakeAstTest::testSubdirDependsBadParse()
3334
QFETCH( CMakeFunctionDesc, function );
3335
CMakeAst* ast = AstFactory::self()->createAst("subdir_depends");
3336
QVERIFY( ast->parseFunctionInfo( function ) == false );
3340
void CMakeAstTest::testSubdirDependsBadParse_data()
3353
void CMakeAstTest::testSubdirsGoodParse()
3356
QFETCH( CMakeFunctionDesc, function );
3357
CMakeAst* ast = AstFactory::self()->createAst("subdirs");
3358
QVERIFY( ast->parseFunctionInfo( function ) == true );
3362
void CMakeAstTest::testSubdirsGoodParse_data()
3366
void CMakeAstTest::testSubdirsBadParse()
3369
QFETCH( CMakeFunctionDesc, function );
3370
CMakeAst* ast = AstFactory::self()->createAst("subdirs");
3371
QVERIFY( ast->parseFunctionInfo( function ) == false );
3375
void CMakeAstTest::testSubdirsBadParse_data()
3388
void CMakeAstTest::testTargetLinkLibrariesGoodParse()
3390
QFETCH( CMakeFunctionDesc, function );
3391
CMakeAst* ast = AstFactory::self()->createAst("target_link_libraries");
3392
QVERIFY( ast->parseFunctionInfo( function ) == true );
3396
void CMakeAstTest::testTargetLinkLibrariesGoodParse_data()
3398
CMakeFunctionDesc func1, func2, func3;
3399
func1.name = "TARGET_LINK_LIBRARIES";
3400
func2.name = func3.name = func1.name.toLower();
3402
QStringList argList1, argList2, argList3;
3404
argList1 << "MYTARGET" << "SOME_VAR";
3405
argList2 << "MYTARGET" << "debug" << "onlydebuglib";
3406
argList3 << "MYTARGET" << "optimized" << "onlyoptimizedlib";
3408
func1.addArguments( argList1 );
3409
func2.addArguments( argList2 );
3410
func3.addArguments( argList3 );
3412
QTest::addColumn<CMakeFunctionDesc>( "function" );
3413
QTest::newRow( "whatever" ) << func1;
3414
QTest::newRow( "whatever" ) << func2;
3415
QTest::newRow( "whatever" ) << func3;
3419
void CMakeAstTest::testTargetLinkLibrariesBadParse()
3421
QFETCH( CMakeFunctionDesc, function );
3422
CMakeAst* ast = AstFactory::self()->createAst("target_link_libraries");
3423
QVERIFY( ast->parseFunctionInfo( function ) == false );
3427
void CMakeAstTest::testTargetLinkLibrariesBadParse_data()
3429
CMakeFunctionDesc func1, func2, func3, func4;
3430
func1.name = "wrong_func_name";
3431
func2.name = func3.name, func4.name = "target_link_libraries";
3433
QStringList argList1, argList2, argList3, argList4;
3435
argList1 << "MYTARGET" << "SOME_VAR";
3436
argList2 << "MYTARGET";
3437
argList3 << "MYTARGET" << "optimized";
3438
argList4 << "MYTARGET" << "debug";
3440
func1.addArguments( argList1 );
3441
func2.addArguments( argList2 );
3442
func3.addArguments( argList3 );
3443
func4.addArguments( argList4 );
3445
QTest::addColumn<CMakeFunctionDesc>( "function" );
3446
QTest::newRow( "whatever" ) << func1;
3447
QTest::newRow( "whatever" ) << func2;
3448
QTest::newRow( "whatever" ) << func3;
3449
QTest::newRow( "whatever" ) << func4;
3456
void CMakeAstTest::testTryCompileGoodParse()
3458
QFETCH( CMakeFunctionDesc, function );
3459
CMakeAst* ast = AstFactory::self()->createAst("try_compile");
3460
QVERIFY( ast->parseFunctionInfo( function ) == true );
3464
void CMakeAstTest::testTryCompileGoodParse_data()
3466
QTest::addColumn<CMakeFunctionDesc>("function");
3468
CMakeFunctionDesc l;
3469
l.name = "try_compile";
3470
l.addArguments(QStringList() << "RESULT" << "mySrcDir" << "myBinDir" << "myProjectName");
3471
QTest::newRow("cmake way") << l;
3473
l.arguments.clear();
3474
l.addArguments(QStringList() << "RESULT" << "mySrcDir" << "myBinDir");
3475
QTest::newRow("compile way") << l;
3477
l.arguments.clear();
3478
l.addArguments(QStringList() << "RESULT" << "mySrcDir" << "myBinDir" << "COMPILE_DEFINITIONS" << "-D LOL");
3479
QTest::newRow("more complex compile") << l;
3482
void CMakeAstTest::testTryCompileBadParse()
3484
QFETCH( CMakeFunctionDesc, function );
3485
CMakeAst* ast = AstFactory::self()->createAst("try_compile");
3486
QVERIFY( ast->parseFunctionInfo( function ) == false );
3490
void CMakeAstTest::testTryCompileBadParse_data()
3492
QTest::addColumn<CMakeFunctionDesc>("function");
3494
CMakeFunctionDesc l;
3495
l.name = "try_compile";
3496
QTest::newRow("no parameters") << l;
3509
void CMakeAstTest::testTryRunGoodParse()
3512
QFETCH( CMakeFunctionDesc, function );
3513
CMakeAst* ast = AstFactory::self()->createAst("try_run");
3514
QVERIFY( ast->parseFunctionInfo( function ) == true );
3518
void CMakeAstTest::testTryRunGoodParse_data()
3522
void CMakeAstTest::testTryRunBadParse()
3525
QFETCH( CMakeFunctionDesc, function );
3526
CMakeAst* ast = AstFactory::self()->createAst("try_run");
3527
QVERIFY( ast->parseFunctionInfo( function ) == false );
3531
void CMakeAstTest::testTryRunBadParse_data()
3544
void CMakeAstTest::testUseMangledMesaGoodParse()
3547
QFETCH( CMakeFunctionDesc, function );
3548
CMakeAst* ast = AstFactory::self()->createAst("use_mangled_mesa");
3549
QVERIFY( ast->parseFunctionInfo( function ) == true );
3553
void CMakeAstTest::testUseMangledMesaGoodParse_data()
3557
void CMakeAstTest::testUseMangledMesaBadParse()
3560
QFETCH( CMakeFunctionDesc, function );
3561
CMakeAst* ast = AstFactory::self()->createAst("use_mangled_mesa");
3562
QVERIFY( ast->parseFunctionInfo( function ) == false );
3566
void CMakeAstTest::testUseMangledMesaBadParse_data()
3579
void CMakeAstTest::testUtilitySourceGoodParse()
3582
QFETCH( CMakeFunctionDesc, function );
3583
CMakeAst* ast = AstFactory::self()->createAst("utility_source");
3584
QVERIFY( ast->parseFunctionInfo( function ) == true );
3588
void CMakeAstTest::testUtilitySourceGoodParse_data()
3592
void CMakeAstTest::testUtilitySourceBadParse()
3595
QFETCH( CMakeFunctionDesc, function );
3596
CMakeAst* ast = AstFactory::self()->createAst("utility_source");
3597
QVERIFY( ast->parseFunctionInfo( function ) == false );
3601
void CMakeAstTest::testUtilitySourceBadParse_data()
3614
void CMakeAstTest::testVariableRequiresGoodParse()
3617
QFETCH( CMakeFunctionDesc, function );
3618
CMakeAst* ast = AstFactory::self()->createAst("variable_requires");
3619
QVERIFY( ast->parseFunctionInfo( function ) == true );
3623
void CMakeAstTest::testVariableRequiresGoodParse_data()
3627
void CMakeAstTest::testVariableRequiresBadParse()
3630
QFETCH( CMakeFunctionDesc, function );
3631
CMakeAst* ast = AstFactory::self()->createAst("variable_requires");
3632
QVERIFY( ast->parseFunctionInfo( function ) == false );
3636
void CMakeAstTest::testVariableRequiresBadParse_data()
3649
void CMakeAstTest::testVtkMakeInstantiatorGoodParse()
3652
QFETCH( CMakeFunctionDesc, function );
3653
CMakeAst* ast = AstFactory::self()->createAst("vtk_make_instantiator");
3654
QVERIFY( ast->parseFunctionInfo( function ) == true );
3658
void CMakeAstTest::testVtkMakeInstantiatorGoodParse_data()
3662
void CMakeAstTest::testVtkMakeInstantiatorBadParse()
3665
QFETCH( CMakeFunctionDesc, function );
3666
CMakeAst* ast = AstFactory::self()->createAst("vtk_make_instantiator");
3667
QVERIFY( ast->parseFunctionInfo( function ) == false );
3671
void CMakeAstTest::testVtkMakeInstantiatorBadParse_data()
3684
void CMakeAstTest::testVtkWrapJavaGoodParse()
3687
QFETCH( CMakeFunctionDesc, function );
3688
CMakeAst* ast = AstFactory::self()->createAst("vtk_wrap_java");
3689
QVERIFY( ast->parseFunctionInfo( function ) == true );
3693
void CMakeAstTest::testVtkWrapJavaGoodParse_data()
3695
QTest::addColumn<CMakeFunctionDesc>("function");
3697
const int NUM_TESTDATA = 2;
3698
CMakeFunctionDesc funcs[NUM_TESTDATA];
3699
QStringList args[NUM_TESTDATA];
3701
for ( int i = 0; i < NUM_TESTDATA; i++ )
3702
funcs[i].name = "VTK_WRAP_JAVA";
3704
//test lowercase too
3705
funcs[NUM_TESTDATA - 1].name = funcs[NUM_TESTDATA - 1].name.toLower();
3707
args[0] << "myLibrary" << "MySourceList" << "source1";
3708
args[1] << "myLibrary" << "MySourceList" << "source1" << "source2";
3710
QTest::addColumn<CMakeFunctionDesc>( "function" );
3712
for ( int i = 0; i < NUM_TESTDATA; i++)
3714
funcs[i].addArguments( args[i] );
3715
QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
3719
void CMakeAstTest::testVtkWrapJavaBadParse()
3722
QFETCH( CMakeFunctionDesc, function );
3723
CMakeAst* ast = AstFactory::self()->createAst("vtk_wrap_java");
3724
QVERIFY( ast->parseFunctionInfo( function ) == false );
3728
void CMakeAstTest::testVtkWrapJavaBadParse_data()
3730
QTest::addColumn<CMakeFunctionDesc>("function");
3732
const int NUM_TESTDATA = 3;
3733
CMakeFunctionDesc funcs[NUM_TESTDATA];
3734
QStringList args[NUM_TESTDATA];
3736
for ( int i = 0; i < NUM_TESTDATA; i++ )
3737
funcs[i].name = "VTK_WRAP_JAVA";
3739
funcs[NUM_TESTDATA - 1].name = "wrong_name";
3741
args[0] << "myLibrary"; //no source list and no sources
3742
args[1] << "myLibrary" << "MySourceList"; //source list but no sources
3743
args[NUM_TESTDATA - 1] << "myLibrary" << "MySourceList" << "source1";
3745
QTest::addColumn<CMakeFunctionDesc>( "function" );
3747
for ( int i = 0; i < NUM_TESTDATA; i++)
3749
funcs[i].addArguments( args[i] );
3750
QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
3763
void CMakeAstTest::testVtkWrapPythonGoodParse()
3766
QFETCH( CMakeFunctionDesc, function );
3767
CMakeAst* ast = AstFactory::self()->createAst("vtk_wrap_python");
3768
QVERIFY( ast->parseFunctionInfo( function ) == true );
3772
void CMakeAstTest::testVtkWrapPythonGoodParse_data()
3774
QTest::addColumn<CMakeFunctionDesc>("function");
3776
const int NUM_TESTDATA = 2;
3777
CMakeFunctionDesc funcs[NUM_TESTDATA];
3778
QStringList args[NUM_TESTDATA];
3780
for ( int i = 0; i < NUM_TESTDATA; i++ )
3781
funcs[i].name = "VTK_WRAP_PYTHON";
3783
//test lowercase too
3784
funcs[NUM_TESTDATA - 1].name = funcs[NUM_TESTDATA - 1].name.toLower();
3786
args[0] << "myLibrary" << "MySourceList" << "source1";
3787
args[1] << "myLibrary" << "MySourceList" << "source1" << "source2";
3789
QTest::addColumn<CMakeFunctionDesc>( "function" );
3791
for ( int i = 0; i < NUM_TESTDATA; i++)
3793
funcs[i].addArguments( args[i] );
3794
QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
3798
void CMakeAstTest::testVtkWrapPythonBadParse()
3801
QFETCH( CMakeFunctionDesc, function );
3802
CMakeAst* ast = AstFactory::self()->createAst("vtk_wrap_python");
3803
QVERIFY( ast->parseFunctionInfo( function ) == false );
3807
void CMakeAstTest::testVtkWrapPythonBadParse_data()
3809
QTest::addColumn<CMakeFunctionDesc>("function");
3811
const int NUM_TESTDATA = 3;
3812
CMakeFunctionDesc funcs[NUM_TESTDATA];
3813
QStringList args[NUM_TESTDATA];
3815
for ( int i = 0; i < NUM_TESTDATA; i++ )
3816
funcs[i].name = "VTK_WRAP_PYTHON";
3818
funcs[NUM_TESTDATA - 1].name = "wrong_name";
3820
args[0] << "myLibrary"; //no source list and no sources
3821
args[1] << "myLibrary" << "MySourceList"; //source list but no sources
3822
args[NUM_TESTDATA - 1] << "myLibrary" << "MySourceList" << "source1";
3824
QTest::addColumn<CMakeFunctionDesc>( "function" );
3826
for ( int i = 0; i < NUM_TESTDATA; i++)
3828
funcs[i].addArguments( args[i] );
3829
QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
3842
void CMakeAstTest::testVtkWrapTclGoodParse()
3845
QFETCH( CMakeFunctionDesc, function );
3846
CMakeAst* ast = AstFactory::self()->createAst("vtk_wrap_tcl");
3847
QVERIFY( ast->parseFunctionInfo( function ) == true );
3851
void CMakeAstTest::testVtkWrapTclGoodParse_data()
3853
QTest::addColumn<CMakeFunctionDesc>("function");
3855
const int NUM_TESTDATA = 6;
3856
CMakeFunctionDesc funcs[NUM_TESTDATA];
3857
QStringList args[NUM_TESTDATA];
3859
for ( int i = 0; i < NUM_TESTDATA; i++ )
3860
funcs[i].name = "VTK_WRAP_TCL";
3862
//test lowercase too
3863
funcs[NUM_TESTDATA - 1].name = funcs[NUM_TESTDATA - 1].name.toLower();
3865
args[0] << "myLibrary" << "MySourceList" << "source1.tcl";
3867
//SOURCES is optional
3868
args[1] << "myLibrary" << "SOURCES" << "MySourceList" << "source1.tcl";
3871
args[2] << "myLibrary" << "SOURCES" << "MySourceList" << "source1.tcl"
3874
//commands are optional
3875
args[3] << "myLibrary" << "MySourceList" << "source1.tcl"
3876
<< "COMMANDS" << "com1";
3879
args[4] << "myLibrary" << "MySourceList" << "source1.tcl"
3880
<< "COMMANDS" << "com1" << "com2";
3882
//line from the cmake example
3883
args[NUM_TESTDATA - 1] << "myLibrary" << "SOURCES"
3884
<< "MySourceList" << "class1" << "class2"
3885
<< "COMMANDS" << "first_command" << "second_command";
3887
QTest::addColumn<CMakeFunctionDesc>( "function" );
3889
for ( int i = 0; i < NUM_TESTDATA; i++)
3891
funcs[i].addArguments( args[i] );
3892
QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
3896
void CMakeAstTest::testVtkWrapTclBadParse()
3899
QFETCH( CMakeFunctionDesc, function );
3900
CMakeAst* ast = AstFactory::self()->createAst("vtk_wrap_tcl");
3901
QVERIFY( ast->parseFunctionInfo( function ) == false );
3905
void CMakeAstTest::testVtkWrapTclBadParse_data()
3907
QTest::addColumn<CMakeFunctionDesc>("function");
3909
const int NUM_TESTDATA = 5;
3910
CMakeFunctionDesc funcs[NUM_TESTDATA];
3911
QStringList args[NUM_TESTDATA];
3913
for ( int i = 0; i < NUM_TESTDATA; i++ )
3914
funcs[i].name = "VTK_WRAP_TCL";
3916
funcs[NUM_TESTDATA - 1].name = "wrong_name";
3918
args[0] << "myLibrary"; //no source list and no sources
3919
args[1] << "myLibrary" << "MySourceList"; //source list but no sources
3920
args[2] << "myLibrary" << "SOURCES" << "MySourceList"; //source list but no sources
3921
args[3] << "myLibrary" << "SOURCES" << "MySourceList" << "foo.tcl";
3922
args[NUM_TESTDATA - 1] << "myLibrary" << "SOURCES"
3923
<< "MySourceList" << "class1" << "class2"
3924
<< "COMMANDS" << "first_command";
3926
QTest::addColumn<CMakeFunctionDesc>( "function" );
3928
for ( int i = 0; i < NUM_TESTDATA; i++)
3930
funcs[i].addArguments( args[i] );
3931
QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
3944
void CMakeAstTest::testWhileGoodParse()
3947
QFETCH( CMakeFunctionDesc, function );
3948
CMakeAst* ast = AstFactory::self()->createAst("while");
3949
QVERIFY( ast->parseFunctionInfo( function ) == true );
3953
void CMakeAstTest::testWhileGoodParse_data()
3957
void CMakeAstTest::testWhileBadParse()
3960
QFETCH( CMakeFunctionDesc, function );
3961
CMakeAst* ast = AstFactory::self()->createAst("while");
3962
QVERIFY( ast->parseFunctionInfo( function ) == false );
3966
void CMakeAstTest::testWhileBadParse_data()
3971
void CMakeAstTest::testWriteFileGoodParse()
3973
QFETCH( CMakeFunctionDesc, function );
3974
CMakeAst* ast = AstFactory::self()->createAst("write_file");
3975
QVERIFY( ast->parseFunctionInfo( function ) == true );
3979
void CMakeAstTest::testWriteFileGoodParse_data()
3981
QTest::addColumn<CMakeFunctionDesc>("function");
3983
const int NUM_TESTDATA = 2;
3984
CMakeFunctionDesc funcs[NUM_TESTDATA];
3985
QStringList args[NUM_TESTDATA];
3987
for ( int i = 0; i < NUM_TESTDATA; i++ )
3989
funcs[i].name = "WRITE_FILE";
3991
funcs[i].name.toLower();
3994
args[0] << "myfile.txt" << "\"this is my message\"";
3995
args[1] << "myfile.txt" << "\"this is also my message\"" << "APPEND";
3997
QTest::addColumn<CMakeFunctionDesc>( "function" );
3999
for ( int i = 0; i < NUM_TESTDATA; i++)
4001
funcs[i].addArguments( args[i] );
4002
QTest::newRow( qPrintable(QString::number(i)) ) << funcs[i];
4006
void CMakeAstTest::testWriteFileBadParse()
4008
QFETCH( CMakeFunctionDesc, function );
4009
CMakeAst* ast = AstFactory::self()->createAst("write_file");
4010
QVERIFY( ast->parseFunctionInfo( function ) == false );
4014
void CMakeAstTest::testWriteFileBadParse_data()
4016
QTest::addColumn<CMakeFunctionDesc>("function");
4018
const int NUM_TESTDATA = 3;
4019
CMakeFunctionDesc funcs[NUM_TESTDATA];
4020
QStringList args[NUM_TESTDATA];
4022
for ( int i = 0; i < NUM_TESTDATA; i++ )
4023
funcs[i].name = "WRITE_FILE";
4025
funcs[NUM_TESTDATA - 1].name = "wrong_name";
4027
args[0] << "myfile.txt";
4028
// args[1] << "myfile.txt" << "APPEND"; //append but no message. Should not crash, "append" is the message.
4029
args[NUM_TESTDATA - 1] << "myfile.txt" << "\"this is also my message\"" << "APPEND";
4031
QTest::addColumn<CMakeFunctionDesc>( "function" );
4033
for ( int i = 0; i < NUM_TESTDATA; i++)
4035
funcs[i].addArguments( args[i] );
4036
QTest::newRow( qPrintable(QString("%1. %2").arg(i).arg(args[i].join(" "))) ) << funcs[i];