From d5add60bfdbd844865ed9911c8541ec9cf2ec1b0 Mon Sep 17 00:00:00 2001 From: Joni Shkurti Date: Tue, 19 May 2015 17:22:33 +0200 Subject: [PATCH] added tests for wrapped_fork --- test/bash/wrapped_fork.sh | 26 ++++++++++++++++++++++++++ test/fixtures/path-check.js | 9 +++++++++ test/pm2_behavior_tests.sh | 2 ++ 3 files changed, 37 insertions(+) create mode 100644 test/bash/wrapped_fork.sh create mode 100644 test/fixtures/path-check.js diff --git a/test/bash/wrapped_fork.sh b/test/bash/wrapped_fork.sh new file mode 100644 index 00000000..a7aec571 --- /dev/null +++ b/test/bash/wrapped_fork.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +SRC=$(cd $(dirname "$0"); pwd) +source "${SRC}/include.sh" + +cd $file_path + +echo "################## Wrapped fork ###################" + +$pm2 kill + +echo "Testing wrapped fork mode values" + +node path-check.js > path-check1.txt +$pm2 start path-check.js -o path-check2.txt +sleep 1 + +OUT=`diff path-check1.txt path-check2.txt` + +rm path-check1.txt +rm path-check2.txt + +[ -z "$OUT" ] || fail "The outputs are not identical" +success "The outputs are identical" + +$pm2 kill diff --git a/test/fixtures/path-check.js b/test/fixtures/path-check.js new file mode 100644 index 00000000..0a40f5ba --- /dev/null +++ b/test/fixtures/path-check.js @@ -0,0 +1,9 @@ +console.log(__filename); +console.log(module.filename); +console.log(module.parent); +console.log(module.children); +console.log(__dirname); +console.log(module); +console.log(process.env.PWD); +console.log(require.main.filename); +console.log(require.main === module); diff --git a/test/pm2_behavior_tests.sh b/test/pm2_behavior_tests.sh index 5eeaf3b8..38fd0fc3 100644 --- a/test/pm2_behavior_tests.sh +++ b/test/pm2_behavior_tests.sh @@ -69,6 +69,8 @@ bash ./test/bash/module.sh spec "module system" bash ./test/bash/vizion.sh spec "vizion features (versioning control)" +bash ./test/bash/wrapped_fork.sh +spec "wrapped fork" bash ./test/bash/pmx_injection.sh spec "automatic pmx injection"