def test_accepts_single_file_snapshot(self): input_files_content = InputFilesContent( (FileContent(path="subdir/a.txt", content=b"test file contents"),) ) snapshot = self.request_single_product(Snapshot, input_files_content) assert SingleFileExecutable(snapshot).exe_filename == "./subdir/a.txt" input_files_content = InputFilesContent( (FileContent(path="some_silly_file_name", content=b"test file contents"),) ) snapshot = self.request_single_product(Snapshot, input_files_content) assert SingleFileExecutable(snapshot).exe_filename == "./some_silly_file_name"
def test_raises_empty_digest(self): snapshot = Snapshot(EMPTY_DIRECTORY_DIGEST, files=('a.txt',), dirs=()) with self.assertRaisesWithMessage( SingleFileExecutable.ValidationError, f'snapshot {snapshot} used for {SingleFileExecutable} should have a non-empty digest!'): SingleFileExecutable(snapshot)
def test_raises_with_multiple_files(self): input_files_content = InputFilesContent(( FileContent(path='a.txt', content=b'test file contents'), FileContent(path='b.txt', content=b'more test file contents'), )) snapshot = self.request_single_product(Snapshot, input_files_content) with self.assertRaisesWithMessage( SingleFileExecutable.ValidationError, f'snapshot {snapshot} used for {SingleFileExecutable} should have exactly 1 file!'): SingleFileExecutable(snapshot)
async def download_cloc_script(cloc_binary_tool: ClocBinary) -> DownloadedClocScript: snapshot = await Get[Snapshot](BinaryToolFetchRequest(cloc_binary_tool)) return DownloadedClocScript(SingleFileExecutable(snapshot))
async def download_cloc_script() -> DownloadedClocScript: url = "https://binaries.pantsbuild.org/bin/cloc/1.80/cloc" sha_256 = "2b23012b1c3c53bd6b9dd43cd6aa75715eed4feb2cb6db56ac3fbbd2dffeac9d" digest = Digest(sha_256, 546279) snapshot = await Get[Snapshot](UrlToFetch(url, digest)) return DownloadedClocScript(SingleFileExecutable(snapshot))
async def download_pex_bin( pex_binary_tool: DownloadedPexBin.Factory) -> DownloadedPexBin: snapshot = await Get[Snapshot](BinaryToolFetchRequest(pex_binary_tool)) return DownloadedPexBin(SingleFileExecutable(snapshot))
async def download_pex_bin() -> DownloadedPexBin: # TODO: Inject versions and digests here through some option, rather than hard-coding it. url = 'https://github.com/pantsbuild/pex/releases/download/v1.6.12/pex' digest = Digest('ce64cb72cd23d2123dd48126af54ccf2b718d9ecb98c2ed3045ed1802e89e7e1', 1842359) snapshot = await Get[Snapshot](UrlToFetch(url, digest)) return DownloadedPexBin(SingleFileExecutable(snapshot))