Skip to content

Commit 79ac919

Browse files
authored
Merge pull request #2010 from apache/tristan/show-cas-digest-tests
tests/frontend/show_artifact_cas_digest.py: Simplification / correction of dependencies test
2 parents 4e1404b + 884f6a5 commit 79ac919

File tree

2 files changed

+8
-30
lines changed

2 files changed

+8
-30
lines changed

tests/frontend/show_artifact_cas_digest.py

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ def test_show_artifact_cas_digest_cached(cli, tmpdir, datafiles, target, expecte
9999
assert received_digest == "{target},{digest}".format(target=target, digest=expected_digest)
100100

101101

102-
# This tests that the target and its dependencies are built
103-
# as expected and that all their artifact CAS digests are
104-
# available.
102+
# This tests that an import element which produces the same content
103+
# as it's dependency, has the same CAS digest as the dependency.
105104
#
106-
# The test is performed without a remote cache.
105+
# This is tested to ensure that we are indeed producing the content hash
106+
# of the files portion of the artifact, and that they are indeed a match.
107107
#
108108
@pytest.mark.datafiles(DATA_DIR)
109109
@pytest.mark.parametrize(
@@ -112,44 +112,22 @@ def test_show_artifact_cas_digest_cached(cli, tmpdir, datafiles, target, expecte
112112
(
113113
"dependencies.bst",
114114
{
115+
# Note that these expect exactly the same cas digest !
115116
"dependencies.bst": "7093d3c89029932ce1518bd2192e1d3cf60fd88e356b39195d10b87b598c78f0/168",
116-
"import-symlinks.bst": "95947ea55021e26cec4fd4f9de90d2b7f4f7d803ccc91656b3e1f2c9923ddf19/131",
117+
"import-basic-files.bst": "7093d3c89029932ce1518bd2192e1d3cf60fd88e356b39195d10b87b598c78f0/168",
117118
},
118119
),
119120
],
120121
ids=["dependencies"],
121122
)
122123
def test_show_artifact_cas_digest_dependencies(cli, tmpdir, datafiles, target, expected_digests):
123124
project = str(datafiles)
124-
expected_no_digest = ""
125-
126-
# Check the target and its dependencies have not been built locally
127-
for component in sorted(expected_digests.keys()):
128-
assert (
129-
# May be "buildable" or "waiting" but shouldn't be "cached"
130-
cli.get_element_state(project, component)
131-
!= "cached"
132-
)
133-
134-
# Check the target and its dependencies have no artifact digest
135-
result = cli.run(project=project, silent=True, args=["show", "--format", "%{name},%{artifact-cas-digest}", target])
136-
result.assert_success()
137-
138-
digests = dict(line.split(",", 2) for line in result.output.splitlines())
139-
assert len(digests) == len(expected_digests)
140-
141-
for component, received in sorted(digests.items()):
142-
assert received == expected_no_digest
143125

144126
# Build the target and its dependencies locally
145127
result = cli.run(project=project, silent=True, args=["build", target])
146128
result.assert_success()
147129

148-
# Check the target and its dependencies have been built locally
149-
for component in sorted(expected_digests.keys()):
150-
assert cli.get_element_state(project, component) == "cached"
151-
152-
# Check the target and its dependencies have an artifact digest
130+
# Check the target and its dependencies have the same CAS digest
153131
result = cli.run(project=project, silent=True, args=["show", "--format", "%{name},%{artifact-cas-digest}", target])
154132
result.assert_success()
155133

tests/frontend/show_artifact_cas_digest_project/elements/dependencies.bst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ sources:
33
- kind: local
44
path: files/basic-files
55
depends:
6-
- import-symlinks.bst
6+
- import-basic-files.bst

0 commit comments

Comments
 (0)