File: meson-test.sh

package info (click to toggle)
gnome-shell 49.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,804 kB
  • sloc: javascript: 75,083; ansic: 66,192; xml: 1,798; sh: 919; python: 666; makefile: 51
file content (108 lines) | stat: -rwxr-xr-x 2,188 bytes parent folder | download
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash

set -e

DEFAULT_TOOLBOX=gnome-shell-devel
CONFIG_FILE=${XDG_CONFIG_HOME:-$HOME/.config}/gnome-shell-toolbox-tools.conf

usage() {
  cat <<-EOF
	Usage: $(basename $0) [OPTION…]

	Run meson project tests in a toolbox

	Options:
	  -t, --toolbox=TOOLBOX   Use TOOLBOX instead of the default "$DEFAULT_TOOLBOX"

	  --gdb                   Run test under gdb
	  --wrapper=WRAPPER       Wrapper to run tests with (e.g. valgrind)

	  --list                  List available tests

	  --suite=SUITE           Only run tests belonging to the given suite
	  --no-suite=SUITE        Do not run tests belonging to the given suite

	  --setup=SETUP           Which test setup to use
	  --test-args=TEST_ARGS   Arguments to pass to the specified test(s) or all tests

	  -v, --verbose           Do not redirect stdout and stderr
	  -q, --quiet             Produce less output to the terminal

	  -h, --help              Display this help

	EOF
}

die() {
  echo "$@" >&2
  exit 1
}

find_toplevel() {
  while true; do
    grep -qs '\<project\>' meson.build && break
    [[ $(pwd) -ef / ]] && die "Error: No meson toplevel found"
    cd ..
  done
}

# load defaults
. $CONFIG_FILE
TOOLBOX=$DEFAULT_TOOLBOX

TEMP=$(getopt \
  --name $(basename $0) \
  --options 't:vqh' \
  --longoptions 'toolbox:' \
  --longoptions 'gdb' \
  --longoptions 'wrapper:' \
  --longoptions 'list' \
  --longoptions 'suite:' \
  --longoptions 'no-suite:' \
  --longoptions 'setup:' \
  --longoptions 'test-args:' \
  --longoptions 'verbose' \
  --longoptions 'quiet' \
  --longoptions 'help' \
  -- "$@") || die "Run $(basename $0) --help to see available options"

eval set -- "$TEMP"
unset TEMP

MESON_ARGS=()

while true; do
  case $1 in
    -t|--toolbox)
      TOOLBOX=$2
      shift 2
    ;;

    --list|--gdb|-v|--verbose|-q|--quiet)
      MESON_ARGS+=($1)
      shift
    ;;

    --wrapper|--suite|--no-suite|--setup|--test-args)
      MESON_ARGS+=($1 $2)
      shift 2
    ;;

    -h|--help)
      usage
      exit 0
    ;;

    --)
      shift
      break
    ;;
  esac
done

find_toplevel

BUILD_DIR=_build-$TOOLBOX

toolbox run --container $TOOLBOX \
  meson test -C $BUILD_DIR ${MESON_ARGS[*]} "$@"