Skip to content

Commit 3d97a88

Browse files
committed
Return to original directory
1 parent 2595ea2 commit 3d97a88

1 file changed

Lines changed: 41 additions & 1 deletion

File tree

.github/workflows/scripts/test_install

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ heartbeat_interval='30s'
5555
# Declare a variable for storing the heartbeat process id:
5656
heartbeat_pid=""
5757

58+
# Get the current working directory:
59+
working_dir=$(pwd)
60+
5861

5962
# FUNCTIONS #
6063

@@ -125,9 +128,42 @@ install_init() {
125128
install_test() {
126129
echo 'Testing installation...' >&2
127130

128-
echo 'Creating test script...' >&2
131+
echo 'Creating test script (require global namespace)...' >&2
129132
echo 'var stdlib = require( "@stdlib/stdlib" ); console.log( stdlib.math.base.special.sin( 3.14 ) );' > "${install_dir}/script.js"
130133

134+
echo 'Running test script...' >&2
135+
node "${install_dir}/script.js"
136+
if [[ "$?" -ne 0 ]]; then
137+
echo "Encountered an error when running test script." >&2
138+
return 1
139+
fi
140+
echo 'Successfully ran test script.' >&2
141+
142+
echo 'Creating test script (import global namespace)...' >&2
143+
echo 'import stdlib from "@stdlib/stdlib"; console.log( stdlib.math.base.special.sin( 3.14 ) );' > "${install_dir}/script.js"
144+
145+
echo 'Running test script...' >&2
146+
node "${install_dir}/script.js"
147+
if [[ "$?" -ne 0 ]]; then
148+
echo "Encountered an error when running test script." >&2
149+
return 1
150+
fi
151+
echo 'Successfully ran test script.' >&2
152+
153+
echo 'Creating test script (require individual package)...' >&2
154+
echo 'var sin = require( "@stdlib/math/base/special/sin" ); console.log( sin( 3.14 ) );' > "${install_dir}/script.js"
155+
156+
echo 'Running test script...' >&2
157+
node "${install_dir}/script.js"
158+
if [[ "$?" -ne 0 ]]; then
159+
echo "Encountered an error when running test script." >&2
160+
return 1
161+
fi
162+
echo 'Successfully ran test script.' >&2
163+
164+
echo 'Creating test script (import individual package)...' >&2
165+
echo 'import sin from "@stdlib/math/base/special/sin"; console.log( sin( 3.14 ) );' > "${install_dir}/script.js"
166+
131167
echo 'Running test script...' >&2
132168
node "${install_dir}/script.js"
133169
if [[ "$?" -ne 0 ]]; then
@@ -140,8 +176,12 @@ install_test() {
140176

141177
# Performs local installation cleanup tasks.
142178
install_clean() {
179+
echo 'Returning to original directory...' >&2
180+
cwd "${working_dir}" || return 1
181+
143182
echo 'Removing installation directory...' >&2
144183
rm -rf "${install_dir}" || return 1
184+
145185
return 0
146186
}
147187

0 commit comments

Comments
 (0)