File tree Expand file tree Collapse file tree 3 files changed +47
-8
lines changed Expand file tree Collapse file tree 3 files changed +47
-8
lines changed Original file line number Diff line number Diff line change
1
+ # Test framework for multihash
2
+ #
3
+ # Copyright (c) 2016 Christian Couder
4
+ # MIT Licensed; see the LICENSE file in this repository.
5
+ #
6
+ # We are using sharness (https://github.com/chriscool/sharness)
7
+ # which was extracted from the Git test framework.
8
+
9
+ # Test the first 'multihash' tool available in the PATH.
10
+
11
+ # Add current bin directory to path, in case multihash tool is there.
12
+ PATH=$( pwd) /bin:${PATH}
13
+
14
+ # Set sharness verbosity. we set the env var directly as
15
+ # it's too late to pass in --verbose, and --verbose is harder
16
+ # to pass through in some cases.
17
+ test " $TEST_VERBOSE " = 1 && verbose=t
18
+
19
+ # Assert a `multihash` tool is available in the PATH.
20
+ type multihash > /dev/null || {
21
+ echo >&2 " Cannot find any 'multihash' tool in '$PATH '."
22
+ echo >&2 " Please make sure 'multihash' is in your PATH."
23
+ exit 1
24
+ }
25
+
26
+ SHARNESS_LIB=" lib/sharness/sharness.sh"
27
+
28
+ . " $SHARNESS_LIB " || {
29
+ echo >&2 " Cannot source: $SHARNESS_LIB "
30
+ echo >&2 " Please check Sharness installation."
31
+ exit 1
32
+ }
33
+
34
+ # Please put multihash specific shell functions below
35
+
36
+ for hashbin in sha1sum shasum; do
37
+ if type " $hashbin " > /dev/null; then
38
+ export SHA1SUMBIN=" $hashbin " &&
39
+ test_set_prereq SHA1SUM &&
40
+ break
41
+ fi
42
+ done
43
+
Original file line number Diff line number Diff line change 2
2
3
3
test_description=" Test multihash basics"
4
4
5
- . ./ lib/sharness/sharness .sh
5
+ . lib/test-lib .sh
6
6
7
7
test_expect_success " current dir is writable" '
8
8
echo "It works!" >test.txt
9
9
'
10
10
11
- test_expect_success " multihash is available" '
12
- type multihash
13
- '
14
-
15
11
test_expect_success " 'multihash --help' looks good" '
16
12
multihash --help >actual 2>&1 || true &&
17
13
egrep -i "usage" actual >/dev/null
Original file line number Diff line number Diff line change 6
6
7
7
test_description=" sha1 tests"
8
8
9
- . ./ lib/sharness/sharness .sh
9
+ . lib/test-lib .sh
10
10
11
11
test_expect_success " setup sha1 tests" '
12
12
echo "Hash me!" >hash_me.txt &&
@@ -22,9 +22,9 @@ test_expect_success "'multihash -a=sha1 -e=hex' output looks good" '
22
22
test_cmp expected actual
23
23
'
24
24
25
- test_expect_success SHASUM " check hash using shasum " '
25
+ test_expect_success SHA1SUM " check hash using ' $SHA1SUMBIN ' " '
26
26
echo "$SHA1 hash_me.txt" >expected &&
27
- $SHASUMBIN hash_me.txt >actual &&
27
+ $SHA1SUMBIN hash_me.txt >actual &&
28
28
test_cmp expected actual
29
29
'
30
30
You can’t perform that action at this time.
0 commit comments