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

Separate thread-safe parts more clearly #10

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/fortuno.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,8 @@

!> Interface module for the Fortuno testing framework
module fortuno
use fortuno_basetypes, only : test_case_base, test_item, test_ptr_item, test_suite_base
use fortuno_checkers, only : is_equal
use fortuno_serial_serialbasetypes, only : serial_case_base, serial_suite_base
use fortuno_serial_serialcmdapp, only : execute_serial_cmd_app, init_serial_cmd_app,&
& serial_cmd_app
use fortuno_serial_serialglobalctx, only : serial_check, serial_check_failed, serial_failed,&
& serial_scope_pointers, serial_skip
use fortuno_serial_serialcase, only : serial_case, serial_case_item
use fortuno_serial_serialsuite, only : serial_suite, serial_suite_item
use fortuno_base
use fortuno_serial
implicit none

end module fortuno
15 changes: 4 additions & 11 deletions src/fortuno/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@
# Licensed under the BSD-2-Clause Plus Patent license.
# SPDX-License-Identifier: BSD-2-Clause-Patent


target_sources(
Fortuno PRIVATE
argumentparser.f90
basetypes.f90
checkers.f90
consolelogger.f90
testcmdapp.f90
testcontext.f90
testdriver.f90
testinfo.f90
testlogger.f90
utils.f90
version.f90
base.f90
serial.f90
)
add_subdirectory(base)
add_subdirectory(serial)
12 changes: 12 additions & 0 deletions src/fortuno/base.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
! This file is part of Fortuno.
! Licensed under the BSD-2-Clause Plus Patent license.
! SPDX-License-Identifier: BSD-2-Clause-Patent

!> Interface module for the base Fortuno testing framework
module fortuno_base
use fortuno_base_basetypes, only : test_case_base, test_item, test_ptr_item, test_suite_base
use fortuno_base_checkers, only : is_equal
use fortuno_base_utils, only : as_char
implicit none

end module fortuno_base
18 changes: 18 additions & 0 deletions src/fortuno/base/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file is part of Fortuno.
# Licensed under the BSD-2-Clause Plus Patent license.
# SPDX-License-Identifier: BSD-2-Clause-Patent

