From cf1098a4b02ff8798bf3d5bee1819c43db27f10c Mon Sep 17 00:00:00 2001 From: Sarthak Khattar Date: Wed, 25 Aug 2021 07:24:22 -0700 Subject: [PATCH] Updated tests scripts to run tests from one directory higher (#461) Summary: Related to discussion on this with gbleaney. PR https://github.com/facebook/pyre-check/issues/433's use of relative imports causes `Import beyond top-level package` errors. Internally, relative imports are required to pass the tests whereas on GitHub, this causes issues. This PR fixes that issue by running tests from one directory higher, unblocking https://github.com/facebook/pyre-check/issues/433. Pull Request resolved: https://github.com/facebook/pyre-check/pull/461 Reviewed By: dkgi Differential Revision: D30518016 Pulled By: gbleaney fbshipit-source-id: e7d76f2059bde5110849923887f928459228e0a8 --- .github/workflows/pysa.yml | 2 +- scripts/run-python-tests.sh | 4 ++-- tools/pysa_integration_tests/utils.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pysa.yml b/.github/workflows/pysa.yml index 72253a8db7c..c61fbdfbc5a 100644 --- a/.github/workflows/pysa.yml +++ b/.github/workflows/pysa.yml @@ -40,7 +40,7 @@ jobs: unzip -qq ./stubs/typeshed/typeshed.zip -d ./typeshed/ ./scripts/setup.sh --local --no-tests make -C source - echo "PYTHONPATH=$GITHUB_WORKSPACE:$PYTHONPATH" >> $GITHUB_ENV + echo "PYTHONPATH=$GITHUB_WORKSPACE/..:$PYTHONPATH" >> $GITHUB_ENV echo "pythonLocation=$GITHUB_WORKSPACE:$pythonLocation" >> $GITHUB_ENV echo "PYRE_BINARY=$GITHUB_WORKSPACE/source/_build/default/main.exe" >> $GITHUB_ENV echo "PYRE_TYPESHED=$GITHUB_WORKSPACE/typeshed/typeshed-master/" >> $GITHUB_ENV diff --git a/scripts/run-python-tests.sh b/scripts/run-python-tests.sh index 6de49f7c331..e924934f8e2 100755 --- a/scripts/run-python-tests.sh +++ b/scripts/run-python-tests.sh @@ -7,10 +7,10 @@ set -e SCRIPTS_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -cd "${SCRIPTS_DIRECTORY}/.." +cd "${SCRIPTS_DIRECTORY}/../.." echo ' Enumerating test files:' -files=$(find client -name '*_test.py' ! -name 'watchman_test.py') +files=$(find 'pyre-check/client' -name '*_test.py' ! -name 'watchman_test.py') echo "${files}" if [[ -z "${files}" ]]; then echo 'No test files found, exiting.' diff --git a/tools/pysa_integration_tests/utils.py b/tools/pysa_integration_tests/utils.py index e659d319a31..8c04955effb 100644 --- a/tools/pysa_integration_tests/utils.py +++ b/tools/pysa_integration_tests/utils.py @@ -155,7 +155,7 @@ def run_pysa_integration_test( if run_from_source: command = [ "python", - "-m" "client.pyre", + "-m" "pyre-check.client.pyre", "--noninteractive", "analyze", ]