Commit 1840a01f authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

Merge branch 'feat/ipfs2-test_sharness'

parents 6f8569db 220e108d
......@@ -51,18 +51,23 @@ func isLocal(cmd *cmds.Command) bool {
return found
}
// NB: when necessary, properties are described using negatives in order to
// provide desirable defaults
type cmdDetails struct {
cannotRunOnClient bool
cannotRunOnDaemon bool
doesNotUseRepo bool
// initializesConfig describes commands that initialize the config.
// pre-command hooks that require configs must not be run before this
// command
initializesConfig bool
// doesNotUseConfigAsInput describes commands that do not use the config as
// input. These commands either initialize the config or perform operations
// that don't require access to the config.
//
// pre-command hooks that require configs must not be run before these
// commands.
doesNotUseConfigAsInput bool
// preemptsAutoUpdate describes commands that must be executed without the
// pre-command update hook
// auto-update pre-command hook
preemptsAutoUpdate bool
}
......@@ -71,21 +76,22 @@ func (d *cmdDetails) String() string {
d.canRunOnClient(), d.canRunOnDaemon(), d.usesRepo())
}
func (d *cmdDetails) canRunOnClient() bool { return !d.cannotRunOnClient }
func (d *cmdDetails) canRunOnDaemon() bool { return !d.cannotRunOnDaemon }
func (d *cmdDetails) usesRepo() bool { return !d.doesNotUseRepo }
func (d *cmdDetails) usesConfigAsInput() bool { return !d.doesNotUseConfigAsInput }
func (d *cmdDetails) canRunOnClient() bool { return !d.cannotRunOnClient }
func (d *cmdDetails) canRunOnDaemon() bool { return !d.cannotRunOnDaemon }
func (d *cmdDetails) usesRepo() bool { return !d.doesNotUseRepo }
// "What is this madness!?" you ask. Our commands have the unfortunate problem of
// not being able to run on all the same contexts. This map describes these
// properties so that other code can make decisions about whether to invoke a
// command or return an error to the user.
var cmdDetailsMap = map[*cmds.Command]cmdDetails{
initCmd: cmdDetails{initializesConfig: true, cannotRunOnDaemon: true, doesNotUseRepo: true},
initCmd: cmdDetails{doesNotUseConfigAsInput: true, cannotRunOnDaemon: true, doesNotUseRepo: true},
daemonCmd: cmdDetails{cannotRunOnDaemon: true},
commandsClientCmd: cmdDetails{doesNotUseRepo: true},
commands.CommandsDaemonCmd: cmdDetails{doesNotUseRepo: true},
commands.DiagCmd: cmdDetails{cannotRunOnClient: true},
commands.VersionCmd: cmdDetails{doesNotUseRepo: true},
commands.VersionCmd: cmdDetails{doesNotUseConfigAsInput: true, doesNotUseRepo: true}, // must be permitted to run before init
commands.UpdateCmd: cmdDetails{preemptsAutoUpdate: true, cannotRunOnDaemon: true},
commands.UpdateCheckCmd: cmdDetails{preemptsAutoUpdate: true},
commands.UpdateLogCmd: cmdDetails{preemptsAutoUpdate: true},
......
......@@ -217,7 +217,7 @@ func callPreCommandHooks(details cmdDetails, req cmds.Request, root *cmds.Comman
// check for updates when 1) commands is going to be run locally, 2) the
// command does not initialize the config, and 3) the command does not
// pre-empt updates
if !daemon && !details.initializesConfig && !details.preemptsAutoUpdate {
if !daemon && details.usesConfigAsInput() && !details.preemptsAutoUpdate {
log.Debug("Calling hook: Check for updates")
......
......@@ -32,8 +32,8 @@ $(SHARNESS):
ipfs:
@echo "*** installing $@ ***"
mkdir -p bin
cd ../cmd/ipfs && go build
cp ../cmd/ipfs/ipfs bin/ipfs
cd ../cmd/ipfs2 && go build
cp ../cmd/ipfs2/ipfs2 bin/ipfs
random:
@echo "*** installing $@ ***"
......
......@@ -52,27 +52,44 @@ test_launch_ipfs_mount() {
ipfs config Mounts.IPNS "$(pwd)/ipns"
'
test_expect_success FUSE "ipfs mount succeeds" '
ipfs mount mountdir >actual &
test_expect_success FUSE "'ipfs daemon' succeeds" '
ipfs daemon >actual &
'
test_expect_success FUSE "ipfs mount output looks good" '
test_expect_success FUSE "'ipfs daemon' output looks good" '
IPFS_PID=$! &&
echo "mounting ipfs at $(pwd)/ipfs" >expected &&
echo "mounting ipns at $(pwd)/ipns" >>expected &&
echo "API server listening on '\''127.0.0.1:5001'\''" >expected &&
test_cmp_repeat_10_sec expected actual
'
test_expect_success FUSE "'ipfs mount' succeeds" '
ipfs mount >actual
'
test_expect_success FUSE "'ipfs mount' output looks good" '
echo "IPFS mounted at: $(pwd)/ipfs" >expected &&
echo "IPNS mounted at: $(pwd)/ipns" >>expected &&
test_cmp expected actual
'
}
test_kill_repeat_10_sec() {
for i in 1 2 3 4 5 6 7 8 9 10
do
kill $1
sleep 1
! kill -0 $1 2>/dev/null && return
done
! kill -0 $1 2>/dev/null
}
test_kill_ipfs_mount() {
test_expect_success FUSE "ipfs mount is still running" '
test_expect_success FUSE "'ipfs daemon' is still running" '
kill -0 $IPFS_PID
'
test_expect_success FUSE "ipfs mount can be killed" '
kill $IPFS_PID &&
sleep 1 &&
! kill -0 $IPFS_PID 2>/dev/null
test_expect_success FUSE "'ipfs daemon' can be killed" '
test_kill_repeat_10_sec $IPFS_PID
'
}
......@@ -25,7 +25,8 @@ test_expect_success "ipfs help succeeds" '
'
test_expect_success "ipfs help output looks good" '
cat help.txt | egrep "^Usage: +ipfs"
cat help.txt | egrep -i "^Usage:" &&
cat help.txt | egrep "ipfs .* <command>"
'
test_done
......
......@@ -17,7 +17,7 @@ test_expect_success "ipfs add succeeds" '
test_expect_success "ipfs add output looks good" '
HASH="QmVr26fY1tKyspEJBniVhqxQeEjhF78XerGiqWAwraVLQH" &&
echo "added $HASH $(pwd)/mountdir/hello.txt" >expected &&
echo "added $HASH mountdir/hello.txt" >expected &&
test_cmp expected actual
'
......@@ -58,7 +58,7 @@ test_expect_success "ipfs add bigfile succeeds" '
test_expect_success "ipfs add bigfile output looks good" '
HASH="QmWXysX1oysyjTqd5xGM2T1maBaVXnk5svQv4GKo5PsGPo" &&
echo "added $HASH $(pwd)/mountdir/bigfile" >expected &&
echo "added $HASH mountdir/bigfile" >expected &&
test_cmp expected actual
'
......
......@@ -20,7 +20,7 @@ test_expect_success "'ipfs block put' succeeds" '
test_expect_success "'ipfs block put' output looks good" '
HASH="QmRKqGMAM6EZngbpjSqrvYzq5Qd8b1bSWymjSUY9zQSNDk" &&
echo "added as '\''$HASH'\''" >expected_out &&
echo "$HASH" >expected_out &&
test_cmp expected_out actual_out
'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment