changeset 23326:71a749eeb7d3 stable

test: publish to a temporary directory to ensure write access. * test/publish/publish.tst: Don't rely on the test directory to be installed in a writeable location. To ensure the integration test to be successful, publish to a temporary directory.
author Kai T. Ohlhus <k.ohlhus@gmail.com>
date Thu, 23 Mar 2017 09:11:35 +0100
parents 336f2e8331fa
children e4bef84213e7 0f1e9743b0a9
files test/publish/publish.tst
diffstat 1 files changed, 31 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/test/publish/publish.tst	Tue Mar 21 15:06:04 2017 -0400
+++ b/test/publish/publish.tst	Thu Mar 23 09:11:35 2017 +0100
@@ -1,3 +1,21 @@
+## Copyright (C) 2016-2017 Kai T. Ohlhus
+##
+## This file is part of Octave.
+##
+## Octave 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.
+##
+## Octave 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 Octave; see the file COPYING.  If not, see
+## <http://www.gnu.org/licenses/>.
+
 ## test for publish
 
 %!test
@@ -16,11 +34,14 @@
 %!   set (0, "defaultfigurevisible", "off");
 %!
 %!   scripts = dir ("test_script*.m");
+%!   tmpDir = tempname ();
+%!   mkdir (tmpDir);
+%!   opts.outputDir = tmpDir;
 %!   for fname = {scripts.name}
-%!     publish (fname{1});
+%!     publish (fname{1}, opts);
 %!   endfor
 %!   confirm_recursive_rmdir (false, "local");
-%!   rmdir ("html", "s");
+%!   rmdir (tmpDir, "s");
 %! unwind_protect_cleanup
 %!   set (0, "defaultfigurevisible", visibility);
 %!   graphics_toolkit (toolkit);
@@ -42,12 +63,16 @@
 %!     end_try_catch
 %!   endif
 %!   set (0, "defaultfigurevisible", "off");
-%!
-%!   publish ("test_script.m");
+%!   ## Create temporary directory
+%!   tmpDir = tempname ();
+%!   mkdir (tmpDir);
+%!   opts.outputDir = tmpDir;
+%!   ## Call publish and grabcode
+%!   publish ("test_script.m", opts);
 %!   str1 = fileread ("test_script.m");
-%!   str2 = grabcode ("html/test_script.html");
+%!   str2 = grabcode (fullfile (tmpDir, "test_script.html"));
 %!   confirm_recursive_rmdir (false, "local");
-%!   rmdir ("html", "s");
+%!   rmdir (tmpDir, "s");
 %!   ## Canonicalize strings
 %!   str1 = strjoin (deblank (strsplit (str1, "\n")), "\n");
 %!   str2 = strjoin (deblank (strsplit (str2, "\n")), "\n");