Skip to content

Commit

Permalink
refactor: consolidate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed Aug 20, 2024
1 parent 67e36de commit be71b6b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 90 deletions.
35 changes: 0 additions & 35 deletions examples/benchmarks/Makefile

This file was deleted.

3 changes: 2 additions & 1 deletion examples/benchmarks/ana_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include "utils.h"
#include "reader.h"

Expand Down Expand Up @@ -85,7 +86,7 @@ int main(int argc, char** argv) {
float px = particles.getFloat(1,row);
float py = particles.getFloat(2,row);
float pz = particles.getFloat(3,row);
double p = sqrt(px*px+py*py+pz*pz);
double p = std::sqrt(px*px+py*py+pz*pz);
double energy = 0.0;
if(responses.count(row)>0){
c3++;
Expand Down
16 changes: 0 additions & 16 deletions examples/fortran/meson.build

This file was deleted.

78 changes: 43 additions & 35 deletions examples/meson.build
Original file line number Diff line number Diff line change
@@ -1,52 +1,60 @@
external_test_file = get_option('test_file')
have_external_test_file = external_test_file != '' # true if a user specified a test file
test_external = external_test_file != '' # true if a user specified a test file

example_sources = [
# {
# 'sources': list of source code files; the example name will be based off the first one
# 'test_this': boolean, whether or not to run this example as a test
# 'test_args': list of arguments for this example, used for testing
# 'first': boolean, whether this test should be run before any others (default = false)
# 'build_this': whether or not to build this (default = true)
# },
{ 'sources': [ 'bankRowList.cc' ], 'test_this': have_external_test_file, 'test_args': [ external_test_file ] },
{ 'sources': [ 'builder.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'dataframe.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'histograms.cc' ], 'test_this': have_external_test_file, 'test_args': [ external_test_file ] },
{ 'sources': [ 'multithread.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'readEvents.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'readFile.cc' ], 'test_this': true, 'test_args': [ 'example_output.hipo' ] },
{ 'sources': [ 'readFileDebug.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'readFileTags.cc' ], 'test_this': true, 'test_args': [] },
{ 'sources': [ 'readFusion.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'readHist.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'readJson.cc' ], 'test_this': have_external_test_file, 'test_args': [ external_test_file ] },
{ 'sources': [ 'schema.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'showFile.cc' ], 'test_this': true, 'test_args': [ 'example_output.hipo', 'event::particle' ] },
{ 'sources': [ 'tupleFile.cc' ], 'test_this': true, 'test_args': [] },
{ 'sources': [ 'writeEvents.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': ['writeFile.cc' ], 'test_this': true, 'test_args': [], 'first': true },
# { 'sources': [ 'writeFileComposite.cc' ], 'test_this': false, 'test_args': [] }, # FIXME: does not compile
{ 'sources': [ 'writeUserHeader.cc' ], 'test_this': true, 'test_args': [] },
{ 'sources': [ 'bankRowList.cc' ], 'test_this': test_external, 'test_args': [ external_test_file ] },
{ 'sources': [ 'builder.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'dataframe.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'histograms.cc' ], 'test_this': test_external, 'test_args': [ external_test_file ] },
{ 'sources': [ 'multithread.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'readEvents.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'readFile.cc' ], 'test_this': true, 'test_args': [ 'example_output.hipo' ] },
{ 'sources': [ 'readFileDebug.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'readFileTags.cc' ], 'test_this': true, 'test_args': [] },
{ 'sources': [ 'readFusion.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'readHist.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'readJson.cc' ], 'test_this': test_external, 'test_args': [ external_test_file ] },
{ 'sources': [ 'schema.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'showFile.cc' ], 'test_this': true, 'test_args': [ 'example_output.hipo', 'event::particle' ] },
{ 'sources': [ 'tupleFile.cc' ], 'test_this': true, 'test_args': [] },
{ 'sources': [ 'writeEvents.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': ['writeFile.cc' ], 'test_this': true, 'test_args': [], 'first': true },
# { 'sources': [ 'writeFileComposite.cc' ], 'test_this': false, 'test_args': [] }, # FIXME: does not compile
{ 'sources': [ 'writeUserHeader.cc' ], 'test_this': true, 'test_args': [] },
##### benchmarks/
{ 'sources': [ 'benchmarks/ana_benchmark.cc' ], 'test_this': false, 'test_args': [] },
{ 'sources': [ 'benchmarks/map_benchmark.cc' ], 'test_this': false, 'test_args': [] },
##### fortran/
{ 'sources': [ 'fortran/freader.F' ], 'test_this': test_external, 'test_args': [ external_test_file ], 'build_this': get_option('test_fortran') },
]

foreach ex : example_sources
example_name = 'hipo_' + fs.stem(ex['sources'][0])
example_exe = executable(
example_name,
sources: ex['sources'],
include_directories: [ hipo_inc ],
link_with: project_libs,
install: get_option('install_examples'),
cpp_args: [ '-Wno-sign-compare' ], # FIXME: fix the warnings; they are suppressed by these args
)
if(ex.get('test_this', true))
test(
if(ex.get('build_this', true))
example_exe = executable(
example_name,
example_exe,
suite: [ 'example' ],
args: ex.get('test_args', []),
priority: ex.get('first', false) ? 1 : 0, # make sure 'first' tests start before any other
is_parallel: ex.get('first', false) ? false : true, # make sure 'first' tests finish before any other
sources: ex['sources'],
include_directories: [ hipo_inc ],
link_with: project_libs,
install: get_option('install_examples'),
cpp_args: [ '-Wno-sign-compare' ], # FIXME: fix the warnings; they are suppressed by these args
)
if(ex.get('test_this', true))
test(
example_name,
example_exe,
suite: [ 'example' ],
args: ex.get('test_args', []),
priority: ex.get('first', false) ? 1 : 0, # make sure 'first' tests start before any other
is_parallel: ex.get('first', false) ? false : true, # make sure 'first' tests finish before any other
)
endif
endif
endforeach
3 changes: 0 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ subdir('hipo4')

# build examples
subdir('examples')
if(get_option('test_fortran'))
subdir('examples/fortran')
endif
if(ROOT_dep.found())
subdir('examples/root')
endif
Expand Down

0 comments on commit be71b6b

Please sign in to comment.