From 5d46512e5b855516ba7a37332455c3c5322a653c Mon Sep 17 00:00:00 2001 From: "Jonathan M. Waldrop" Date: Fri, 26 Apr 2024 12:22:23 -0500 Subject: [PATCH 1/4] test with clang-14 --- .github/workflows/pull_request.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 916d3a9e..b0ec9f5f 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -26,6 +26,6 @@ jobs: with: config_file: '.github/.licenserc.yaml' source_dir: 'include src tests' - compilers: '["gcc-11", "clang-11"]' + compilers: '["gcc-11", "clang-14"]' doc_target: 'parallelzone_cxx_api' secrets: inherit From 33f2f4f5772bc25ea6a2a6ffcab818aa7927aadf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 26 Apr 2024 21:41:52 +0000 Subject: [PATCH 2/4] Committing clang-format changes --- tests/python/doc_snippets/test_doc_snippets.py | 4 +--- tests/python/doc_snippets/test_quickstart.py | 3 +++ tests/python/doc_snippets/test_ram.py | 2 ++ tests/python/doc_snippets/test_resource_set.py | 2 ++ tests/python/doc_snippets/test_runtime_view.py | 2 ++ tests/python/unit_tests/hardware/test_ram.py | 6 ++++-- tests/python/unit_tests/runtime/test_resource_set.py | 7 ++++--- tests/python/unit_tests/runtime/test_runtime_view.py | 10 +++++----- tests/python/unit_tests/test_logging/test_logger.py | 10 ++++++---- tests/python/unit_tests/test_parallelzone.py | 4 +--- 10 files changed, 30 insertions(+), 20 deletions(-) diff --git a/tests/python/doc_snippets/test_doc_snippets.py b/tests/python/doc_snippets/test_doc_snippets.py index 984abc38..1e1f47b6 100644 --- a/tests/python/doc_snippets/test_doc_snippets.py +++ b/tests/python/doc_snippets/test_doc_snippets.py @@ -18,8 +18,6 @@ import sys import unittest - - if __name__ == '__main__': # Make a RuntimeView and hold it until all tests run so MPI isn't shut # down @@ -28,7 +26,7 @@ my_dir = os.path.dirname(os.path.realpath(__file__)) print(my_dir) loader = unittest.TestLoader() - tests = loader.discover(my_dir) + tests = loader.discover(my_dir) testrunner = unittest.runner.TextTestRunner() ret = not testrunner.run(tests).wasSuccessful() sys.exit(ret) diff --git a/tests/python/doc_snippets/test_quickstart.py b/tests/python/doc_snippets/test_quickstart.py index e9be6127..cdcfa2a2 100644 --- a/tests/python/doc_snippets/test_quickstart.py +++ b/tests/python/doc_snippets/test_quickstart.py @@ -16,10 +16,13 @@ import parallelzone as pz import unittest + def get_runtime(): return pz.runtime.RuntimeView() + class TestQuickstartTestCase(unittest.TestCase): + def test_quickstart(self): # 99.9% of the time you will be using an existing RuntimeView rt = get_runtime() diff --git a/tests/python/doc_snippets/test_ram.py b/tests/python/doc_snippets/test_ram.py index adeb4869..328a3a97 100644 --- a/tests/python/doc_snippets/test_ram.py +++ b/tests/python/doc_snippets/test_ram.py @@ -16,7 +16,9 @@ import parallelzone as pz import unittest + class TestRAMTestCase(unittest.TestCase): + def test_ram(self): rv = pz.runtime.RuntimeView() diff --git a/tests/python/doc_snippets/test_resource_set.py b/tests/python/doc_snippets/test_resource_set.py index 47ae54ef..16c0c868 100644 --- a/tests/python/doc_snippets/test_resource_set.py +++ b/tests/python/doc_snippets/test_resource_set.py @@ -16,7 +16,9 @@ import parallelzone as pz import unittest + class TestResourceSetTestCase(unittest.TestCase): + def test_resourceset(self): rv = pz.runtime.RuntimeView() diff --git a/tests/python/doc_snippets/test_runtime_view.py b/tests/python/doc_snippets/test_runtime_view.py index b46f68d8..0f169ff7 100644 --- a/tests/python/doc_snippets/test_runtime_view.py +++ b/tests/python/doc_snippets/test_runtime_view.py @@ -16,7 +16,9 @@ import parallelzone as pz import unittest + class TestRuntimeViewTestCase(unittest.TestCase): + def test_runtimeview(self): rv = pz.runtime.RuntimeView() result = [0, 1, 2] diff --git a/tests/python/unit_tests/hardware/test_ram.py b/tests/python/unit_tests/hardware/test_ram.py index 9129b4cf..77bec2b6 100644 --- a/tests/python/unit_tests/hardware/test_ram.py +++ b/tests/python/unit_tests/hardware/test_ram.py @@ -16,7 +16,9 @@ import parallelzone as pz import unittest + class RAMTestCase(unittest.TestCase): + def setUp(self): """ For unit testing purposes we "create" two RAM instances: @@ -26,8 +28,8 @@ def setUp(self): """ self.defaulted = pz.hardware.RAM() - self.rv = pz.runtime.RuntimeView() - self.rs = self.rv.my_resource_set() + self.rv = pz.runtime.RuntimeView() + self.rs = self.rv.my_resource_set() self.has_value = self.rs.ram() def test_default_ctor(self): diff --git a/tests/python/unit_tests/runtime/test_resource_set.py b/tests/python/unit_tests/runtime/test_resource_set.py index 096d7975..9d6c68e7 100644 --- a/tests/python/unit_tests/runtime/test_resource_set.py +++ b/tests/python/unit_tests/runtime/test_resource_set.py @@ -16,7 +16,9 @@ import parallelzone as pz import unittest + class ResourceSetTestCase(unittest.TestCase): + def test_default_ctor(self): self.assertTrue(self.defaulted.empty()) self.assertFalse(self.defaulted.is_mine()) @@ -57,7 +59,6 @@ def test_ram(self): self.assertEqual(my_ram, default_ram) self.assertNotEqual(self.rs.ram(), default_ram) - def test_logger(self): """ Default-initialized instances have no logger object, so we check that @@ -90,5 +91,5 @@ def test_comparisons(self): def setUp(self): self.defaulted = pz.runtime.ResourceSet() - self.rv = pz.runtime.RuntimeView() - self.rs = self.rv.my_resource_set() + self.rv = pz.runtime.RuntimeView() + self.rs = self.rv.my_resource_set() diff --git a/tests/python/unit_tests/runtime/test_runtime_view.py b/tests/python/unit_tests/runtime/test_runtime_view.py index 6c72a569..8065aaac 100644 --- a/tests/python/unit_tests/runtime/test_runtime_view.py +++ b/tests/python/unit_tests/runtime/test_runtime_view.py @@ -16,7 +16,9 @@ import parallelzone as pz import unittest + class RuntimeViewTestCase(unittest.TestCase): + def test_default_ctor(self): self.assertGreater(self.defaulted.size(), 0) self.assertFalse(self.defaulted.did_i_start_mpi()) @@ -47,7 +49,6 @@ def test_at(self): self.assertEqual(rs0, default_rs) self.assertNotEqual(self.defaulted.at(0), default_rs) - def test_has_me(self): self.assertTrue(self.defaulted.has_me()) @@ -67,10 +68,9 @@ def test_my_resource_set(self): self.assertEqual(my_rs, default_rs) self.assertNotEqual(self.defaulted.my_resource_set(), default_rs) - def test_count_ram(self): default_ram = pz.hardware.RAM() - ram = self.defaulted.my_resource_set().ram() + ram = self.defaulted.my_resource_set().ram() self.assertEqual(self.defaulted.count(default_ram), 0) self.assertEqual(self.defaulted.count(ram), 1) @@ -81,10 +81,10 @@ def test_logger(self): def test_stack_callback_1(self): is_running = [True] - + def turn_off(val=is_running): val[0] = False - + falls_off = pz.runtime.RuntimeView() falls_off.stack_callback(turn_off) del falls_off diff --git a/tests/python/unit_tests/test_logging/test_logger.py b/tests/python/unit_tests/test_logging/test_logger.py index 7cd5b42c..e544391d 100644 --- a/tests/python/unit_tests/test_logging/test_logger.py +++ b/tests/python/unit_tests/test_logging/test_logger.py @@ -17,6 +17,7 @@ import parallelzone as pz import unittest + class LoggerTestCase(unittest.TestCase): """ Testing the logger from Python is difficult because we have not @@ -30,9 +31,11 @@ def setUp(self): severity = pz.Logger.severity self.defaulted = pz.Logger() - self.log = pz.runtime.RuntimeView().logger() - self.severities = [severity.trace, severity.debug, severity.info, - severity.warn, severity.error, severity.critical] + self.log = pz.runtime.RuntimeView().logger() + self.severities = [ + severity.trace, severity.debug, severity.info, severity.warn, + severity.error, severity.critical + ] def test_set_severity(self): self.defaulted.set_severity(pz.Logger.severity.debug) @@ -97,7 +100,6 @@ def test_log1(self): self.defaulted.log("Hello").log("World!") self.log.log("Hello").log("World!") - def test_log2(self): """ This method tests the overload of the Logger class which takes the diff --git a/tests/python/unit_tests/test_parallelzone.py b/tests/python/unit_tests/test_parallelzone.py index ebaa1ca2..f7efd028 100644 --- a/tests/python/unit_tests/test_parallelzone.py +++ b/tests/python/unit_tests/test_parallelzone.py @@ -19,8 +19,6 @@ import sys import unittest - - if __name__ == '__main__': # Make a RuntimeView and hold it until all tests run so MPI isn't shut # down @@ -29,7 +27,7 @@ my_dir = os.path.dirname(os.path.realpath(__file__)) loader = unittest.TestLoader() - tests = loader.discover(my_dir) + tests = loader.discover(my_dir) testrunner = unittest.runner.TextTestRunner() ret = not testrunner.run(tests).wasSuccessful() sys.exit(ret) From 2a8a6cc5b84423bab5944b89bc38479a507d0c4d Mon Sep 17 00:00:00 2001 From: "Jonathan M. Waldrop" Date: Sat, 27 Apr 2024 12:15:06 -0500 Subject: [PATCH 3/4] Update quickstart.rst with no newlines in literalinclude --- docs/source/quickstart.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/quickstart.rst b/docs/source/quickstart.rst index ed211f20..074824ce 100644 --- a/docs/source/quickstart.rst +++ b/docs/source/quickstart.rst @@ -35,7 +35,7 @@ the current process. As an example: .. literalinclude:: ../../tests/python/doc_snippets/test_quickstart.py :language: python - :lines: 24-34 + :lines: 24-25, 27-28, 30-31, 33-34 :dedent: 8 The ``RuntimeView`` also allows you to access other ``ResourceSet`` instances. From eea13cd4236b7f749a307f960344497a6cee4c63 Mon Sep 17 00:00:00 2001 From: "Jonathan M. Waldrop" Date: Mon, 29 Apr 2024 10:29:40 -0500 Subject: [PATCH 4/4] Fix python example linenos after formatting changes. --- docs/source/quickstart.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/quickstart.rst b/docs/source/quickstart.rst index 074824ce..84956b1e 100644 --- a/docs/source/quickstart.rst +++ b/docs/source/quickstart.rst @@ -35,7 +35,7 @@ the current process. As an example: .. literalinclude:: ../../tests/python/doc_snippets/test_quickstart.py :language: python - :lines: 24-25, 27-28, 30-31, 33-34 + :lines: 27-37 :dedent: 8 The ``RuntimeView`` also allows you to access other ``ResourceSet`` instances. @@ -94,7 +94,7 @@ environment. Say we wanted to know how much total RAM each resource set has: .. literalinclude:: ../../tests/python/doc_snippets/test_quickstart.py :language: python - :lines: 36-37 + :lines: 39-40 :dedent: 8 To summarize: