Skip to content

Commit 7124bbf

Browse files
committed
Merge branch 'develop' into 'main'
tools v0.4.1 See merge request njoy/tools!11
2 parents e0eb6b4 + 6c3c373 commit 7124bbf

37 files changed

+494
-100
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#! /bin/bash
2+
echo "
3+
check_return_code() {
4+
if [ \$? -ne 0 ]; then
5+
echo \"Memory leak detected. Test Failed...\"
6+
exit 1
7+
fi
8+
}
9+
10+
" > test_valgrind.sh
11+
12+
find . -iname "*.test" -type f | while IFS= read -r line; do
13+
dirname=$(dirname "$line")
14+
realname=$(basename "$line")
15+
echo "cd ${dirname}; valgrind --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all --error-exitcode=1 ./${realname}; check_return_code; cd -" >> test_valgrind.sh
16+
done

.github/workflows/ContinuousIntegration.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ on:
1111
pull_request:
1212
branches: 'main'
1313

14+
# ubuntu-22.04 is x64
15+
# macos-13 is intel
16+
# macos-14 is arm64 (M1)
1417
jobs:
1518
build:
1619
runs-on: ${{matrix.os}}
1720
strategy:
1821
matrix:
19-
os: [ ubuntu-22.04, macos-12 ]
22+
os: [ ubuntu-22.04, macos-13, macos-14 ]
2023
cxx: [ clang++, g++-12 ]
2124
build_type: [ Debug, Release ]
2225

@@ -29,11 +32,24 @@ jobs:
2932
- name: mkdir bin
3033
run: mkdir bin
3134
- name: cmake
32-
run: cmake -DPYTHON_EXECUTABLE=$(which python3) -D CMAKE_CXX_COMPILER=`which ${{matrix.cxx}}` -D CMAKE_BUILD_TYPE=${{matrix.build_type}} -D tools.tests=ON ..
35+
run: cmake -DCMAKE_CXX_FLAGS="-gdwarf-4" -DPYTHON_EXECUTABLE=$(which python3) -D CMAKE_CXX_COMPILER=`which ${{matrix.cxx}}` -D CMAKE_BUILD_TYPE=${{matrix.build_type}} -D tools.tests=ON ..
3336
working-directory: ./bin
3437
- name: make
3538
run: make -j2
3639
working-directory: ./bin
3740
- name: ctest
3841
run: ctest -j2
3942
working-directory: ./bin
43+
44+
- name: Setup Valgrind on Ubuntu
45+
if: ${{matrix.os == 'ubuntu-22.04'}}
46+
run: |
47+
sudo apt-get install valgrind;
48+
bash .github/scripts/prep_valgrind_test.sh
49+
working-directory: .
50+
51+
- name: Run tests with Valgrind
52+
if: ${{matrix.os == 'ubuntu-22.04'}}
53+
run: |
54+
bash test_valgrind.sh
55+
working-directory: .

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
# Preamble
33
########################################################################
44

5-
cmake_minimum_required( VERSION 3.24 )
5+
cmake_minimum_required( VERSION 3.27 )
66

77
set( subproject OFF )
88
if( DEFINED PROJECT_NAME )
99
set( subproject ON )
1010
endif()
1111

1212
project( tools
13-
VERSION 0.4.0
13+
VERSION 0.4.1
1414
LANGUAGES CXX
1515
)
1616

@@ -83,7 +83,7 @@ if( tools.python )
8383

8484
target_link_libraries( tools.python PRIVATE tools )
8585
target_include_directories( tools.python PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/python/src )
86-
target_compile_options( tools.python PRIVATE "-fvisibility=hidden" )
86+
set_target_properties( tools.python PROPERTIES CXX_VISIBILITY_PRESET hidden)
8787
set_target_properties( tools.python PROPERTIES OUTPUT_NAME tools )
8888
set_target_properties( tools.python PROPERTIES COMPILE_DEFINITIONS "PYBIND11" )
8989
set_target_properties( tools.python PROPERTIES POSITION_INDEPENDENT_CODE ON )

ReleaseNotes.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Release Notes—tools
22
Given here are some release notes for tools.
33

