Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build no tests by default #572

Merged
merged 3 commits into from
Sep 23, 2021

Conversation

Sideboard
Copy link
Contributor

Fixes #92

  • Change default behavior of build to exclude tests (sources with FPM_SCOPE_TEST)
  • Add command line option --test to force building tests
  • Update help messages

Building tests can be enforced using --test for build. It is done
automatically before running tests.
Copy link
Member

@awvwgk awvwgk left a comment

Choose a reason for hiding this comment

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

Thanks for sharing. Works nicely for a couple of projects I tested so far.

I have one suggestion about the new logical value, though.

Comment on lines 200 to 202
if (.not. include_tests) then
if (sources(i)%unit_scope == FPM_SCOPE_TEST) cycle
end if
Copy link
Member

Choose a reason for hiding this comment

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

It would be beneficial to make the include_tests logical part of the fpm_model_t, this way it can be easily accessed here without requiring to change the signature of all procedures until we get to the target list builder.

Copy link
Contributor Author

@Sideboard Sideboard Sep 19, 2021

Choose a reason for hiding this comment

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

I agree that it would be nicer to have it in the model. But it did not seem to fit with the existing, more fundamental components:

type :: fpm_model_t
    character(:), allocatable :: package_name
    type(package_t), allocatable :: packages(:)
    type(compiler_t) :: compiler
    type(archiver_t) :: archiver
    character(:), allocatable :: fortran_compile_flags
    character(:), allocatable :: output_directory
    type(string_t), allocatable :: include_dirs(:)
    type(string_t), allocatable :: link_libraries(:)
    type(string_t), allocatable :: external_modules(:)
    type(dependency_tree_t) :: deps

    logical :: include_tests
end type fpm_model_t

Is this ok?

@Sideboard Sideboard closed this Sep 21, 2021
@Sideboard Sideboard reopened this Sep 21, 2021
@LKedward LKedward self-requested a review September 21, 2021 13:34
@LKedward
Copy link
Member

Thanks very much @Sideboard! This all looks good - I agree with Sebastian's comment regarding the logical value, I think it is fine to include it in the model.

@Sideboard
Copy link
Contributor Author

Sideboard commented Sep 23, 2021

I changed the structure and renamed the internal settings name from test to build_tests to avoid semantic clashes due to inheritance (the external build option is still --test).

Shall I …

  1. … squash the commits?
  2. … remove the leftover space changes in call targets_from_sources(targets, model, error)?

Copy link
Member

@awvwgk awvwgk left a comment

Choose a reason for hiding this comment

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

Looks good to me. I usually squash small PRs on merge, so no worries about polluting the history here. But feel free to rebase your branch if you like.

@Sideboard
Copy link
Contributor Author

Merge-squash is fine with me and there is no need for a bare rebase as far as I see. The second commit message can be scrapped.

Copy link
Member

@LKedward LKedward left a comment

Choose a reason for hiding this comment

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

Great stuff, many thanks Sascha @Sideboard 👍

@Sideboard
Copy link
Contributor Author

Sideboard commented Sep 23, 2021

I just realized that the cargo option is --tests instead of --test. Should change that before the merge.

--test name...
Build the specified integration test. This flag may be specified multiple times and supports common Unix glob patterns.
--tests
Build all targets in test mode that have the test = true manifest flag set. By default this includes the library and binaries built as unittests, and integration tests. Be aware that this will also build any required dependencies, so the lib target may be built twice (once as a unittest, and once as a dependency for binaries, integration tests, etc.). Targets may be enabled or disabled by setting the test flag in the manifest settings for the target.

@awvwgk
Copy link
Member

awvwgk commented Sep 23, 2021

Thanks, I'll go ahead and merge.

@awvwgk awvwgk merged commit 6bb5f6c into fortran-lang:main Sep 23, 2021
@Sideboard Sideboard deleted the feature/build-no-tests-by-default branch September 23, 2021 10:01
@certik
Copy link
Member

certik commented Sep 23, 2021

Thank you @Sideboard for this contribution!

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.

Only compile tests for fpm test command
4 participants