Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for error termination in a pure procedure #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@
*.exe
*.out
*.app

# Build directories
build*
22 changes: 9 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
FC ?= gfortran

testdir := tests
builddir := build
builddir := build-$(FC)

features := $(wildcard $(testdir)/*)
tests := $(subst $(testdir)/,,$(foreach feature,$(features),$(wildcard $(feature)/*)))
Expand All @@ -13,17 +11,17 @@ $(builddir):

define FEATURE_DIR_RULE

$(builddir)/$(subst $(testdir)/,,$(1)): $(builddir)
mkdir $@
$(builddir)/$(1): $(builddir)
mkdir $(builddir)/$(1)

endef

$(foreach feature,$(features),$(eval $(call FEATURE_DIR_RULE,$(feature))))
$(foreach feature,$(features),$(eval $(call FEATURE_DIR_RULE,$(subst $(testdir)/,,$(feature)))))

define TEST_DIR_RULE

$(builddir)/$(1): $(builddir)/$(1)
mkdir $@
$(builddir)/$(1): $(builddir)/$(dir $(1))
mkdir $(builddir)/$(1)

endef

Expand All @@ -32,12 +30,10 @@ $(foreach test,$(tests),$(eval $(call TEST_DIR_RULE,$(test))))
define TEST_RULE

$(builddir)/$(1)/RESULT: $(builddir)/$(1)/main.exe
$^ || true
$(if $(not $(exists $@)) echo "FAILED" > $@)
cd $(builddir)/$(1) && ./main.exe || echo FAILED > RESULT

$(builddir)/$(1)/main.exe: $(1)/main.f90 $(builddir)/$(1)
$FC $^ -o $@ || true
$(if $(not $(exits $@)) touch $@)
$(builddir)/$(1)/main.exe: $(testdir)/$(1)/main.f90 $(builddir)/$(1)
$(FC) $(testdir)/$(1)/main.f90 -o $(builddir)/$(1)/main.exe || touch $(builddir)/$(1)/main.exe

endef

Expand Down
14 changes: 14 additions & 0 deletions tests/error-stop-in-pure/internal-subroutine-no-code/main.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
program main
!! Check whether error stop is allowed inside a pure procedure
implicit none

integer file_unit

open(newunit=file_unit, file="RESULT", status="REPLACE")
write(file_unit,'(a)') "PASSED"

contains
pure subroutine error_stop_in_pure()
error stop
end subroutine
end program