From 9450140098721b1c7623792663f11296fc376a89 Mon Sep 17 00:00:00 2001 From: Duc Le Date: Wed, 28 Aug 2024 18:27:06 +0100 Subject: [PATCH] Fix euphonic doc test for R2022b and newer --- test/EuphonicHelpTest.m | 16 +++++++++++----- .../+internal/+doc/+reference/getReferencePage.m | 9 +++++++++ update_module_versions.py | 11 ++++++----- 3 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 test/mymockfuncs/+matlab/+internal/+doc/+reference/getReferencePage.m diff --git a/test/EuphonicHelpTest.m b/test/EuphonicHelpTest.m index 64c85dc..9fb4a74 100644 --- a/test/EuphonicHelpTest.m +++ b/test/EuphonicHelpTest.m @@ -57,11 +57,17 @@ function run_euphonic_doc_tests(testCase) import matlab.unittest.constraints.IsFalse txt_fc_noimport = eval_doc('doc euphonic.ForceConstants'); txt_fc_import = eval_doc_import('doc euphonic.ForceConstants'); - % Checks both cases called "web" with the "-helpbrowser" argument - testCase.verifySubstring(txt_fc_noimport{2}, 'helpbrowser'); - testCase.verifySubstring(txt_fc_import{2}, 'helpbrowser'); - % Checks the two text are different - testCase.verifyThat(strcmp(txt_fc_noimport{1}, txt_fc_import{1}), IsFalse); + if verLessThan('matlab', '9.13') + % Checks both cases called "web" with the "-helpbrowser" argument + testCase.verifySubstring(txt_fc_noimport{2}, 'helpbrowser'); + testCase.verifySubstring(txt_fc_import{2}, 'helpbrowser'); + % Checks the two text are different + testCase.verifyThat(strcmp(txt_fc_noimport{1}, txt_fc_import{1}), IsFalse); + else + % Doc system changed in R2020b does not use the "web" command any more. + testCase.verifySubstring(txt_fc_noimport{1}.Topic, 'ForceConstants'); + testCase.verifySubstring(txt_fc_import{2}, 'helpbrowser'); + end % Checks we still have hyperlinks in the imported version testCase.verifyThat(contains(txt_fc_import{1}, 'href'), IsTrue); % Checks that __init__ method is included diff --git a/test/mymockfuncs/+matlab/+internal/+doc/+reference/getReferencePage.m b/test/mymockfuncs/+matlab/+internal/+doc/+reference/getReferencePage.m new file mode 100644 index 0000000..e02e82b --- /dev/null +++ b/test/mymockfuncs/+matlab/+internal/+doc/+reference/getReferencePage.m @@ -0,0 +1,9 @@ +function [docPage, displayText, primitive] = getReferencePage(varargin) + % Function to overload built-in "getReferencePage" function + global web_called_with; + web_called_with = varargin; + displayText = string.empty; + primitive = true; + docPage = []; +end + diff --git a/update_module_versions.py b/update_module_versions.py index 5019354..686dbce 100644 --- a/update_module_versions.py +++ b/update_module_versions.py @@ -4,11 +4,12 @@ def get_module_versions(): # gets the required module versions from `min_requirements.txt` file curdir = os.path.dirname(os.path.abspath(__file__)) - req_file = os.path.join( - curdir, 'euphonic_sqw_models', 'min_requirements.txt') - if not os.path.isfile(req_file): - from update_dependencies import update_submodules - update_submodules('euphonic_sqw_models') + for submodule in [['light_python_wrapper', '+light_python_wrapper'], + ['euphonic_sqw_models', 'min_requirements.txt']]: + if not os.path.isfile(os.path.join(curdir, *submodule)): + from update_dependencies import update_submodules + update_submodules(submodule[0]) + req_file = os.path.join(curdir, 'euphonic_sqw_models', 'min_requirements.txt') with open(req_file, 'r') as minreq: reqstrs = minreq.read().splitlines() reqmods = []