Commit Graph

1191 Commits

Author SHA1 Message Date
Brad King 86578eccf2 Simplify CMake per-source license notices
Per-source copyright/license notice headers that spell out copyright holder
names and years are hard to maintain and often out-of-date or plain wrong.
Precise contributor information is already maintained automatically by the
version control tool.  Ultimately it is the receiver of a file who is
responsible for determining its licensing status, and per-source notices are
merely a convenience.  Therefore it is simpler and more accurate for
each source to have a generic notice of the license name and references to
more detailed information on copyright holders and full license terms.

Our `Copyright.txt` file now contains a list of Contributors whose names
appeared source-level copyright notices.  It also references version control
history for more precise information.  Therefore we no longer need to spell
out the list of Contributors in each source file notice.

Replace CMake per-source copyright/license notice headers with a short
description of the license and links to `Copyright.txt` and online information
available from "https://cmake.org/licensing".  The online URL also handles
cases of modules being copied out of our source into other projects, so we
can drop our notices about replacing links with full license text.

Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority
of the replacements mechanically.  Manually fix up shebang lines and trailing
newlines in a few files.  Manually update the notices in a few files that the
script does not handle.
2016-09-27 15:14:44 -04:00
Brad King f4475eb92b Merge topic 'test-fixtures'
73f47c9e CTest: Add support for test fixtures
2016-09-22 08:09:55 -04:00
Brad King 2c2ffd3874 Merge topic 'ctest-capture-error'
adf1e32f Help: Add notes for topic 'ctest-capture-error'
d328dc68 CTest: Add CAPTURE_CMAKE_ERROR val to `ctest_*` commands
9ac2e189 ctest_coverage: If gcov is not found just warn, not error
2016-09-21 08:47:51 -04:00
Craig Scott 73f47c9e46 CTest: Add support for test fixtures
Add new test properties:

* FIXTURES_SETUP
* FIXTURES_CLEANUP
* FIXTURES_REQUIRED

to specify the roles and dependencies of tests providing/using
test fixtures.
2016-09-20 14:37:38 -04:00
Bill Hoffman d328dc6853 CTest: Add CAPTURE_CMAKE_ERROR val to `ctest_*` commands
If a `ctest_*` command has CAPTURE_CMAKE_ERROR then any errors generated
by cmake during that command will cause the value to be assigned `-1`.
This will prevent a `ctest -S` script from returning non-zero unless the
script explicitly calls `message(FATAL_ERROR)`.
2016-09-20 13:14:20 -04:00
Bill Hoffman 9ac2e18960 ctest_coverage: If gcov is not found just warn, not error 2016-09-20 13:06:57 -04:00
Nils Gladitz b35311ca44 CTestSVN: Fix segfault when CTEST_UPDATE_VERSION_ONLY is enabled
Before the change the list of externals was queried only
before the svn update.

With the change the list is queried both before and after.
This should also be more accurate since the list of externals might
change during the update.
2016-09-12 19:40:13 +02:00
Daniel Pfeifer 1a9de8035c surround macro arguments with parentheses 2016-09-05 22:09:49 +02:00
Daniel Pfeifer 3849164454 CTest: fix include-what-you-use violations 2016-08-25 09:34:37 -04:00
Daniel Pfeifer 5cbb548807 fix a batch of include-what-you-use violations 2016-08-24 00:29:15 +02:00
Daniel Pfeifer 50ad1e0a14 CTest: don't use else after return 2016-08-18 20:04:21 +02:00
Daniel Pfeifer e7b842e189 Make sure unnused parameters are /*named*/ 2016-08-17 01:49:57 +02:00
Dāvis Mosāns b1f87a50b3 Use better KWSys SystemTools::GetEnv and HasEnv signatures 2016-07-18 09:51:01 -04:00
Brad King b5ec5b0901 Avoid using KWSys auto_ptr by adopting it ourselves
Replace use of cmsys::auto_ptr with a CM_AUTO_PTR macro that maps to
our own implementation adopted from the KWSys auto_ptr implementation.
Later we may be able to map CM_AUTO_PTR to std::auto_ptr on compilers
that do not warn about it.

Automate the client site conversions:

    git grep -l auto_ptr -- Source/ | grep -v Source/kwsys/ | xargs sed -i \
      's|cmsys::auto_ptr|CM_AUTO_PTR|;s|cmsys/auto_ptr.hxx|cm_auto_ptr.hxx|'
2016-06-29 09:47:58 -04:00
Daniel Pfeifer 1d6909a287 use CM_NULLPTR 2016-06-28 09:02:26 -04:00
Daniel Pfeifer a7a9239096 mark functions with CM_OVERRIDE 2016-06-27 23:24:38 +02:00
Daniel Pfeifer 7647f6afa4 Add CM_OVERRIDE to some functions
Run clang-tidy's modernize-use-override checker.  This checker must have
issues in version 3.8.  It has way too little matches.  And it adds
override to destructors.  Revert the changes on the destructors and
change override to CM_OVERRIDE.
2016-06-27 10:37:41 -04:00
Daniel Pfeifer 24ab29b882 Prefer istringstream and ostringstream over stringstream.
Use istringsream for parsing, ostringstream for generation.
2016-06-14 22:37:36 +02:00
Daniel Pfeifer a16bf141bc Add missing braces around statements.
Apply fixits of clang-tidy's readability-braces-around-statements
checker.
2016-06-10 18:36:24 +02:00
Daniel Pfeifer 9f25fc4dbb Prefer std::ostream& over derivatives as parameters 2016-06-08 23:08:40 +02:00
Daniel Pfeifer fa277b29e4 Remove c_str() calls from stream arguments.
Mostly automated:

