From 086b068316e5b3b769af197da19ea784e89855d0 Mon Sep 17 00:00:00 2001 From: Aiden Fujiwara Date: Wed, 4 Oct 2023 14:59:01 -0700 Subject: [PATCH] test runinng rojo serve and killing --- .github/workflows/ci.yml | 18 ++++++++++++ scripts/kill-process-test-unix.sh | 48 +++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 scripts/kill-process-test-unix.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4bc8922..bdcb7a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,3 +70,21 @@ jobs: foreman --version PATH=$PATH:~/.foreman/bin ./scripts/end-to-end-tests.sh + kill-process-test-unix: + strategy: + matrix: + os: [ubuntu-latest] + + runs-on: ${{ matrix.os }} + needs: build + + steps: + - uses: actions/checkout@v2 + + - name: End-to-end tests + shell: bash + run: | + cargo install --path . + foreman --version + PATH=$PATH:~/.foreman/bin + ./scripts/kill-process-test-unix.sh diff --git a/scripts/kill-process-test-unix.sh b/scripts/kill-process-test-unix.sh new file mode 100644 index 0000000..096d81a --- /dev/null +++ b/scripts/kill-process-test-unix.sh @@ -0,0 +1,48 @@ +write_foreman_toml () { + echo "[tools]" > foreman.toml + echo "$2 = { $1 = \"$3\", version = \"=$4\" }" >> foreman.toml +} + +create_rojo_files() { + echo "{ + \"name\": \"test\", + \"tree\": { + \"\$path\": \"src\" + } + }" > default.project.json +} + +setup_rojo() { + write_foreman_toml github rojo "rojo-rbx/rojo" "7.3.0" + cargo run --release -- install + create_rojo_files +} + +delay_kill_process_and_check() { + sleep 5 + echo "waiting 5 seconds before killing rojo" + ps -ef | grep "rojo serve" | grep -v grep | awk '{print $2}' | xargs kill -INT + check_killed_subprocess +} + +run_rojo_serve_and_kill_process() { + setup_rojo + (rojo serve default.project.json) & (delay_kill_process_and_check) +} + +check_killed_subprocess(){ + if ps -ef | grep "rojo" | grep -v grep + then + echo "rojo subprocess was not killed properly" + rm foreman.toml + rm default.project.json + exit 1 + else + echo "rojo subprocess was killed properly" + rm foreman.toml + rm default.project.json + exit 0 + fi +} + +run_rojo_serve_and_kill_process \ No newline at end of file