Skip to content

Commit

Permalink
[Chrome Stdlib] Move .sha256 files to separate directory from test data
Browse files Browse the repository at this point in the history
We need to move the .sha256 files to a separate directory to the actual
test data. This is because Cog does not support contents of a directory
coming from multiple sources i.e. both Git and GCS. So we need a
separate directory for files coming from GCS from the files coming from
Git.

Change-Id: I16fee14405a2b4faee842e01dd1e94ed2ccf0eec
Bug: 312895063
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5582049
Reviewed-by: Josip Sokcevic <[email protected]>
Commit-Queue: Rasika Navarange <[email protected]>
Reviewed-by: Andrew Grieve <[email protected]>
Reviewed-by: Stephen Nusko <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1308600}
  • Loading branch information
Rasika Navarange authored and Chromium LUCI CQ committed May 31, 2024
1 parent 87c1b30 commit 08e5421
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 15 deletions.
7 changes: 4 additions & 3 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -3386,7 +3386,7 @@ def CheckForNewDEPSDownloadFromGoogleStorageHooks(input_api, output_api):

def CheckEachPerfettoTestDataFileHasDepsEntry(input_api, output_api):
test_data_filter = lambda f: input_api.FilterSourceFile(
f, files_to_check=[r'^base/tracing/test/data/.*\.sha256'])
f, files_to_check=[r'^base/tracing/test/data_sha256/.*\.sha256'])
if not any(input_api.AffectedFiles(file_filter=test_data_filter)):
return []

Expand All @@ -3397,9 +3397,10 @@ def CheckEachPerfettoTestDataFileHasDepsEntry(input_api, output_api):
new_deps = _ParseDeps('\n'.join(f.NewContents()))['deps']
deps_entry = new_deps['src/base/tracing/test/data']
if not deps_entry:
return [output_api.PresubmitError(
# TODO(312895063):Add back error when .sha256 files have been moved.
return [output_api.PresubmitNotifyResult(
'You must update the DEPS file when you update a '
'.sha256 file in base/tracing/test/data'
'.sha256 file in base/tracing/test/data_sha256'
)]

output = []
Expand Down
12 changes: 6 additions & 6 deletions PRESUBMIT_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,12 @@ class CheckEachPerfettoTestDataFileHasDepsEntry(unittest.TestCase):
def testNewSha256FileNoDEPS(self):
input_api = MockInputApi()
input_api.files = [
MockFile('base/tracing/test/data/new.pftrace.sha256', []),
MockFile('base/tracing/test/data_sha256/new.pftrace.sha256', []),
]
results = PRESUBMIT.CheckEachPerfettoTestDataFileHasDepsEntry(input_api, MockOutputApi())
self.assertEqual(
('You must update the DEPS file when you update a .sha256 file '
'in base/tracing/test/data'), results[0].message)
'in base/tracing/test/data_sha256'), results[0].message)

def testNewSha256FileSuccess(self):
input_api = MockInputApi()
Expand All @@ -256,7 +256,7 @@ def testNewSha256FileSuccess(self):
},
}""".splitlines()
input_api.files = [
MockFile('base/tracing/test/data/new.pftrace.sha256', ['a1b2c3f4']),
MockFile('base/tracing/test/data_sha256/new.pftrace.sha256', ['a1b2c3f4']),
MockFile('DEPS', new_deps),
]
results = PRESUBMIT.CheckEachPerfettoTestDataFileHasDepsEntry(input_api, MockOutputApi())
Expand All @@ -279,7 +279,7 @@ def testNewSha256FileWrongSha256(self):
'dep_type': 'gcs'
},
}""".splitlines()
f = MockFile('base/tracing/test/data/new.pftrace.sha256', ['a1b2c3f4'])
f = MockFile('base/tracing/test/data_sha256/new.pftrace.sha256', ['a1b2c3f4'])
input_api.files = [
f,
MockFile('DEPS', new_deps),
Expand Down Expand Up @@ -308,7 +308,7 @@ def testDeleteSha256File(self):
'dep_type': 'gcs'
},
}""".splitlines()
f = MockFile('base/tracing/test/data/new.pftrace.sha256', [], ['a1b2c3f4'], action='D')
f = MockFile('base/tracing/test/data_sha256/new.pftrace.sha256', [], ['a1b2c3f4'], action='D')
input_api.files = [
f,
MockFile('DEPS', old_deps),
Expand Down Expand Up @@ -342,7 +342,7 @@ def testDeleteSha256Success(self):
'dep_type': 'gcs'
},
}""".splitlines()
f = MockFile('base/tracing/test/data/new.pftrace.sha256', [], ['a1b2c3f4'], action='D')
f = MockFile('base/tracing/test/data_sha256/new.pftrace.sha256', [], ['a1b2c3f4'], action='D')
input_api.files = [
f,
MockFile('DEPS', new_deps, old_deps),
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
70f5511ba0cd6ce1359e3cadb4d1d9301fb6e26be85158e3384b06f41418d386
70f5511ba0cd6ce1359e3cadb4d1d9301fb6e26be85158e3384b06f41418d386
16 changes: 11 additions & 5 deletions base/tracing/test/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@
from download_from_google_storage import Gsutil, GSUTIL_DEFAULT_PATH


# Write .sha256 file to be rolled into Perfetto.
# Write .sha256 file to test/data_sha256 to be rolled into Perfetto.
def write_sha256_file(filepath: str):
sha256sum = get_sha256sum(filepath)
with open(filepath + '.sha256', 'w') as sha_file:
sha256_filepath = os.path.abspath(os.path.join(
os.path.dirname(filepath),
'..',
'data_sha256',
os.path.basename(filepath) + '.sha256'))
with open(sha256_filepath, 'w') as sha_file:
sha_file.write(sha256sum)
return sha256sum

Expand Down Expand Up @@ -107,11 +112,12 @@ def generate_deps_entry(filepath: str):

# Generate the full deps entry for Perfetto test data
def generate_all_deps():
path = os.path.join(SRC_PATH, 'base/tracing/test/data')
sha256_path = os.path.join(SRC_PATH, 'base/tracing/test/data_sha256')
data_path = os.path.join(SRC_PATH, 'base/tracing/test/data')
objects = []
for file in os.listdir(path):
for file in os.listdir(sha256_path):
if file.endswith('.sha256'):
filepath = os.path.join(path, file)[:-7]
filepath = os.path.join(data_path, file)[:-7]
assert os.path.isfile(filepath), 'File does not exist'
object_entry = generate_deps_entry(filepath)
objects.append(object_entry)
Expand Down

0 comments on commit 08e5421

Please sign in to comment.