Skip to content

Commit

Permalink
make it easy to run a specific redis version
Browse files Browse the repository at this point in the history
Which we also use in Travis.
  • Loading branch information
alicebob committed Jan 9, 2019
1 parent cfad8ac commit 3e4b003
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/integration/redis_src/
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
language: go

before_script:
- (cd ./integration && ./get_redis.sh)

install: go get -t

script: make test testrace int
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ Commands which will probably not be implemented:

## &c.

Tests are run against Redis 4.0.6 (Debian). The [./integration](./integration/)
Tests are run against Redis 5.0.3. The [./integration](./integration/)
subdir compares miniredis against a real redis instance.


Expand Down
5 changes: 5 additions & 0 deletions integration/ephemeral.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ package main
import (
"fmt"
"net"
"os"
"os/exec"
"strconv"
"time"
)

const (
localSrc = "./redis_src/"
executable = "redis-server"
)

Expand All @@ -34,6 +36,9 @@ func RedisAuth(passwd string) (*ephemeral, string) {
func runRedis(extraConfig string) (*ephemeral, string) {
port := arbitraryPort()

// we prefer the executable from ./redis_src, if any. See ./get_redis.sh
os.Setenv("PATH", fmt.Sprintf("%s:PATH", localSrc))

c := exec.Command(executable, "-")
stdin, err := c.StdinPipe()
if err != nil {
Expand Down
13 changes: 13 additions & 0 deletions integration/get_redis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

set -eu

VERSION=5.0.3

rm -rf ./redis_src/
mkdir -p ./redis_src/
cd ./redis_src/
wget http://download.redis.io/releases/redis-${VERSION}.tar.gz -O ./redis.tar.gz
tar -xf ./redis.tar.gz
(cd ./redis-${VERSION}/src/ && make)
cp ./redis-${VERSION}/src/redis-server .

0 comments on commit 3e4b003

Please sign in to comment.