mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-18 22:16:18 -05:00
ci: identify overdue Rust tests and last running target by hash
This commit is contained in:
2 files changed
+43
No files matched your search
@@ -34,6 +34,17 @@ def report_tests(output):
|
||||
for name, line, column in panics}
|
||||
for fingerprint, line, column in sorted(locations):
|
||||
print(f'::error::Rust test panic location: {fingerprint} {line}:{column}')
|
||||
overdue = set(re.findall(r'^test (.+?) has been running for over 60 seconds\r?$',
|
||||
output, re.MULTILINE))
|
||||
for fingerprint in sorted(hashlib.sha256(name.encode()).hexdigest() for name in overdue):
|
||||
print(f'::error::Rust overdue test fingerprint: {fingerprint}')
|
||||
running = re.findall(r'^\s+Running (.+?) \(([^\r\n]+)\)\r?$', output, re.MULTILINE)
|
||||
if running:
|
||||
source, executable = running[-1]
|
||||
basename = re.sub(r'-[0-9a-f]{16}$', '', Path(executable).name)
|
||||
identity = f'{" ".join(source.split())} ({basename})'
|
||||
fingerprint = hashlib.sha256(identity.encode()).hexdigest()
|
||||
print(f'::error::Rust last running target fingerprint: {fingerprint}')
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -254,6 +254,38 @@ class PrivateTestStageTests(unittest.TestCase):
|
||||
f'::error::Rust test panic location: {digest} 321:9\n')
|
||||
self.assertEqual(result.stderr, '')
|
||||
|
||||
def test_overdue_diagnostics_hash_names_without_exposing_messages(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
log = Path(temporary) / 'private.log'
|
||||
log.write_text('test private::slow has been running for over 60 seconds\n'
|
||||
'PRIVATE_SOURCE_PATH: PRIVATE_PAYLOAD\n'
|
||||
'test private::slow has been running for over 60 seconds\n')
|
||||
result = subprocess.run([sys.executable, str(ROOT / 'scripts/private-ci-diagnostics.py'),
|
||||
'tests', str(log)], capture_output=True, text=True)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
digest = hashlib.sha256(b'private::slow').hexdigest()
|
||||
self.assertEqual(result.stdout, f'::error::Rust overdue test fingerprint: {digest}\n')
|
||||
self.assertEqual(result.stderr, '')
|
||||
|
||||
def test_last_running_target_hash_is_stable_without_paths_or_build_hashes(self):
|
||||
for source, basename in [('unittests src/lib.rs', 'private_crate'),
|
||||
('tests/PRIVATE_HARNESS.rs', 'private_harness')]:
|
||||
for prefix, build_hash in [('/PRIVATE_SOURCE_ONE', '0123456789abcdef'),
|
||||
('/PRIVATE_SOURCE_TWO', 'fedcba9876543210')]:
|
||||
with self.subTest(source=source, prefix=prefix), tempfile.TemporaryDirectory() as temporary:
|
||||
log = Path(temporary) / 'private.log'
|
||||
log.write_text(' Running tests/previous.rs (/PRIVATE_SOURCE/previous-1111111111111111)\n'
|
||||
f' Running {source} ({prefix}/target/debug/deps/{basename}-{build_hash})\n'
|
||||
'PRIVATE_PAYLOAD\n')
|
||||
result = subprocess.run([sys.executable, str(ROOT / 'scripts/private-ci-diagnostics.py'),
|
||||
'tests', str(log)], capture_output=True, text=True)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
identity = f'{source} ({basename})'
|
||||
digest = hashlib.sha256(identity.encode()).hexdigest()
|
||||
self.assertEqual(result.stdout,
|
||||
f'::error::Rust last running target fingerprint: {digest}\n')
|
||||
self.assertEqual(result.stderr, '')
|
||||
|
||||
|
||||
class MacOSArtifactSelectionTests(unittest.TestCase):
|
||||
def select(self, jobs, artifacts=None):
|
||||
|
||||
Reference in new issue
Block a user