summaryrefslogtreecommitdiff
path: root/qmake-features/am-qml-testcase.prf
blob: ac97d1fa410174f44fa5dedab28fc65f0d352424 (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
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 -r --no-dlt-logging
mac: COMMAND += --dbus=none
multi-process: COMMAND += --start-session-dbus
!multi-process: {
    !build_pass:!qmltest-mode-auto:message("am-qml-testcase: forcing MODE to single-process, because 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) {
    COMMAND += -c $$absolute_path($$config, $$_PRO_FILE_PWD_)
}
OTHER_FILES += $$AM_CONFIG

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

QMAKE_EXTRA_TARGETS *= check

# Execute a testrunner for every file
for(file, TEST_FILES) {
    !equals(MODE, "single-process"):check.commands += $$COMMAND $$absolute_path($$file, $$_PRO_FILE_PWD_) --force-multi-process -- $(TESTARGS) &&
    !equals(MODE, "multi-process"):check.commands += $$COMMAND $$absolute_path($$file, $$_PRO_FILE_PWD_) --force-single-process -- $(TESTARGS) &&
}
check.commands += true;
OTHER_FILES += $$TEST_FILES