From c25451bcfb55a9510d0d0d20fb89df12e309804c Mon Sep 17 00:00:00 2001 From: Eric Scouten Date: Thu, 17 Sep 2026 16:02:50 -0700 Subject: [PATCH] Make test_sdk_version aware of the RC-preflight ref file test_sdk_version compares the loaded native library's version against c2pa-native-version.txt, but an RC-preflight run (per test-c2pa-rs-source-build.yml) actually builds from whatever ref is in c2pa-rs-preflight-ref.txt instead, so the test always failed on that one assertion during a preflight even when everything else passed. parse_native_version() now prefers c2pa-rs-preflight-ref.txt when present, falling back to c2pa-native-version.txt otherwise -- the same precedence the workflow itself uses to decide what to build. Verified both paths locally: green against the pinned 0.90.22 with no preflight file, and green against a c2pa-rc-v0.91.0-rc.3 build with the file present. Co-Authored-By: Claude Sonnet 5 --- tests/test_unit_tests.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/test_unit_tests.py b/tests/test_unit_tests.py index d8eca739..5ab85c91 100644 --- a/tests/test_unit_tests.py +++ b/tests/test_unit_tests.py @@ -76,16 +76,25 @@ def load_test_settings_json(): def parse_native_version(): """ - Parse the expected native SDK version from c2pa-native-version.txt. + Parse the expected native SDK version. + + Prefers c2pa-rs-preflight-ref.txt when present: that's the same file + test-c2pa-rs-source-build.yml reads to decide which c2pa-rs ref to build + from for an RC preflight (see that workflow's header comment), so the + native library actually loaded during such a run was built from that + ref, not from c2pa-native-version.txt. Falls back to + c2pa-native-version.txt otherwise. Returns: str: The semantic version string (e.g. "0.85.2"). """ repo_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + preflight_path = os.path.join(repo_root, 'c2pa-rs-preflight-ref.txt') version_path = os.path.join(repo_root, 'c2pa-native-version.txt') - with open(version_path, 'r') as f: + path = preflight_path if os.path.isfile(preflight_path) else version_path + with open(path, 'r') as f: raw = f.read().strip() - # Strip the "c2pa-v" prefix to get the bare semantic version. + # Strip the "c2pa-v" / "c2pa-rc-v" prefix to get the bare semantic version. return raw.split('v', 1)[1] if 'v' in raw else raw