Skip to content

Conversation

@bretbrownjr
Copy link
Member

Problem

Given a setting of BEMAN_EXEMPLAR_BUILD_TESTS equal to OFF, when a user runs a basic CMake test command such as:

cmake --build binary-dir/ --target test

Then the user gets an error that indicates there is no CMake test target defined.

$ cmake --build build2/ --target test
ninja: error: unknown target 'test', did you mean 'help'?

Solution

It is not required to actually build any tests to define the CMake test target. This commit defines the CMake test target unconditionally.

This is good practice for a few reasons:

  • A user or tool doesn't have to know project-specific details to perform basic actions on this project.

  • A user or tool doesn't have to know how to interpret the "unknown target 'test'" error.

  • When no tests are built, the user sees a successful run of zero tests instead of a more ambiguous situation where test aren't run for unclear reasons.

Problem
-------

Given a setting of `BEMAN_EXEMPLAR_BUILD_TESTS` equal to `OFF`,
when a user runs a basic CMake test command such as:

```
cmake --build binary-dir/ --target test
```

Then the user gets an error that indicates there is no CMake
test target defined.

```
$ cmake --build build2/ --target test
ninja: error: unknown target 'test', did you mean 'help'?
```

Solution
--------

It is not required to actually build any tests to define the CMake
test target. This commit defines the CMake `test` target
unconditionally.

This is good practice for a few reasons:

* A user or tool doesn't have to know project-specific details to
perform basic actions on this project.

* A user or tool doesn't have to know how to interpret the
"unknown target 'test'" error.

* When no tests are built, the user sees a successful run of zero
tests instead of a more ambiguous situation where test aren't run
for unclear reasons.
Copy link
Member

@neatudarius neatudarius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with this change, but we should be consistent with the update.

I would create an issue in https://github.com/bemanproject/beman to update the Beman Standard first. Then I would update all other repos.

Copy link
Member

@wusatosi wusatosi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea!

@bretbrownjr bretbrownjr merged commit 4d9f05a into bemanproject:main Jan 6, 2025
46 checks passed
@bretbrownjr bretbrownjr deleted the better-test-target branch January 6, 2025 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants