Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
1840a01f
Commit
1840a01f
authored
Nov 16, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feat/ipfs2-test_sharness'
parents
6f8569db
220e108d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
27 deletions
+51
-27
cmd/ipfs2/ipfs.go
cmd/ipfs2/ipfs.go
+16
-10
cmd/ipfs2/main.go
cmd/ipfs2/main.go
+1
-1
test/Makefile
test/Makefile
+2
-2
test/lib/test-lib.sh
test/lib/test-lib.sh
+27
-10
test/t0010-basic-commands.sh
test/t0010-basic-commands.sh
+2
-1
test/t0040-add-and-cat.sh
test/t0040-add-and-cat.sh
+2
-2
test/t0050-block.sh
test/t0050-block.sh
+1
-1
No files found.
cmd/ipfs2/ipfs.go
View file @
1840a01f
...
...
@@ -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
{
doesNotUse
Repo
:
true
},
commands
.
VersionCmd
:
cmdDetails
{
doesNotUse
ConfigAsInput
:
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
},
...
...
cmd/ipfs2/main.go
View file @
1840a01f
...
...
@@ -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"
)
...
...
test/Makefile
View file @
1840a01f
...
...
@@ -32,8 +32,8 @@ $(SHARNESS):
ipfs
:
@
echo
"*** installing
$@
***"
mkdir
-p
bin
cd
../cmd/ipfs
&&
go build
cp
../cmd/ipfs/ipfs bin/ipfs
cd
../cmd/ipfs
2
&&
go build
cp
../cmd/ipfs
2
/ipfs
2
bin/ipfs
random
:
@
echo
"*** installing
$@
***"
...
...
test/lib/test-lib.sh
View file @
1840a01f
...
...
@@ -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
'
}
test/t0010-basic-commands.sh
View file @
1840a01f
...
...
@@ -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
...
...
test/t0040-add-and-cat.sh
View file @
1840a01f
...
...
@@ -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
'
...
...
test/t0050-block.sh
View file @
1840a01f
...
...
@@ -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
'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment