From c9b3196203032538e1d67d93176e694b230064d7 Mon Sep 17 00:00:00 2001 From: Siddarth Kumar Date: Thu, 26 Oct 2023 23:24:23 +0530 Subject: [PATCH] improve make component-test robustness (#17743) Many times devs run `make component-test` or `make component-test-watch` when there is already a metro or clojure terminal running on their system. This causes weird behaviour and it is advised to not run these commands together. This commit prevents that and shows a warning. --- Makefile | 2 ++ scripts/check-metro-shadow-process.sh | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100755 scripts/check-metro-shadow-process.sh diff --git a/Makefile b/Makefile index 51b2e9fa4b..02c0c57e12 100644 --- a/Makefile +++ b/Makefile @@ -362,6 +362,7 @@ component-test-watch: export TARGET := clojure component-test-watch: export COMPONENT_TEST := true component-test-watch: export BABEL_ENV := test component-test-watch: ##@ Watch tests and re-run no changes to cljs files + @@scripts/check-metro-shadow-process.sh rm -rf ./component-spec yarn install nodemon --exec 'yarn shadow-cljs compile component-test && jest --config=test/jest/jest.config.js' -e cljs @@ -370,6 +371,7 @@ component-test: export TARGET := clojure component-test: export COMPONENT_TEST := true component-test: export BABEL_ENV := test component-test: ##@test Run component tests once in NodeJS + @scripts/check-metro-shadow-process.sh rm -rf ./component-spec yarn install yarn shadow-cljs compile component-test && \ diff --git a/scripts/check-metro-shadow-process.sh b/scripts/check-metro-shadow-process.sh new file mode 100755 index 0000000000..385571253b --- /dev/null +++ b/scripts/check-metro-shadow-process.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +if pgrep -f 'shadow-cljs watch mobile' > /dev/null; then + echo "Error: make run-clojure is already running in another terminal" >&2 + echo "Please close that terminal before running this command." >&2 + exit 1 +fi + +if pgrep -f 'react-native start' > /dev/null; then + echo "Error: make run-metro is already running in another terminal" >&2 + echo "Please close that terminal before running this command." >&2 + exit 1 +fi + +exit 0