|
1 | 1 | #!/bin/bash
|
2 | 2 |
|
| 3 | +set -e |
| 4 | +set -xv |
| 5 | + |
| 6 | +py_version_short=$(python -c "import sys; print(''.join(str(x) for x in sys.version_info[:2]))") |
| 7 | +# -> 26 or 27 or 34 or .. |
| 8 | + |
3 | 9 | get_name (){
|
4 | 10 | echo $(python -c 'import json; print json.load(open("'$1'package.json"))["name"]')
|
5 | 11 | }
|
6 | 12 |
|
| 13 | +SHI_DST=test/tmp/shinken |
| 14 | + |
7 | 15 | setup_submodule (){
|
| 16 | + local dep |
| 17 | + local mname |
| 18 | + local mpath |
8 | 19 | for dep in $(cat test/dep_modules.txt); do
|
9 | 20 | mname=$(basename $dep | sed 's/.git//g')
|
10 |
| - git clone --depth=15 $dep ~/$mname |
11 |
| - rmname=$(get_name ~/$mname/) |
12 |
| - cp -r ~/$mname/module ~/shinken/modules/$rmname |
13 |
| - [ -f ~/$mname/requirements.txt ] && pip install -r ~/$mname/requirements.txt |
| 21 | + mpath="test/tmp/$mname" |
| 22 | + git clone --depth 10 "$dep" "$mpath" |
| 23 | + ( cd $mpath && git status && git log -1) |
| 24 | + rmname=$(get_name "$mpath/") |
| 25 | + ln -s "$PWD/$mpath/module" "$PWD/$SHI_DST/test/modules/$rmname" |
| 26 | + |
| 27 | + if [ -f "$PWD/$mpath/test/mock_livestatus.py" ] |
| 28 | + then |
| 29 | + ln -s "$PWD/$mpath/test/mock_livestatus.py" "$PWD/$SHI_DST/test/modules/$rmname/mock_livestatus.py" |
| 30 | + fi |
| 31 | + |
| 32 | + if [ -f "$PWD/$mpath/test/etc" ] |
| 33 | + then |
| 34 | + cp -r "$PWD/$mpath/test/etc" "$PWD/$SHI_DST/test/etc" |
| 35 | + fi |
| 36 | + |
| 37 | + if [ -f "$mpath/requirements.txt" ] |
| 38 | + then |
| 39 | + pip install -r "$mpath/requirements.txt" |
| 40 | + fi |
| 41 | + |
| 42 | + ls -alH "$PWD/$SHI_DST/test/modules/$rmname" |
14 | 43 | done
|
15 |
| - # we need the livestatus test config files to be in shinken test config dir: |
16 |
| - cp -r ~/mod-livestatus/test/etc/* ~/shinken/test/etc/ |
17 | 44 | }
|
18 | 45 |
|
19 | 46 | name=$(get_name)
|
20 | 47 |
|
21 | 48 | pip install pycurl
|
22 | 49 | pip install coveralls
|
23 |
| -git clone https://github.com/naparuba/shinken.git ~/shinken |
24 | 50 |
|
25 |
| -[ -f test/dep_modules.txt ] && setup_submodule |
26 |
| -[ -f requirements.txt ] && pip install -r requirements.txt |
27 |
| -[ -f test/requirements.txt ] && pip install -r test/requirements.txt |
| 51 | +rm -rf test/tmp |
| 52 | +mkdir -p test/tmp/ |
| 53 | + |
| 54 | +git clone --depth 10 https://github.com/naparuba/shinken.git "$SHI_DST" |
| 55 | +( cd "$SHI_DST" && git status && git log -1) |
| 56 | + |
| 57 | +spec_requirement="requirements-${py_version_short}.txt" |
| 58 | + |
| 59 | +( |
| 60 | + cd "$SHI_DST" |
| 61 | + pip install -r test/requirements.txt |
| 62 | + if [ -f "test/${spec_requirement}" ] |
| 63 | + then |
| 64 | + pip install -r "test/${spec_requirement}" |
| 65 | + fi |
| 66 | +) |
| 67 | + |
| 68 | +if [ -f test/dep_modules.txt ] |
| 69 | +then |
| 70 | + setup_submodule |
| 71 | +fi |
28 | 72 |
|
29 |
| -# if we have test config files we probably also need them in the shinken/test directory : |
30 |
| -[ -d test/etc ] && cp -r test/etc ~/shinken/test/ |
| 73 | +test_requirement="test/requirements.txt" |
| 74 | +if [ -f "$test_requirement" ] |
| 75 | +then |
| 76 | + pip install -r "$test_requirement" |
| 77 | +fi |
| 78 | +test_requirement="test/$spec_requirement" |
| 79 | +if [ -f "$test_requirement" ] |
| 80 | +then |
| 81 | + pip install -r "$test_requirement" |
| 82 | +fi |
31 | 83 |
|
32 |
| -# copy our module package to the shinken modules directory: |
33 |
| -cp -r module ~/shinken/modules/$name |
34 |
| -# and make a link to it from the test/modules directory: |
35 |
| -ln -sf ~/shinken/modules/ ~/shinken/test/modules |
| 84 | +ln -s "$PWD/module" "$SHI_DST/test/modules/$name" |
0 commit comments