From 4966eea356a93837c1116a630c1c5ae27114454d Mon Sep 17 00:00:00 2001
From: sebastien <sebastien@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Thu, 11 Jun 2009 15:36:02 +0000
Subject: [PATCH] 4.0: merged r2760 changeset from trunk (testsuite for Octave)

git-svn-id: https://www.dynare.org/svn/dynare/branches/4.0@2762 ac1d8469-bf42-47a9-8791-bf33cf982152
---
 Makefile                | 13 +++++--
 tests/Makefile          | 76 +++++++++++++++++++++++++++++++++++++++++
 tests/run_test_octave.m | 38 +++++++++++++++++++++
 3 files changed, 125 insertions(+), 2 deletions(-)
 create mode 100644 tests/Makefile
 create mode 100644 tests/run_test_octave.m

diff --git a/Makefile b/Makefile
index 4bdd337dd2..7fabee88e9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,20 @@
-# Makefile for creating the source tarball
+DYNARE_VERSION=4.0.4
 
-DYNAREBASE=dynare-4.0.4
+DYNAREBASE=dynare-$(DYNARE_VERSION)
+
+all:
+.PHONY: all
+
+check:
+	make -C tests $@ DYNARE_VERSION=$(DYNARE_VERSION)
+.PHONY: check
 
 srctarball:
 	make -C preprocessor clean
 	make -C doc clean
+	make -C tests clean
 	rm -f matlab/dynare_m matlab/dynare_m.exe
 	rm -f mex/2007a/* mex/2007b/* mex/octave/*.mex
 	rm -f windows/*.exe
 	tar cvzf ../$(DYNAREBASE).tar.gz --transform 's,^\./,$(DYNAREBASE)/,' --exclude=debian --exclude='*~' --exclude-vcs .
+.PHONY: srctarball
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000000..9b2be49708
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,76 @@
+OCTAVE = octave
+
+DYNARE_ROOT = `pwd`/../matlab
+
+# Under Octave we only test a subset of MOD files, because of missing features (models with unit roots, reading Excel files)
+OCTAVE_MODS = \
+	ramst.mod \
+	ramst_a.mod \
+	example1.mod \
+	t_sgu_ex1.mod \
+	arima/mod1.mod \
+	arima/mod1a.mod \
+	arima/mod2.mod \
+	arima/mod2c.mod \
+	fs2000/fs2000.mod \
+	homotopy/ramst_homotopy.mod
+
+MODS = $(OCTAVE_MODS) \
+	arima/mod1b.mod \
+	arima/mod1c.mod \
+	arima/mod2a.mod \
+	arima/mod2b.mod \
+	fs2000/fs2000a.mod \
+	bvar_a_la_sims/bvar_standalone.mod \
+	bvar_a_la_sims/bvar_and_dsge.mod
+
+check: check-octave check-matlab
+.PHONY: check
+
+check-octave: $(OCTAVE_MODS)
+ifdef OCTAVE
+	@set -e; \
+		for modfile in $(OCTAVE_MODS); do \
+			GNUTERM=dumb $(OCTAVE) --norc --silent --no-history run_test_octave.m $$modfile $(DYNARE_ROOT) $(DYNARE_VERSION); \
+		done
+endif
+.PHONY: check-octave
+
+check-matlab: $(MODS)
+# MATLAB stuff to be added here
+.PHONY: check-matlab
+
+clean:
+	# Files generated by the preprocessor
+	rm -f $(patsubst %.mod, %.m, $(MODS)) \
+		$(patsubst %.mod, %_static.m, $(MODS)) \
+		$(patsubst %.mod, %_dynamic.m, $(MODS))
+
+	# Results
+	rm -f $(patsubst %.mod, %_results.mat, $(MODS)) \
+		$(patsubst %.mod, %_mode.mat, $(MODS)) \
+		$(patsubst %.mod, %_mh_mode.mat, $(MODS)) \
+		$(patsubst %.mod, %_mean.mat, $(MODS)) \
+		$(patsubst %.mod, %_pindx.mat, $(MODS)) \
+		$(patsubst %.mod, %_params.mat, $(MODS)) \
+		$(patsubst %.mod, %.log, $(MODS))
+	rm -rf $(patsubst %.mod, %, $(MODS))
+
+	# Graphics
+	rm -f $(patsubst %.mod, %*.pdf, $(MODS)) \
+		$(patsubst %.mod, %*.eps, $(MODS)) \
+		$(patsubst %.mod, %*.fig, $(MODS))
+
+	# Files generated by csminwel.m
+	rm -f $(shell find -name g1.mat) \
+		$(shell find -name g2.mat) \
+		$(shell find -name g3.mat) \
+		$(shell find -name H.dat)
+
+	# Generated data files
+	rm -f arima/data1.m arima/data2.m
+
+	# Backup files
+	rm -f $(shell find -name '*~')
+
+.PHONY: clean
diff --git a/tests/run_test_octave.m b/tests/run_test_octave.m
new file mode 100644
index 0000000000..9c81c692ad
--- /dev/null
+++ b/tests/run_test_octave.m
@@ -0,0 +1,38 @@
+## Copyright (C) 2009 Dynare Team
+##
+## This file is part of Dynare.
+##
+## Dynare is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## Dynare is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
+
+## First argument is MOD file (possibly with a path prefix)
+## Second argument is path to Dynare installation to be checked
+## Third argument is Dynare version to be checked
+
+[directory, name, ext] = fileparts(argv(){1});
+
+printf("TEST: %s...\n", name)
+
+addpath(argv(){2})
+
+if !strcmp(dynare_version(), argv(){3})
+  error("Incorrect version of Dynare is being tested")
+endif
+
+cd(directory)
+
+dynare(name)
+
+## Local variables:
+## mode: Octave
+## End:
-- 
GitLab