summaryrefslogtreecommitdiff
path: root/qmake-features/am-qml-testcase.prf
blob: adf91f1eb91201e466fd5a5b78edce0c54363a8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
TEMPLATE = aux

load(am-config)

# Add environment for non-installed builds. Do this first, so the
# 'make' variable expansions don't end up in a batch file/script.
QT_TOOL_NAME = appman-qmltestrunner
!isEmpty(TEST_FILES): qtAddTargetEnv(COMMAND, QT)

# If the test ends up in a different directory, we should cd to that directory.
TESTRUN_CWD = $$DESTDIR

debug_and_release:debug_and_release_target {
    # But in debug-and-release-target mode we don't want to cd into the debug/release
    # directory (e.g. if the test goes to foo/release/tst_thing.exe, we want to do
    # 'cd foo && release/tst_thing.exe', not 'cd foo/release && tst_thing.exe').

    TESTRUN_CWD ~= s/(release|debug)$//
    TEST_TARGET_DIR = $$relative_path($$absolute_path($$DESTDIR, $$OUT_PWD), $$absolute_path($$TESTRUN_CWD, $$OUT_PWD))
}

# Allow for a custom test runner script
COMMAND += $(TESTRUNNER)

# Define how the appman should be run, single-process, multi-process, both
isEmpty(MODE) {
    MODE = both
    CONFIG *= qmltest-mode-auto
}

# Determine the location of the testrunner
prefix_build {
    AM_TESTRUNNER_DIR = $$BUILD_DIR/bin
} else {
    !isEmpty(INSTALL_PREFIX) {
        AM_TESTRUNNER_DIR = $${INSTALL_PREFIX}/bin
    } else {
        AM_TESTRUNNER_DIR = $$[QT_INSTALL_BINS]
    }
}

# The check command
COMMAND += $$AM_TESTRUNNER_DIR/appman-qmltestrunner --no-cache --no-dlt-logging
mac: COMMAND += --dbus=none
!multi-process: {
    !build_pass:!qmltest-mode-auto:message("am-qml-testcase: forcing MODE to single-process, because the application manager is built in single-process mode")
    MODE = single-process
}

# Add import dirs
for(import, IMPORTS_DIR) {
    COMMAND += -I $$absolute_path($$import, $$_PRO_FILE_PWD_)
}
OTHER_FILES += $$IMPORTS_DIR

# Read a config file
for(config, AM_CONFIG) {
    isEmpty(TESTRUN_CWD): COMMAND += -c $$absolute_path($$config, $$_PRO_FILE_PWD_)
    else: COMMAND += -c $$config
}
OTHER_FILES += $$AM_CONFIG

# Make AM_TESTDATA_DIR known
!isEmpty(AM_TESTDATA_DIR) {
    COMMAND += -o \'systemProperties: { public: { AM_TESTDATA_DIR: $$AM_TESTDATA_DIR } }\'
}

!isEmpty(TESTRUN_CWD):!contains(TESTRUN_CWD, ^\\./?): \
    COMMAND = cd $$shell_path($$TESTRUN_CWD) && $$eval(COMMAND)

QMAKE_EXTRA_TARGETS *= check

# Set default test configuration (each config is run separately)
isEmpty(TEST_CONFIGURATIONS) {
    !equals(MODE, "single-process"): TEST_CONFIGURATIONS = "--force-multi-process"
    !equals(MODE, "multi-process"): TEST_CONFIGURATIONS += "--force-single-process"
}

# Execute a testrunner for every file
for(file, TEST_FILES) {
    for(config, TEST_CONFIGURATIONS) {
        check.commands += $$COMMAND $$absolute_path($$file, $$_PRO_FILE_PWD_) $${config} -- $(TESTARGS) &&
    }
}
msvc:check.commands += VER>NUL
else:check.commands += true;
OTHER_FILES += $$TEST_FILES

# Copy assets to build folder
for (d , DIRECTORIES) {
    do_copydata.commands += $(COPY_DIR) $$shell_path($$_PRO_FILE_PWD_/$${d}) $$shell_path($$OUT_PWD/$${d}) $$escape_expand(\n\t)
}
for (f , FILES) {
    do_copydata.commands += $(COPY) $$shell_path($$_PRO_FILE_PWD_/$${f}) $$shell_path($$OUT_PWD/$${f}) $$escape_expand(\n\t)
}

!equals(_PRO_FILE_PWD_, $$OUT_PWD) {
    check.depends = do_copydata
    QMAKE_EXTRA_TARGETS += do_copydata
}

# Make sure that possible apps are in OTHER_FILES
for (app, TEST_APPS): OTHER_FILES += apps/$${app}/*.yaml apps/$${app}/*.qml  apps/$${app}/*.png