4+
## tools v0.4.1
5+
Bug fixes:
6+
- iterator guards were added to the disco parser to avoid valgrind errors in ENDFtk.
7+
- the stride_view iterator was missing the reference type, which is required to create vectors using these stride view iterators in C++17.
8+
9+
A few updates were made in the CMake files for Windows compilation issues. The GitHub CI was also updated: macos-14 (arm64 architecture) was added in addition to macos-13 (intel architecture).
10+
411
## [tools v0.4.0](https://github.com/njoy/tools/pull/44)
512
New features:
613
- added a partial implementation of the C++23 ranges standard: chunk_view, chunk_by_view, stride_view and repeat_view (LLVM implementations for these views were used as models for our C++17 based implementations)

cmake/dependencies.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required( VERSION 3.24 )
1+
cmake_minimum_required( VERSION 3.27 )
22
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/.cmake)
33
include( shacl_FetchContent )
44
#######################################################################

src/tools/Log.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ namespace tools {
1616
*/
1717
class Log {
1818

19-
static auto initialize_logger() {
19+
static std::shared_ptr<spdlog::logger> initialize_logger() {
2020

21-
auto instance = spdlog::stdout_color_st( "njoy" );
21+
std::shared_ptr<spdlog::logger> instance = spdlog::stdout_color_st( "njoy" );
2222
instance->set_pattern( "[%^%l%$] %v" );
2323
#ifndef NDEBUG
2424
instance->set_level( spdlog::level::debug );
2525
#endif
2626
return instance;
2727
}
2828

29-
static auto& logger() {
29+
static std::shared_ptr<spdlog::logger>& logger() {
3030

31-
static auto instance = initialize_logger();
31+
static std::shared_ptr<spdlog::logger> instance = initialize_logger();
3232
return instance;
3333
}
3434

src/tools/disco/BaseField/test/BaseField.test.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@ class TestBaseField : protected BaseField {
1818

1919
SCENARIO( "BaseField" ) {
2020

21-
std::string string = " a\t\n\r\n\f";
22-
string += char{ std::char_traits<char>::eof() };
21+
std::string string = "+abc";
2322
auto iter = string.begin();
2423
unsigned int position = 0;
2524

26-
string = "+abc";
27-
position = 0;
28-
iter = string.begin();
2925
TestBaseField::skipPlusSign( iter, position );
3026
CHECK( iter == string.begin() + 1 );
3127
CHECK( position == 1 );

src/tools/disco/BaseFixedWidthField/test/BaseFixedWidthField.test.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@ class TestBaseFixedWidthField : protected BaseFixedWidthField< Width > {
2020

2121
SCENARIO( "BaseFixedWidthField" ) {
2222

23-
std::string string = " a\t\n\r\n\f";
24-
string += char{ std::char_traits<char>::eof() };
23+
std::string string = "+abc";
2524
auto iter = string.begin();
2625
unsigned int position = 0;
2726

28-
string = "+abc";
29-
position = 0;
30-
iter = string.begin();
3127
TestBaseFixedWidthField< 6 >::skipPlusSign( iter, position );
3228
CHECK( iter == string.begin() + 1 );
3329
CHECK( position == 1 );

src/tools/disco/Character.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@ class Character : public BaseFixedWidthField< Width > {
3838
* @param[in,out] iter an iterator to a character in a range
3939
*/
4040
template < typename Representation, typename Iterator >
41-
static Representation read( Iterator& iter, const Iterator& ) {
41+
static Representation read( Iterator& iter, const Iterator& end ) {
4242

4343
Representation value;
44+
if ( iter >= end ) {
45+
46+
return value;
47+
}
4448
value.reserve( Width );
4549

4650
unsigned int position = 0;
47-
while( position < Width && ! ( isNewLine( iter ) || isEndOfFile( iter ) ) ) {
51+
while( position < Width && ! isNewLine( iter ) ) {
4852

4953
++position;
5054
value.push_back( *iter++ );

src/tools/disco/Column.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class Column : public BaseFixedWidthField< Width > {
3737
* @param[in,out] iter an iterator to a character in a range
3838
*/
3939
template < typename Iterator >
40-
static void read( Iterator& iter, const Iterator& ) {
40+
static void read( Iterator& iter, const Iterator& end ) {
4141

4242
unsigned int position = 0;
43-
while( position < Width && ! ( isNewLine( iter ) || isEndOfFile( iter ) ) ) {
43+
while( position < Width && ! ( isNewLine( iter ) || iter >= end ) ) {
4444

4545
++position;
4646
++iter;

0 commit comments

Comments
 (0)