| This error message is printed when a project's tests encounter a failure | This error message is printed when a project's tests encounter a failure | ||||
| condition. The exact behavior of tests is determined by a project's | condition. The exact behavior of tests is determined by a project's | ||||
| ``Test-Driver``. | |||||
| ``test_driver``. | |||||
| If you see this error, it is most likely that you have an issue in the tests of | If you see this error, it is most likely that you have an issue in the tests of | ||||
| your project. | your project. |
| Error: Unknown ``Test-Driver`` | |||||
| Error: Unknown ``test_driver`` | |||||
| ############################## | ############################## | ||||
| ``dds`` has a set of known ``Test-Driver``s built-in, and they may be specified | |||||
| with the ``Test-Driver`` key. Receiving this error indicates that the specified | |||||
| ``Test-Driver`` was not recognized by ``dds``. Check your spelling, and check | |||||
| ``dds`` has a set of known ``test_driver``s built-in, and they may be specified | |||||
| with the ``test_driver`` key. Receiving this error indicates that the specified | |||||
| ``test_driver`` was not recognized by ``dds``. Check your spelling, and check | |||||
| that the driver you want to use is supported by ``dds``. Refer to the | that the driver you want to use is supported by ``dds``. Refer to the | ||||
| :doc:`/guide/packages` page. | :doc:`/guide/packages` page. |
| A *test* source file is a source file whose file stem ends with ``.test``. Like | A *test* source file is a source file whose file stem ends with ``.test``. Like | ||||
| application sources, a *test* source file is omitted from the main library, and | application sources, a *test* source file is omitted from the main library, and | ||||
| it will be used to generate tests. The exact behavior of tests is determined by | it will be used to generate tests. The exact behavior of tests is determined by | ||||
| the ``Test-Driver`` setting for the package, but the default is that each test | |||||
| the ``test_driver`` setting for the package, but the default is that each test | |||||
| source file will generate a single test executable that is executed by ``dds`` | source file will generate a single test executable that is executed by ``dds`` | ||||
| when running unit tests. | when running unit tests. | ||||
| diagnostics? | diagnostics? | ||||
| A ``Test-Driver``: Using *Catch2* | |||||
| A ``test_driver``: Using *Catch2* | |||||
| ********************************* | ********************************* | ||||
| ``dds`` ships with built-in support for the `Catch2`_ C and C++ testing | ``dds`` ships with built-in support for the `Catch2`_ C and C++ testing | ||||
| } | } | ||||
| If you now run ``dds build``, we will get a linker error for a multiply-defined | If you now run ``dds build``, we will get a linker error for a multiply-defined | ||||
| ``main`` function. When setting the ``Test-Driver`` to ``Catch-Main``, ``dds`` | |||||
| ``main`` function. When setting the ``test_driver`` to ``Catch-Main``, ``dds`` | |||||
| will compile an entrypoint separately from any particular test, and the tests | will compile an entrypoint separately from any particular test, and the tests | ||||
| will link against that entrypoint. This means we cannot provide our own | will link against that entrypoint. This means we cannot provide our own | ||||
| ``main`` function, and should instead use Catch's ``TEST_CASE`` macro to | ``main`` function, and should instead use Catch's ``TEST_CASE`` macro to |
| return "The source ditsribution already exists at the destination <- (Seeing this " | return "The source ditsribution already exists at the destination <- (Seeing this " | ||||
| "text is a `dds` bug. Please report it.)"; | "text is a `dds` bug. Please report it.)"; | ||||
| case errc::unknown_test_driver: | case errc::unknown_test_driver: | ||||
| return "The specified Test-Driver is not known to `dds`"; | |||||
| return "The specified test_driver is not known to `dds`"; | |||||
| case errc::dependency_resolve_failure: | case errc::dependency_resolve_failure: | ||||
| return "`dds` was unable to find a solution for the package dependencies given."; | return "`dds` was unable to find a solution for the package dependencies given."; | ||||
| case errc::dup_lib_name: | case errc::dup_lib_name: |
| namespace dds { | namespace dds { | ||||
| /** | /** | ||||
| * Represents the contents of a `library.dds`. This is somewhat a stripped-down | |||||
| * Represents the contents of a `library.json5`. This is somewhat a stripped-down | |||||
| * version of lm::library, to only represent exactly the parts that we want to | * version of lm::library, to only represent exactly the parts that we want to | ||||
| * offer via `library.dds`. | |||||
| * offer via `library.json5`. | |||||
| */ | */ | ||||
| struct library_manifest { | struct library_manifest { | ||||
| /// The name of the library | /// The name of the library |
| } else { | } else { | ||||
| auto dym = *did_you_mean(test_driver_str, {"Catch-Main", "Catch"}); | auto dym = *did_you_mean(test_driver_str, {"Catch-Main", "Catch"}); | ||||
| throw_user_error< | throw_user_error< | ||||
| errc::unknown_test_driver>("Unknown 'Test-Driver' '{}' (Did you mean '{}'?)", | |||||
| errc::unknown_test_driver>("Unknown 'test_driver' '{}' (Did you mean '{}'?)", | |||||
| test_driver_str, | test_driver_str, | ||||
| dym); | dym); | ||||
| } | } | ||||
| } else { | } else { | ||||
| auto dym = *did_you_mean(test_driver, {"Catch-Main", "Catch"}); | auto dym = *did_you_mean(test_driver, {"Catch-Main", "Catch"}); | ||||
| throw_user_error<errc::unknown_test_driver>( | throw_user_error<errc::unknown_test_driver>( | ||||
| "Unknown 'Test-Driver' '{}' (Did you mean '{}'?)", | |||||
| "Unknown 'test_driver' '{}' (Did you mean '{}'?)", | |||||
| test_driver, | test_driver, | ||||
| dym); | dym); | ||||
| } | } |
| package_id pkg_id; | package_id pkg_id; | ||||
| /// The declared `Namespace` of the package. This directly corresponds with the libman Namespace | /// The declared `Namespace` of the package. This directly corresponds with the libman Namespace | ||||
| std::string namespace_; | std::string namespace_; | ||||
| /// The `Test-Driver` that this package declares, or `nullopt` if absent. | |||||
| /// The `test_driver` that this package declares, or `nullopt` if absent. | |||||
| std::optional<test_lib> test_driver; | std::optional<test_lib> test_driver; | ||||
| /// The dependencies declared with the `Depends` fields, if any. | /// The dependencies declared with the `Depends` fields, if any. | ||||
| std::vector<dependency> dependencies; | std::vector<dependency> dependencies; |