[geary] Basic unit test build configuration.



commit 6ce262a3b7e90f827e3d19ea3a611bf4930f5218
Author: Michael James Gratton <mike vee net>
Date:   Mon Dec 12 22:47:53 2016 +1100

    Basic unit test build configuration.

 CMakeLists.txt      |   18 ++++++++++++++-
 Makefile.in         |    9 +++++--
 src/CMakeLists.txt  |    3 +-
 test/CMakeLists.txt |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++
 test/main.vala      |   11 +++++++++
 5 files changed, 94 insertions(+), 6 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fa39396..0d091bd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,6 +23,13 @@ set(VERSION "0.11.2-dev")
 set(VERSION_INFO "Release")
 set(LANGUAGE_SUPPORT_DIRECTORY ${CMAKE_INSTALL_PREFIX}/share/locale)
 
+#
+# Primary library minimum version requirements. See src/CMakeLists.txt
+# for others.
+#
+set(TARGET_GLIB 2.42) # Also passed to valac, so don't include a point rev
+set(TARGET_GTK 3.14.0)
+
 if (NOT ISO_CODE_639_XML)
   find_path(ISOCODES_DIRECTORY NAMES iso_639.xml PATHS ${CMAKE_INSTALL_PREFIX} /usr/share/xml/iso-codes)
   if (ISOCODES_DIRECTORY)
@@ -141,6 +148,14 @@ endif ()
 include(GlibCompileResourcesSupport)
 
 #
+# Unit tests.
+#
+# We don't use CMake's enable_testing/add_test built-ins because they
+# use ctest.
+add_custom_target(test ALL geary-test)
+add_dependencies(test geary-test)
+
+#
 # Uninstall target
 #
 configure_file(
@@ -169,7 +184,7 @@ add_dependencies(uninstall uninstall-base)
 # everything has has been removed
 add_custom_target(
     post-uninstall
-)
+    )
 
 # Dist
 # This generates the dist tarballs
@@ -216,3 +231,4 @@ add_subdirectory(po)
 add_subdirectory(sql)
 add_subdirectory(ui)
 add_subdirectory(src)
+add_subdirectory(test)
diff --git a/Makefile.in b/Makefile.in
index 32ccaff..81575c6 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -37,16 +37,19 @@ distclean: clean
        @-rm -rf $(BUILD_DIR)
        @-rm -f Makefile
 
+.PHONY: test
+test:
+       @$(MAKE) -C $(BUILD_DIR) $@
+
 .PHONY: dist
-dist:
+dist: test
        @$(MAKE) -C $(BUILD_DIR) dist
        @cp build/*.xz .
 
 .PHONY: ubuntu
-ubuntu:
+ubuntu: test
        @$(MAKE) -C $(BUILD_DIR) ubuntu
 
 .PHONY: valadoc
 valadoc:
        @$(MAKE) -C $(BUILD_DIR) valadoc
-
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bc8d728..56ef18e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -481,13 +481,12 @@ else ()
     )
 endif ()
 
-set(TARGET_GLIB 2.42)
 
 pkg_check_modules(DEPS REQUIRED
     gthread-2.0
     glib-2.0>=${TARGET_GLIB}.0
     gio-2.0>=${TARGET_GLIB}.0
-    gtk+-3.0>=3.14.0
+    gtk+-3.0>=${TARGET_GTK}
     libsoup-2.4>=2.48
     gee-0.8>=0.8.5
     libnotify>=0.7.5
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644
index 0000000..83e6023
--- /dev/null
+++ b/test/CMakeLists.txt
@@ -0,0 +1,59 @@
+# Geary build script
+# Copyright 2016 Software Freedom Conservancy Inc.
+# Copyright 2016 Michael Gratton <mike vee net>
+
+set(TEST_SRC
+  main.vala
+)
+
+# Vala
+find_package(Vala REQUIRED)
+include(ValaVersion)
+include(ValaPrecompile)
+
+pkg_check_modules(DEPS REQUIRED
+  gee-0.8
+  gio-2.0
+  glib-2.0
+  gmime-2.6
+  gthread-2.0
+)
+
+set(TEST_PACKAGES
+  glib-2.0 gio-2.0 gee-0.8 gmime-2.6 geary-static
+)
+
+set(CFLAGS
+    ${DEPS_CFLAGS}
+    ${DEPS_CFLAGS_OTHER}
+    -D_BUILD_ROOT_DIR=\"${CMAKE_BINARY_DIR}\"
+    -D_SOURCE_ROOT_DIR=\"${CMAKE_SOURCE_DIR}\"
+)
+
+set(LIB_PATHS ${DEPS_LIBRARY_DIRS})
+link_directories(${LIB_PATHS})
+add_definitions(${CFLAGS})
+
+set(VALAC_OPTIONS
+    --vapidir=${CMAKE_SOURCE_DIR}/bindings/vapi
+    --metadatadir=${CMAKE_SOURCE_DIR}/bindings/metadata
+    --target-glib=${TARGET_GLIB}
+    --thread
+    --debug
+    --enable-checking
+    --enable-deprecated
+    --fatal-warnings
+    ${EXTRA_VALA_OPTIONS}
+)
+
+vala_precompile(TEST_VALA_C geary-test
+    ${TEST_SRC}
+PACKAGES
+    ${TEST_PACKAGES}
+OPTIONS
+    ${VALAC_OPTIONS}
+    --vapidir=${CMAKE_BINARY_DIR}/src
+)
+
+add_executable(geary-test ${TEST_VALA_C})
+target_link_libraries(geary-test ${DEPS_LIBRARIES} gthread-2.0 geary-static)
diff --git a/test/main.vala b/test/main.vala
new file mode 100644
index 0000000..3636691
--- /dev/null
+++ b/test/main.vala
@@ -0,0 +1,11 @@
+/*
+ * Copyright 2016 Michael Gratton <mike vee net>
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later). See the COPYING file in this distribution.
+ */
+
+void main(string[] args) {
+    Test.init(ref args);
+    print("OHHAI!");
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]