-
Notifications
You must be signed in to change notification settings - Fork 32
/
travis-fold
executable file
·44 lines (40 loc) · 1019 Bytes
/
travis-fold
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
#!/bin/sh -ef
# Invoke desired command, wrapping it before and after with special
# Travis CI formatting commands that make output of the command appear
# as foldable (and folded by default) in console output.
#
# Usage:
# travis-fold <name> <command> [arguments]
name=$1
shift
echo "travis_fold:start:$name"
{ $@; status=$?; } || true
echo "travis_fold:end:$name"
exit $status
# Test cases for this script:
#
# Case 1:
# Command:
# $ { ./travis-fold 'exit_0' echo "hello"; echo $?; }
# Expected output:
# travis_fold:start:exit_0
# hello
# travis_fold:end:exit_0
# 0
#
# Case 2:
# Command:
# $ { ./travis-fold 'exit_1' false; echo $?; }
# Expected output:
# travis_fold:start:exit_1
# travis_fold:end:exit_1
# 1
#
# Case 3:
# Command:
# $ { ./travis-fold 'exit_127' not-existing_command; echo $?; }
# Expected output:
# travis_fold:start:exit_127
# ./travis-fold: line 14: not-existing_command: command not found
# travis_fold:end:exit_127
# 127