Skip to content

[clang-doc][NFC] Make test resilient to line changes #119811

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

ilovepi
Copy link
Contributor

@ilovepi ilovepi commented Dec 13, 2024

This just reorganizes the test code, so its easy to use @line directives
in the test, and avoid needing to update all the line numbers when making
unrelated changes.

Created using spr 1.3.6-beta.1

[skip ci]
Created using spr 1.3.6-beta.1
@llvmbot
Copy link
Member

llvmbot commented Dec 13, 2024

@llvm/pr-subscribers-clang-tools-extra

Author: Paul Kirth (ilovepi)

Changes

This just reorganizes the test code, so its easy to use @LINE directives
in the test, and avoid needing to update all the line numbers when making
unrelated changes.


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

1 Files Affected:

  • (modified) clang-tools-extra/test/clang-doc/templates.cpp (+14-10)
diff --git a/clang-tools-extra/test/clang-doc/templates.cpp b/clang-tools-extra/test/clang-doc/templates.cpp
index d5a9e7d201e1e5..1adfbe0cf18282 100644
--- a/clang-tools-extra/test/clang-doc/templates.cpp
+++ b/clang-tools-extra/test/clang-doc/templates.cpp
@@ -6,22 +6,17 @@
 // RUN: cat %t/docs/index.yaml | FileCheck %s --check-prefix=YAML
 // RUN: rm -rf %t
 
-template<typename T, int U = 1>
-void function(T x) {}
-
-template<>
-void function<bool, 0>(bool x) {}
+// YAML: ---
+// YAML-NEXT: USR:             '{{([0-9A-F]{40})}}'
 
 template<class... T>
 void ParamPackFunction(T... args);
 
-// YAML: ---
-// YAML-NEXT: USR:             '{{([0-9A-F]{40})}}'
 // YAML-NEXT: ChildFunctions:
 // YAML-NEXT:  - USR:             '{{([0-9A-F]{40})}}'
 // YAML-NEXT:    Name:            'ParamPackFunction'
 // YAML-NEXT:    Location:
-// YAML-NEXT:      - LineNumber:      16
+// YAML-NEXT:      - LineNumber:      [[# @LINE - 6]]
 // YAML-NEXT:        Filename:        '{{.*}}'
 // YAML-NEXT:    Params:
 // YAML-NEXT:      - Type:
@@ -35,10 +30,14 @@ void ParamPackFunction(T... args);
 // YAML-NEXT:    Template:
 // YAML-NEXT:      Params:
 // YAML-NEXT:        - Contents:        'class... T'
+
+template<typename T, int U = 1>
+void function(T x) {}
+
 // YAML-NEXT:   - USR:             '{{([0-9A-F]{40})}}'
 // YAML-NEXT:     Name:            'function'
 // YAML-NEXT:     DefLocation:
-// YAML-NEXT:       LineNumber:      10
+// YAML-NEXT:       LineNumber:      [[# @LINE - 5]]
 // YAML-NEXT:       Filename:        '{{.*}}'
 // YAML-NEXT:     Params:
 // YAML-NEXT:       - Type:
@@ -53,10 +52,14 @@ void ParamPackFunction(T... args);
 // YAML-NEXT:       Params:
 // YAML-NEXT:         - Contents:        'typename T'
 // YAML-NEXT:         - Contents:        'int U = 1'
+
+template<>
+void function<bool, 0>(bool x) {}
+
 // YAML-NEXT:   - USR:             '{{([0-9A-F]{40})}}'
 // YAML-NEXT:     Name:            'function'
 // YAML-NEXT:     DefLocation:
-// YAML-NEXT:       LineNumber:      12
+// YAML-NEXT:       LineNumber:      [[# @LINE - 6]]
 // YAML-NEXT:       Filename:        '{{.*}}'
 // YAML-NEXT:     Params:
 // YAML-NEXT:       - Type:
@@ -74,3 +77,4 @@ void ParamPackFunction(T... args);
 // YAML-NEXT:           - Contents:        'bool'
 // YAML-NEXT:           - Contents:        '0'
 // YAML-NEXT: ...
+

Created using spr 1.3.6-beta.1

[skip ci]
Created using spr 1.3.6-beta.1
@ilovepi ilovepi changed the base branch from users/ilovepi/spr/main.clang-docnfc-make-test-resilient-to-line-changes to main December 13, 2024 17:39
@ilovepi ilovepi merged commit b856952 into main Dec 13, 2024
7 of 9 checks passed
@ilovepi ilovepi deleted the users/ilovepi/spr/clang-docnfc-make-test-resilient-to-line-changes branch December 13, 2024 17:39
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