File: run.sh

package info (click to toggle)
ruby-nokogiri 1.10.0%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,088 kB
  • sloc: xml: 28,081; ruby: 16,687; java: 13,293; ansic: 4,954; yacc: 265; sh: 76; makefile: 19
file content (87 lines) | stat: -rwxr-xr-x 1,895 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
#! /usr/bin/env bash

set -e -x -u

APT_UPDATED=false

function ensure-apt-update {
  if [[ $APT_UPDATED != "false" ]] ; then
    return
  fi

  apt-get update
  APT_UPDATED=true
}

if [[ ${TEST_WITH_APT_REPO_RUBY:-} != "" ]] ; then
  ensure-apt-update
  apt-get install -y ruby ruby-dev bundler libxslt-dev libxml2-dev pkg-config
fi

VERSION_INFO=$(ruby -v)
RUBY_ENGINE=$(cut -d" " -f1 <<< "${VERSION_INFO}")
RUBY_VERSION=$(cut -d" " -f2 <<< "${VERSION_INFO}")

FROZEN_STRING_REF="53f9b66"

function mri-24-or-greater {
  if [[ $RUBY_ENGINE != "ruby" ]] ; then
    return 1
  fi

  if echo $RUBY_VERSION | grep "^[0-2]\.[0-3]\." > /dev/null ; then
    return 1
  fi

  return 0
}

function commit-is-post-frozen-string-support {
  if git merge-base --is-ancestor ${FROZEN_STRING_REF} HEAD ; then
    return 0
  fi
  return 1
}

function rbx-engine {
  if [[ $RUBY_ENGINE == "rubinius" ]] ; then
    return 0
  fi
  return 1
}

pushd nokogiri

  RAKE_TASK="test"

  if rbx-engine ; then
    ensure-apt-update
    apt-get install -y ca-certificates gcc pkg-config libxml2-dev libxslt-dev patch
  fi

  if [[ ${TEST_WITH_VALGRIND:-} != "" ]] ; then
    ensure-apt-update
    apt-get install -y valgrind
  fi

  bundle install
  bundle exec rake generate # do this before setting frozen string option, because racc isn't compatible with frozen string literals yet

  if mri-24-or-greater && commit-is-post-frozen-string-support ; then
    export RUBYOPT="--enable-frozen-string-literal --debug=frozen-string-literal"
  fi

  if [[ ${TEST_WITH_VALGRIND:-} != "" ]] ; then
    RAKE_TASK="test:valgrind" # override
    export TESTOPTS="-v" # see more verbose output to help narrow down warnings

    # always use the CI suppressions if they exist
    if [[ -d ../ci/suppressions ]] ; then
      rm -rf suppressions
      cp -var ../ci/suppressions .
    fi
  fi

  bundle exec rake ${RAKE_TASK}

popd