File: run.sh

package info (click to toggle)
weevely 4.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,336 kB
  • sloc: python: 7,732; php: 1,035; sh: 53; makefile: 2
file content (51 lines) | stat: -rwxr-xr-x 1,493 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
#!/bin/bash
set -e
 
# Load docker defaults and check conf
docker info

# Change folder to the root folder
PARENTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../ && pwd )"
cd $PARENTDIR

# Delete any instance if previously existent
docker rm -f httpbin-inst || echo ''
docker rm -f weevely-inst || echo ''
docker network rm weevely-testnet || echo ''

# Create the network
docker network create weevely-testnet

# Run httpbin container for local testing
docker pull kennethreitz/httpbin
docker run -p 8888:80 --net=weevely-testnet --rm --name httpbin-inst -d kennethreitz/httpbin

# Wait until the http server is serving
until $(curl --output /dev/null --silent --head http://localhost:8888/); do
    sleep 1
done

# Build weevely container
docker build -f tests/docker/Dockerfile . -t weevely
docker run  --rm --net=weevely-testnet --name weevely-inst -v `pwd`:/app/ -p 80:80 -d weevely

# Wait until the http server is serving
until $(curl --output /dev/null --silent --head http://localhost/); do
    sleep 1
done

if [ "$1" = "bash" ]; then
  docker exec -e "AGENT=$AGENT" -it weevely-inst /bin/bash
else
  for AGENT in agent.php agent.phar; do
    if [ -z "$1" ]; then
      docker exec -e "AGENT=$AGENT" -it weevely-inst python -m unittest discover ./tests/ "test_*.py"
    else
      docker exec -e "AGENT=$AGENT" -it weevely-inst python -m unittest discover ./tests/ "test_$1.py"
    fi
  done
fi

docker rm -f weevely-inst 
docker rm -f httpbin-inst
docker network rm weevely-testnet