From 4aa98e8a22539636c8516da17c769f9625a78afe Mon Sep 17 00:00:00 2001 From: Jean-Christophe Morin Date: Mon, 14 Oct 2024 12:15:29 -0400 Subject: [PATCH] Make rez-test tests cross-platform Signed-off-by: Jean-Christophe Morin --- .../tests/builds/packages/testing_obj/1.0.0/package.py | 9 +++++++-- src/rez/tests/test_test.py | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/rez/data/tests/builds/packages/testing_obj/1.0.0/package.py b/src/rez/data/tests/builds/packages/testing_obj/1.0.0/package.py index 709cf0349..a7542b20e 100644 --- a/src/rez/data/tests/builds/packages/testing_obj/1.0.0/package.py +++ b/src/rez/data/tests/builds/packages/testing_obj/1.0.0/package.py @@ -23,9 +23,14 @@ def commands(): tests = { "check_car_ideas": { - "command": "[[ -z ${CAR_IDEA} ]] && exit 1 || exit 0" + "command": ["python", "-c", "import os; assert os.environ.get('CAR_IDEA') == 'STURDY STEERING WHEEL'"], + "requires": ["python"] }, "move_meeting_to_noon": { - "command": "[[ -z ${SKIP_LUNCH} ]] && exit 1 || exit 0" + # We want this test to fail. SKIP_LUNCH should not be set. + # TODO: We should not test for failures here. Testing failures, str vs lsit commands, etc + # should we tested separately. + "command": ["python", "-c", "import os; assert os.environ.get('SKIP_LUNCH') is not None"], + "requires": ["python"] } } diff --git a/src/rez/tests/test_test.py b/src/rez/tests/test_test.py index ec46be9ab..549d088f0 100644 --- a/src/rez/tests/test_test.py +++ b/src/rez/tests/test_test.py @@ -53,8 +53,8 @@ def _run_tests(self, r): failed_test = self._get_test_result(runner, "move_meeting_to_noon") self.assertEqual(runner.test_results.num_tests, 2) - self.assertEqual(successful_test["status"], "success") - self.assertEqual(failed_test["status"], "failed") + self.assertEqual(successful_test["status"], "success", "check_car_ideas did not succeed") + self.assertEqual(failed_test["status"], "failed", "move_meeting_to_noon did not succeed") def _get_test_result(self, runner, test_name): return next(