victorious-animal-71161
06/11/2022, 11:40 AM/tmp
when running test with pants? Our test code is having trouble reading docker-compose.yml
(the purpose of this file is to create a test redis cluster) when launching snap-based docker, since snap based docker can't access to /tmp
.victorious-animal-71161
06/11/2022, 11:41 AMvictorious-animal-71161
06/11/2022, 11:41 AMhappy-kitchen-89482
06/11/2022, 11:54 AMvictorious-animal-71161
06/11/2022, 12:06 PM[GLOBAL].local_execution_root_dir
, but regardless of that option, pants still creates new workdir under /tmp
:(happy-kitchen-89482
06/12/2022, 9:23 AMhappy-kitchen-89482
06/12/2022, 9:23 AMvictorious-animal-71161
06/13/2022, 2:33 AMvictorious-animal-71161
06/13/2022, 2:33 AMvictorious-animal-71161
06/13/2022, 2:34 AMrootdir
columnhappy-kitchen-89482
06/18/2022, 6:25 PMvictorious-animal-71161
06/20/2022, 1:25 PM--subprocess-environment-env-vars="['TMPDIR=$(pwd)/.tmp']"
flag, but pytest still starts from /tmp
. I’ll keep look for some other options.rhythmic-morning-87313
07/10/2022, 2:05 PMpex
to override its current working directory? TMPDIR
seems to have no effects in this case.rhythmic-morning-87313
07/10/2022, 2:05 PMpytest
itself does not assume anything about the current working directory.rhythmic-morning-87313
07/10/2022, 2:06 PMrhythmic-morning-87313
07/10/2022, 2:14 PM[GLOBAL].local_execution_root_dir
setting in pants.toml
has no effect neither.rhythmic-morning-87313
07/10/2022, 2:15 PMrhythmic-morning-87313
07/10/2022, 2:15 PMrhythmic-morning-87313
07/10/2022, 2:15 PMrhythmic-morning-87313
07/10/2022, 2:20 PMrhythmic-morning-87313
07/10/2022, 2:20 PMrhythmic-morning-87313
07/10/2022, 2:37 PMrhythmic-morning-87313
07/10/2022, 2:37 PMrhythmic-morning-87313
07/10/2022, 2:37 PMrhythmic-morning-87313
07/10/2022, 2:37 PMrhythmic-morning-87313
07/10/2022, 3:05 PMrhythmic-morning-87313
07/10/2022, 3:05 PMrhythmic-morning-87313
07/10/2022, 3:05 PMsetup_pex_cli_process()
seems to be legitimate.. hmmrhythmic-morning-87313
07/10/2022, 3:09 PMrhythmic-morning-87313
07/10/2022, 3:09 PMrhythmic-morning-87313
07/10/2022, 3:09 PMrhythmic-morning-87313
07/10/2022, 3:10 PMrhythmic-morning-87313
07/10/2022, 3:10 PMPath.cwd()
in my test fixture differsrhythmic-morning-87313
07/10/2022, 3:10 PMrhythmic-morning-87313
07/10/2022, 3:12 PMrhythmic-morning-87313
07/10/2022, 3:39 PMrhythmic-morning-87313
07/10/2022, 3:40 PMrhythmic-morning-87313
07/10/2022, 4:01 PMpex.py
, process.py
, ... to determine the source of this tmp directory, but still i cannot find itrhythmic-morning-87313
07/10/2022, 4:02 PMrhythmic-morning-87313
07/10/2022, 4:02 PMrhythmic-morning-87313
07/10/2022, 4:06 PMrhythmic-morning-87313
07/10/2022, 4:06 PMrhythmic-morning-87313
07/10/2022, 4:09 PMrhythmic-morning-87313
07/10/2022, 4:09 PMrhythmic-morning-87313
07/10/2022, 4:10 PMrhythmic-morning-87313
07/10/2022, 4:13 PMVENVSCRIPT SANDBOX_ROOT = /tmp/.tmpebTVkM/.
rhythmic-morning-87313
07/10/2022, 4:13 PMenough-analyst-54434
07/10/2022, 4:26 PMlocal_execution_root_dir
definitely works. @victorious-animal-71161 here's what I ran on Pants main with commentary:
$ mkdir bob
$ ./pants \
--local-execution-root-dir=bob \
--pants-ignore=bob \
--pytest-args="[]" \
test \
--force \
--output=all \
src/python/pants/util/strutil_test.py \
-- -vvs
10:20:09.03 [INFO] Completed: Run Pytest - src/python/pants/util/strutil_test.py:tests succeeded.
============================= test session starts ==============================
platform linux -- Python 3.7.13, pytest-7.0.1, pluggy-1.0.0 -- /home/jsirois/.cache/pants/named_caches/pex_root/venvs/s/06648b60/venv/bin/python3.7
cachedir: .pytest_cache
metadata: {'Python': '3.7.13', 'Platform': 'Linux-5.18.10-arch1-1-x86_64-with-arch', 'Packages': {'pytest': '7.0.1', 'py': '1.11.0', 'pluggy': '1.0.0'}, 'Plugins': {'metadata': '2.0.1', 'html': '3.1.1', 'cov': '3.0.0', 'asyncio': '0.18.3', 'icdiff': '0.5'}}
rootdir: /home/jsirois/dev/pantsbuild/jsirois-pants/bob/pants-sandbox-ppykzK, configfile: pyproject.toml
plugins: metadata-2.0.1, html-3.1.1, cov-3.0.0, asyncio-0.18.3, icdiff-0.5
asyncio: mode=auto
collecting ... collected 17 items
src/python/pants/util/strutil_test.py::test_pluralize PASSED
...
src/python/pants/util/strutil_test.py::test_fmt_memory_sizes[2199023255552-2048GiB] PASSED
- generated xml file: /home/jsirois/dev/pantsbuild/jsirois-pants/bob/pants-sandbox-ppykzK/src.python.pants.util.strutil_test.py.tests.xml -
============================== 17 passed in 0.13s ==============================
✓ src/python/pants/util/strutil_test.py:tests succeeded in 0.28s.
+ The mkdir bob
was needed due to a bug (https://github.com/pantsbuild/pants/issues/16119)
+ The --pants-ignore=bob
was needed since bob
is a relative directory (in the build root) and is otherwise watched by pantsd which leads to continual re-starts.
+ The `--pytest-args="[]"`is to turn pytest headers back on where rootdir is printed (The Pants repo turns those headers off with --no-header
in its pants.toml
)
+ The --force --output=all
is to make sure the test re-runs so we can see the result of the experiment.
+ The -- -vvs
is to pass pytest some verbosity args directly.
You'll notice the result of the experiment in the pytest header - it sees: rootdir: /home/jsirois/dev/pantsbuild/jsirois-pants/bob/pants-sandbox-ppykzK, configfile: pyproject.toml
@victorious-animal-71161 what version of Pants are you using?rhythmic-morning-87313
07/10/2022, 4:32 PMrhythmic-morning-87313
07/10/2022, 4:33 PM<http://intrinsic.rs|intrinsic.rs>
seems to create maybe_tempdir
andrhythmic-morning-87313
07/10/2022, 4:33 PMrhythmic-morning-87313
07/10/2022, 4:33 PMrun_in_workspace
is expected to be set false when run interactivelyenough-analyst-54434
07/10/2022, 4:33 PMrhythmic-morning-87313
07/10/2022, 4:33 PMenough-analyst-54434
07/10/2022, 4:34 PMrhythmic-morning-87313
07/10/2022, 4:34 PM/tmp/.tmpxxxxx/.tmp
comes from when local_execution_root_dir
is set to use %(build_root)s/.tmp
enough-analyst-54434
07/10/2022, 4:35 PMrhythmic-morning-87313
07/10/2022, 4:35 PM/tmp
in the host to mount inside the container..)rhythmic-morning-87313
07/10/2022, 4:36 PMrhythmic-morning-87313
07/10/2022, 4:37 PMrhythmic-morning-87313
07/10/2022, 4:37 PMenough-analyst-54434
07/10/2022, 4:37 PMrhythmic-morning-87313
07/10/2022, 4:38 PMrhythmic-morning-87313
07/10/2022, 4:38 PM/tmp
path in the pants codeenough-analyst-54434
07/10/2022, 4:38 PMenough-analyst-54434
07/10/2022, 4:39 PMrhythmic-morning-87313
07/10/2022, 4:39 PMrhythmic-morning-87313
07/10/2022, 4:39 PM./pants-local test --debug tests/agent/docker/test_agent.py:tests -- -k test_auto_pull_digest_when_digest_matching -s -v
rhythmic-morning-87313
07/10/2022, 4:40 PMenough-analyst-54434
07/10/2022, 4:40 PMrhythmic-morning-87313
07/10/2022, 4:40 PMenough-analyst-54434
07/10/2022, 4:40 PMrhythmic-morning-87313
07/10/2022, 4:40 PMenough-analyst-54434
07/10/2022, 4:40 PMrhythmic-morning-87313
07/10/2022, 4:41 PMrhythmic-morning-87313
07/10/2022, 4:41 PMenough-analyst-54434
07/10/2022, 4:41 PMrhythmic-morning-87313
07/10/2022, 4:42 PMrhythmic-morning-87313
07/10/2022, 4:42 PMrhythmic-morning-87313
07/10/2022, 4:42 PMrhythmic-morning-87313
07/10/2022, 4:42 PM/tmp/.tmpxxxx
rhythmic-morning-87313
07/10/2022, 4:43 PMenough-analyst-54434
07/10/2022, 4:44 PMrhythmic-morning-87313
07/10/2022, 4:45 PMrhythmic-morning-87313
07/10/2022, 4:45 PMrhythmic-morning-87313
07/10/2022, 4:46 PMinteractive_process()
in <http://intrinsic.rs|intrinsic.rs>
rhythmic-morning-87313
07/10/2022, 4:46 PMinteractive_process()
and some bits of immutable digest stuffsrhythmic-morning-87313
07/10/2022, 4:47 PMenough-analyst-54434
07/10/2022, 4:47 PMrhythmic-morning-87313
07/10/2022, 4:48 PMenough-analyst-54434
07/10/2022, 4:48 PMenough-analyst-54434
07/10/2022, 4:48 PMrhythmic-morning-87313
07/10/2022, 4:51 PMrhythmic-morning-87313
07/10/2022, 4:52 PM:?
or :#?
... building againrhythmic-morning-87313
07/10/2022, 4:56 PMrhythmic-morning-87313
07/10/2022, 4:56 PMrhythmic-morning-87313
07/10/2022, 4:57 PMenough-analyst-54434
07/10/2022, 4:58 PM.pants.d/pants.log
or run with --no-pantsd
rhythmic-morning-87313
07/10/2022, 5:00 PMrhythmic-morning-87313
07/10/2022, 5:01 PMrhythmic-morning-87313
07/10/2022, 5:01 PMrhythmic-morning-87313
07/10/2022, 5:01 PMrhythmic-morning-87313
07/10/2022, 5:01 PMenough-analyst-54434
07/10/2022, 5:02 PMrhythmic-morning-87313
07/10/2022, 5:03 PMrhythmic-morning-87313
07/10/2022, 5:03 PMenough-analyst-54434
07/10/2022, 5:03 PMrhythmic-morning-87313
07/10/2022, 5:07 PMrhythmic-morning-87313
07/10/2022, 5:08 PM--debug
flag to see what happens locallyrhythmic-morning-87313
07/10/2022, 5:08 PM--debug
makes...rhythmic-morning-87313
07/10/2022, 5:08 PMrhythmic-morning-87313
07/10/2022, 5:08 PMrhythmic-morning-87313
07/10/2022, 5:09 PMrhythmic-morning-87313
07/10/2022, 5:25 PMenough-analyst-54434
07/10/2022, 5:33 PM--pants-ignore=bob
in my example above - it is expected. The interactive bit is the key thing I was missing. I was not using that in my testing above. So I think the summary is non-interactive works fine? But --debug
does not, which is tracked now by the issue you filed.rhythmic-morning-87313
07/10/2022, 5:36 PM--pants-ignore=bob
resolves the infinite loopenough-analyst-54434
07/10/2022, 5:38 PMrhythmic-morning-87313
07/10/2022, 5:44 PMenough-analyst-54434
07/10/2022, 5:46 PM