summaryrefslogtreecommitdiffstats
path: root/llvm/utils/unittest/UnitTestMain
Commit message (Collapse)AuthorAgeFilesLines
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Add the 'googlemock' component of Google Test to LLVM's unittest libraries.Chandler Carruth2017-01-101-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I have two immediate motivations for adding this: 1) It makes writing expectations in tests *dramatically* easier. A quick example that is a taste of what is possible: std::vector<int> v = ...; EXPECT_THAT(v, UnorderedElementsAre(1, 2, 3)); This checks that v contains '1', '2', and '3' in some order. There are a wealth of other helpful matchers like this. They tend to be highly generic and STL-friendly so they will in almost all cases work out of the box even on custom LLVM data structures. I actually find the matcher syntax substantially easier to read even for simple assertions: EXPECT_THAT(a, Eq(b)); EXPECT_THAT(b, Ne(c)); Both of these make it clear what is being *tested* and what is being *expected*. With `EXPECT_EQ` this is implicit (the LHS is expected, the RHS is tested) and often confusing. With `EXPECT_NE` it is just not clear. Even the failure error messages are superior with the matcher based expectations. 2) When testing any kind of generic code, you are continually defining dummy types with interfaces and then trying to check that the interfaces are manipulated in a particular way. This is actually what mocks are *good* for -- testing *interface interactions*. With generic code, there is often no "fake" or other object that can be used. For a concrete example of where this is currently causing significant pain, look at the pass manager unittests which are riddled with counters incremented when methods are called. All of these could be replaced with mocks. The result would be more effective at testing the code by having tighter constraints. It would be substantially more readable and maintainable when updating the code. And the error messages on failure would have substantially more information as mocks automatically record stack traces and other information *when the API is misused* instead of trying to diagnose it after the fact. I expect that #1 will be the overwhelming majority of the uses of gmock, but I think that is sufficient to justify having it. I would actually like to update the coding standards to encourage the use of matchers rather than any other form of `EXPECT_...` macros as they are IMO a strict superset in terms of functionality and readability. I think that #2 is relatively rarely useful, but there *are* cases where it is useful. Historically, I think misuse of actual mocking as described in #2 has led to resistance towards this framework. I am actually sympathetic to this -- mocking can easily be overused. However I think this is not a significant concern in LLVM. First and foremost, LLVM has very careful and rare exposure of abstract interfaces or dependency injection, which are the most prone to abuse with mocks. So there are few opportunities to abuse them. Second, a large fraction of LLVM's unittests are testing *generic code* where mocks actually make tremendous sense. And gmock is well suited to building interfaces that exercise generic libraries. Finally, I still think we should be willing to have testing utilities in tree even if they should be used rarely. We can use code review to help guide the usage here. For a longer and more complete discussion of this, see the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2017-January/108672.html The general consensus seems that this is a reasonable direction to start down, but that doesn't mean we should race ahead and use this everywhere. I have one test that is blocked on this to land and that was specifically used as an example. Before widespread adoption, I'm going to work up some (brief) guidelines as some of these facilities should be used sparingly and carefully. Differential Revision: https://reviews.llvm.org/D28156 llvm-svn: 291606
* [cmake] Export gtest/gtest_main and its dependencies via a special build ↵Michael Gottesman2016-09-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tree only cmake exports file. Previously, gtest/gtest_main were not exported via cmake. The intention here was to ensure that users whom are linking against the LLVM install tree would not get the gtest/gtest_main targets. This prevents downstream projects that link against the LLVM build tree (i.e. Swift) from getting this dependency information in their cmake builds. Without such dependency information, linker issues can result on linux due to LLVMSupport being put before gtest on the linker command line. This commit preserves behavior that we want for the install tree, while adding support for the build tree by: 1. The special casing for gtest/gtest_main in the add_llvm_library code is removed in favor of a flag called "BUILDTREE_ONLY". If this is set, then the library is communicating that it is only meant to be exported into the build tree and is not meant to be installed or exported via the install tree. This part is just a tweak to remove the special case, the underlying code is the same. 2. The cmake code that exports cmake targets for the build tree has special code to import an additional targets file called LLVMBuildTreeOnlyExports.cmake. Additionally the extra targets are added to the LLVMConfig.cmake's LLVM_EXPORTED_TARGETS variable. In contrast, the "installation" cmake file uses the normal LLVM_EXPORTS_TARGETS as before and does not include the extra exports file. This is implemented by defining/undefining variables when performing a configure of the build/install tree LLVMConfig.cmake files. llvm-svn: 281085
* Search for llvm-symbolizer binary in the same directory as argv[0], beforeRichard Smith2016-06-091-1/+2
| | | | | | | looking for it along $PATH. This allows installs of LLVM tools outside of $PATH to find the symbolizer and produce pretty backtraces if they crash. llvm-svn: 272232
* Avoid linking LLVM component libraries with libLLVMAndrew Wilkins2016-02-121-1/+3
| | | | | | | | | | | Patch by Jack Howarth. When linking to libLLVM, don't also link to the component libraries that constitute libLLVM. Differential Revision: http://reviews.llvm.org/D16945 llvm-svn: 260641
* Remove autoconf supportChris Bieneman2016-01-261-32/+0
| | | | | | | | | | | | | | | | Summary: This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html "I felt a great disturbance in the [build system], as if millions of [makefiles] suddenly cried out in terror and were suddenly silenced. I fear something [amazing] has happened." - Obi Wan Kenobi Reviewers: chandlerc, grosbach, bob.wilson, tstellarAMD, echristo, whitequark Subscribers: chfast, simoncook, emaste, jholewinski, tberghammer, jfb, danalbert, srhines, arsenm, dschuff, jyknight, dsanders, joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D16471 llvm-svn: 258861
* Make UnitTestMain/TestMain.cpp free from llvm/Config/config.h.NAKAMURA Takumi2015-07-061-3/+2
| | | | | | llvm/Config/config.h is unavailable outside of build tree. llvm-svn: 241523
* Add boolean to PrintStackTraceOnErrorSignal to disable crash reporting.Pete Cooper2015-04-071-1/+1
| | | | | | | | | | | | | | | | | | | The current crash reporting on Mac OS is only disabled via an environment variable. This adds a boolean (default false) which can also disable crash reporting. The only client right now is the unittests which don't ever want crash reporting, but do want to detect killed programs. Reduces the time to run the APFloat unittests on my machine from [----------] 47 tests from APFloatTest (51250 ms total) to [----------] 47 tests from APFloatTest (765 ms total) Reviewed by Reid Kleckner and Justin Bogner llvm-svn: 234353
* [CMake] Use LINK_LIBS instead of target_link_libraries().NAKAMURA Takumi2014-02-261-4/+2
| | | | llvm-svn: 202238
* [CMake] Add dependencies to gtest.NAKAMURA Takumi2014-02-101-0/+6
| | | | llvm-svn: 201079
* Sink add_llvm_library(gtest_main) to UnitTestMain/CMakeLists.txt.NAKAMURA Takumi2014-01-101-0/+3
| | | | llvm-svn: 198933
* Try to fix ProgramTest on FreeBSDReid Kleckner2013-04-301-0/+5
| | | | | | | This seemed like the cleanest way to find the test executable. Also fix the file mode. llvm-svn: 180770
* Add basic command line parsing to TestMain.Manuel Klimek2013-01-181-0/+2
| | | | | | | | | | | | | Summary: This allows unit tests for components that use Support/Debug.h to print debug information from test runs by specifying -debug when running the test. CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D301 llvm-svn: 172801
* build/unittests: Fix llvm-config names for gtest libraries, and bring MakefileDaniel Dunbar2011-12-151-1/+1
| | | | | | | library names in line with those used by CMake. - Patch by Johannes Obermayr, with tweaks by me. llvm-svn: 146706
* Don't install libUnitTestMain.a. It might be useless without gtest headers.NAKAMURA Takumi2011-02-281-0/+2
| | | | llvm-svn: 126632
* Make Win32's header file name lower for cross build on case-sensitive ↵NAKAMURA Takumi2011-02-041-1/+1
| | | | | | filesystem. llvm-svn: 124864
* Merge System into Support.Michael J. Spencer2010-11-291-1/+1
| | | | llvm-svn: 120298
* Fix MSVC release mode compilation error.Francois Pichet2010-10-021-6/+6
| | | | llvm-svn: 115407
* Fix line endings from my last commit.Michael J. Spencer2010-09-241-3/+3
| | | | llvm-svn: 114728
* unittests: Support Windows.Michael J. Spencer2010-09-241-0/+27
| | | | llvm-svn: 114727
* Disable pthread support in googletest if llvm was configured without threads.Benjamin Kramer2010-06-031-0/+5
| | | | llvm-svn: 105390
* Turns out gtest still prefers the system <tr1/tuple> over it's ownBenjamin Kramer2010-06-031-0/+3
| | | | | | implementation. Force the internal one to unbreak clang selfhost on linux. llvm-svn: 105386
* Update Readme and Makefiles for the new gtest.Benjamin Kramer2010-06-021-4/+0
| | | | llvm-svn: 105355
* Continue propagating the GoogleTest flags until we can update our version toChandler Carruth2010-03-091-0/+6
| | | | | | | eliminate this problem. This will hopefully let us make progress on Linux bootstrapping. llvm-svn: 98095
* make -fno-rtti the default unless a directory builds with REQUIRES_RTTI.Chris Lattner2010-01-241-0/+1
| | | | llvm-svn: 94378
* Remove / use flags that are now set in the Makefile.config.Julien Lerouge2009-10-261-2/+0
| | | | llvm-svn: 85149
* Follow googletest logic for suppressing warnings in unittests/UnitTestMain.Daniel Dunbar2009-09-201-1/+3
| | | | llvm-svn: 82373
* Move unittest driver to utils/unittest/UnitTestMain.Daniel Dunbar2009-09-132-0/+34
- This eliminates a race between building the unittests and linking the UnitTestMain library. llvm-svn: 81719
OpenPOWER on IntegriCloud