@@ -47,115 +47,109 @@ python -m build
4747wheel_package=$( ls dist/* .whl)
4848python -m uv pip install " trio @ $wheel_package " -c test-requirements.txt
4949
50- if [ " $CHECK_FORMATTING " = " 1" ]; then
51- python -m uv pip install -r test-requirements.txt exceptiongroup
52- echo " ::endgroup::"
53- source check.sh
50+ # Actual tests
51+ # expands to 0 != 1 if NO_TEST_REQUIREMENTS is not set, if set the `-0` has no effect
52+ # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02
53+ if [ " ${NO_TEST_REQUIREMENTS-0} " == 1 ]; then
54+ python -m uv pip install pytest coverage -c test-requirements.txt
55+ flags=" --skip-optional-imports"
5456else
55- # Actual tests
56- # expands to 0 != 1 if NO_TEST_REQUIREMENTS is not set, if set the `-0` has no effect
57- # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02
58- if [ " ${NO_TEST_REQUIREMENTS-0} " == 1 ]; then
59- python -m uv pip install pytest coverage -c test-requirements.txt
60- flags=" --skip-optional-imports"
61- else
62- python -m uv pip install -r test-requirements.txt
63- flags=" "
64- fi
57+ python -m uv pip install -r test-requirements.txt
58+ flags=" "
59+ fi
6560
66- # So we can run the test for our apport/excepthook interaction working
67- if [ -e /etc/lsb-release ] && grep -q Ubuntu /etc/lsb-release; then
68- sudo apt install -q python3-apport
69- fi
61+ # So we can run the test for our apport/excepthook interaction working
62+ if [ -e /etc/lsb-release ] && grep -q Ubuntu /etc/lsb-release; then
63+ sudo apt install -q python3-apport
64+ fi
7065
71- # If we're testing with a LSP installed, then it might break network
72- # stuff, so wait until after we've finished setting everything else
73- # up.
74- if [ " $LSP " != " " ]; then
75- echo " Installing LSP from ${LSP} "
76- # We use --insecure because one of the LSP's has been observed to give
77- # cert verification errors:
78- #
79- # https://github.com/python-trio/trio/issues/1478
80- #
81- # *Normally*, you should never ever use --insecure, especially when
82- # fetching an executable! But *in this case*, we're intentionally
83- # installing some untrustworthy quasi-malware onto into a sandboxed
84- # machine for testing. So MITM attacks are really the least of our
85- # worries.
86- if [ " $LSP_EXTRACT_FILE " != " " ]; then
87- # We host the Astrill VPN installer ourselves, and encrypt it
88- # so as to decrease the chances of becoming an inadvertent
89- # public redistributor.
90- curl-harder -o lsp-installer.zip " $LSP "
91- unzip -P " not very secret trio ci key" lsp-installer.zip " $LSP_EXTRACT_FILE "
92- mv " $LSP_EXTRACT_FILE " lsp-installer.exe
93- else
94- curl-harder --insecure -o lsp-installer.exe " $LSP "
95- fi
96- # This is only needed for the Astrill LSP, but there's no harm in
97- # doing it all the time. The cert was manually extracted by installing
98- # the package in a VM, clicking "Always trust from this publisher"
99- # when installing, and then running 'certmgr.msc' and exporting the
100- # certificate. See:
101- # http://www.migee.com/2010/09/24/solution-for-unattendedsilent-installs-and-would-you-like-to-install-this-device-software/
102- certutil -addstore " TrustedPublisher" src/trio/_tests/astrill-codesigning-cert.cer
103- # Double-slashes are how you tell windows-bash that you want a single
104- # slash, and don't treat this as a unix-style filename that needs to
105- # be replaced by a windows-style filename.
106- # http://www.mingw.org/wiki/Posix_path_conversion
107- ./lsp-installer.exe //silent //norestart
108- echo " Waiting for LSP to appear in Winsock catalog"
109- while ! netsh winsock show catalog | grep " Layered Chain Entry" ; do
110- sleep 1
111- done
112- netsh winsock show catalog
66+ # If we're testing with a LSP installed, then it might break network
67+ # stuff, so wait until after we've finished setting everything else
68+ # up.
69+ if [ " $LSP " != " " ]; then
70+ echo " Installing LSP from ${LSP} "
71+ # We use --insecure because one of the LSP's has been observed to give
72+ # cert verification errors:
73+ #
74+ # https://github.com/python-trio/trio/issues/1478
75+ #
76+ # *Normally*, you should never ever use --insecure, especially when
77+ # fetching an executable! But *in this case*, we're intentionally
78+ # installing some untrustworthy quasi-malware onto into a sandboxed
79+ # machine for testing. So MITM attacks are really the least of our
80+ # worries.
81+ if [ " $LSP_EXTRACT_FILE " != " " ]; then
82+ # We host the Astrill VPN installer ourselves, and encrypt it
83+ # so as to decrease the chances of becoming an inadvertent
84+ # public redistributor.
85+ curl-harder -o lsp-installer.zip " $LSP "
86+ unzip -P " not very secret trio ci key" lsp-installer.zip " $LSP_EXTRACT_FILE "
87+ mv " $LSP_EXTRACT_FILE " lsp-installer.exe
88+ else
89+ curl-harder --insecure -o lsp-installer.exe " $LSP "
11390 fi
114- echo " ::endgroup::"
115-
116- echo " ::group::Setup for tests"
91+ # This is only needed for the Astrill LSP, but there's no harm in
92+ # doing it all the time. The cert was manually extracted by installing
93+ # the package in a VM, clicking "Always trust from this publisher"
94+ # when installing, and then running 'certmgr.msc' and exporting the
95+ # certificate. See:
96+ # http://www.migee.com/2010/09/24/solution-for-unattendedsilent-installs-and-would-you-like-to-install-this-device-software/
97+ certutil -addstore " TrustedPublisher" src/trio/_tests/astrill-codesigning-cert.cer
98+ # Double-slashes are how you tell windows-bash that you want a single
99+ # slash, and don't treat this as a unix-style filename that needs to
100+ # be replaced by a windows-style filename.
101+ # http://www.mingw.org/wiki/Posix_path_conversion
102+ ./lsp-installer.exe //silent //norestart
103+ echo " Waiting for LSP to appear in Winsock catalog"
104+ while ! netsh winsock show catalog | grep " Layered Chain Entry" ; do
105+ sleep 1
106+ done
107+ netsh winsock show catalog
108+ fi
109+ echo " ::endgroup::"
117110
118- # We run the tests from inside an empty directory, to make sure Python
119- # doesn't pick up any .py files from our working dir. Might have already
120- # been created by a previous run.
121- mkdir empty || true
122- cd empty
111+ echo " ::group::Setup for tests"
123112
124- INSTALLDIR=$( python -c " import os, trio; print(os.path.dirname(trio.__file__))" )
125- cp ../pyproject.toml " $INSTALLDIR " # TODO: remove this
113+ # We run the tests from inside an empty directory, to make sure Python
114+ # doesn't pick up any .py files from our working dir. Might have already
115+ # been created by a previous run.
116+ mkdir empty || true
117+ cd empty
126118
127- # get mypy tests a nice cache
128- MYPYPATH= " .. " mypy --config-file= --cache-dir=./.mypy_cache -c " import trio " > /dev/null 2> /dev/null || true
119+ INSTALLDIR= $( python -c " import os, trio; print(os.path.dirname(trio.__file__)) " )
120+ cp ../pyproject.toml " $INSTALLDIR " # TODO: remove this
129121
130- # support subprocess spawning with coverage.py
131- echo " import coverage; coverage.process_startup() " | tee -a " $INSTALLDIR /../sitecustomize.py "
122+ # get mypy tests a nice cache
123+ MYPYPATH= " .. " mypy --config-file= --cache-dir=./.mypy_cache -c " import trio " > /dev/null 2> /dev/null || true
132124
133- perl -i -pe ' s/-p trio\._tests\.pytest_plugin//' " $INSTALLDIR /pyproject.toml"
125+ # support subprocess spawning with coverage.py
126+ echo " import coverage; coverage.process_startup()" | tee -a " $INSTALLDIR /../sitecustomize.py"
134127
135- echo " ::endgroup::"
136- echo " ::group:: Run Tests"
137- if PYTHONPATH=../tests COVERAGE_PROCESS_START=$( pwd) /../pyproject.toml \
138- coverage run --rcfile=../pyproject.toml -m \
139- pytest -ra --junitxml=../test-results.xml \
140- -p _trio_check_attrs_aliases --verbose --durations=10 \
141- -p trio._tests.pytest_plugin --run-slow $flags " ${INSTALLDIR} " ; then
142- PASSED=true
143- else
144- PASSED=false
145- fi
146- echo " ::endgroup::"
147- echo " ::group::Coverage"
128+ perl -i -pe ' s/-p trio\._tests\.pytest_plugin//' " $INSTALLDIR /pyproject.toml"
148129
149- coverage combine --rcfile ../pyproject.toml
150- coverage report -m --rcfile ../pyproject.toml
151- coverage xml --rcfile ../pyproject.toml
130+ echo " ::endgroup::"
131+ echo " ::group:: Run Tests"
132+ if PYTHONPATH=../tests COVERAGE_PROCESS_START=$( pwd) /../pyproject.toml \
133+ coverage run --rcfile=../pyproject.toml -m \
134+ pytest -ra --junitxml=../test-results.xml \
135+ -p _trio_check_attrs_aliases --verbose --durations=10 \
136+ -p trio._tests.pytest_plugin --run-slow $flags " ${INSTALLDIR} " ; then
137+ PASSED=true
138+ else
139+ PASSED=false
140+ fi
141+ echo " ::endgroup::"
142+ echo " ::group::Coverage"
152143
153- # Remove the LSP again; again we want to do this ASAP to avoid
154- # accidentally breaking other stuff.
155- if [ " $LSP " != " " ]; then
156- netsh winsock reset
157- fi
144+ coverage combine --rcfile ../pyproject.toml
145+ coverage report -m --rcfile ../pyproject.toml
146+ coverage xml --rcfile ../pyproject.toml
158147
159- echo " ::endgroup::"
160- $PASSED
148+ # Remove the LSP again; again we want to do this ASAP to avoid
149+ # accidentally breaking other stuff.
150+ if [ " $LSP " != " " ]; then
151+ netsh winsock reset
161152fi
153+
154+ echo " ::endgroup::"
155+ $PASSED
0 commit comments