git grep -l '.c_str() <<' | xargs sed -i 's|\.c_str() <<| <<|g'
2016-06-06 23:53:32 +02:00
Brad King 3d6638471a Merge topic 'size-empty'
c6220de2 Use the empty() method to check for emptyness.
2016-06-03 10:45:52 -04:00
Daniel Pfeifer c6220de276 Use the empty() method to check for emptyness.
Apply fix-its from clang-tidy's readability-container-size-empty
checker.
2016-06-02 21:35:50 +02:00
Daniel Pfeifer 7f6b8d3399 Simplify boolean expressions
Use clang-tidy's readability-simplify-boolean-expr checker.
After applying the fix-its, revise all changes *very* carefully.
Be aware of false positives and invalid changes.
2016-06-02 08:24:04 -04:00
Brad King fb1f5d50af Merge topic 'remove-needless-copies'
27ead963 Remove unnecessary local copies.
618fb23f Pass arguments that are not modified as const&.
2016-05-27 09:08:21 -04:00
Daniel Pfeifer 1b2bb93302 Remove redundant c_str() calls.
Run clang-tidy's readability-redundant-string-cstr checker.
Ignore findings in kwsys.
2016-05-26 22:52:22 +02:00
Daniel Pfeifer 27ead96305 Remove unnecessary local copies.
Use clang-tidy's performance-unnecessary-copy-initialization checker.
After applying the fix-its (which turns the copies into const&), revise
the changes and see whether the copies can be removed entirely by using
the original instead.
2016-05-26 22:21:15 +02:00
Daniel Pfeifer 618fb23fc9 Pass arguments that are not modified as const&.
Use clang-tidy's performance-unnecessary-value-param checker to find
value parameter declarations of expensive to copy types that are not
modified inside the function.  Ignore findings in kwsys.
After applying the fix-its, manually change `const T&` to `T const&`.
2016-05-26 21:58:51 +02:00
Daniel Pfeifer 5784747d1b Improve string find: prefer character overloads.
Apply fix-its from clang-tidy's performance-faster-string-find checker.
Ignore findings in kwsys.
2016-05-24 23:22:24 +02:00
Daniel Pfeifer 34bc6e1f3b cmCTestScriptHandler: don't call find repeatedly.
Also, prefer the character overload.
2016-05-24 23:22:08 +02:00
Kitware Robot d9fd2f5402 Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2016-05-16 16:05:19 -04:00
Brad King eafe541ff6 CTest: Do not treat "Note: ..." lines as errors (#14394)
Otherwise CTest interprets the Qt5 moc tool output

    Note: No relevant classes found. No output generated.

as a compiler error.
2016-05-11 09:56:51 -04:00
Brad King 0ac18d40c8 Remove `//------...` horizontal separator comments
Modern editors provide plenty of ways to visually separate functions.
Drop the explicit comments that previously served this purpose.
Use the following command to automate the change:

    $ git ls-files -z -- \
        "*.c" "*.cc" "*.cpp" "*.cxx" "*.h" "*.hh" "*.hpp" "*.hxx" |
      egrep -z -v "^Source/cmCommandArgumentLexer\." |
      egrep -z -v "^Source/cmCommandArgumentParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmDependsJavaLexer\." |
      egrep -z -v "^Source/cmDependsJavaParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmExprLexer\." |
      egrep -z -v "^Source/cmExprParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmFortranLexer\." |
      egrep -z -v "^Source/cmFortranParser(\.y|\.cxx|Tokens\.h)" |
      egrep -z -v "^Source/cmListFileLexer\." |
      egrep -z -v "^Source/cm_sha2" |
      egrep -z -v "^Source/(kwsys|CursesDialog/form)/" |
      egrep -z -v "^Utilities/(KW|cm).*/" |
      xargs -0 sed -i '/^\(\/\/---*\|\/\*---*\*\/\)$/ {d;}'

This avoids modifying third-party sources and generated sources.
2016-05-09 09:41:43 -04:00
Brad King 85425a3e6c Move comments off of class access specifier lines
The clang-format tool may turn this:

   public: // comment about access specifier

     // unrelated comment indented with code
     ...

Into:

   public: // comment about access specifier

           // unrelated comment indented with code
     ...

Avoid this by moving comments off of access specifier lines.
2016-05-06 14:51:26 -04:00
Brad King 64b5520346 Isolate formatted streaming blocks with clang-format off/on
The clang-format tool can do a good job formatting most code, but
well-organized streaming blocks are best left manually formatted.

Find blocks of the form

    os <<
      "...\n"
      "...\n"
      ;

using the command

    $ git ls-files -z -- Source |
      egrep -v -z '^Source/kwsys/' |
      xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
        '<<[^\n]*\n(^ *("[^\n]*("|<<|;)$|;)\n){2,}'

Find blocks of the form

    os << "...\n"
       << "...\n"
       << "...\n";

using the command

    $ git ls-files -z -- Source |
      egrep -v -z '^Source/kwsys/' |
      xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
        '<<[^\n]*\n(^ *<<[^\n]*(\\n"|<<|;)$\n){2,}'

Surround such blocks with the pair

    /* clang-format off */
    ...
    /* clang-format on */

in order to protect them from update by clang-format.  Use the C-style
`/*...*/` comments instead of C++-style `//...` comments in order to
prevent them from ever being swallowed by re-formatting of surrounding
comments.
2016-05-06 14:25:55 -04:00
Brad King 7b6ffa59b1 Source: Sort includes of sys/types.h as clang-format would
When this header is included in blocks where order does not matter, just
place it in lexicographic order as clang-format would by default.
2016-05-03 10:08:41 -04:00
Brad King e1c7747253 Format include directive blocks and ordering with clang-format
Sort include directives within each block (separated by a blank line) in
lexicographic order (except to prioritize `sys/types.h` first).  First
run `clang-format` with the config file:

    ---
    SortIncludes: false
    ...

Commit the result temporarily.  Then run `clang-format` again with:

    ---
    SortIncludes: true
    IncludeCategories:
      - Regex:    'sys/types.h'
        Priority: -1
    ...

Commit the result temporarily.  Start a new branch and cherry-pick the
second commit.  Manually resolve conflicts to preserve indentation of
re-ordered includes.  This cleans up the include ordering without
changing any other style.

Use the following command to run `clang-format`:

    $ git ls-files -z -- \
        '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' |
      egrep -z -v '(Lexer|Parser|ParserHelper)\.' |
      egrep -z -v '^Source/cm_sha2' |
      egrep -z -v '^Source/(kwsys|CursesDialog/form)/' |
      egrep -z -v '^Utilities/(KW|cm).*/' |
      egrep -z -v '^Tests/Module/GenerateExportHeader' |
      egrep -z -v '^Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h' |
      xargs -0 clang-format -i

This selects source files that do not come from a third-party.

Inspired-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
2016-04-29 13:58:54 -04:00
Brad King 180538c706 Source: Stabilize include order
Each source file has a logical first include file.  Include it in an
isolated block so that tools that sort includes do not move them.
2016-04-29 13:58:31 -04:00
Brad King fd40b0f875 Merge topic 'ctest-run-submodule-sync'
c18d91ad Help: add release notes for topic 'ctest-run-submodule-sync'
7f560743 cmCTestGIT: run `git submodule sync` before updating submodules
06b310b5 cmCTestGIT: add an option to initialize submodules on update
56c1ea40 cmCTestGIT: fix git version references
2016-04-05 09:38:06 -04:00
Brad King 25a38ecfe7 Merge topic 'cobertura_off_by_one'
398b8800 cmParseCoberturaCoverage: Remove extra coverage line
2016-04-05 09:38:04 -04:00
Ben Boeckel 7f5607439e cmCTestGIT: run `git submodule sync` before updating submodules
If the URL of a submodule changes upstream, the commits referenced at
the old URL may not be available and will cause an update failure.
2016-04-01 15:50:31 -04:00
Ben Boeckel 06b310b5d5 cmCTestGIT: add an option to initialize submodules on update
Currently, CTest will not initialize any submodules within the already
checked out source tree. Add an option to do so. The use case for not
doing so is that some submodules may not be necessary for the current
test and keeping network usage down may be important.
2016-04-01 15:50:31 -04:00
Ben Boeckel 56c1ea40c5 cmCTestGIT: fix git version references
Git does not use a 4-component version number.
2016-04-01 15:50:27 -04:00
Zack Galbreath 398b8800e3 cmParseCoberturaCoverage: Remove extra coverage line
Fix off-by-one error in cmParseCoberturaCoverage that added an
extra blank line to the end of source file being covered.
2016-03-30 14:22:07 -04:00
Felix Geyer 49e82c15d5 Fix spelling typos in comments and documentation (#16037)
The Debian package checker tool (lintian) detected several typos in
CMake.
2016-03-29 14:31:02 -04:00
Zack Galbreath 06b7f5d2ca CTest: Only apply the secondary test timeout once
This commit fixes a bug in the implementation of the test property
TIMEOUT_AFTER_MATCH.  The new timeout value was being applied
every time a line was output by the test after the match had been
encountered.  Now the new timeout value is only set once.

This commit also improves some output formatting related to this
property.
2016-03-23 12:09:41 -04:00
Zack Galbreath 993e48d045 CTest: Optionally use a secondary test timeout after matching output
Allow a test N seconds to complete after we detect a matching line in
its output.  Activate this behavior with a new TIMEOUT_AFTER_MATCH test
property.
2016-03-22 11:17:55 -04:00
Joseph Snyder bc29ed542b CTest: Make coverage file selection more specific.
When performing some other testing, the globs for Blanket.js and Delphi
code coverage are picking up unintended files.  Change the query for the
Delphi coverage to follow the naming convention, and check the second line
of the found JSON files for certain text before parsing them as coverage files.
2016-02-25 13:01:37 -05:00
Zack Galbreath a7393cbd40 ctest_test: Report which tests failed even when QUIET is used
Since commit v3.3.0-rc1~410^2~3 (ctest_test: Add QUIET option,
2015-02-17) if tests fail when QUIET is used one sees:

  The following tests FAILED:

but not the subsequent line(s) indicating which tests failed.
Restore the list of failed tests.
2016-01-13 10:32:24 -05:00
Joseph Snyder 32268810d9 CTest: Expand directories for Cobertura search
Change the Cobertura handler to look for an environment variable
called "COBERTURADIR" which contains the directory where the
coverage.xml file is found.  If that variable doesn't exist,
continue to use the default of the binary directory.

Update the test to use an appropriate value in the environment
variables.
2015-11-23 12:41:36 -05:00