hundreds-father-404
11/22/2019, 8:22 PMDigest with the engine but not have it be created in the test build root? I’m rewriting fmt-v2 to use Workspace and want to test that fmt-v2 properly converts a FmtResult.digest into workspace.materialize_directories() . However, my test setup doesn’t work properly because when I call self.scheduler.product_request(Digest, [InputFilesContent(..)] in the test setup,  the digest gets materialized into the build root prematurely
https://github.com/pantsbuild/pants/pull/8691/files#diff-beb17e333eb84b51667078f6c4785f16R40
Is there a way for that Digest to instead be created in a temporary directory?aloof-angle-91616
11/22/2019, 8:23 PMmaterialize_directories i thought was supposed to take a root dir param? if not i might hack it to do that just for testing, just a thought. back to keyboard in a fewhundreds-father-404
11/22/2019, 8:24 PMfmt.py  to use path='./' (for context, binary.py uses path='dist/')witty-crayon-22786
11/22/2019, 8:32 PMFilesContenthundreds-father-404
11/22/2019, 8:33 PMInputFilesContent as the subject type?witty-crayon-22786
11/22/2019, 8:33 PMInputFilesContent .witty-crayon-22786
11/22/2019, 8:33 PMwitty-crayon-22786
11/22/2019, 8:34 PMhundreds-breakfast-49010
11/22/2019, 8:35 PMhundreds-breakfast-49010
11/22/2019, 8:35 PMhundreds-breakfast-49010
11/22/2019, 8:37 PMwitty-crayon-22786
11/22/2019, 8:37 PMwitty-crayon-22786
11/22/2019, 8:37 PMInputFilesContent puts it directly into the database, and then gives you a Digest for it.hundreds-father-404
11/22/2019, 8:38 PMthat’s what that doesWhat what does?
InputFilesContent -> Digest  writes to disk, which I do not want, and FilesContent -> Digest isn’t registeredwitty-crayon-22786
11/22/2019, 8:38 PMwitty-crayon-22786
11/22/2019, 8:38 PMwitty-crayon-22786
11/22/2019, 8:38 PMwitty-crayon-22786
11/22/2019, 8:39 PMwitty-crayon-22786
11/22/2019, 8:39 PMwitty-crayon-22786
11/22/2019, 8:39 PM__init__.py  fileshundreds-breakfast-49010
11/22/2019, 8:40 PMworkspace_console_rule test in fs_test.py  may be what you wantwitty-crayon-22786
11/22/2019, 8:40 PMwitty-crayon-22786
11/22/2019, 8:41 PMwitty-crayon-22786
11/22/2019, 8:41 PMwitty-crayon-22786
11/22/2019, 8:41 PMwitty-crayon-22786
11/22/2019, 8:42 PMInputFilesContent  ?hundreds-father-404
11/22/2019, 8:44 PMhundreds-father-404
11/22/2019, 8:44 PM./pants clean-all and then ./pants test src/python/pants/rules/core:tests -- -k test_non_union_member_noops works, but then it fails to run ./pants test src/python/pants/rules/core:tests -- -k FmtTest. I think this is because the other two tests are writing to the workdir and not cleaning up after themselveswitty-crayon-22786
11/22/2019, 8:44 PMwitty-crayon-22786
11/22/2019, 8:46 PMhundreds-breakfast-49010
11/22/2019, 8:46 PMhundreds-breakfast-49010
11/22/2019, 8:46 PMhundreds-breakfast-49010
11/22/2019, 8:46 PMhundreds-father-404
11/22/2019, 8:46 PMoh. wait, are you using the Workspace in this test...?Yes, the rule requires a
Workspace arg so I’m passing it Workspace(self.scheduler)hundreds-breakfast-49010
11/22/2019, 8:47 PMhundreds-breakfast-49010
11/22/2019, 8:47 PMhundreds-breakfast-49010
11/22/2019, 8:47 PMwitty-crayon-22786
11/22/2019, 8:47 PMself.scheduler in a TestBase test should have an "anonymous" buildroothundreds-breakfast-49010
11/22/2019, 8:47 PMwitty-crayon-22786
11/22/2019, 8:48 PMWorkspace  should either take a buildroot arg, or get it from the scheduler.hundreds-father-404
11/22/2019, 8:48 PMbut Workspace, right now, should actually be writing something to disk, that’s what it’s forAgreed, and it’s important that the tests confirm we are actually writing to disk. But somehow we do need to isolate each individual unit test. Hm
witty-crayon-22786
11/22/2019, 8:48 PMget_buildroot  is insidiouswitty-crayon-22786
11/22/2019, 8:49 PMwitty-crayon-22786
11/22/2019, 8:49 PMwitty-crayon-22786
11/22/2019, 8:50 PMwitty-crayon-22786
11/22/2019, 8:50 PMself.scheduler  should have an anonymous buildroot.hundreds-father-404
11/22/2019, 8:51 PM@memoized_method
  def _build_root(self):
    return os.path.realpath(mkdtemp(suffix='_BUILD_ROOT'))witty-crayon-22786
11/22/2019, 8:51 PMwitty-crayon-22786
11/22/2019, 8:53 PMWorkspace absolute paths...?witty-crayon-22786
11/22/2019, 8:53 PMDirectoryToMaterialize(path="./", directory_digest=result.digest),witty-crayon-22786
11/22/2019, 8:54 PMWorkspace.materialize_directory , and should be ...?witty-crayon-22786
11/22/2019, 8:54 PMwitty-crayon-22786
11/22/2019, 8:54 PM./  will result in "cwd", not the buildroot, unless it is prefixed with the right pathhundreds-father-404
11/22/2019, 8:55 PMpath=dist/ in binary.py  will also use cwdwitty-crayon-22786
11/22/2019, 8:55 PMsrc/python/pants/rules/core/binary.py  a bit brokenwitty-crayon-22786
11/22/2019, 8:55 PMwitty-crayon-22786
11/22/2019, 8:57 PMWorkspace, and we should probably either prefix in Workspace.materialize_directory or deeper in https://github.com/pantsbuild/pants/blob/3896fb088fb979057062615351954df7f12eee1b/src/rust/engine/fs/store/src/lib.rs#L682-L691hundreds-breakfast-49010
11/22/2019, 8:58 PMwitty-crayon-22786
11/22/2019, 8:58 PMwitty-crayon-22786
11/22/2019, 8:58 PMwitty-crayon-22786
11/22/2019, 8:59 PMhundreds-breakfast-49010
11/22/2019, 8:59 PMhundreds-breakfast-49010
11/22/2019, 9:01 PMhundreds-breakfast-49010
11/22/2019, 9:01 PMwitty-crayon-22786
11/22/2019, 9:01 PMhundreds-father-404
11/22/2019, 9:03 PMbuild_root to the TestBase scheduler. https://github.com/pantsbuild/pants/blob/master/src/python/pants/testutil/test_base.py#L388-L396 could take an argument build_root and without it uses get_buildroot()witty-crayon-22786
11/22/2019, 9:08 PMwitty-crayon-22786
11/22/2019, 9:08 PMwitty-crayon-22786
11/22/2019, 9:08 PM--chroot is on by default?hundreds-father-404
11/22/2019, 9:15 PMget_buildroot() , it will still operate outside the true buildroot inside a .pants.d  folder, but not where we want itwitty-crayon-22786
11/22/2019, 9:15 PMhundreds-father-404
11/22/2019, 9:46 PMWorkspace, right? Not for any arbitrary materialize_directories() call?witty-crayon-22786
11/22/2019, 9:54 PMwitty-crayon-22786
11/22/2019, 9:54 PMaloof-angle-91616
11/22/2019, 9:55 PMwitty-crayon-22786
11/22/2019, 9:55 PMhundreds-father-404
11/22/2019, 9:57 PMwitty-crayon-22786
11/22/2019, 9:57 PMwitty-crayon-22786
11/22/2019, 9:57 PMDirectoryToMaterializehundreds-father-404
11/22/2019, 9:58 PMawait in scheduler.materialize_directorieswitty-crayon-22786
11/22/2019, 9:58 PMwitty-crayon-22786
11/22/2019, 9:59 PMwitty-crayon-22786
11/22/2019, 9:59 PMwitty-crayon-22786
11/22/2019, 9:59 PMhundreds-father-404
11/22/2019, 10:01 PMnot pathlib.Path(f).is_absolute() or we have to validte that it’s relative to the build root? That is, can we avoid knowing what the build root is on the Python sidewitty-crayon-22786
11/22/2019, 10:02 PMwitty-crayon-22786
11/22/2019, 10:02 PMwitty-crayon-22786
11/22/2019, 10:02 PMnot is_absolute()  workshundreds-father-404
11/22/2019, 10:02 PMwitty-crayon-22786
11/22/2019, 10:08 PMhundreds-father-404
11/22/2019, 10:09 PMwitty-crayon-22786
11/22/2019, 10:10 PMStore already had a root path, but it doesn't. so not there, i suppose.witty-crayon-22786
11/22/2019, 10:12 PMhundreds-father-404
11/22/2019, 11:04 PM