run 3.64 KB
Newer Older
Kenneth Reitz's avatar
Kenneth Reitz committed
1
#!/usr/bin/env bash
Kenneth Reitz's avatar
Kenneth Reitz committed
2

Casey Faist's avatar
Casey Faist committed
3
testAirflow() {
4
  export SLUGIFY_USES_TEXT_UNIDECODE="yes"
Casey Faist's avatar
Casey Faist committed
5 6 7 8 9
  compile "airflow"
  assertCaptured "apache-airflow==1.10"
  assertCapturedSuccess
}

Kenneth Reitz's avatar
Kenneth Reitz committed
10 11 12 13 14
testPipenv() {
  compile "pipenv"
  assertCapturedSuccess
}

Kenneth Reitz's avatar
Kenneth Reitz committed
15 16 17 18 19
testPipenvLock() {
  compile "pipenv-lock"
  assertCapturedSuccess
}

Kenneth Reitz's avatar
Kenneth Reitz committed
20 21
testPipenvVersion() {
  compile "pipenv-version"
22
  assertCaptured "3.6.6"
Kenneth Reitz's avatar
Kenneth Reitz committed
23 24
  assertCapturedSuccess
}
Kenneth Reitz's avatar
Kenneth Reitz committed
25

Kenneth Reitz's avatar
Kenneth Reitz committed
26 27
testPipenvFullVersion() {
  compile "pipenv-full-version"
28
  assertCaptured "3.6.3"
Kenneth Reitz's avatar
Kenneth Reitz committed
29 30 31
  assertCapturedSuccess
}

Kenneth Reitz's avatar
Kenneth Reitz committed
32 33 34 35 36
testNoRequirements() {
  compile "no-requirements"
  assertCapturedError
}

Kenneth Reitz's avatar
Kenneth Reitz committed
37 38 39 40 41
testCollectstatic() {
  compile "collectstatic"
  assertCaptured "collectstatic"
}

Kenneth Reitz's avatar
Kenneth Reitz committed
42 43 44 45 46
testGEOS() {
  BUILD_WITH_GEO_LIBRARIES=1 compile "geos"
  assertCaptured "geos"
  assertCapturedSuccess
}
Kenneth Reitz's avatar
Kenneth Reitz committed
47

Kenneth Reitz's avatar
Kenneth Reitz committed
48
testNLTK() {
49 50 51 52 53
  # NOTE: This is a RuntimeWarning emitted by Python 3's runpy.py script
  # which is what is used when you call `python -m <module>`. This is due to
  # how nltk imports things. It's not actually an error, but it would probably
  # be bad to silence in Production.
  export PYTHONWARNINGS="ignore::RuntimeWarning"
Kenneth Reitz's avatar
Kenneth Reitz committed
54
  compile "nltk"
55
  assertCaptured "Downloading NLTK packages: city_database stopwords"
Kenneth Reitz's avatar
Kenneth Reitz committed
56 57 58
  assertCapturedSuccess
}

Kenneth Reitz's avatar
Kenneth Reitz committed
59 60 61 62 63 64
testSetupPy() {
  compile "setup-py"
  assertCaptured "maya"
  assertCapturedSuccess
}

Kenneth Reitz's avatar
Kenneth Reitz committed
65 66 67 68 69 70 71 72 73 74 75

testStandardRequirements() {
  compile "requirements-standard"
  assertCaptured "requests"
  assertCapturedSuccess
}

testPsycopg2() {
  compile "psycopg2"
  assertCaptured "psycopg2"
  assertCapturedSuccess
76 77 78 79 80 81
}

testCffi() {
  compile "cffi"
  assertCaptured "cffi"
  assertCapturedSuccess
Kenneth Reitz's avatar
Kenneth Reitz committed
82 83
}

Kenneth Reitz's avatar
Kenneth Reitz committed
84 85 86 87 88 89
testPylibmc() {
  compile "pylibmc"
  assertCaptured "pylibmc"
  assertCapturedSuccess
}

Kenneth Reitz's avatar
Kenneth Reitz committed
90
testPython2() {
91 92 93 94 95
    compile "python2"
    assertCaptured "python-2.7.15"
    assertCapturedSuccess
}

Kenneth Reitz's avatar
Kenneth Reitz committed
96 97
testPython3() {
  compile "python3"
98
  assertCaptured "python-3.6.6"
Kenneth Reitz's avatar
Kenneth Reitz committed
99 100 101
  assertCapturedSuccess
}

102 103 104 105 106 107
testGitEgg() {
  compile "git-egg"
  assertCaptured "requests"
  assertCapturedSuccess
}

108 109 110 111 112 113 114 115 116 117
testSmartRequirements() {
  local cache_dir="$(mktmpdir)"
  compile "requirements-standard" "$cache_dir"
  assertFile "requests" ".heroku/python/requirements-declared.txt"
  assertCapturedSuccess
  compile "psycopg2" "$cache_dir"
  assertCaptured "Uninstalling requests"
  assertFile "psycopg2" ".heroku/python/requirements-declared.txt"
  assertCapturedSuccess
}
Kenneth Reitz's avatar
Kenneth Reitz committed
118

119 120 121 122 123 124 125 126 127
testStackChange() {
  local cache_dir="$(mktmpdir)"
  mkdir -p "${cache_dir}/.heroku"
  echo "different-stack" > "${cache_dir}/.heroku/python-stack"
  compile "requirements-standard" "$cache_dir"
  assertCaptured "clearing cache"
  assertFile "$STACK" ".heroku/python-stack"
  assertCapturedSuccess
}
Kenneth Reitz's avatar
Kenneth Reitz committed
128 129


Kenneth Reitz's avatar
Kenneth Reitz committed
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
pushd $(dirname 0) >/dev/null
popd >/dev/null

source $(pwd)/test/utils

mktmpdir() {
  dir=$(mktemp -t testXXXXX)
  rm -rf $dir
  mkdir $dir
  echo $dir
}

detect() {
  capture $(pwd)/bin/detect $(pwd)/test/fixtures/$1
}

compile_dir=""

default_process_types_cleanup() {
  file="/tmp/default_process_types"
  if [ -f "$file" ]; then
    rm "$file"
  fi
}

compile() {
  default_process_types_cleanup
  bp_dir=$(mktmpdir)
  compile_dir=$(mktmpdir)
  cp -a $(pwd)/* ${bp_dir}
  cp -a ${bp_dir}/test/fixtures/$1/. ${compile_dir}
  capture ${bp_dir}/bin/compile ${compile_dir} ${2:-$(mktmpdir)} $3
}

compileDir() {
  default_process_types_cleanup

  local bp_dir=$(mktmpdir)
  local compile_dir=${1:-$(mktmpdir)}
  local cache_dir=${2:-$(mktmpdir)}
  local env_dir=$3

  cp -a $(pwd)/* ${bp_dir}
  capture ${bp_dir}/bin/compile ${compile_dir} ${cache_dir} ${env_dir}
}

release() {
  bp_dir=$(mktmpdir)
  cp -a $(pwd)/* ${bp_dir}
  capture ${bp_dir}/bin/release ${bp_dir}/test/fixtures/$1
}

assertFile() {
  assertEquals "$1" "$(cat ${compile_dir}/$2)"
}

source $(pwd)/test/shunit2