~ubuntu-branches/ubuntu/utopic/ibus-cangjie/utopic-updates

« back to all changes in this revision

Viewing changes to test-driver

  • Committer: Package Import Robot
  • Author(s): Didier Roche
  • Date: 2015-05-26 09:19:14 UTC
  • mfrom: (6.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20150526091914-bterkby7t7a62eux
Tags: 2.4-1~utopic1
Backporting wily release sync to utopic to fix multiple UX issues
as per upstream request (LP: #1452376)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /bin/sh
2
2
# test-driver - basic testsuite driver script.
3
3
 
4
 
scriptversion=2012-06-27.10; # UTC
 
4
scriptversion=2013-07-13.22; # UTC
5
5
 
6
 
# Copyright (C) 2011-2013 Free Software Foundation, Inc.
 
6
# Copyright (C) 2011-2014 Free Software Foundation, Inc.
7
7
#
8
8
# This program is free software; you can redistribute it and/or modify
9
9
# it under the terms of the GNU General Public License as published by
44
44
Usage:
45
45
  test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
46
46
              [--expect-failure={yes|no}] [--color-tests={yes|no}]
47
 
              [--enable-hard-errors={yes|no}] [--] TEST-SCRIPT
 
47
              [--enable-hard-errors={yes|no}] [--]
 
48
              TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
48
49
The '--test-name', '--log-file' and '--trs-file' options are mandatory.
49
50
END
50
51
}
51
52
 
52
 
# TODO: better error handling in option parsing (in particular, ensure
53
 
# TODO: $log_file, $trs_file and $test_name are defined).
54
53
test_name= # Used for reporting.
55
54
log_file=  # Where to save the output of the test script.
56
55
trs_file=  # Where to save the metadata of the test run.
69
68
  --enable-hard-errors) enable_hard_errors=$2; shift;;
70
69
  --) shift; break;;
71
70
  -*) usage_error "invalid option: '$1'";;
 
71
   *) break;;
72
72
  esac
73
73
  shift
74
74
done
75
75
 
 
76
missing_opts=
 
77
test x"$test_name" = x && missing_opts="$missing_opts --test-name"
 
78
test x"$log_file"  = x && missing_opts="$missing_opts --log-file"
 
79
test x"$trs_file"  = x && missing_opts="$missing_opts --trs-file"
 
80
if test x"$missing_opts" != x; then
 
81
  usage_error "the following mandatory options are missing:$missing_opts"
 
82
fi
 
83
 
 
84
if test $# -eq 0; then
 
85
  usage_error "missing argument"
 
86
fi
 
87
 
76
88
if test $color_tests = yes; then
77
89
  # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.
78
90
  red='' # Red.
94
106
# Test script is run here.
95
107
"$@" >$log_file 2>&1
96
108
estatus=$?
 
109
 
97
110
if test $enable_hard_errors = no && test $estatus -eq 99; then
98
 
  estatus=1
 
111
  tweaked_estatus=1
 
112
else
 
113
  tweaked_estatus=$estatus
99
114
fi
100
115
 
101
 
case $estatus:$expect_failure in
 
116
case $tweaked_estatus:$expect_failure in
102
117
  0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
103
118
  0:*)   col=$grn res=PASS  recheck=no  gcopy=no;;
104
119
  77:*)  col=$blu res=SKIP  recheck=no  gcopy=yes;;
107
122
  *:*)   col=$red res=FAIL  recheck=yes gcopy=yes;;
108
123
esac
109
124
 
 
125
# Report the test outcome and exit status in the logs, so that one can
 
126
# know whether the test passed or failed simply by looking at the '.log'
 
127
# file, without the need of also peaking into the corresponding '.trs'
 
128
# file (automake bug#11814).
 
129
echo "$res $test_name (exit status: $estatus)" >>$log_file
 
130
 
110
131
# Report outcome to console.
111
132
echo "${col}${res}${std}: $test_name"
112
133