microscopic-receptionist-80998
06/14/2024, 12:23 PMLOGLEVEL
environment variable to the test execution environment so what I did is modify the python_tests
target to pass it:
python_tests(
dependencies=[
"backend#asyncpg",
],
extra_env_vars=(
"LOGLEVEL",
),
)
and then run it like this:
LOGLEVEL=debug pants --keep-sandboxes=always --level=debug test tests/api/test_tasks.py:tests
Still, the variable is not passed and I don't get it what I do wrong.
Anyone has some tips that might help me figure this out?microscopic-receptionist-80998
06/14/2024, 12:26 PMbroad-processor-92400
06/14/2024, 12:38 PMLOGLEVEL
exists in the __run.sh
script, to indicate whether it's a pants problem (doesn't exist), or maybe it's peculiar/unexpected behaviour from the process being executed (does exist but is ignored)microscopic-receptionist-80998
06/14/2024, 12:52 PM❯ more /private/var/folders/v7/lj0l76_974z62kvrtzy7x5xw0000gn/T/pants-sandbox-o8dZQw/__run.sh
#!/usr/bin/env bash
# This command line should execute the same process as pants did internally.
cd /private/var/folders/v7/lj0l76_974z62kvrtzy7x5xw0000gn/T/pants-sandbox-o8dZQw
env -i PEX_EXTRA_SYS_PATH=backend ./pytest_runner.pex_pex_shim.sh $'--color=yes' $'--junit-xml=backend.tests.api.test_tasks.py.tests.xml' -o $'junit_family=xunit2' backend/tests/api/test_tasks.py
better-van-82973
06/14/2024, 6:54 PMLOGLEVEL
in the extra_env_vars
argument for the test
goal: https://www.pantsbuild.org/2.21/reference/goals/test#extra_env_vars
[test]
use_coverage = true
extra_env_vars=[
"REDIS_HOST=localhost",
"CI",q
]
broad-processor-92400
06/14/2024, 9:03 PMmicroscopic-receptionist-80998
06/17/2024, 8:34 AMLOGLEVEL
in the extra_env_vars
argument for the test
goal
After adding it to the pants test
call as an argument (--extra-env-vars="['LOGLEVEL']"
) it now does successfully pass it and if I execute the __run.sh
from the sandbox I do see it logging but I still don't see it if I run it through pants
:
LOGLEVEL=debug pants --keep-sandboxes=always --level=info test --extra-env-vars="['LOGLEVEL']" --force tests/some_test.py:tests -- --log-cli-level=DEBUG
and this is how __run.sh
looks like:
#!/usr/bin/env bash
# This command line should execute the same process as pants did internally.
cd /private/var/folders/v7/lj0l76_974z62kvrtzy7x5xw0000gn/T/pants-sandbox-DZDyqY
env -i LOGLEVEL=debug PEX_EXTRA_SYS_PATH=backend ./pytest_runner.pex_pex_shim.sh $'--log-cli-level=DEBUG' $'--color=yes' $'--junit-xml=backend.tests.some_test.py.tests.xml' -o $'junit_family=xunit2' backend/tests/some_test.py
broad-processor-92400
06/17/2024, 11:03 AMtest
version of this option seems to work better. If we can get a reproducer, we might be able to confirm if there's a bug or not.
Pants will still capture and hide the output of passing tests. Using the test --debug ...
option too stops pants from doing this, by running each test sequentially