target_sources(
Fortuno PRIVATE
argumentparser.f90
basetypes.f90
checkers.f90
consolelogger.f90
testcmdapp.f90
testcontext.f90
testdriver.f90
testinfo.f90
testlogger.f90
utils.f90
version.f90
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
! SPDX-License-Identifier: BSD-2-Clause-Patent

!> Implements a simple command line argument parser
module fortuno_argumentparser
use fortuno_testlogger, only : test_logger
use fortuno_utils, only : basename, nl, string, string_list
module fortuno_base_argumentparser
use fortuno_base_testlogger, only : test_logger
use fortuno_base_utils, only : basename, nl, string, string_list
implicit none

type :: argument_types_enum_
Expand Down Expand Up @@ -376,4 +376,4 @@ subroutine print_argument_help_(logger, argument, helpmsg, linelength)

end subroutine print_argument_help_

end module fortuno_argumentparser
end module fortuno_base_argumentparser
4 changes: 2 additions & 2 deletions src/fortuno/basetypes.f90 → src/fortuno/base/basetypes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
! SPDX-License-Identifier: BSD-2-Clause-Patent

!> Contains base classes for itemizable test objects
module fortuno_basetypes
module fortuno_base_basetypes
implicit none

private
Expand Down Expand Up @@ -71,4 +71,4 @@ subroutine test_base_get_as_char(this, repr)

end subroutine test_base_get_as_char

end module fortuno_basetypes
end module fortuno_base_basetypes
8 changes: 4 additions & 4 deletions src/fortuno/checkers.f90 → src/fortuno/base/checkers.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
! SPDX-License-Identifier: BSD-2-Clause-Patent

!> Contains some built-in checkers
module fortuno_checkers
use fortuno_testinfo, only : check_result, failure_details
use fortuno_utils, only : as_char, nl
module fortuno_base_checkers
use fortuno_base_testinfo, only : check_result, failure_details
use fortuno_base_utils, only : as_char, nl
implicit none

private
Expand Down Expand Up @@ -68,4 +68,4 @@ function is_equal_i0_i0(obtained, expected) result(checkresult)

end function is_equal_i0_i0

end module fortuno_checkers
end module fortuno_base_checkers
101 changes: 51 additions & 50 deletions src/fortuno/consolelogger.f90 → src/fortuno/base/consolelogger.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
! SPDX-License-Identifier: BSD-2-Clause-Patent

!> Contains the implementation of the test logger for logging on the console
module fortuno_consolelogger
use fortuno_testinfo, only : drive_result, failure_info, test_result, teststatus
use fortuno_testlogger, only : test_logger, testtypes
use fortuno_utils, only : ansicolors, as_char, stderr, stdout
module fortuno_base_consolelogger
use fortuno_base_testinfo, only : drive_result, failure_info, test_result, teststatus
use fortuno_base_testlogger, only : test_logger, testtypes
use fortuno_base_utils, only : ansicolors, as_char, stderr, stdout
implicit none

private
public :: console_logger


!> Implements a logger which logs to the console
type, extends(test_logger), abstract :: console_logger
type, extends(test_logger) :: console_logger
contains
procedure(console_logger_is_active), deferred :: is_active
procedure(console_logger_get_failure_info_repr), deferred :: get_failure_info_repr
procedure :: is_active => console_logger_is_active
procedure :: get_failure_info_repr => console_logger_get_failure_info_repr
procedure :: log_message => console_logger_log_message
procedure :: log_error => console_logger_log_error
procedure :: start_drive => console_logger_start_drive
Expand All @@ -29,48 +29,6 @@ module fortuno_consolelogger
end type console_logger


abstract interface

!> Returns whether the logger is active
function console_logger_is_active(this) result(isactive)
import :: console_logger
implicit none

!> Instance
class(console_logger), intent(in) :: this

!> Whether logger is active
logical :: isactive

end function console_logger_is_active


!> Returns the representation of the failure information (called collectively)
subroutine console_logger_get_failure_info_repr(this, failureinfo, location, message,&
& details)
import :: console_logger, failure_info
implicit none

!> Instance
class(console_logger), intent(in) :: this

!> Failure info to get the representation from
type(failure_info), allocatable, intent(in) :: failureinfo

!> Location string (unallocated if not available or not relevant)
character(:), allocatable, intent(out) :: location

!> Message string (unallocated if not available or not relevant)
character(:), allocatable, intent(out) :: message

!> Details string (unallocated if not available or not relevant)
character(:), allocatable, intent(out) :: details

end subroutine console_logger_get_failure_info_repr

end interface


character(*), parameter :: notrun_short_ = "!"
character(*), parameter :: succeeded_short_ = "."
character(*), parameter :: failed_short_ = "F"
Expand Down Expand Up @@ -98,6 +56,49 @@ end subroutine console_logger_get_failure_info_repr

contains


!> Returns whether the logger is active
function console_logger_is_active(this) result(isactive)

!> Instance
class(console_logger), intent(in) :: this

!> Whether logger is active
logical :: isactive

isactive = .true.

end function console_logger_is_active


!> Returns the representation of the failure information (called collectively)
subroutine console_logger_get_failure_info_repr(this, failureinfo, location, message,&
& details)

!> Instance
class(console_logger), intent(in) :: this

!> Failure info to get the representation from
type(failure_info), allocatable, intent(in) :: failureinfo

!> Location string (unallocated if not available or not relevant)
character(:), allocatable, intent(out) :: location

!> Message string (unallocated if not available or not relevant)
character(:), allocatable, intent(out) :: message

!> Details string (unallocated if not available or not relevant)
character(:), allocatable, intent(out) :: details

character(:), allocatable :: buffer

location = failureinfo%location%as_char()
if (allocated(failureinfo%message)) message = failureinfo%message
if (allocated(failureinfo%details)) details = failureinfo%details%as_char()

end subroutine console_logger_get_failure_info_repr


!> Logs a normal message
subroutine console_logger_log_message(this, message)

Expand Down Expand Up @@ -419,4 +420,4 @@ subroutine log_success_(successful)

end subroutine log_success_

end module fortuno_consolelogger
end module fortuno_base_consolelogger
17 changes: 17 additions & 0 deletions src/fortuno/base/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This file is part of Fortuno.
# Licensed under the BSD-2-Clause Plus Patent license.
# SPDX-License-Identifier: BSD-2-Clause-Patent

fortuno_srcs += files(
'argumentparser.f90',
'basetypes.f90',
'checkers.f90',
'consolelogger.f90',
'testcmdapp.f90',
'testcontext.f90',
'testdriver.f90',
'testinfo.f90',
'testlogger.f90',
'utils.f90',
'version.f90',
)
14 changes: 7 additions & 7 deletions src/fortuno/testcmdapp.f90 → src/fortuno/base/testcmdapp.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
! SPDX-License-Identifier: BSD-2-Clause-Patent

!> Contains common code used by the various command line apps
module fortuno_testcmdapp
use fortuno_argumentparser, only : argtypes, argument_def, argument_values, argument_parser,&
module fortuno_base_testcmdapp
use fortuno_base_argumentparser, only : argtypes, argument_def, argument_values, argument_parser,&
& init_argument_parser
use fortuno_basetypes, only : test_item
use fortuno_utils, only : string
use fortuno_testdriver, only : test_driver, test_selection
use fortuno_testlogger, only : test_logger
use fortuno_base_basetypes, only : test_item
use fortuno_base_utils, only : string
use fortuno_base_testdriver, only : test_driver, test_selection
use fortuno_base_testlogger, only : test_logger
implicit none

private
Expand Down Expand Up @@ -177,4 +177,4 @@ function default_argument_defs() result(argdefs)

end function default_argument_defs

end module fortuno_testcmdapp
end module fortuno_base_testcmdapp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
! SPDX-License-Identifier: BSD-2-Clause-Patent

!> Contains the base context definition
module fortuno_testcontext
use fortuno_basetypes, only : test_base, test_ptr_item
use fortuno_testinfo, only : check_result, failure_info, failure_location, init_failure_location,&
module fortuno_base_testcontext
use fortuno_base_basetypes, only : test_base, test_ptr_item
use fortuno_base_testinfo, only : check_result, failure_info, failure_location, init_failure_location,&
& teststatus
implicit none

Expand Down Expand Up @@ -311,4 +311,4 @@ subroutine test_context_create_failure_location(this, failureloc, file, line)

end subroutine test_context_create_failure_location

end module fortuno_testcontext
end module fortuno_base_testcontext
Loading
Loading