[PATCH] D97625: fix check-clang-tools tests that fail due to Windows CRLF line endings

Aaron Puchert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 24 13:44:39 PDT 2022


aaronpuchert added a comment.

In D97625#3337018 <https://reviews.llvm.org/D97625#3337018>, @dmgreen wrote:

> I'm not sure it will do much where it is.

It won't, to quote **gitattributes**(5):

> When deciding what attributes are assigned to a path, Git consults `$GIT_DIR/info/attributes` file (which has the highest precedence), `.gitattributes` file in the same directory as the path in question, and its parent directories up to the toplevel of the work tree (the further the directory that contains `.gitattributes` is from the path in question, the lower its precedence).

Obviously `test/` is not a parent directory of `clang-tools-extra/test`.

In D97625#3394751 <https://reviews.llvm.org/D97625#3394751>, @bcain wrote:

> If it makes sense, it could be re-applied to `clang-tools-extra/test/`.

I thought that maybe `lit` would try to run it as a test then, but `llvm-lit --show-tests clang-tools-extra/test/` doesn't list it if I move it there. Specifically `llvm-lit --show-tests clang-tools-extra/test/.gitattributes` prints:

  llvm-lit: [...]/llvm/utils/lit/lit/discovery.py:176: error: 'Clang Tools :: .gitattributes' would not be run indirectly: change name or LIT config(e.g. suffixes or standalone_tests variables)
  1 errors, exiting.

Indeed, in `llvm/utils/lit/lit/formats/base.py`:

  class FileBasedTest(TestFormat):
      def getTestsInDirectory(self, testSuite, path_in_suite,
                              litConfig, localConfig):
          source_path = testSuite.getSourcePath(path_in_suite)
          for filename in os.listdir(source_path):
              # Ignore dot files and excluded tests.
              if (filename.startswith('.') or
                  filename in localConfig.excludes):
                  continue

It also applies the attributes correctly:

  > git check-attr -a clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp
  clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp: text: set
  clang-tools-extra/test/clang-apply-replacements/Inputs/crlf/crlf.cpp: eol: crlf

Previously that printed nothing.

So I went ahead and just fixed this in ac5f7be6a8688955a282becf00eebc542238a86b <https://reviews.llvm.org/rGac5f7be6a8688955a282becf00eebc542238a86b>.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97625/new/

https://reviews.llvm.org/D97625



More information about the llvm-commits mailing list