Skip to content

Conversation

@hnrklssn
Copy link
Member

@hnrklssn hnrklssn commented Nov 6, 2025

With this change DiffUpdater can update expected files even if both files are created by split-files, if one of them ends with ".expected". This is useful when a file is created and then modified during the test.

With this change DiffUpdater can update expected files even if both
files are created by split-files, if one of them ends with ".expected".
This is useful when a file is created and then modified during the test.
@llvmbot
Copy link
Member

llvmbot commented Nov 6, 2025

@llvm/pr-subscribers-testing-tools

Author: Henrik G. Olsson (hnrklssn)

Changes

With this change DiffUpdater can update expected files even if both files are created by split-files, if one of them ends with ".expected". This is useful when a file is created and then modified during the test.


Full diff: https://github.com/llvm/llvm-project/pull/166679.diff

5 Files Affected:

  • (modified) llvm/utils/lit/lit/DiffUpdater.py (+13-8)
  • (modified) llvm/utils/lit/tests/Inputs/diff-test-update/.gitignore (+1)
  • (renamed) llvm/utils/lit/tests/Inputs/diff-test-update/split-both.in (+1-3)
  • (added) llvm/utils/lit/tests/Inputs/diff-test-update/split-both.out (+9)
  • (modified) llvm/utils/lit/tests/diff-test-update.py (+2-1)
