|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
3 | | -if [[ $0 == /* ]] |
4 | | -then |
5 | | - HOME=$(dirname $0) |
6 | | -else |
7 | | - HOME=$(pwd)/$(dirname $0) |
8 | | -fi |
9 | | -cd ${HOME} |
10 | | - |
11 | | -DOT_TEST=${HOME}/.test |
12 | | -NEOGET=${HOME}/neoget.sh |
| 3 | +# Copyright (c) 2002-2015 "Neo Technology," |
| 4 | +# Network Engine for Objects in Lund AB [http://neotechnology.com] |
| 5 | +# |
| 6 | +# This file is part of Neo4j. |
| 7 | +# |
| 8 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | +# you may not use this file except in compliance with the License. |
| 10 | +# You may obtain a copy of the License at |
| 11 | +# |
| 12 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | +# |
| 14 | +# Unless required by applicable law or agreed to in writing, software |
| 15 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | +# See the License for the specific language governing permissions and |
| 18 | +# limitations under the License. |
| 19 | + |
| 20 | +DRIVER_HOME=$(dirname $0) |
13 | 21 |
|
14 | 22 | FORCE_DOWNLOAD=0 |
15 | 23 | RUNNING=0 |
16 | 24 |
|
17 | | -function runserverandtests { |
18 | | - |
19 | | - PYTHON_VERSION=$(python --version) |
20 | | - NEO_VERSION=$1 |
21 | | - |
22 | | - echo "======================================================================" |
23 | | - echo "Running with ${PYTHON_VERSION} against Neo4j ${NEO_VERSION}" |
24 | | - echo "----------------------------------------------------------------------" |
25 | | - |
26 | | - cd ${HOME} |
27 | | - |
28 | | - if [ ${FORCE_DOWNLOAD} -ne 0 ] |
29 | | - then |
30 | | - rm -rf ${DOT_TEST} |
31 | | - fi |
32 | | - mkdir -p ${DOT_TEST} 2> /dev/null |
33 | | - |
34 | | - pushd ${DOT_TEST} > /dev/null |
35 | | - tar xf $(${NEOGET} ${NEOGET_ARGS}) |
36 | | - NEO_HOME=$(ls -1Ft | grep "/$" | head -1) # finds the newest directory relative to .test |
37 | | - echo "xx.bolt.enabled=true" >> ${NEO_HOME}/conf/neo4j-server.properties |
38 | | - ${NEO_HOME}/bin/neo4j start |
39 | | - STATUS=$? |
40 | | - if [ ${STATUS} -ne 0 ] |
41 | | - then |
42 | | - exit ${STATUS} |
43 | | - fi |
44 | | - popd > /dev/null |
45 | | - |
46 | | - echo -n "Testing" |
47 | | - coverage run -m unittest "${TESTS}" |
48 | | - |
49 | | - pushd ${DOT_TEST} > /dev/null |
50 | | - ${NEO_HOME}/bin/neo4j stop |
51 | | - rm -rf ${NEO_HOME} |
52 | | - popd > /dev/null |
53 | | - |
54 | | - coverage report --show-missing |
55 | | - |
56 | | - echo "======================================================================" |
57 | | - echo "" |
58 | | - |
59 | | -} |
60 | | - |
61 | | -function runtests { |
62 | | - |
63 | | - PYTHON_VERSION=$(python --version) |
64 | | - |
65 | | - echo "======================================================================" |
66 | | - echo "Running with ${PYTHON_VERSION} against running Neo4j instance" |
67 | | - echo "----------------------------------------------------------------------" |
68 | | - |
69 | | - cd ${HOME} |
70 | | - |
71 | | - echo -n "Testing" |
72 | | - coverage run -m unittest test |
73 | | - |
74 | | - coverage report --show-missing |
75 | | - |
76 | | - echo "======================================================================" |
77 | | - echo "" |
| 25 | +if [ -z "${TEST}" ] |
| 26 | +then |
| 27 | + TEST="test" |
| 28 | +fi |
78 | 29 |
|
79 | | -} |
| 30 | +VERSIONS=$* |
| 31 | +if [ "${VERSIONS}" == "" ] |
| 32 | +then |
| 33 | + VERSIONS="nightly" |
| 34 | +fi |
80 | 35 |
|
| 36 | +# Parse options |
81 | 37 | while getopts ":dr" OPTION |
82 | 38 | do |
83 | 39 | case ${OPTION} in |
|
93 | 49 | esac |
94 | 50 | done |
95 | 51 |
|
96 | | -TESTS=$1 |
97 | | -if [ "${TESTS}" == "" ] |
| 52 | +# Run tests |
| 53 | +echo "Running tests with $(python --version)" |
| 54 | +pip install --upgrade -r ${DRIVER_HOME}/test_requirements.txt |
| 55 | +echo "" |
| 56 | +TEST_RUNNER="coverage run -m unittest discover -vfs ${TEST}" |
| 57 | +if [ ${RUNNING} -eq 1 ] |
98 | 58 | then |
99 | | - TESTS="test" |
| 59 | + ${TEST_RUNNER} |
| 60 | + EXIT_STATUS=$? |
| 61 | +else |
| 62 | + neokit/neorun "${TEST_RUNNER}" ${VERSIONS} |
| 63 | + EXIT_STATUS=$? |
| 64 | + if [ ${EXIT_STATUS} -eq 0 ] |
| 65 | + then |
| 66 | + coverage report --show-missing |
| 67 | + fi |
100 | 68 | fi |
101 | 69 |
|
102 | | -if [ ${RUNNING} -eq 1 ] |
| 70 | +# Exit correctly |
| 71 | +if [ ${EXIT_STATUS} -ne 0 ] |
103 | 72 | then |
104 | | - runtests |
105 | | -else |
106 | | - NEOGET_ARGS="-eax" |
107 | | - runserverandtests "3.0.0-M01" |
| 73 | + exit ${EXIT_STATUS} |
108 | 74 | fi |
0 commit comments