-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[utils] support both files originating from split-file in DiffUpdater #166679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
|
@llvm/pr-subscribers-testing-tools Author: Henrik G. Olsson (hnrklssn) ChangesWith 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:
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
|
|
ping |
|
LLVM Buildbot has detected a new failure on builder 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 |
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.