Fix GSetttings schema error running tests. Bug 776837.

* test/main.vala (main): Set the location of the compiled dev schema
  before running any tests.

* test/CMakeLists.txt: Pass location of compiled GSettings schema through
  to the test source. Depend on the geary binary so things like the
  shcema are already compiled before compiling the tests.
This commit is contained in:
Michael James Gratton 2017-01-09 09:14:31 +11:00
parent c68810a6b6
commit 17ce3ed913
2 changed files with 10 additions and 0 deletions

View file

@ -47,6 +47,7 @@ set(CFLAGS
${DEPS_CFLAGS}
${DEPS_CFLAGS_OTHER}
-D_BUILD_ROOT_DIR=\"${CMAKE_BINARY_DIR}\"
-D_GSETTINGS_DIR=\"${CMAKE_BINARY_DIR}/gsettings\"
-D_SOURCE_ROOT_DIR=\"${CMAKE_SOURCE_DIR}\"
)
@ -78,4 +79,7 @@ OPTIONS
)
add_executable(geary-test ${TEST_VALA_C})
# Depend on geary so things like GResources, GSetting, etc are
# compiled before the tests are built and run.
add_dependencies(geary-test geary)
target_link_libraries(geary-test ${DEPS_LIBRARIES} geary-client geary-engine)

View file

@ -5,6 +5,9 @@
* (version 2.1 or later). See the COPYING file in this distribution.
*/
// Defined by CMake build script.
extern const string _GSETTINGS_DIR;
int main(string[] args) {
/*
* Set env vars right up front to avoid weird bugs
@ -14,6 +17,9 @@ int main(string[] args) {
// values, and b) don't persist any changes made during a test
Environment.set_variable("GSETTINGS_BACKEND", "memory", true);
// Let GSettings know where to find the dev schema
Environment.set_variable("GSETTINGS_SCHEMA_DIR", _GSETTINGS_DIR, true);
/*
* Initialise all the things.
*/