File: testHeadless.m

package info (click to toggle)
matlab2tikz 1.1.0-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,668 kB
  • sloc: objc: 6,143; makefile: 55; sh: 40
file content (62 lines) | stat: -rw-r--r-- 2,211 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function [ status ] = testHeadless( varargin )
%TESTGRAPHICAL Runs the M2T test suite without graphical output
%
% This is quite a thin wrapper around testMatlab2tikz to run the test suite to
% produce a textual report and checks for regressions by checking the MD5 hash
% of the output
%
% Its allowed arguments are the same as those of testMatlab2tikz.
%
% Usage:
%
%     status = TESTHEADLESS(...) % gives programmatical access to the data
%
%     TESTHEADLESS(...); % automatically invokes makeTravisReport afterwards
%
% See also: testMatlab2tikz, testGraphical, makeTravisReport

% The width and height are specified to circumvent different DPIs in developer
% machines. The float format reduces the probability that numerical differences
% in the order of numerical precision disrupt the output.
    extraOptions = {'width' ,'\figureWidth', ...
                    'height','\figureHeight',...
                    'floatFormat', '%4g',    ... % see #604
                    'extraCode',{            ...
                        '\newlength\figureHeight \setlength{\figureHeight}{6cm}', ...
                        '\newlength\figureWidth \setlength{\figureWidth}{10cm}'}
                   };

    [state] = initializeGlobalState();
    finally_restore_state = onCleanup(@() restoreGlobalState(state));

    status = testMatlab2tikz('extraOptions', extraOptions, ...
                             'actionsToExecute', @actionsToExecute, ...
                             varargin{:});

    if nargout == 0
        makeTravisReport(status);
    end
end
% ==============================================================================
function status = actionsToExecute(status, ipp)
    status = execute_plot_stage(status, ipp);

    if status.skip
        return
    end

    status = execute_tikz_stage(status, ipp);
    status = execute_hash_stage(status, ipp);
    status = execute_type_stage(status, ipp);

    if ~status.closeall && ~isempty(status.plotStage.fig_handle)
        try
            close(status.plotStage.fig_handle);
        catch
            close('all');
        end
    else
        close all;
    end
end
% ==============================================================================