[all-commits] [llvm/llvm-project] d3260b: [clangd] Errors in TestTU cause test failures unle...

Sam McCall via All-commits all-commits at lists.llvm.org
Fri Jan 24 02:16:44 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: d3260bf5b2f7bdd0c37c892b8ddecce12263b213
      https://github.com/llvm/llvm-project/commit/d3260bf5b2f7bdd0c37c892b8ddecce12263b213
  Author: Sam McCall <sam.mccall at gmail.com>
  Date:   2020-01-24 (Fri, 24 Jan 2020)

  Changed paths:
    M clang-tools-extra/clangd/unittests/ASTTests.cpp
    M clang-tools-extra/clangd/unittests/CollectMacrosTests.cpp
    M clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
    M clang-tools-extra/clangd/unittests/FileIndexTests.cpp
    M clang-tools-extra/clangd/unittests/FindTargetTests.cpp
    M clang-tools-extra/clangd/unittests/HoverTests.cpp
    M clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
    M clang-tools-extra/clangd/unittests/PrintASTTests.cpp
    M clang-tools-extra/clangd/unittests/QualityTests.cpp
    M clang-tools-extra/clangd/unittests/RenameTests.cpp
    M clang-tools-extra/clangd/unittests/SelectionTests.cpp
    M clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
    M clang-tools-extra/clangd/unittests/SymbolInfoTests.cpp
    M clang-tools-extra/clangd/unittests/TestTU.cpp
    M clang-tools-extra/clangd/unittests/TestTU.h
    M clang-tools-extra/clangd/unittests/TweakTests.cpp
    M clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
    M clang-tools-extra/clangd/unittests/XRefsTests.cpp

  Log Message:
  -----------
  [clangd] Errors in TestTU cause test failures unless suppressed with error-ok.

Summary:
The historic behavior of TestTU is to gather diagnostics and otherwise ignore
them. So if a test has a syntax error, and doesn't assert diagnostics, it
silently misbehaves.
This can be annoying when developing tests, as evidenced by various tests
gaining "assert no diagnostics" where that's not really the point of the test.

This patch aims to make that default behavior. For the first error
(not warning), TestTU will call ADD_FAILURE().

This can be suppressed with a comment containing "error-ok". For now that will
suppress any errors in the TU. We can make this stricter later -verify style.
(-verify itself is hard to reuse because of DiagnosticConsumer interfaces...)
A magic-comment was chosen over a TestTU option because of table-driven tests.

In addition to the behavior change, this patch:
  - adds //error-ok where we're knowingly testing invalid code
    (e.g. for diagnostics, crash-resilience, or token-level tests)
  - fixes a bunch of errors in the checked-in tests, mostly trivial (missing ;)
  - removes a bunch of now-redundant instances of "assert no diagnostics"

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73199




More information about the All-commits mailing list