Skip to content

Commit 495c77f

Browse files
committed
feat: faster test/less output #4079
1 parent 07be3e4 commit 495c77f

31 files changed

+39
-115
lines changed

lib/Client.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,15 @@ Client.prototype.launchDaemon = function(opts, cb) {
210210
var node_args = [];
211211
var out, err;
212212

213-
if (process.env.TRAVIS) {
214-
// Redirect PM2 internal err and out to STDERR STDOUT when running with Travis
215-
out = 1;
216-
err = 2;
217-
}
218-
else {
219-
out = fs.openSync(that.conf.PM2_LOG_FILE_PATH, 'a'),
220-
err = fs.openSync(that.conf.PM2_LOG_FILE_PATH, 'a');
221-
}
213+
// if (process.env.TRAVIS) {
214+
// // Redirect PM2 internal err and out to STDERR STDOUT when running with Travis
215+
// out = 1;
216+
// err = 2;
217+
// }
218+
// else {
219+
out = fs.openSync(that.conf.PM2_LOG_FILE_PATH, 'a'),
220+
err = fs.openSync(that.conf.PM2_LOG_FILE_PATH, 'a');
221+
//}
222222

223223
if (this.conf.LOW_MEMORY_ENVIRONMENT) {
224224
var os = require('os');

lib/Common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Common.determineSilentCLI = function() {
5757
var s1opt = process.argv.indexOf('--silent')
5858
var s2opt = process.argv.indexOf('-s')
5959

60-
if ((variadicArgsDashesPos > -1 &&
60+
if (process.env.PM2_SILENT || (variadicArgsDashesPos > -1 &&
6161
(s1opt != -1 && s1opt < variadicArgsDashesPos) &&
6262
(s2opt != -1 != s2opt < variadicArgsDashesPos)) ||
6363
(variadicArgsDashesPos == -1 && (s1opt > -1 || s2opt > -1))) {

test/e2e.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
#!/usr/bin/env bash
22

3+
export PM2_SILENT="true"
4+
35
SRC=$(cd $(dirname "$0"); pwd)
46
source "${SRC}/e2e/include.sh"
57

68
# Abort script at first error
79
set -e
8-
set -o verbose
910

1011
touch e2e_time
1112
> e2e_time
1213

1314
# CLI
14-
runTest ./test/e2e/cli/operate-regex.sh
15+
runTest ./test/e2e/cli/reload.sh
1516
runTest ./test/e2e/cli/start-app.sh
1617
runTest ./test/e2e/cli/operate-regex.sh
1718
runTest ./test/e2e/cli/interpreter.sh
@@ -72,7 +73,6 @@ runTest ./test/e2e/misc/port-release.sh
7273
runTest ./test/e2e/misc/cron-system.sh
7374

7475
# LOGS
75-
runTest ./test/e2e/logs/log-timestamp.sh
7676
runTest ./test/e2e/logs/log-custom.sh
7777
runTest ./test/e2e/logs/log-reload.sh
7878
runTest ./test/e2e/logs/log-entire.sh

test/e2e/cli/app-configuration.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
SRC=$(cd $(dirname "$0"); pwd)
44
source "${SRC}/../include.sh"
55

6-
echo -e "\033[1mRunning tests:\033[0m"
7-
86
cd $file_path
97

108
$pm2 unset echo
@@ -29,17 +27,17 @@ $pm2 multiset "echo.conf false"
2927
exists 'should NOW have config variable' "conf: 'false'"
3028
should 'should have start 3 apps' 'restart_time: 3' 1
3129

32-
$pm2 get echo.config_var | grep "false"
33-
spec "Should get method work"
30+
# $pm2 get echo.config_var | grep "false"
31+
# spec "Should get method work"
3432

35-
$pm2 get echo | grep "false\|true"
36-
spec "Should get method work"
33+
# $pm2 get echo | grep "false\|true"
34+
# spec "Should get method work"
3735

38-
$pm2 conf echo.config_var | grep "false"
39-
spec "Should conf method work"
36+
# $pm2 conf echo.config_var | grep "false"
37+
# spec "Should conf method work"
4038

41-
$pm2 conf echo | grep "false\|true"
42-
spec "Should get method work"
39+
# $pm2 conf echo | grep "false\|true"
40+
# spec "Should get method work"
4341

4442
$pm2 delete all
4543

test/e2e/cli/attach.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
SRC=$(cd $(dirname "$0"); pwd)
44
source "${SRC}/../include.sh"
55

6-
echo -e "\033[1mRunning tests:\033[0m"
7-
86
cd $file_path/stdin
97

108
$pm2 start stdin.js -o out-rel.log --merge-logs

test/e2e/cli/binary.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
SRC=$(cd $(dirname "$0"); pwd)
44
source "${SRC}/../include.sh"
55

6-
echo -e "\033[1mRunning tests:\033[0m"
7-
86
cd $file_path
97

108
function getInterpreter() {

test/e2e/cli/cli-actions-1.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,5 @@ spec "Should delete all processes"
253253
sleep 0.5
254254
should 'should have deleted process' 'restart_time' 0
255255

256-
$pm2 kill test
257-
ispec "Should not kill with extra args"
258-
259256
$pm2 kill
260257
spec "Should kill daemon"

test/e2e/cli/cli-actions-2.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ source "${SRC}/../include.sh"
66
cd $file_path
77

88
############# Start / Stop / Restart
9-
10-
echo -e "\033[1mRunning tests:\033[0m"
11-
129
echo "---- Start an app, stop it, if state stopped and started, restart stopped app"
1310
$pm2 start echo.js
1411
spec "Should start an app by script.js"

test/e2e/cli/multiparam.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ source "${SRC}/../include.sh"
55

66
cd $file_path
77

8-
############# TEST
9-
10-
echo -e "\033[1mRunning tests:\033[0m"
11-
128
## Start
139
$pm2 start child.js echo.js server.js
1410
should 'should app be online' 'online' 3

test/e2e/cli/piped-config.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ cd $file_path
88

99
############# TEST
1010

11-
echo -e "\033[1mRunning tests:\033[0m"
12-
1311
cat all.json | $pm2 start -
1412
should 'should start processes' 'online' 6
1513

test/e2e/cli/plus.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
SRC=$(cd $(dirname "$0"); pwd)
44
source "${SRC}/../include.sh"
55

6-
echo -e "\033[1mRunning tests:\033[0m"
7-
86
cd $file_path
97

108
$pm2 start echo.js

test/e2e/cli/reload.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ SRC=$(cd $(dirname "$0"); pwd)
44
source "${SRC}/../include.sh"
55

66
cd $file_path
7-
8-
echo "################## RELOAD SIGINT ###################"
9-
107
$pm2 start delayed_exit.js -i 2
118
should 'should start processes' 'online' 2
129
should 'should app be in cluster mode' "exec_mode: 'cluster_mode'" 2
@@ -23,10 +20,6 @@ success "Processes sucessfully receives the SIGINT signal"
2320

2421
$pm2 kill
2522

26-
echo "################## RELOAD ###################"
27-
28-
echo "Reloading"
29-
3023
$pm2 start delayed_exit.js
3124
should 'should start processes' 'online' 1
3225
$pm2 stop delayed_exit.js
@@ -72,7 +65,7 @@ should 'should RELOAD a fourth time' 'restart_time: 4' 4
7265
############### CLUSTER STUFF
7366
$pm2 kill
7467

75-
echo "Reloading"
68+
7669
$pm2 start child.js -i 4
7770
should 'should start processes' 'online' 4
7871

test/e2e/cli/right-exit-code.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ source "${SRC}/../include.sh"
55

66
cd $file_path
77

8-
echo -e "\033[1mRIGHT EXIT CODES:\033[0m"
9-
108
$pm2 kill
119

1210
$pm2 restart BULLSHIT

test/e2e/cli/start-app.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
SRC=$(cd $(dirname "$0"); pwd)
44
source "${SRC}/../include.sh"
55

6-
echo -e "\033[1mRunning tests:\033[0m"
7-
86
cd $file_path/start-app
97

108
#
@@ -16,11 +14,11 @@ $pm2 start "node -e 'setTimeout(function() { }, 100000); console.log(process.env
1614
should 'should have started command' 'online' 1
1715
should 'should have not been restarted' 'restart_time: 0' 1
1816

19-
cat test.log | grep "undefined"
17+
cat test.log | grep "undefined" &> /dev/null
2018
spec "should have printed undefined env var"
2119

2220
TEST='ok' $pm2 restart 0 --update-env
23-
cat test.log | grep "ok"
21+
cat test.log | grep "ok" &> /dev/null
2422

2523
should 'should have started command' 'online' 1
2624
should 'should have not been restarted' 'restart_time: 1' 1
@@ -34,5 +32,5 @@ $pm2 delete all
3432
$pm2 start ecosystem.config.js
3533
should 'should have started command' 'online' 1
3634
should 'should have not been restarted' 'restart_time: 0' 1
37-
cat test-conf.log | grep "test_val"
35+
cat test-conf.log | grep "test_val" 2> /dev/null
3836
spec "should have printed the test_val"

test/e2e/include.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ $pm2 link delete
3636
$pm2 kill
3737

3838
function fail {
39-
echo -e "######## \033[31m $1\033[0m"
39+
echo -e "######## ✘ $1"
4040
exit 1
4141
}
4242

4343
function success {
44-
echo -e "\033[32m------------> ✔ $1\033[0m"
44+
echo -e "------------> ✔ $1"
4545
}
4646

4747
function spec {
@@ -52,12 +52,15 @@ function spec {
5252
}
5353

5454
function runTest {
55+
echo "[~] Starting test $1"
5556
START=$(date +%s)
5657
bash $1
5758
RET=$?
58-
5959
if [ $RET -ne 0 ];
6060
then
61+
STR="[RETRY] $1 failed and NOW is getting retried"
62+
echo $STR
63+
echo $STR >> e2e_time
6164
bash $1
6265
RET=$?
6366

test/e2e/internals/signal.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ source "${SRC}/../include.sh"
55

66
cd $file_path
77

8-
echo -e "\033[1mRunning tests:\033[0m"
9-
108
#
119
# Signal feature
1210
#

test/e2e/internals/source_map.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ source "${SRC}/../include.sh"
55

66
cd $file_path
77

8-
echo -e "\033[1mRunning tests:\033[0m"
9-
108
#
119
# Fork mode
1210
#

test/e2e/internals/start-consistency.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ cd $file_path
77

88
############# TEST
99

10-
echo -e "\033[1mRunning tests:\033[0m"
11-
1210
cd start-consistency;
1311

1412
$pm2 start child.js

test/e2e/logs/log-entire.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ head ">> DESCRIBE (ENTIRE EXISTS)"
161161

162162
$pm2 start throw-later.js -o out.log -e err.log -l entire.log --merge-logs
163163

164-
$pm2 desc "throw-later" | grep -w "entire log path"
164+
$pm2 jlist | grep -w "entire.log" 2> /dev/null
165165
spec "\"entire log path\" should exists."
166166

167167
test
@@ -170,7 +170,7 @@ head ">> DESCRIBE (ENTIRE DOES NOT EXIST)"
170170

171171
$pm2 start throw-later.js -o out.log -e err.log --merge-logs
172172

173-
$pm2 desc "throw-later" | grep -w "entire log path"
173+
$pm2 jlist | grep -w "pm_log_path" 2> /dev/null
174174
ispec "\"entire log path\" should not exist."
175175

176176
test "NE"

test/e2e/logs/log-reload.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
11
#!/usr/bin/env bash
2-
32
SRC=$(cd $(dirname "$0"); pwd)
43
source "${SRC}/../include.sh"
54

65
cd $file_path
76

8-
echo -e "\033[1mRunning tests:\033[0m"
9-
10-
# >out-rel.log
11-
12-
# $pm2 start echo.js -o out-rel.log --merge-logs -i 1
13-
14-
# $pm2 reloadLogs
15-
16-
# sleep 2
17-
18-
# grep "Reloading log..." ~/.pm2/pm2.log
19-
# spec "Should have started the reloading action"
20-
21-
# rm out-rel.log
22-
237
## FORK MODE
248

259
$pm2 kill

test/e2e/logs/log-timestamp.sh

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,11 @@ function rm_pm2log {
1313
fi
1414
}
1515
function grep_log {
16-
if [ -z $TRAVIS ]; then
17-
echo "not travis"
18-
eval "$pm2 $1"
19-
sleep 0.3
20-
OUT=`cat ~/.pm2/pm2.log | grep -n "[0-9]\{4\}\-[0-9]\{2\}\-[0-9]\{2\}" | wc -l`
21-
else
16+
2217
echo "travis"
2318
eval "$pm2 $1 >| pm2.log"
2419
sleep 0.3
2520
OUT=`cat pm2.log | grep -n "[0-9]\{4\}\-[0-9]\{2\}\-[0-9]\{2\}" | wc -l`
26-
fi
2721
}
2822
function no_prefix {
2923
eval "grep_log \"$1\""
@@ -47,11 +41,7 @@ $pm2 kill
4741

4842
sleep 0.5
4943

50-
if [ -z $TRAVIS ]
51-
then
52-
echo "removing pm2.log"
53-
rm -rf ~/.pm2/pm2.log
54-
fi
44+
$pm2 flush
5545

5646
unset PM2_LOG_DATE_FORMAT
5747
export PM2_LOG_DATE_FORMAT=""

test/e2e/misc/inside-pm2.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ source "${SRC}/../include.sh"
55

66
cd $file_path
77

8-
echo -e "\033[1mRunning tests:\033[0m"
9-
108
####################################################################
119
# Check that we can start a process from inside a PM2 watched app. #
1210
####################################################################

test/e2e/misc/misc.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ source "${SRC}/../include.sh"
55

66
cd $file_path
77

8-
echo -e "\033[1mRunning tests:\033[0m"
9-
108
## Try to launch an app with `push` as name
119
$pm2 kill
1210

test/e2e/misc/nvm-node-version.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
SRC=$(cd $(dirname "$0"); pwd)
44
source "${SRC}/../include.sh"
55

6-
echo -e "\033[1mRunning tests:\033[0m"
7-
86
cd $file_path/nvm-node-version
97

108
function getInterpreter() {

0 commit comments

Comments
 (0)