From 6db4cfed4d92b535fa53e505af22c570b254702d Mon Sep 17 00:00:00 2001 From: Marco Sulla Date: Tue, 11 Jun 2024 21:04:12 +0200 Subject: [PATCH 1/8] improved coverage --- .gitignore | 1 + test/base.py | 8 ++++++++ test/common.py | 25 ++++++++++++++++++++++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index c07b4cc..2b5aa86 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ test/core.* .idea/ .vs/ .coverage +coverage/ diff --git a/test/base.py b/test/base.py index 512ff6f..de7a709 100644 --- a/test/base.py +++ b/test/base.py @@ -84,6 +84,10 @@ def fd_dict_2(self): def fd_dict_sabina(self): return {'Corrado': 'Guzzanti', 'Sabina': 'Guzzanti'} + @pytest.fixture + def fd_dict_none(self): + return {'Corrado': None, 'Sabina': None} + @pytest.fixture def generator_seq2(self, fd_dict): seq2 = list(fd_dict.items()) @@ -117,6 +121,10 @@ def fd2(self, fd_dict_2): def fd_sabina(self, fd_dict_sabina): return self.FrozendictClass(fd_dict_sabina) + @pytest.fixture + def fromkeys_keys(self): + return ["Corrado", "Sabina"] + @pytest.fixture def fd_items(self, fd_dict): return tuple(fd_dict.items()) diff --git a/test/common.py b/test/common.py index 9fbacb3..05ef129 100644 --- a/test/common.py +++ b/test/common.py @@ -129,6 +129,14 @@ def test_todict(self, fd, fd_dict): def test_get(self, fd): assert fd.get("Guzzanti") == "Corrado" + def test_get_bad(self, fd): + with pytest.raises(TypeError): + fd.get() + + def test_get_bad_2(self, fd): + with pytest.raises(TypeError): + fd.get(1, 2, 3) + def test_get_fail(self, fd): default = object() assert fd.get("Brignano", default) is default @@ -142,11 +150,22 @@ def test_values(self, fd, fd_dict): def test_items(self, fd, fd_dict): assert tuple(fd.items()) == tuple(fd_dict.items()) - def test_fromkeys(self, fd_sabina): - keys = ["Corrado", "Sabina"] - f = self.FrozendictClass.fromkeys(keys, "Guzzanti") + def test_fromkeys(self, fd_sabina, fromkeys_keys): + f = self.FrozendictClass.fromkeys(fromkeys_keys, "Guzzanti") assert f == fd_sabina + def test_fromkeys_bad(self): + with pytest.raises(TypeError): + f = self.FrozendictClass.fromkeys() + + def test_fromkeys_bad_2(self): + with pytest.raises(TypeError): + f = self.FrozendictClass.fromkeys(1, 2, 3) + + def test_fromkeys_default(self, fd_dict_none, fromkeys_keys): + f = self.FrozendictClass.fromkeys(fromkeys_keys) + assert f == fd_dict_none + def test_fromkeys_dict(self, fd_sabina, fd_dict_sabina): f = self.FrozendictClass.fromkeys(fd_dict_sabina, "Guzzanti") assert f == fd_sabina From 36fa570cac4df028a1ee6380daa07738dbb722e7 Mon Sep 17 00:00:00 2001 From: Marco Sulla Date: Tue, 11 Jun 2024 22:24:54 +0200 Subject: [PATCH 2/8] updated mytest scripts --- mytest.bat | 2 +- mytest.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mytest.bat b/mytest.bat index 944f844..ca2e70a 100644 --- a/mytest.bat +++ b/mytest.bat @@ -1 +1 @@ -python test/debug.py && pytest +python test/debug.py && python -X faulthandler -m pytest -p no:faulthandler diff --git a/mytest.sh b/mytest.sh index 6887c4e..2339920 100755 --- a/mytest.sh +++ b/mytest.sh @@ -1,3 +1,3 @@ rm test/core.* -./test/debug.py && pytest +./test/debug.py && python -X faulthandler -m pytest -p no:faulthandler From c1908bdaca8e500ebe76eaa2f9a26aea6ee69998 Mon Sep 17 00:00:00 2001 From: Marco Sulla Date: Tue, 11 Jun 2024 22:25:13 +0200 Subject: [PATCH 3/8] improved debug.py --- test/debug.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/test/debug.py b/test/debug.py index a686379..d5b10df 100755 --- a/test/debug.py +++ b/test/debug.py @@ -1052,6 +1052,50 @@ def func_110(): functions.append(func_110) +@trace() +def func_111(): + try: + fd_1.get() + except TypeError: + pass + + +functions.append(func_111) + + +@trace() +def func_112(): + try: + fd_1.get(1, 2, 3) + except TypeError: + pass + + +functions.append(func_112) + + +@trace() +def func_113(): + try: + frozendict.fromkeys() + except TypeError: + pass + + +functions.append(func_113) + + +@trace() +def func_114(): + try: + frozendict.fromkeys(1, 2, 3) + except TypeError: + pass + + +functions.append(func_114) + + print_sep() for frozendict_class in (frozendict, F): From a70917a64da1d47830300ba715c32d593692d478 Mon Sep 17 00:00:00 2001 From: Marco Sulla Date: Wed, 12 Jun 2024 18:44:59 +0200 Subject: [PATCH 4/8] test --- test/subclass_only.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/subclass_only.py b/test/subclass_only.py index d0006f8..73efca7 100644 --- a/test/subclass_only.py +++ b/test/subclass_only.py @@ -70,6 +70,6 @@ def test_del_empty_sub(self, fd_empty): assert f2 == fd_empty assert f2 is not fd_empty - def test_missing(self, fd): - fd_missing = self.FrozendictMissingClass(fd) - assert fd_missing[0] == 0 + # def test_missing(self, fd): + # fd_missing = self.FrozendictMissingClass(fd) + # assert fd_missing[0] == 0 From ca2a1c4d898f097158050617ec52b89a04f3dcdd Mon Sep 17 00:00:00 2001 From: Marco Sulla Date: Wed, 12 Jun 2024 19:16:34 +0200 Subject: [PATCH 5/8] try to get core files --- .github/workflows/build_secondary_wheels.yml | 11 +++++++++++ test/subclass_only.py | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_secondary_wheels.yml b/.github/workflows/build_secondary_wheels.yml index 54caba2..a1b5c6f 100644 --- a/.github/workflows/build_secondary_wheels.yml +++ b/.github/workflows/build_secondary_wheels.yml @@ -72,6 +72,10 @@ jobs: CIBW_SKIP: "*-musllinux_*" CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: > + sudo mkdir /cores && + sudo chmod 777 /cores && + sudo bash -c 'echo "/cores/%e.%p.%t" > /proc/sys/kernel/core_pattern' && + ulimit -c unlimited && python -X faulthandler {package}/test/debug.py && python -X faulthandler -m pytest -p no:faulthandler -s {package} with: @@ -84,3 +88,10 @@ jobs: uses: actions/upload-artifact@v3 with: path: dist/*.tar.gz + + - name: Upload core files + uses: actions/upload-artifact@v3 + if: ${{ failure() }} + with: + name: cores + path: /cores diff --git a/test/subclass_only.py b/test/subclass_only.py index 73efca7..d0006f8 100644 --- a/test/subclass_only.py +++ b/test/subclass_only.py @@ -70,6 +70,6 @@ def test_del_empty_sub(self, fd_empty): assert f2 == fd_empty assert f2 is not fd_empty - # def test_missing(self, fd): - # fd_missing = self.FrozendictMissingClass(fd) - # assert fd_missing[0] == 0 + def test_missing(self, fd): + fd_missing = self.FrozendictMissingClass(fd) + assert fd_missing[0] == 0 From c000610f3a37c1a28dc4d428238d4894df7d669c Mon Sep 17 00:00:00 2001 From: Marco Sulla Date: Wed, 12 Jun 2024 19:24:10 +0200 Subject: [PATCH 6/8] removed sudo --- .github/workflows/build_secondary_wheels.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_secondary_wheels.yml b/.github/workflows/build_secondary_wheels.yml index a1b5c6f..13244c9 100644 --- a/.github/workflows/build_secondary_wheels.yml +++ b/.github/workflows/build_secondary_wheels.yml @@ -72,9 +72,9 @@ jobs: CIBW_SKIP: "*-musllinux_*" CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: > - sudo mkdir /cores && - sudo chmod 777 /cores && - sudo bash -c 'echo "/cores/%e.%p.%t" > /proc/sys/kernel/core_pattern' && + mkdir /cores && + chmod 777 /cores && + echo "/cores/%e.%p.%t" > /proc/sys/kernel/core_pattern && ulimit -c unlimited && python -X faulthandler {package}/test/debug.py && python -X faulthandler -m pytest -p no:faulthandler -s {package} From f1ca140e84074c679dc4ab33c5841a493c2ebf9b Mon Sep 17 00:00:00 2001 From: Marco Sulla Date: Wed, 12 Jun 2024 19:32:11 +0200 Subject: [PATCH 7/8] trying installing sudo --- .github/workflows/build_secondary_wheels.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_secondary_wheels.yml b/.github/workflows/build_secondary_wheels.yml index 13244c9..ff482e0 100644 --- a/.github/workflows/build_secondary_wheels.yml +++ b/.github/workflows/build_secondary_wheels.yml @@ -72,9 +72,10 @@ jobs: CIBW_SKIP: "*-musllinux_*" CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: > - mkdir /cores && - chmod 777 /cores && - echo "/cores/%e.%p.%t" > /proc/sys/kernel/core_pattern && + apt-get install -y sudo && + sudo mkdir /cores && + sudo chmod 777 /cores && + sudo bash -c 'echo "/cores/%e.%p.%t" > /proc/sys/kernel/core_pattern' && ulimit -c unlimited && python -X faulthandler {package}/test/debug.py && python -X faulthandler -m pytest -p no:faulthandler -s {package} From 32993b1c411aa78d8f7a6f94b18c3d3cf365a986 Mon Sep 17 00:00:00 2001 From: Marco Sulla Date: Wed, 12 Jun 2024 19:40:40 +0200 Subject: [PATCH 8/8] execute preparation for core dumps in a separate step --- .github/workflows/build_secondary_wheels.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_secondary_wheels.yml b/.github/workflows/build_secondary_wheels.yml index ff482e0..f574f2a 100644 --- a/.github/workflows/build_secondary_wheels.yml +++ b/.github/workflows/build_secondary_wheels.yml @@ -62,6 +62,12 @@ jobs: - name: Copy sdist package run: cp dist/frozendict-*.tar.gz dist/frozendict.tar.gz + + - name: Prepare system for core dumps + run: | + sudo mkdir /cores && + sudo chmod 777 /cores && + sudo bash -c 'echo "/cores/%e.%p.%t" > /proc/sys/kernel/core_pattern' - name: Build wheels uses: pypa/cibuildwheel@v2.16.5 @@ -72,10 +78,6 @@ jobs: CIBW_SKIP: "*-musllinux_*" CIBW_TEST_REQUIRES: pytest CIBW_TEST_COMMAND: > - apt-get install -y sudo && - sudo mkdir /cores && - sudo chmod 777 /cores && - sudo bash -c 'echo "/cores/%e.%p.%t" > /proc/sys/kernel/core_pattern' && ulimit -c unlimited && python -X faulthandler {package}/test/debug.py && python -X faulthandler -m pytest -p no:faulthandler -s {package}