Debian Codegraph @

test/private/execute_hash_stage.m

raw
1 function [status] = execute_hash_stage(status, ipp)
2 % test stage: check recorded hash checksum
3 calculated = '';
4 expected = '';
5 try
6 expected = getReferenceHash(status, ipp);
7 calculated = calculateMD5Hash(status.tikzStage.texFile);
8
9 % do the actual check
10 if ~strcmpi(expected, calculated)
11 % throw an error to signal the testing framework
12 error('testMatlab2tikz:HashMismatch', ...
13 'The hash "%s" does not match the reference hash "%s"', ...
14 calculated, expected);
15 end
16 catch %#ok
17 e = lasterror('reset'); %#ok
18 [status.hashStage] = errorHandler(e);
19 end
20 status.hashStage.expected = expected;
21 status.hashStage.found = calculated;
22 end
23 % ==============================================================================
24 function hash = getReferenceHash(status, ipp)
25 % retrieves a reference hash from a hash table
26 % WARNING: do not make `hashTable` persistent, since this is slower
27
28 hashTable = loadHashTable(ipp.Results.testsuite);
29 if isfield(hashTable.contents, status.function)
30 hash = hashTable.contents.(status.function);
31 else
32 hash = '';
33 end
34 end