This is an automated email from the ASF dual-hosted git repository.

juergbi pushed a commit to branch jbilleter/recc
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit ffaa0b26f8f74ff1401bdd5c297a4aade7e930c0
Author: Jürg Billeter <[email protected]>
AuthorDate: Fri Sep 5 10:41:04 2025 +0200

    tests/integration/recc.py: Add recc cache-only test
---
 .../project/elements/recc/cacheonly.bst            |  29 ++++++
 tests/integration/recc.py                          | 113 +++++++++++++++++++++
 2 files changed, 142 insertions(+)

diff --git a/tests/integration/project/elements/recc/cacheonly.bst 
b/tests/integration/project/elements/recc/cacheonly.bst
new file mode 100644
index 000000000..5de70248c
--- /dev/null
+++ b/tests/integration/project/elements/recc/cacheonly.bst
@@ -0,0 +1,29 @@
+kind: autotools
+description: recc test with autotools
+
+build-depends:
+- filename: base/base-debian.bst
+  config:
+    digest-environment: RECC_REMOTE_PLATFORM_chrootRootDigest
+- recc/recc.bst
+
+sources:
+- kind: tar
+  url: project_dir:/files/amhello.tar.gz
+  ref: 534a884bc1974ffc539a9c215e35c4217b6f666a134cd729e786b9c84af99650
+
+sandbox:
+  remote-apis-socket:
+    path: /tmp/casd.sock
+    action-cache-enable-update: true
+
+environment:
+  CC: recc gcc
+  RECC_LOG_LEVEL: debug
+  RECC_LOG_DIRECTORY: .recc-log
+  RECC_DEPS_GLOBAL_PATHS: 1
+  RECC_NO_PATH_REWRITE: 1
+  RECC_LINK: 1
+  RECC_CACHE_ONLY: 1
+  RECC_CACHE_UPLOAD_LOCAL_BUILD: 1
+  RECC_SERVER: unix:/tmp/casd.sock
diff --git a/tests/integration/recc.py b/tests/integration/recc.py
index c43ece5b6..f1e9e2ba5 100644
--- a/tests/integration/recc.py
+++ b/tests/integration/recc.py
@@ -140,3 +140,116 @@ def test_remote_execution(cli, datafiles):
 
     # Verify recc is getting action cache hits for both, compiling and linking
     assert recc_log.count("Action Cache hit") == 2
+
+
[email protected](not HAVE_SANDBOX, reason="Only available with a 
functioning sandbox")
[email protected](DATA_DIR)
+def test_cache_only(cli, datafiles):
+    project = str(datafiles)
+    checkout1 = os.path.join(cli.directory, "checkout1")
+    checkout2 = os.path.join(cli.directory, "checkout2")
+    element_name = "recc/cacheonly.bst"
+
+    # Always cache buildtrees to be able to check recc logs
+    result = cli.run(project=project, args=["--cache-buildtrees", "always", 
"build", element_name])
+    if result.exit_code != 0:
+        # Output recc logs in case of failure
+        cli.run(
+            project=project,
+            args=[
+                "shell",
+                "--build",
+                "--use-buildtree",
+                element_name,
+                "--",
+                "sh",
+                "-c",
+                "cat config.log .recc-log/* */.recc-log/*",
+            ],
+        )
+    assert result.exit_code == 0
+
+    result = cli.run(project=project, args=["artifact", "checkout", 
element_name, "--directory", checkout1])
+    assert result.exit_code == 0
+
+    assert_contains(
+        checkout1,
+        [
+            "/usr",
+            "/usr/bin",
+            "/usr/share",
+            "/usr/bin/hello",
+            "/usr/share/doc",
+            "/usr/share/doc/amhello",
+            "/usr/share/doc/amhello/README",
+        ],
+    )
+
+    # Check the main build log
+    result = cli.run(project=project, args=["artifact", "log", element_name])
+    assert result.exit_code == 0
+    log = result.output
+
+    # Verify we get expected output exactly once
+    assert log.count("Making all in src") == 1
+
+    result = cli.run(
+        project=project,
+        args=[
+            "shell",
+            "--build",
+            "--use-buildtree",
+            element_name,
+            "--",
+            "sh",
+            "-c",
+            "cat src/.recc-log/recc.buildbox*",
+        ],
+    )
+    assert result.exit_code == 0
+    recc_log = result.output
+
+    # Verify recc is using local execution for both, compiling and linking
+    assert recc_log.count("Action not cached and running in cache-only mode, 
executing locally") == 2
+
+    # Delete artifact from BuildStream cache to trigger a BuildStream rebuild 
with action cache hits for recc
+    result = cli.run(project=project, args=["artifact", "delete", 
element_name])
+    assert result.exit_code == 0
+
+    result = cli.run(project=project, args=["--cache-buildtrees", "always", 
"build", element_name])
+    assert result.exit_code == 0
+
+    result = cli.run(project=project, args=["artifact", "checkout", 
element_name, "--directory", checkout2])
+    assert result.exit_code == 0
+
+    assert_contains(
+        checkout2,
+        [
+            "/usr",
+            "/usr/bin",
+            "/usr/share",
+            "/usr/bin/hello",
+            "/usr/share/doc",
+            "/usr/share/doc/amhello",
+            "/usr/share/doc/amhello/README",
+        ],
+    )
+
+    result = cli.run(
+        project=project,
+        args=[
+            "shell",
+            "--build",
+            "--use-buildtree",
+            element_name,
+            "--",
+            "sh",
+            "-c",
+            "cat src/.recc-log/recc.buildbox*",
+        ],
+    )
+    assert result.exit_code == 0
+    recc_log = result.output
+
+    # Verify recc is getting action cache hits for both, compiling and linking
+    assert recc_log.count("Action Cache hit") == 2

Reply via email to