add write_file() function
[profile/ivi/qtbase.git] / tests / auto / tools / qmake / testdata / functions / functions.pro
1 CONFIG = qt thread
2
3 #count
4 !count( CONFIG, 2 ) {
5    message( "FAILED: count function: $$CONFIG" )
6 }
7
8 #contains
9 !contains( CONFIG, thread ) {
10    message( "FAILED: contains function: $$CONFIG" )
11 }
12
13 #exists
14 !exists( functions.pro ) {
15    message( "FAILED: exists function" )
16 }
17
18 #isEmpty
19 isEmpty( CONFIG ) {
20    message( "FAILED: isEmpty function: $CONFIG" )
21 }
22
23 #files
24 !equals($$list($$files(one/*.cpp)), "one/1.cpp one/2.cpp") {
25    message( "FAILED: files function: one/*.cpp" )
26 }
27 !equals($$list($$files(one/1*.cpp)), "one/1.cpp") {
28    message( "FAILED: files function: one/1*.cpp" )
29 }
30 !equals($$list($$files(two/*.cpp)), "two/1.cpp two/2.cpp") {
31    message( "FAILED: files function: two/*.cpp" )
32 }
33 !equals($$list($$files(three/wildcard*.cpp)), "three/wildcard21.cpp three/wildcard22.cpp") {
34    message( "FAILED: files function: three/wildcard*.cpp" )
35 }
36 !equals($$list($$files(*.cpp)), "1.cpp 2.cpp wildcard21.cpp wildcard22.cpp") {
37    message( "FAILED: files function: *.cpp" )
38 }
39 !equals($$list($$files(wildcard*.cpp)), "wildcard21.cpp wildcard22.cpp") {
40    message( "FAILED: files function: wildcard*.cpp" )
41 }
42
43 #infile
44 !infile( infiletest.pro, DEFINES, QT_DLL ){
45    message( "FAILED: infile function" )
46 }
47
48 #include
49 include( infiletest.pro, "", true ) 
50 !contains( DEFINES, QT_DLL ) {
51    message( "FAILED: include function: $$DEFINES" )
52 }
53
54 #replace
55 VERSION=1.0.0
56 VERSION_replaced=$$replace(VERSION,\\.,_)
57 !isEqual(VERSION_replaced, 1_0_0) {
58    message( "FAILED: replace function: $$VERSION_replaced" )
59 }
60
61 #test functions
62 defineTest(myTestFunction) {
63    RESULT =
64    list=$$1
65    for(l, list) {
66        RESULT += $$l
67    }
68    export(RESULT)
69 }
70 myTestFunction(oink baa moo)
71 !equals($$list($$member(RESULT, 0)), "oink") {
72      message("FAILED: myTestFunction: $$RESULT")
73 }
74 myTestFunction("oink baa" moo)
75 !equals($$list($$member(RESULT, 0)), "oink baa") {
76      message("FAILED: myTestFunction: $$RESULT")
77 }
78 myTestFunction(oink "baa moo")
79 !equals($$list($$member(RESULT, 0)), "oink") {
80      message("FAILED: myTestFunction: $$RESULT")
81 }
82 myTestFunction("oink baa moo")
83 !equals($$list($$member(RESULT, 0)), "oink baa moo") {
84      message("FAILED: myTestFunction: $$RESULT")
85 }
86
87 moo = "this is a test" "for real"
88 fn = $$OUT_PWD/testdir/afile
89 write_file($$fn, moo)|message("FAILED: write_file() failed")
90 exists($$fn)|message("FAILED: write_file() didn't write anything")
91 mooout = $$cat($$fn, line)
92 equals(moo, $$mooout)|message("FAILED: write_file() wrote something wrong")
93 moo += "another line"
94 write_file($$fn, moo)|message("FAILED: write_file() failed (take 2)")
95 mooout = $$cat($$fn, line)
96 equals(moo, $$mooout)|message("FAILED: write_file() wrote something wrong (take 2)")
97 mooadd = "yet another line"
98 write_file($$fn, mooadd, append)|message("FAILED: write_file() failed (append)")
99 moo += $$mooadd
100 mooout = $$cat($$fn, line)
101 equals(moo, $$mooout)|message("FAILED: write_file() wrote something wrong when appending")