Index: tests/Makefile.in
===================================================================
--- tests/Makefile.in	(revision f806b61240fa8f82c3add1d6bac8a1176b4d9868)
+++ tests/Makefile.in	(revision 07ac6d092667095aa2528937bba2b663c746b8f2)
@@ -384,8 +384,35 @@
 	-quiet @CFA_FLAGS@ -DIN_DIR="${abs_srcdir}/.in/" \
 	${DEBUG_FLAGS} ${INSTALL_FLAGS} ${ARCH_FLAGS}
-PRETTY_PATH = cd ${srcdir} &&
+PRETTY_PATH = mkdir -p $(dir $(abspath ${@})) && cd ${srcdir} &&
 avl_test_SOURCES = avltree/avl_test.cfa avltree/avl0.cfa avltree/avl1.cfa avltree/avl2.cfa avltree/avl3.cfa avltree/avl4.cfa avltree/avl-private.cfa
 # automake doesn't know we still need C/CPP rules so pretend like we have a C program
 _dummy_hack_SOURCES = .dummy_hack.c .dummy_hackxx.cpp
+
+#----------------------------------------------------------------------------------------------------------------
+
+# Use for all tests, make sure the path are correct and all flags are added
+CFACOMPILETEST = $(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) $($(shell echo "${@}_FLAGS" | sed 's/-\|\//_/g'))
+
+# Use for tests that either generate an executable, print directyl to stdout or the make command is expected to fail
+CFATEST_STDOUT = $(CFACOMPILETEST) -o $(abspath ${@})
+
+# Use for tests where the make command is expecte to succeed but the expected.txt should be compared to stderr
+CFATEST_STDERR = $(CFACOMPILETEST) 2> $(abspath ${@})
+
+#------------------------------------------------------------------------------
+# TARGET WITH STANDARD RULE BUT CUSTOM FLAGS
+#------------------------------------------------------------------------------
+# Expected failures
+declarationSpecifier_FLAGS = -CFA -XCFA -p
+gccExtensions_FLAGS = -CFA -XCFA -p
+extension_FLAGS = -CFA -XCFA -p
+attributes_FLAGS = -CFA -XCFA -p
+functions_FLAGS = -CFA -XCFA -p
+KRfunctions_FLAGS = -CFA -XCFA -p
+gmp_FLAGS = -lgmp
+
+#------------------------------------------------------------------------------
+# Expected failures
+completeTypeError_FLAGS = -DERR1
 all: all-am
 
@@ -770,74 +797,43 @@
 # implicit rule so not all test require a rule
 % : %.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
+	$(CFATEST_STDOUT)
 
 % : %.cpp
 	$(PRETTY_PATH) $(CXXCOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
 
-declarationSpecifier: declarationSpecifier.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-gccExtensions : gccExtensions.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-extension : extension.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-attributes : attributes.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-functions: functions.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-KRfunctions : KRfunctions.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-sched-ext-parse : sched-ext-parse.c $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -CFA -XCFA -p $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-gmp : gmp.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -lgmp $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
+#------------------------------------------------------------------------------
+# CUSTOM TARGET
+#------------------------------------------------------------------------------
+typedefRedef-ERR1: typedefRedef.cfa $(CFACC)
+	$(CFATEST_STDOUT) -DERR1
+
+alloc-ERROR: alloc.cfa $(CFACC)
+	$(CFATEST_STDOUT) -DERR1
+
+nested-types-ERR1: nested-types.cfa $(CFACC)
+	$(CFATEST_STDOUT) -DERR1
+
+nested-types-ERR2: nested-types.cfa $(CFACC)
+	$(CFATEST_STDOUT) -DERR2
+
+raii/dtor-early-exit-ERR1: raii/dtor-early-exit.cfa $(CFACC)
+	$(CFATEST_STDOUT) -DERR1
+
+raii/dtor-early-exit-ERR2: raii/dtor-early-exit.cfa $(CFACC)
+	$(CFATEST_STDOUT) -DERR2
+
+raii/memberCtors-ERR1: raii/memberCtors.cfa $(CFACC)
+	$(CFATEST_STDOUT) -DERR1
+
+raii/ctor-autogen-ERR1: raii/ctor-autogen.cfa $(CFACC)
+	$(CFATEST_STDOUT) -DERR1
 
 #builtins
 builtins/sync: builtins/sync.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only
-
-#------------------------------------------------------------------------------
-
-#To make errors path independent we need to cd into the correct directories
-completeTypeError : completeTypeError.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-typedefRedef-ERR1: typedefRedef.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-alloc-ERROR: alloc.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-fallthrough-ERROR: fallthrough.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-nested-types-ERR1: nested-types.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-nested-types-ERR2: nested-types.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-# Constructor/destructor tests
-raii/dtor-early-exit-ERR1: raii/dtor-early-exit.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-raii/dtor-early-exit-ERR2: raii/dtor-early-exit.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -DERR2 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-raii/memberCtors-ERR1: raii/memberCtors.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
-
-raii/ctor-autogen-ERR1: raii/ctor-autogen.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) -DERR1 $(shell realpath --relative-to=${srcdir} ${<}) -o $(abspath ${@})
+	$(CFATEST_STDERR) -fsyntax-only
 
 # Warnings
 warnings/self-assignment: warnings/self-assignment.cfa $(CFACC)
-	$(PRETTY_PATH) $(CFACOMPILE) $(shell realpath --relative-to=${srcdir} ${<}) 2> $(abspath ${@}) -fsyntax-only
+	$(CFATEST_STDERR) -fsyntax-only
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
