[fractal] build: hook up tests with meson



commit f4ce5e7c0d5df113086e3d9e6c283974b2a26ba9
Author: Christopher Davis <brainblasted disroot org>
Date:   Mon Apr 22 12:00:05 2019 -0400

    build: hook up tests with meson
    
    Adds our cargo test to meson's testing system so that
    `ninja test` runs it in addition to our resource validation tests.

 .gitlab-ci.yml  | 2 +-
 meson.build     | 9 +++++++++
 scripts/test.sh | 9 +++++++++
 3 files changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c4d2ee25..e5694988 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -49,7 +49,7 @@ flatpak:
               --env=CARGO_HOME="target/cargo-home" \
               --env=CARGO_TARGET_DIR="target_test/" \
               app ${MANIFEST_PATH} \
-              cargo test
+              ninja -C _build test
 
         # Create a flatpak bundle
         - flatpak-builder --finish-only app ${MANIFEST_PATH}
diff --git a/meson.build b/meson.build
index 27c21231..41bed42a 100644
--- a/meson.build
+++ b/meson.build
@@ -71,6 +71,7 @@ cargo = find_program('cargo', required: false)
 gresource = find_program('glib-compile-resources', required: false)
 cargo_vendor = find_program('cargo-vendor', required: false)
 cargo_script = find_program('scripts/cargo.sh')
+test_script = find_program('scripts/test.sh')
 grabber = find_program('scripts/grabber.sh')
 
 subdir('fractal-gtk/src')
@@ -81,6 +82,14 @@ meson.add_dist_script(
   join_paths(meson.build_root(), 'meson-dist', meson.project_name() + '-' + fractal_version)
 )
 
+test(
+  'cargo-test',
+  test_script,
+  args: meson.build_root(),
+  workdir: meson.source_root(),
+  timeout: 3000,
+)
+
 if get_option('profile') == 'development'
     # Setup pre-commit hook for ensuring coding style is always consistent
     message('Setting up git pre-commit hook..')
diff --git a/scripts/test.sh b/scripts/test.sh
new file mode 100644
index 00000000..35ed2411
--- /dev/null
+++ b/scripts/test.sh
@@ -0,0 +1,9 @@
+#! /usr/bin/sh
+
+set -o errexit
+set -o pipefail
+
+export CARGO_TARGET_DIR="$1/target/"
+export CARGO_HOME="$CARGO_TARGET_DIR/cargo-home"
+
+cargo test -j 1 -- --test-threads=1 --nocapture


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