...
Code Block |
---|
. ├── mod ├── src │ └── <your_module>.f90 ├── test │ ├── <your_module>_test.f90 │ ├── fruit_generator.rb | └──├── fruit.f90 | └── Makefile └── rake_base.rb |
- fruit.f90 - fruit source code
- mod - directory used to store .mod files
- <your_module>.f90 - your actual module
- <your_module>_test.f90 - file with unit tests for your module
- fruit_geneator.rb - script used to generate test driver and basket files
- Makefile - used to compile and run all tests
Install requirements
FRUIT source code
Code Block |
---|
cd <project_dir>/test wget https://githubraw.githubusercontent.com/mortele/FRUIT/blob/master/src/fruit.f90 |
Ruby
...
Download fruit_processog_gem direcotry from FRUIT repository
This could be downloaded anywhereto any location, just to install additional ruby package.
...
To do this:
- Open in your browser
...
- https://github.dev/mortele/FRUIT/tree/master/fruit_processor_gem
- Login if asked
- Right click fruit_processor_gem directory on the project explorer panel and click download.
...
Code Block |
---|
cd <project_dir> wget https://raw.githubusercontent.com/mortele/FRUIT/master/rake_base.rb |
Create project files
calculator.f90
Code Block |
---|
!file <project_directory>/src/calculator.f90
module calculator
implicit none
contains
subroutine add(a,b,output)
integer, intent (in) :: a,b
integer, intent (out) :: output
output=a+b
end subroutine add
end module calculator |
calculator_test.f90
Code Block |
---|
!file <project_directory>/test/calculator_test.f90 module calculator_test use fruit contains subroutine setup print *, "setup subroutine ran" end subroutine setup subroutine teardown print *, "teardown subroutine ran" end subroutine teardown subroutine test_calculator use calculator integer :: result !test add subroutine call add (2,2,result) call assert_equals(4,result) end subroutine test_calculator end module calculator_test |
NOTE: in order to autogenerate test_driver and test_bucket basket files, you need to follow naming convention:
...
Code Block |
---|
#file <project_dir>/test/fruit_generator.rb require 'rubygems' require 'fruit_processor' load "../rake_base.rb" $build_dir = "" $goal = "fruit_driver_dummy" fp = FruitProcessor.new fp.pre_process |
Configuration
You may need to change your compiler from gfortran to other. To do this modify below lines in rake_base.rb file:
Makefile
Code Block |
---|
#file <project_dir>/test/Makefile
compiler=gfortran
option= |
Code Block |
$compiler = 'gfortran' $option = "-Wall -Wextra -Wno-tabs -pedantic -fbounds-check " + "-Wuninitialized -O -g \ -Wno-unused-parameter -cpp" fruit_code = ./fruit.f90 code = ../src/*.f90 ./*_test.f90 code_gen = fruit_basket_gen.f90 fruit_driver_gen.f90 all_code = $(fruit_code) $(code) $(code_gen) driver = fruit_driver all : build run build : $(driver) fruit_basket_gen.f90 : $(code) ruby fruit_generator.rb fruit_driver_gen.f90 : $(code) ruby fruit_generator.rb fruit_driver : $(all_code) $(compiler) $(option) $(all_code) -J ../mod -o fruit_driver clean : rm -f *.o *.mod *.obj fruit_driver rm -f fruit_driver_gen.f90 rm -f fruit_basket_gen.f90 rm -f result.xml result_tmp.xml run : $(driver) ./$(driver) .PHONY : all clean run |
Run tests
Code Block |
---|
cd <project_dir>/test
make |