diff --git a/llvm/utils/lit/lit/DiffUpdater.py b/llvm/utils/lit/lit/DiffUpdater.py
index a29c46fb8508f..9e75e4b4513df 100644
--- a/llvm/utils/lit/lit/DiffUpdater.py
+++ b/llvm/utils/lit/lit/DiffUpdater.py
@@ -117,27 +117,32 @@ def get_source_and_target(a, b, test_path, commands):
     Try to figure out which file is the test output and which is the reference.
     """
     split_target_dir = SplitFileTarget.get_target_dir(commands, test_path)
+    a_target = None
+    b_target = None
     if split_target_dir:
         a_target = SplitFileTarget.create(a, commands, test_path, split_target_dir)
         b_target = SplitFileTarget.create(b, commands, test_path, split_target_dir)
-        if a_target and b_target:
-            return None
-        if a_target:
+        if a_target and not b_target:
             return b, a_target
-        if b_target:
+        if b_target and not a_target:
             return a, b_target
 
+    if not a_target:
+        a_target = NormalFileTarget(a)
+    if not b_target:
+        b_target = NormalFileTarget(b)
+
     expected_suffix = ".expected"
     if a.endswith(expected_suffix) and not b.endswith(expected_suffix):
-        return b, NormalFileTarget(a)
+        return b, a_target
     if b.endswith(expected_suffix) and not a.endswith(expected_suffix):
-        return a, NormalFileTarget(b)
+        return a, b_target
 
     tmp_substr = ".tmp"
     if tmp_substr in a and not tmp_substr in b:
-        return a, NormalFileTarget(b)
+        return a, b_target
     if tmp_substr in b and not tmp_substr in a:
-        return b, NormalFileTarget(a)
+        return b, a_target
 
     return None
 
diff --git a/llvm/utils/lit/tests/Inputs/diff-test-update/.gitignore b/llvm/utils/lit/tests/Inputs/diff-test-update/.gitignore
index aea8ee3be4982..5a7c177454546 100644
--- a/llvm/utils/lit/tests/Inputs/diff-test-update/.gitignore
+++ b/llvm/utils/lit/tests/Inputs/diff-test-update/.gitignore
@@ -8,3 +8,4 @@ multiple-split-file-populated.test
 single-split-file-no-expected.test
 split-c-comments.test
 split whitespace.test
+split-both.test
diff --git a/llvm/utils/lit/tests/Inputs/diff-test-update/split-both.test b/llvm/utils/lit/tests/Inputs/diff-test-update/split-both.in
similarity index 56%
rename from llvm/utils/lit/tests/Inputs/diff-test-update/split-both.test
rename to llvm/utils/lit/tests/Inputs/diff-test-update/split-both.in
index f564f446cc94b..df767f704f1c1 100644
--- a/llvm/utils/lit/tests/Inputs/diff-test-update/split-both.test
+++ b/llvm/utils/lit/tests/Inputs/diff-test-update/split-both.in
@@ -1,9 +1,7 @@
 # RUN: split-file %s %t
+# RUN: echo baz > %t/split-both.out
 # RUN: diff %t/split-both.expected %t/split-both.out
 
-# ignore the fact that it's called ".expected"
-# when comparing two files originating in split-file
-
 #--- split-both.expected
 FOO
 #--- split-both.out
diff --git a/llvm/utils/lit/tests/Inputs/diff-test-update/split-both.out b/llvm/utils/lit/tests/Inputs/diff-test-update/split-both.out
new file mode 100644
index 0000000000000..a2f74d4db3fee
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/diff-test-update/split-both.out
@@ -0,0 +1,9 @@
+# RUN: split-file %s %t
+# RUN: echo baz > %t/split-both.out
+# RUN: diff %t/split-both.expected %t/split-both.out
+
+#--- split-both.expected
+baz
+#--- split-both.out
+BAR
+
diff --git a/llvm/utils/lit/tests/diff-test-update.py b/llvm/utils/lit/tests/diff-test-update.py
index 8b9f4610f7f95..e23d3879bb56c 100644
--- a/llvm/utils/lit/tests/diff-test-update.py
+++ b/llvm/utils/lit/tests/diff-test-update.py
@@ -5,6 +5,7 @@
 # RUN: cp %S/Inputs/diff-test-update/single-split-file-no-expected.in %S/Inputs/diff-test-update/single-split-file-no-expected.test
 # RUN: cp %S/Inputs/diff-test-update/split-c-comments.in %S/Inputs/diff-test-update/split-c-comments.test
 # RUN: cp %S/Inputs/diff-test-update/split-whitespace.in "%S/Inputs/diff-test-update/split whitespace.test"
+# RUN: cp %S/Inputs/diff-test-update/split-both.in %S/Inputs/diff-test-update/split-both.test
 
 # RUN: not %{lit} --update-tests -v %S/Inputs/diff-test-update | FileCheck %s
 
@@ -15,6 +16,7 @@
 # RUN: diff --strip-trailing-cr %S/Inputs/diff-test-update/single-split-file-no-expected.out %S/Inputs/diff-test-update/single-split-file-no-expected.test
 # RUN: diff --strip-trailing-cr %S/Inputs/diff-test-update/split-c-comments.out %S/Inputs/diff-test-update/split-c-comments.test
 # RUN: diff --strip-trailing-cr %S/Inputs/diff-test-update/split-whitespace.out "%S/Inputs/diff-test-update/split whitespace.test"
+# RUN: diff --strip-trailing-cr %S/Inputs/diff-test-update/split-both.out %S/Inputs/diff-test-update/split-both.test
 
 
 # CHECK: # update-diff-test: could not deduce source and target from {{.*}}1.in and {{.*}}2.in
@@ -22,7 +24,6 @@
 # CHECK: # update-diff-test: copied {{.*}}my-file.txt to {{.*}}my-file.expected
 # CHECK: # update-diff-test: copied {{.*}}1.txt to {{.*}}empty.txt
 # CHECK: # update-diff-test: copied {{.*}}diff-tmp.test.tmp.txt to {{.*}}diff-t-out.txt
-# CHECK: # update-diff-test: could not deduce source and target from {{.*}}split-both.expected and {{.*}}split-both.out
 # CHECK: # update-diff-test: copied {{.*}}unrelated-split.txt to {{.*}}unrelated-split.expected
 
 

@hnrklssn
Copy link
Member Author

ping

@hnrklssn hnrklssn merged commit 83118de into llvm:main Nov 13, 2025
13 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 13, 2025

LLVM Buildbot has detected a new failure on builder lldb-aarch64-ubuntu running on linaro-lldb-aarch64-ubuntu while building llvm at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/27264

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: commands/platform/basic/TestPlatformPython.py (193 of 2381)
PASS: lldb-api :: commands/platform/basic/TestPlatformCommand.py (194 of 2381)
PASS: lldb-api :: commands/platform/file/close/TestPlatformFileClose.py (195 of 2381)
PASS: lldb-api :: commands/platform/file/read/TestPlatformFileRead.py (196 of 2381)
PASS: lldb-api :: commands/memory/read/TestMemoryRead.py (197 of 2381)
PASS: lldb-api :: commands/platform/connect/TestPlatformConnect.py (198 of 2381)
PASS: lldb-api :: commands/platform/process/launch/TestPlatformProcessLaunch.py (199 of 2381)
UNSUPPORTED: lldb-api :: commands/platform/sdk/TestPlatformSDK.py (200 of 2381)
PASS: lldb-api :: commands/plugin/TestPlugin.py (201 of 2381)
UNRESOLVED: lldb-api :: commands/gui/spawn-threads/TestGuiSpawnThreads.py (202 of 2381)
******************** TEST 'lldb-api :: commands/gui/spawn-threads/TestGuiSpawnThreads.py' FAILED ********************
Script:
--
/usr/bin/python3.10 /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --arch aarch64 --build-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --cmake-build-type Release /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/commands/gui/spawn-threads -p TestGuiSpawnThreads.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 22.0.0git (https://github.com/llvm/llvm-project.git revision 83118de7223867da39aa997c5d6d0cda4d185dd1)
  clang revision 83118de7223867da39aa997c5d6d0cda4d185dd1
  llvm revision 83118de7223867da39aa997c5d6d0cda4d185dd1
Skipping the following test categories: ['libc++', 'msvcstl', 'dsym', 'pdb', 'gmodules', 'debugserver', 'objc']

--
Command Output (stderr):
--
FAIL: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_gui (TestGuiSpawnThreads.TestGuiSpawnThreadsTest)
======================================================================
ERROR: test_gui (TestGuiSpawnThreads.TestGuiSpawnThreadsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py", line 156, in wrapper
    return func(*args, **kwargs)
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/commands/gui/spawn-threads/TestGuiSpawnThreads.py", line 44, in test_gui
    self.child.expect_exact(f"thread #{i + 2}: tid =")
  File "/usr/local/lib/python3.10/dist-packages/pexpect/spawnbase.py", line 432, in expect_exact
    return exp.expect_loop(timeout)
  File "/usr/local/lib/python3.10/dist-packages/pexpect/expect.py", line 179, in expect_loop
    return self.eof(e)
  File "/usr/local/lib/python3.10/dist-packages/pexpect/expect.py", line 122, in eof
    raise exc
pexpect.exceptions.EOF: End Of File (EOF). Exception style platform.
<pexpect.pty_spawn.spawn object at 0xec8e5be2d420>
command: /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/lldb
args: ['/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/lldb', '--no-lldbinit', '--no-use-colors', '-O', 'settings clear --all', '-O', 'settings set symbols.enable-external-lookup false', '-O', 'settings set target.inherit-tcc true', '-O', 'settings set target.disable-aslr false', '-O', 'settings set target.detach-on-error false', '-O', 'settings set target.auto-apply-fixits false', '-O', 'settings set plugin.process.gdb-remote.packet-timeout 60', '-O', 'settings set symbols.clang-modules-cache-path "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api"', '-O', 'settings set use-color false', '-O', 'settings set show-statusline false', '--file', '/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/commands/gui/spawn-threads/TestGuiSpawnThreads.test_gui/a.out']
buffer (last 100 chars): b''
before (last 100 chars): b'2 0x0000ab82a7fa5330 _start (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/lldb+0x45330)\n'
after: <class 'pexpect.exceptions.EOF'>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants