@@ -438,8 +438,9 @@ def setup_test():
438438 ("%{deps}" , "- import-dev.bst\n - import-links.bst\n - import-bin.bst" ),
439439 ("%{build-deps}" , "- import-dev.bst\n - import-links.bst" ),
440440 ("%{runtime-deps}" , "- import-links.bst\n - import-bin.bst" ),
441+ ("%{artifact-cas-digest}" , "(no artifact CAS digest)" ),
441442 ],
442- ids = ["deps" , "build-deps" , "runtime-deps" ],
443+ ids = ["deps" , "build-deps" , "runtime-deps" , "artifact-cas-digest" ],
443444)
444445def test_format_deps (cli , datafiles , dep_kind , expected_deps ):
445446 project = str (datafiles )
@@ -553,6 +554,64 @@ def test_strict_dependencies(cli, datafiles, target, expected_state):
553554 assert states [target ] == expected_state
554555
555556
557+ # This tests that cache keys behave as expected when
558+ # dependencies have been specified as `strict` and
559+ # when building in strict mode.
560+ #
561+ # This test will:
562+ #
563+ # * Build the target once (and assert that it is cached)
564+ # * Modify some local files which are imported
565+ # by an import element which the target depends on
566+ # * Assert that the cached state of the target element
567+ # is as expected
568+ #
569+ # We run the test twice, once with an element which strict
570+ # depends on the changing import element, and one which
571+ # depends on it regularly.
572+ #
573+ @pytest .mark .datafiles (os .path .join (DATA_DIR , "project" ))
574+ @pytest .mark .parametrize (
575+ "target, expected_digests" ,
576+ [
577+ ("target.bst" , {
578+ "compose-all.bst" : "c742f599e198f348ba7600bf50194ae45af6cba759e0005dcd980ad596c51959/78" ,
579+ "import-bin.bst" : "594334e3e9f15c9eac5b8325befc3f53af8ffbaa664424bb308484abb892944f/77" ,
580+ "import-dev.bst" : "42203f9284db4817a2fc2d57714c6c92ec318f82a23a25e5325852e5dd6effc3/77" ,
581+ "target.bst" : "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855/0" ,
582+ }),
583+ ],
584+ )
585+ def test_format_artifact_cas_digest (cli , datafiles , target , expected_digests ):
586+ project = str (datafiles )
587+ expected_no_digest = "(no artifact CAS digest)"
588+
589+ result = cli .run (project = project , silent = True , args = ["show" , "--format" , "%{name},%{artifact-cas-digest}" , target ])
590+ result .assert_success ()
591+
592+ digests = dict (line .split ("," , 2 ) for line in result .output .splitlines ())
593+
594+ assert len (digests ) == len (expected_digests )
595+ for component , received in sorted (digests .items ()):
596+ expected = expected_no_digest
597+ if received != expected :
598+ raise AssertionError ("Expected output:\n {}\n Instead received output:\n {}" .format (expected , received ))
599+
600+ result = cli .run (project = project , silent = True , args = ["build" , target ])
601+ result .assert_success ()
602+
603+ result = cli .run (project = project , silent = True , args = ["show" , "--format" , "%{name},%{artifact-cas-digest}" , target ])
604+ result .assert_success ()
605+
606+ digests = dict (line .split ("," , 2 ) for line in result .output .splitlines ())
607+
608+ assert len (digests ) == len (expected_digests )
609+ for component , received in sorted (digests .items ()):
610+ expected = expected_digests [component ]
611+ if received != expected :
612+ raise AssertionError ("Expected output:\n {}\n Instead received output:\n {}" .format (expected , received ))
613+
614+
556615@pytest .mark .datafiles (os .path .join (DATA_DIR , "project" ))
557616@pytest .mark .parametrize ("fatal" , [True , False ], ids = ["fatal" , "non-fatal" ])
558617def test_unaliased_url (cli , tmpdir , datafiles , fatal ):
0 commit comments