From 63bcd2558e39b0a9a44d7425f9d08ab8aab59406 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Wed, 23 Feb 2022 12:12:08 +0100
Subject: [PATCH] Testsuite: when running Octave, use --no-window-system option
 rather than forcing gnuplot toolkit

In practice --no-window-system currently implies the gnuplot toolkit with dumb
terminal, but it is cleaner this way.
---
 tests/Makefile.am                   | 6 +++---
 tests/run_block_byte_tests_octave.m | 5 -----
 tests/run_reporting_test_octave.m   | 7 +------
 tests/run_test_octave.m             | 6 +-----
 4 files changed, 5 insertions(+), 19 deletions(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 823641da4c..df950cf4ff 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1435,7 +1435,7 @@ check-matlab-ols: $(M_OLS_TRS_FILES)
 %.o.trs %.o.log: %.mod
 	@echo "`tput bold``tput setaf 8`OCTAVE: $(CURDIR)/$*... `tput sgr0`"
 	@DYNARE_VERSION="$(PACKAGE_VERSION)" TOP_TEST_DIR="$(CURDIR)" FILESTEM="$*" \
-		$(OCTAVE) --no-init-file --silent --no-history --path "$*.mod" run_test_octave.m > $*.o.log 2>&1 || \
+		$(OCTAVE) --no-window-system --no-init-file --silent --no-history --path "$*.mod" run_test_octave.m > $*.o.log 2>&1 || \
 	printf ":test-result: FAIL\n:number-tests: 1\n:number-failed-tests: 1\n:list-of-failed-tests: $*.mod\n:elapsed-time: 0.0\n" > $*.o.trs
 	@if test -z "$(filter $*.o.trs,$(O_XFAIL_TRS_FILES))"; then pass_color=2; fail_color=1; else pass_color=1; fail_color=2; fi; \
 	if grep -q ":test-result: PASS" $*.o.trs; then \
@@ -1450,7 +1450,7 @@ check-matlab-ols: $(M_OLS_TRS_FILES)
 %.o.trs %.o.log : %.m
 	@echo "`tput bold``tput setaf 8`OCTAVE: $(CURDIR)/$*... `tput sgr0`"
 	@DYNARE_VERSION="$(PACKAGE_VERSION)" TOP_TEST_DIR="$(CURDIR)" \
-		$(OCTAVE) --no-init-file --silent --no-history $< > $*.o.log 2>&1 || \
+		$(OCTAVE) --no-window-system --no-init-file --silent --no-history $< > $*.o.log 2>&1 || \
 		printf ":test-result: FAIL\n:number-tests: 1\n:number-failed-tests: 1\n:list-of-failed-tests: $*.m\n:elapsed-time: 0.0\n" > $*.o.trs
 	@echo "`tput bold``tput setaf 8`OCTAVE: $(CURDIR)/$* Done!`tput sgr0`"
 
@@ -1464,7 +1464,7 @@ check-matlab-ols: $(M_OLS_TRS_FILES)
 %.o.tls : %.m
 	@echo "`tput bold``tput setaf 8`OCTAVE: $(CURDIR)/$*... `tput sgr0`"
 	@TOP_TEST_DIR="$(CURDIR)"  FILESTEM="$*" \
-		$(OCTAVE) --no-init-file --silent --no-history run_o_script.m 2>&1
+		$(OCTAVE) --no-window-system --no-init-file --silent --no-history run_o_script.m 2>&1
 	@touch $*.o.tls
 	@echo "`tput bold``tput setaf 8`OCTAVE: $(CURDIR)/$* Done!`tput sgr0`"
 
diff --git a/tests/run_block_byte_tests_octave.m b/tests/run_block_byte_tests_octave.m
index b6319ca272..d2533a1427 100644
--- a/tests/run_block_byte_tests_octave.m
+++ b/tests/run_block_byte_tests_octave.m
@@ -30,11 +30,6 @@ if !strcmp(dynare_version(), getenv("DYNARE_VERSION"))
     error("Incorrect version of Dynare is being tested")
 endif
 
-## Ask gnuplot to create graphics in text mode
-## Note that setenv() was introduced in Octave 3.0.2, for compatibility
-## with MATLAB
-putenv("GNUTERM", "dumb")
-
 ## Test block_bytecode/ls2003.mod with various combinations of
 ## block/bytecode/solve_algo/stack_solve_algo
 failedBlock = {};
diff --git a/tests/run_reporting_test_octave.m b/tests/run_reporting_test_octave.m
index 96ea7e35ac..df23692179 100644
--- a/tests/run_reporting_test_octave.m
+++ b/tests/run_reporting_test_octave.m
@@ -1,4 +1,4 @@
-## Copyright (C) 2013-2019 Dynare Team
+## Copyright (C) 2013-2022 Dynare Team
 ##
 ## This file is part of Dynare.
 ##
@@ -25,11 +25,6 @@ if !strcmp(dynare_version(), getenv("DYNARE_VERSION"))
     error("Incorrect version of Dynare is being tested")
 endif
 
-## Ask gnuplot to create graphics in text mode
-## Note that setenv() was introduced in Octave 3.0.2, for compatibility
-## with MATLAB
-putenv("GNUTERM", "dumb")
-
 ## To add default directories, empty dseries objects
 dynare_config();
 
diff --git a/tests/run_test_octave.m b/tests/run_test_octave.m
index e628fa1880..1fdfeb5801 100644
--- a/tests/run_test_octave.m
+++ b/tests/run_test_octave.m
@@ -1,4 +1,4 @@
-## Copyright (C) 2009-2017 Dynare Team
+## Copyright (C) 2009-2022 Dynare Team
 ##
 ## This file is part of Dynare.
 ##
@@ -32,10 +32,6 @@ if !strcmp(dynare_version(), getenv("DYNARE_VERSION"))
     error("Incorrect version of Dynare is being tested")
 endif
 
-## Ask gnuplot to create graphics in text mode
-graphics_toolkit gnuplot;
-setenv("GNUTERM", "dumb");
-
 ## Test MOD files listed in Makefile.am
 name = getenv("FILESTEM");
 [directory, testfile, ext] = fileparts([top_test_dir '/' name]);
-- 
GitLab