Skip to content

Commit

Permalink
Move E2EExpr unit tests back into E2EExpr.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ayylol committed Jan 23, 2025
1 parent d1f8409 commit cff4341
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
39 changes: 39 additions & 0 deletions sycl/test-e2e/E2EExpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,42 @@ def parseAll(self):
self.parseOR()
self.expect(BooleanExpression.END)
return self.findal_unknown_value if self.unknown else self.value


import unittest


class TestE2EExpr(unittest.TestCase):
def test_basic(self):
# Non build-only expressions should work the same
self.assertTrue(E2EExpr.evaluate("linux", {"linux", "rt_feature"}, False))
self.assertTrue(E2EExpr.evaluate("rt_feature", {"linux", "rt_feature"}, False))
self.assertFalse(E2EExpr.evaluate( "another_aspect && rt_feature", {"linux", "rt_feature"}, False))
# build-only expressions with no unknowns should work the same
self.assertTrue(E2EExpr.evaluate("linux", {"linux"}, True, final_unknown_value=False))
self.assertFalse(E2EExpr.evaluate( "linux && windows", {"linux"}, True, final_unknown_value=True))
self.assertTrue(E2EExpr.evaluate( "!(windows || zstd)", {"linux"}, True, final_unknown_value=False))
# build-only expressions where unknown affects the resulting value
self.assertTrue(E2EExpr.evaluate("rt_feature", {}, True, final_unknown_value=True))
self.assertFalse(E2EExpr.evaluate("rt_feature", {}, True, final_unknown_value=False))
self.assertTrue(E2EExpr.evaluate("rt_feature", {"rt_feature"}, True, final_unknown_value=True))
self.assertFalse(E2EExpr.evaluate("rt_feature", {"rt_feature"}, True, final_unknown_value=False))
self.assertFalse(E2EExpr.evaluate("!rt_feature", {}, True, final_unknown_value=False))
self.assertFalse(E2EExpr.evaluate("!!rt_feature", {}, True, final_unknown_value=False))
self.assertTrue(E2EExpr.evaluate("windows || rt_feature", {"linux"}, True, final_unknown_value=True))
self.assertFalse(E2EExpr.evaluate("windows || rt_feature", {"linux"}, True, final_unknown_value=False))
self.assertTrue(E2EExpr.evaluate("linux && rt_feature", {"linux"}, True, final_unknown_value=True))
self.assertFalse(E2EExpr.evaluate("linux && rt_feature", {"linux"}, True, final_unknown_value=False))
self.assertTrue(E2EExpr.evaluate( "linux && !(windows || rt_feature)", {"linux"}, True, final_unknown_value=True))
self.assertFalse(E2EExpr.evaluate( "linux && !(windows || rt_feature)", {"linux"}, True, final_unknown_value=False))
# build-only expressions where unknown does not affect the resulting value
self.assertTrue(E2EExpr.evaluate("linux || rt_feature", {"linux"}, True, final_unknown_value=True))
self.assertTrue(E2EExpr.evaluate("linux || rt_feature", {"linux"}, True, final_unknown_value=False))
self.assertFalse(E2EExpr.evaluate("windows && rt_feature", {"linux"}, True, final_unknown_value=True))
self.assertFalse(E2EExpr.evaluate("windows && rt_feature", {"linux"}, True, final_unknown_value=False))
self.assertFalse(E2EExpr.evaluate( "linux && (windows && rt_feature)", {"linux"}, True, final_unknown_value=True))
self.assertFalse(E2EExpr.evaluate( "linux && (windows && rt_feature)", {"linux"}, True, final_unknown_value=False))


if __name__ == "__main__":
unittest.main()
39 changes: 0 additions & 39 deletions sycl/test/e2e_test_requirements/E2EExpr_tests.py

This file was deleted.

4 changes: 2 additions & 2 deletions sycl/test/e2e_test_requirements/check_e2eexpr_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
// statements. This test runs the unit tests related to these expressions.
//
// REQUIRES: linux
// DEFINE: %{e2e_folder}=%S/../../test-e2e
// DEFINE: %{E2EExpr}=%S/../../test-e2e/E2EExpr.py
// DEFINE: %{lit_source}=%S/../../../llvm/utils/lit
// RUN: env PYTHONPATH=%{lit_source}:%{e2e_folder} python %S/E2EExpr_tests.py
// RUN: env PYTHONPATH=%{lit_source} python %{E2EExpr}

0 comments on commit cff4341

Please sign in to comment.