From c28c35f1adadc2127b0ea63076e012b66730702a Mon Sep 17 00:00:00 2001 From: Kert Date: Tue, 16 May 2023 09:30:09 -0700 Subject: [PATCH] Re-enable Pytest runs on Windows (#385) Enables Pytest runs on windows with a few changes: * Enable Windows pytest runs * Enable pip caching - Speeds up tests by caching pip install results * Add missing atomicwrites - Required on Windows for pytest+coverage runs. It's an undeclared indirect dependency of some involved packages. * Disable Raspi launcher tests on Windows - The pexpect and shell handling as written wont work on Windows, and this module isn't written or intended to run on it. * Disable Build-id tests on Win - These are newly added and fail with absolute/temporary path handling. Need to be looked at. * Disable failing SABI test on Windows - Old test that fails due to invalid temporary path handling on Win b/279747505 b/282040638 b/281098312 --- .github/workflows/pytest.yaml | 4 ++-- cobalt/build/get_build_id_test.py | 2 ++ docker/pytest/requirements.in | 1 + docker/pytest/requirements.txt | 3 +++ starboard/raspi/shared/launcher_test.py | 1 + starboard/sabi/generate_sabi_id_test.py | 3 +++ 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 8f6ff79e009a1..028aec017afa6 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -17,8 +17,7 @@ jobs: python-test: strategy: matrix: - # TODO(b/281098312): pytest fails on windows-latest - os: [ubuntu-latest] + os: [ubuntu-latest, windows-latest] python-version: ['3.7', '3.11'] fail-fast: false runs-on: ${{ matrix.os }} @@ -32,6 +31,7 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + cache: 'pip' - name: Install Pip Packages run: pip install --require-hashes --no-deps -r ${{ github.workspace }}/docker/pytest/requirements.txt - name: Run Tests diff --git a/cobalt/build/get_build_id_test.py b/cobalt/build/get_build_id_test.py index 0579a72940caa..f9ea8c3c3033c 100644 --- a/cobalt/build/get_build_id_test.py +++ b/cobalt/build/get_build_id_test.py @@ -26,6 +26,8 @@ _TEST_BUILD_NUMBER = 1234 + get_build_id.COMMIT_COUNT_BUILD_NUMBER_OFFSET +# TODO(b/282040638): fix and re-enabled this +@unittest.skipIf(os.name == 'nt', 'Broken on Windows') class GetBuildIdTest(unittest.TestCase): def setUp(self): diff --git a/docker/pytest/requirements.in b/docker/pytest/requirements.in index a15dd49dfe2b4..fffb347035535 100644 --- a/docker/pytest/requirements.in +++ b/docker/pytest/requirements.in @@ -5,3 +5,4 @@ jsonschema<5 junitparser==2.8.0 pexpect==4.8.0 six==1.12.0 +atomicwrites==1.4.1 diff --git a/docker/pytest/requirements.txt b/docker/pytest/requirements.txt index be346fdc5f10e..3dcbe0f1819e5 100644 --- a/docker/pytest/requirements.txt +++ b/docker/pytest/requirements.txt @@ -4,6 +4,9 @@ # # pip-compile --generate-hashes requirements.in # +atomicwrites==1.4.1 \ + --hash=sha256:81b2c9071a49367a7f770170e5eec8cb66567cfbbc8c73d20ce5ca4a8d71cf11 + # via -r docker/pytest/requirements.in attrs==21.4.0 \ --hash=sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4 \ --hash=sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd diff --git a/starboard/raspi/shared/launcher_test.py b/starboard/raspi/shared/launcher_test.py index 5fe6794046187..58712cbaad31c 100644 --- a/starboard/raspi/shared/launcher_test.py +++ b/starboard/raspi/shared/launcher_test.py @@ -28,6 +28,7 @@ # pylint: disable=missing-class-docstring +@unittest.skipIf(os.name == 'nt', 'Pexpect does not work on Windows') class LauncherTest(unittest.TestCase): def setUp(self): diff --git a/starboard/sabi/generate_sabi_id_test.py b/starboard/sabi/generate_sabi_id_test.py index 8b9477d75512f..ec230f67b9288 100755 --- a/starboard/sabi/generate_sabi_id_test.py +++ b/starboard/sabi/generate_sabi_id_test.py @@ -45,6 +45,9 @@ def testRainyDayNonexistentFile(self): with self.assertRaises(IOError): generate_sabi_id.DoMain(['-f', 'invalid_filename']) + # TODO(b/281098312): fix and re-enable this + @unittest.skipIf(os.name == 'nt', + 'Broken on Windows due to temp path handling') def testRainyDayBadFile(self): bad_sabi_json = tempfile.NamedTemporaryFile(mode='w') # pylint: disable=consider-using-with bad_sabi_json.write('{}')