Skip to content

Commit 0a79888

Browse files
gabrieldonadelfacebook-github-bot
authored andcommitted
fix: Access to relative paths when invoking test-manual-e2e (facebook#33000)
Summary: Running `test-manual-e2e.sh` from any folder other than the repo root results in errors regarding files not existing, that's because we're not taking into consideration the path from where the script is invoked. This PR updates it so that we get the absolute path of the script and then use it to get the parent directory and `cd` to the repo root folder. Closes facebook#32999 ## Changelog [Internal] [Fixed] - fix access to relative paths when invoking `test-manual-e2e.sh` from folders other than the repo root Pull Request resolved: facebook#33000 Test Plan: 1. Clone this repo 2. Navigate to the rn-tester folder `cd packages/rn-tester/` 3. Run `../../scripts/test-manual-e2e.sh` 4. Select RNTester, Android and Hermes https://user-images.githubusercontent.com/11707729/151730441-18bc37de-0224-4f5e-a2fe-408e3ace5c1f.mov Reviewed By: ShikaSD Differential Revision: D33915561 Pulled By: cortinico fbshipit-source-id: 66f2d1ebee50bba3fe884d6346ea08ffced47a96
1 parent fa85417 commit 0a79888

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

scripts/test-manual-e2e.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ENDCOLOR="\033[0m"
1111

1212
error() {
1313
echo -e "$RED""$*""$ENDCOLOR"
14+
popd >/dev/null || exit
1415
exit 1
1516
}
1617

@@ -22,6 +23,10 @@ info() {
2223
echo -e "$BLUE""$*""$ENDCOLOR"
2324
}
2425

26+
# Ensures commands are executed from the repo root folder
27+
dir_absolute_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" || exit ; pwd -P )
28+
pushd "$dir_absolute_path/../" >/dev/null || exit
29+
2530
repo_root=$(pwd)
2631
selected_platform=""
2732
selected_vm=""
@@ -126,7 +131,7 @@ init_template_app(){
126131

127132
project_name="RNTestProject"
128133

129-
cd /tmp/ || exit
134+
pushd /tmp/ >/dev/null || exit
130135
rm -rf "$project_name"
131136
node "$repo_root/cli.js" init "$project_name" --template "$repo_root"
132137

@@ -135,13 +140,15 @@ init_template_app(){
135140
grep -E "com.facebook.react:react-native:\\+" "${project_name}/android/app/build.gradle" || error "Dependency in /tmp/${project_name}/android/app/build.gradle must be com.facebook.react:react-native:+"
136141

137142
success "New sample project generated at /tmp/${project_name}"
143+
popd >/dev/null || exit
138144
}
139145

140146
test_template_app(){
141147
if [ "$PACKAGE_VERSION" == "" ]; then
142148
init_template_app
143149
fi
144150

151+
pushd "/tmp/${project_name}" >/dev/null || exit
145152
if [ "$selected_platform" == "1" ]; then
146153
info "Test the following on Android:"
147154
info " - Disable Fast Refresh. It might be enabled from last time (the setting is stored on the device)"
@@ -150,7 +157,7 @@ test_template_app(){
150157
info "Press any key to run the sample in Android emulator/device"
151158
info ""
152159
read -r -n 1
153-
cd "/tmp/${project_name}" && npx react-native run-android
160+
npx react-native run-android
154161
elif [ "$selected_platform" == "2" ]; then
155162
info "Test the following on iOS:"
156163
info " - Disable Fast Refresh. It might be enabled from last time (the setting is stored on the device)"
@@ -163,9 +170,9 @@ test_template_app(){
163170
info "Press any key to open the project in Xcode"
164171
info ""
165172
read -r -n 1
166-
open "/tmp/${project_name}/ios/${project_name}.xcworkspace"
173+
open "ios/${project_name}.xcworkspace"
167174
fi
168-
cd "$repo_root" || exit
175+
popd >/dev/null || exit
169176
}
170177

171178

@@ -209,6 +216,7 @@ handle_menu_input(){
209216
if [ "$confirm" == "${confirm#[Yy]}" ]; then
210217
info "Next steps:"
211218
info "https://github.com/facebook/react-native/wiki/Release-Process"
219+
popd >/dev/null || exit
212220
exit 1
213221
else
214222
show_menu

0 commit comments

Comments
 (0)