astonishing-london-2419
08/30/2021, 1:59 PMpoetry
, nox
+ custom scripts) to pants, and I’m facing problems in how to configure tests. We mark some tests as integration
and these are usually not run locally but only in the CI; in the past, our nox configuration took care of this by adding -m 'not integration
when running the normal tests and we would have a special “target” to run full tests.
I am not sure which is the best pattern to use in pants to achieve this. My first approach was to do something like
python_tests(
name="tests",
sources=["tests/**/*.py"],
extra_env_vars=["PYTEST_ADDOPTS=-m 'not integration'"],
**tests_kwargs,
)
and then create a tests_full
without the extra env vars, but this doesn’t work when I run ./pants test lib:tests
, because the skipped tests give a return code 5 in pytests
. What would be another solution to achieve this?happy-kitchen-89482
08/30/2021, 3:31 PMpython_tests(
name="unit",
sources=[...]
)
python_tests(
name="integration",
sources=[...],
tags=["integration"],
)
happy-kitchen-89482
08/30/2021, 3:34 PM./pants test :: --tag=-integration # Only run non-integration tests
./pants test :: --tag=integration # Only run integration tests
./pants test :: # Run all tests
happy-kitchen-89482
08/30/2021, 3:34 PMhappy-kitchen-89482
08/30/2021, 3:36 PM_integration.py
suffix, so they are easy to include/exclude in the targets' sources=
globs.astonishing-london-2419
08/30/2021, 4:07 PMastonishing-london-2419
08/30/2021, 4:07 PMtests/integration
vs test/unit
astonishing-london-2419
08/30/2021, 4:07 PMastonishing-london-2419
08/30/2021, 4:08 PM./pants test :: --tag=-integration
the default? to minimize dev frictionhundreds-father-404
08/30/2021, 4:44 PMunit
and it
maybe? They would behave like test
but automatically apply the filter for youastonishing-london-2419
08/31/2021, 9:22 AMastonishing-london-2419
08/31/2021, 9:22 AMastonishing-london-2419
08/31/2021, 12:06 PMhappy-kitchen-89482
09/01/2021, 4:01 PMhappy-kitchen-89482
09/01/2021, 4:02 PMhappy-kitchen-89482
09/01/2021, 4:04 PMUnmatched glob
warning, but it shouldn't fail the buildastonishing-london-2419
09/02/2021, 8:22 AMastonishing-london-2419
09/06/2021, 1:06 PMUnmatched glob
Do the file(s) exist? If so, check if the file(s) are in your `.gitignore` or the global `pants_ignore` option, which may result in Pants not being able to see the file(s) even though they exist on disk. Refer to <https://www.pantsbuild.org/v2.6/docs/troubleshooting#pants-cannot-find-a-file-in-your-project>.
15:04:32.36 [WARN] Unmatched glob from lib/common:integration's `sources` field: "lib/common/tests/integration/*.py"
So it works! Any way to silence these warnings? I prefer to have a “clean” test suitehappy-kitchen-89482
09/06/2021, 3:12 PMignore_warnings
global option: https://www.pantsbuild.org/docs/reference-global#section-ignore-warningshappy-kitchen-89482
09/06/2021, 3:12 PMpants.toml
astonishing-london-2419
09/14/2021, 9:31 AMDo the file(s) exist? If so, check if the file(s) are in your `.gitignore` or the global `pants_ignore` option, which may result in Pants not being able to see the file(s) even though they exist on disk. Refer to <https://www.pantsbuild.org/v2.6/docs/troubleshooting#pants-cannot-find-a-file-in-your-project>.
11:28:14.18 [WARN] Unmatched glob from lib/notifications:unit's `sources` field: "lib/notifications/tests/unit/*.py"
Do the file(s) exist? If so, check if the file(s) are in your `.gitignore` or the global `pants_ignore` option, which may result in Pants not being able to see the file(s) even though they exist on disk. Refer to <https://www.pantsbuild.org/v2.6/docs/troubleshooting#pants-cannot-find-a-file-in-your-project>.
11:28:14.26 [WARN] The target app/csv_importer imports `clickhouse_driver.errors.Error`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['app/csv_importer:clickhouse-driver', 'lib/common:clickhouse-driver'].
The first one is a well understood side effect of the discussion we had above, the bottom one is a config mistake (why is it a WARN and not an error?)happy-kitchen-89482
09/14/2021, 1:55 PMhappy-kitchen-89482
09/14/2021, 1:56 PMhappy-kitchen-89482
09/14/2021, 1:56 PM