File tree Expand file tree Collapse file tree 5 files changed +49
-16
lines changed
episodes/3-writing-your-first-unit-test Expand file tree Collapse file tree 5 files changed +49
-16
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,16 @@ FROM mcr.microsoft.com/vscode/devcontainers/base:$DEBIAN_VERSION
55RUN apt update
66RUN apt upgrade -y
77RUN apt install -y --no-install-recommends \
8- gfortran git wget cmake python3-pip m4 openmpi-bin openmpi-doc libopenmpi-dev
8+ gfortran git wget cmake python3-pip m4 openmpi-bin openmpi-doc libopenmpi-dev python3.11-venv
99RUN apt clean && rm -rf /var/lib/apt/lists/*
1010
1111# Install fpm
1212RUN wget -O /usr/bin/fpm https://github.com/fortran-lang/fpm/releases/download/v0.10.1/fpm-0.10.1-linux-x86_64 && chmod 555 /usr/bin/fpm
1313RUN apt update && apt install -y locales && rm -rf /var/lib/apt/lists/* && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
1414
15+ # Create symlink to python3
16+ RUN ln -s /usr/bin/python3 /usr/bin/python
17+
1518# Allow MPI to oversubscribe
1619ENV OMPI_MCA_rmaps_base_oversubscribe=true
1720
Original file line number Diff line number Diff line change @@ -6,26 +6,52 @@ COPY --chown=vscode episodes/3-writing-your-first-unit-test /home/vscode/3-writi
66
77WORKDIR /home/vscode/3-writing-your-first-unit-test/challenge
88
9- # Rebuild without pFUnit
9+ # Build with CMake
1010RUN cmake -B build-std && \
1111 cmake --build build-std
1212
13- # Test without pFUnit
13+ # Test with CMake
1414RUN ctest --test-dir build-std --output-on-failure
1515
16+ # Build with Make
17+ RUN FC=/usr/bin/f95 make tests
18+
19+ # Test with Make
20+ RUN ./build/standard_fortran_tests
1621
17- # Test the Solution code
1822
19- # Cleanup directories
20- RUN rm -rf build-std build-pf
23+ # Test the Solution code
2124
2225# Copy solution code
23- RUN cp ../solution/test_temp_conversions.f90 test/standard_fortran/ && \
24- cp ../solution/test_temp_conversions.pf test/pfunit/
26+ RUN cp ../solution/standard_fortran/test_temp_conversions.f90 test/standard_fortran/test_temp_conversions.f90 && \
27+ cp ../solution/pfunit/* test/pfunit/
28+
29+ # Build with make
30+
31+ # Uncomment pfunit comments
32+ RUN sed -i -E 's/tests: standard_fortran_tests \#\| pfunit_tests/tests: standard_fortran_tests \| pfunit_tests/g' Makefile
33+ RUN sed -i -E 's/clean: \#clean_pfunit/clean: clean_pfunit/g' Makefile
34+
35+ # Clean up anything from the previous builds
36+ RUN make clean
37+ RUN rm -rf build-std
38+
39+ # Build
40+ RUN FC=/usr/bin/f95 PFUNIT_SOURCE_DIR=/home/vscode/pfunit make tests
41+
42+ # Run pFUnit tests
43+ RUN ./test/pfunit/tests
44+
45+ # Run standard_fortran tests
46+ RUN ./build/standard_fortran_tests
47+
48+ # Run cleanup again
49+ RUN make clean
50+
2551
26- RUN ls test/pfunit/
52+ # Build with CMake
2753
28- # Rebuild without pFUnit
54+ # Build without pFUnit
2955RUN cmake -B build-std && \
3056 cmake --build build-std
3157
Original file line number Diff line number Diff line change 11# Top level variables
22ROOT_DIR = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST ) ) ) )
3- FC = gfortran
3+ FC ? = gfortran
44
55# ------------------------------------#
66# Targets for compiling src #
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ $(BUILD_DIR)/%.o: $(STANDARD_FORTRAN_TEST_DIR)/%.f90 | $(BUILD_DIR)
66 $(FC ) -c -J $(BUILD_DIR ) -o $@ $<
77
88# Build test executable
9- $(STANDARD_FORTRAN_TEST_EXE ) : $(TEST_OBJS ) | $(SRC_OBJS )
10- $(FC ) -o $@ $^
9+ $(STANDARD_FORTRAN_TEST_EXE ) : $(TEST_OBJS ) $(SRC_OBJS )
10+ $(FC ) -o $@ $?
1111
1212tests : $(STANDARD_FORTRAN_TEST_EXE )
Original file line number Diff line number Diff line change 1- PFUNIT_SOURCE_DIR = $(ROOT_DIR ) /../../../pfunit
2- PFUNIT_INCLUDE_DIR = $( PFUNIT_SOURCE_DIR ) /build/installed/PFUNIT- 4.12/include
3- include $( PFUNIT_INCLUDE_DIR ) / PFUNIT.mk
1+ PFUNIT_SOURCE_DIR ? = $(ROOT_DIR ) /../../../pfunit
2+ PFUNIT_VERSION ?= 4.12
3+ PFUNIT_INCLUDE_DIR = $( PFUNIT_SOURCE_DIR ) /build/installed/ PFUNIT- $( PFUNIT_VERSION ) /include
44
5+ # Don't try to include if we're cleaning as this doesn't depend on pFUnit
6+ ifneq ($(MAKECMDGOALS ) ,clean)
7+ include $(PFUNIT_INCLUDE_DIR ) /PFUNIT.mk
58TEST_FLAGS = -I$(BUILD_DIR ) $(PFUNIT_EXTRA_FFLAGS )
9+ endif
610
711# Define variables to be picked up by make_pfunit_test
812tests_TESTS = \
You can’t perform that action at this time.
0 commit comments