Skip to content

Commit cdab1cf

Browse files
committed
Fix ep 3 dockerfile test
1 parent 808c29d commit cdab1cf

File tree

5 files changed

+49
-16
lines changed

5 files changed

+49
-16
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ FROM mcr.microsoft.com/vscode/devcontainers/base:$DEBIAN_VERSION
55
RUN apt update
66
RUN apt upgrade -y
77
RUN 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
99
RUN apt clean && rm -rf /var/lib/apt/lists/*
1010

1111
# Install fpm
1212
RUN 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
1313
RUN 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
1619
ENV OMPI_MCA_rmaps_base_oversubscribe=true
1720

docker/Dockerfile.ep-3

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,52 @@ COPY --chown=vscode episodes/3-writing-your-first-unit-test /home/vscode/3-writi
66

77
WORKDIR /home/vscode/3-writing-your-first-unit-test/challenge
88

9-
# Rebuild without pFUnit
9+
# Build with CMake
1010
RUN cmake -B build-std && \
1111
cmake --build build-std
1212

13-
# Test without pFUnit
13+
# Test with CMake
1414
RUN 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
2955
RUN cmake -B build-std && \
3056
cmake --build build-std
3157

episodes/3-writing-your-first-unit-test/challenge/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Top level variables
22
ROOT_DIR = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
3-
FC = gfortran
3+
FC ?= gfortran
44

55
#------------------------------------#
66
# Targets for compiling src #

episodes/3-writing-your-first-unit-test/challenge/test/standard_fortran/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

1212
tests: $(STANDARD_FORTRAN_TEST_EXE)

episodes/3-writing-your-first-unit-test/solution/pfunit/Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
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
58
TEST_FLAGS = -I$(BUILD_DIR) $(PFUNIT_EXTRA_FFLAGS)
9+
endif
610

711
# Define variables to be picked up by make_pfunit_test
812
tests_TESTS = \

0 commit comments

Comments
 (0)