Commit 9ed10b1e authored by Sam Thursfield's avatar Sam Thursfield

tests: Explicitly mark the unit tests which require D-Bus

The unit tests should in theory never talk to D-Bus. In practice,
some don't follow this rule. We now run these tests in a separate
D-Bus session so that they are correctly isolated from the host,
which is nice, but eventually we should either move such tests into
the functional-tests suite, or modify them so that they don't need
to spawn and communicate with external processes.
parent fc09a26b
Pipeline #84148 passed with stage
in 2 minutes and 6 seconds
......@@ -24,7 +24,8 @@ foreach base_name: libtracker_data_tests
tests += {
'name': test_name,
'exe': binary
'exe': binary,
'requires_dbus': true,
}
endforeach
......@@ -40,6 +41,7 @@ foreach base_name: libtracker_data_slow_tests
tests += {
'name': test_name,
'exe': binary,
'requires_dbus': true,
'timeout': 180
}
endforeach
......@@ -6,5 +6,6 @@ fts_test = executable('tracker-fts-test',
tests += {
'name': 'fts',
'exe': fts_test
'exe': fts_test,
'requires_dbus': true,
}
libtracker_sparql_tests = [
'resource',
'sparql',
]
libtracker_sparql_test_c_args = tracker_c_args + [
'-DTEST',
'-DTEST_DOMAIN_ONTOLOGY_RULE="@0@"'.format(tracker_uninstalled_domain_rule),
......@@ -13,19 +8,24 @@ libtracker_sparql_test_deps = [
tracker_common_dep, tracker_sparql_dep
]
foreach base_name: libtracker_sparql_tests
source = 'tracker-@0@-test.c'.format(base_name)
binary_name = 'tracker-@0@-test'.format(base_name)
test_name = 'sparql-@0@'.format(base_name)
tracker_resource_test = executable('tracker-resource-test',
'tracker-resource-test.c',
dependencies: libtracker_sparql_test_deps,
c_args: libtracker_sparql_test_c_args)
tests += {
'name': 'tracker-resource-test',
'exe': tracker_resource_test,
}
binary = executable(binary_name, source,
dependencies: libtracker_sparql_test_deps,
c_args: libtracker_sparql_test_c_args)
tracker_sparql_test = executable('tracker-sparql-test',
'tracker-sparql-test.c',
dependencies: libtracker_sparql_test_deps,
c_args: libtracker_sparql_test_c_args)
tests += {
'name': test_name,
'exe': binary,
'is_parallel': false
}
[[test_name, binary]]
endforeach
tests += {
'name': 'tracker-sparql-test',
'exe': tracker_sparql_test,
'is_parallel': false,
'requires_dbus': true,
}
......@@ -29,8 +29,16 @@ foreach t: tests
test_name = t.get('name')
test_exe = t.get('exe')
test_timeout = t.get('timeout', 30)
# This flag marks unit tests which can't run alongside other unit tests. It
# generally indicates a bug or design flaw in that test.
test_is_parallel = t.get('is_parallel', true)
# This flag marks unit tests which need to contact a D-Bus session bus. This
# is a sign of a bad unit test -- anything which uses D-Bus belongs in the
# functional-tests directory.
test_requires_dbus = t.get('requires_dbus', false)
test_env = environment()
test_env.set('GSETTINGS_SCHEMA_DIR', join_paths(build_root, 'data'))
test_env.set('TRACKER_LANGUAGE_STOP_WORDS_DIR', join_paths(source_root, 'src', 'libtracker-common', 'stop-words'))
......@@ -38,11 +46,18 @@ foreach t: tests
test_env.set('TRACKER_DB_ONTOLOGIES_DIR', join_paths(source_root, 'src', 'ontologies', 'nepomuk'))
test_env.set('LANG', 'en_US.UTF8')
test (test_name, dbus_run_session,
env: test_env,
args: ['--config-file=@0@'.format(join_paths(meson.current_build_dir(), 'test-bus.conf')),
'--',
test_exe],
timeout: test_timeout,
is_parallel: test_is_parallel)
if test_requires_dbus
test (test_name, dbus_run_session,
env: test_env,
args: ['--config-file=@0@'.format(join_paths(meson.current_build_dir(), 'test-bus.conf')),
'--',
test_exe],
timeout: test_timeout,
is_parallel: test_is_parallel)
else
test (test_name, test_exe,
env: test_env,
timeout: test_timeout,
is_parallel: test_is_parallel)
endif
endforeach
......@@ -9,5 +9,6 @@ steroids_test = executable('tracker-steroids-test',
c_args: [tracker_c_args, test_c_args])
tests += {
'name': 'steroids',
'exe': steroids_test
'exe': steroids_test,
'requires_dbus': true,
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment