diff --git a/+dj/+lib/compareVersions.m b/+dj/+lib/compareVersions.m deleted file mode 100644 index 7380bb32..00000000 --- a/+dj/+lib/compareVersions.m +++ /dev/null @@ -1,100 +0,0 @@ -function res = compareVersions(verArray, verComp) - % compareVersions - Semantic version comparison (greater than or equal) - % - % This function evaluates if an array of semantic versions is greater than - % or equal to a reference version. - % - % DISTRIBUTION: - % GitHub: https://github.com/guzman-raphael/compareVersions - % FileExchange: https://www.mathworks.com/matlabcentral/fileexchange/71849-compareversions - % - % res = compareVersions(verArray, verComp) - % INPUT: - % verArray: Cell array with the following conditions: - % - be of length >= 1, - % - contain only string elements, and - % - each element must be of length >= 1. - % verComp: String or Char array that verArray will compare against for - % greater than evaluation. Must be: - % - be of length >= 1, and - % - a string. - % OUTPUT: - % res: Logical array that identifies if each cell element in verArray - % is greater than or equal to verComp. - % TESTS: - % Tests included for reference. From root package directory, - % use command: runtests - % - % EXAMPLES: - % output = compareVersions({'3.2.4beta','9.5.2.1','8.0'}, '8.0.0'); %logical([0 1 1]) - % - % NOTES: - % Tests included for reference. From root package directory, - % use command: runtests - % - % Tested: Matlab 9.5.0.944444 (R2018b) Linux - % Author: Raphael Guzman, DataJoint - % - % $License: MIT (use/copy/change/redistribute on own risk) $ - % $File: compareVersions.m $ - % History: - % 001: 2019-06-12 11:00, First version. - % - % OPEN BUGS: - % - None - res_n = length(verArray); - if ~res_n || max(cellfun(@(c) ~ischar(c) && ... - ~isstring(c),verArray)) > 0 || min(cellfun('length',verArray)) == 0 - msg = { - 'compareVersions:Error:CellArray' - 'Cell array to verify must:' - '- be of length >= 1,' - '- contain only string elements, and' - '- each element must be of length >= 1.' - }; - error('compareVersions:Error:CellArray', sprintf('%s\n',msg{:})); - end - if ~ischar(verComp) && ~isstring(verComp) || length(verComp) == 0 - msg = { - 'compareVersions:Error:VersionRef' - 'Version reference must:' - '- be of length >= 1, and' - '- a string.' - }; - error('compareVersions:Error:VersionRef', sprintf('%s\n',msg{:})); - end - res = false(1, res_n); - for i = 1:res_n - shortVer = strsplit(verArray{i}, '.'); - shortVer = cellfun(@(x) str2double(regexp(x,'\d*','Match')), shortVer(1,:)); - longVer = strsplit(verComp, '.'); - longVer = cellfun(@(x) str2double(regexp(x,'\d*','Match')), longVer(1,:)); - shortVer_p = true; - longVer_p = false; - shortVer_s = length(shortVer); - longVer_s = length(longVer); - - if shortVer_s > longVer_s - [longVer shortVer] = deal(shortVer,longVer); - [longVer_s shortVer_s] = deal(shortVer_s,longVer_s); - [longVer_p shortVer_p] = deal(shortVer_p,longVer_p); - end - - shortVer = [shortVer zeros(1,longVer_s - shortVer_s)]; - diff = shortVer - longVer; - match = diff ~= 0; - - if ~match - res(i) = true; - else - pos = 1:longVer_s; - pos = pos(match); - val = diff(pos(1)); - if val > 0 - res(i) = shortVer_p; - elseif val < 0 - res(i) = longVer_p; - end - end - end -end diff --git a/+dj/Connection.m b/+dj/Connection.m index 650814ed..ea5d23f9 100644 --- a/+dj/Connection.m +++ b/+dj/Connection.m @@ -27,16 +27,7 @@ % specify the connection to the database. % initQuery is the SQL query to be executed at the start % of each new session. - setupDJ(true); - try - mymVersion = mym('version'); - assert(mymVersion.major > 2 || mymVersion.major==2 && mymVersion.minor>=6) - catch - error 'Outdated version of mYm. Please upgrade to version 2.6 or later' - end - if verLessThan('matlab', '8.6') - error 'MATLAB version 8.6 (R2015b) or greater is required' - end + dj.setup('prompt', ~dj.set('suppressPrompt')); self.host = host; self.user = username; self.password = password; diff --git a/+dj/conn.m b/+dj/conn.m index b6c4cf10..b7899692 100644 --- a/+dj/conn.m +++ b/+dj/conn.m @@ -45,7 +45,6 @@ end end else - % invoke setupDJ % optional environment variables specifying the connection. env = struct(... 'host', 'DJ_HOST', ... diff --git a/+dj/setup.m b/+dj/setup.m new file mode 100644 index 00000000..9df99be9 --- /dev/null +++ b/+dj/setup.m @@ -0,0 +1,80 @@ +function setup(varargin) + p = inputParser; + addOptional(p, 'force', false); + addOptional(p, 'prompt', true); + parse(p, varargin{:}); + force = p.Results.force; + prompt = p.Results.prompt; + persistent INVOKED + if ~isempty(INVOKED) && ~force + return + end + % check MATLAB + if verLessThan('matlab', '9.1') + error('DataJoint:System:UnsupportedMatlabVersion', ... + 'MATLAB version 9.1 (R2016b) or greater is required'); + end + % require certain toolboxes + requiredToolboxes = {... + struct(... + 'Name', 'GHToolbox', ... + 'ResolveTarget', 'datajoint/GHToolbox'... + ), ... + struct(... + 'Name', 'mym', ... + 'ResolveTarget', 'datajoint/mym', ... + 'Version', @(v) compareVersions(v, '2.7.3', @(v_actual,v_ref) v_actual>=v_ref)... + )... + }; + try + ghtb.require(requiredToolboxes, 'prompt', prompt); + catch ME + installPromptMsg = { + 'Toolbox ''%s'' did not meet the minimum requirements.' + 'Would you like to proceed with an upgrade?' + }; + if strcmp(ME.identifier, 'MATLAB:undefinedVarOrClass') && (~prompt || strcmpi('yes',... + dj.internal.ask(sprintf(sprintf('%s\n', installPromptMsg{:}), 'GHToolbox')))) + % fetch + tmp_toolbox = [tempname '.mltbx']; + websave(tmp_toolbox, ['https://github.com/' requiredToolboxes{1}.ResolveTarget ... + '/releases/download/' ... + subsref(webread(['https://api.github.com/repos/' ... + requiredToolboxes{1}.ResolveTarget ... + '/releases/latest'], ... + weboptions('Timeout', 60)), ... + substruct('.', 'tag_name')) ... + '/GHToolbox.mltbx'], weboptions('Timeout', 60)); + % install + try + matlab.addons.install(tmp_toolbox, 'overwrite'); + catch ME + if strcmp(ME.identifier, 'MATLAB:undefinedVarOrClass') + matlab.addons.toolbox.installToolbox(tmp_toolbox); + else + rethrow(ME); + end + end + % remove temp toolbox file + delete(tmp_toolbox); + % retrigger dependency validation + ghtb.require(requiredToolboxes, 'prompt', prompt); + elseif strcmp(ME.identifier, 'MATLAB:undefinedVarOrClass') + GHToolboxMsg = { + 'Toolbox ''GHToolbox'' did not meet the minimum requirements.' + 'Please proceed to install it.' + }; + error('DataJoint:verifyGHToolbox:Failed', ... + sprintf('%s\n', GHToolboxMsg{:})); + else + rethrow(ME) + end + end + % check mym + mymVersion = mym('version'); + assert(mymVersion.major > 2 || mymVersion.major==2 && mymVersion.minor>=6, ... + 'DataJoint:System:mYmIncompatible', ... + 'Outdated version of mYm. Please upgrade to version 2.6 or later'); + % set cache + INVOKED = true; +end \ No newline at end of file diff --git a/+dj/version.m b/+dj/version.m index 2b79a3cb..3efacd05 100644 --- a/+dj/version.m +++ b/+dj/version.m @@ -1,7 +1,7 @@ function varargout = version % report DataJoint version -v = struct('major',3,'minor',3,'bugfix',1); +v = struct('major',3,'minor',3,'bugfix',2); if nargout varargout{1}=v; diff --git a/+tests/+lib/compareVersions.m b/+tests/+lib/compareVersions.m deleted file mode 100644 index 46d7b27d..00000000 --- a/+tests/+lib/compareVersions.m +++ /dev/null @@ -1,100 +0,0 @@ -function res = compareVersions(verArray, verComp) - % compareVersions - Semantic version comparison (greater than or equal) - % - % This function evaluates if an array of semantic versions is greater than - % or equal to a reference version. - % - % DISTRIBUTION: - % GitHub: https://github.com/guzman-raphael/compareVersions - % FileExchange: https://www.mathworks.com/matlabcentral/fileexchange/71849-compareversions - % - % res = compareVersions(verArray, verComp) - % INPUT: - % verArray: Cell array with the following conditions: - % - be of length >= 1, - % - contain only string elements, and - % - each element must be of length >= 1. - % verComp: String or Char array that verArray will compare against for - % greater than evaluation. Must be: - % - be of length >= 1, and - % - a string. - % OUTPUT: - % res: Logical array that identifies if each cell element in verArray - % is greater than or equal to verComp. - % TESTS: - % Tests included for reference. From root package directory, - % use command: runtests - % - % EXAMPLES: - % output = compareVersions({'3.2.4beta','9.5.2.1','8.0'}, '8.0.0'); %logical([0 1 1]) - % - % NOTES: - % Tests included for reference. From root package directory, - % use command: runtests - % - % Tested: Matlab 9.5.0.944444 (R2018b) Linux - % Author: Raphael Guzman, DataJoint - % - % $License: MIT (use/copy/change/redistribute on own risk) $ - % $File: compareVersions.m $ - % History: - % 001: 2019-06-12 11:00, First version. - % - % OPEN BUGS: - % - None - res_n = length(verArray); - if ~res_n || max(cellfun(@(c) ~ischar(c) && ... - ~isstring(c),verArray)) > 0 || min(cellfun('length',verArray)) == 0 - msg = { - 'compareVersions:Error:CellArray' - 'Cell array to verify must:' - '- be of length >= 1,' - '- contain only string elements, and' - '- each element must be of length >= 1.' - }; - error('compareVersions:Error:CellArray', sprintf('%s\n',msg{:})); - end - if ~ischar(verComp) && ~isstring(verComp) || length(verComp) == 0 - msg = { - 'compareVersions:Error:VersionRef' - 'Version reference must:' - '- be of length >= 1, and' - '- a string.' - }; - error('compareVersions:Error:VersionRef', sprintf('%s\n',msg{:})); - end - res = false(1, res_n); - for i = 1:res_n - shortVer = strsplit(verArray{i}, '.'); - shortVer = cellfun(@(x) str2double(regexp(x,'\d*','Match')), shortVer(1,:)); - longVer = strsplit(verComp, '.'); - longVer = cellfun(@(x) str2double(regexp(x,'\d*','Match')), longVer(1,:)); - shortVer_p = true; - longVer_p = false; - shortVer_s = length(shortVer); - longVer_s = length(longVer); - - if shortVer_s > longVer_s - [longVer shortVer] = deal(shortVer,longVer); - [longVer_s shortVer_s] = deal(shortVer_s,longVer_s); - [longVer_p shortVer_p] = deal(shortVer_p,longVer_p); - end - - shortVer = [shortVer zeros(1,longVer_s - shortVer_s)]; - diff = shortVer - longVer; - match = diff ~= 0; - - if ~match - res(i) = true; - else - pos = 1:longVer_s; - pos = pos(match); - val = diff(pos(1)); - if val > 0 - res(i) = shortVer_p; - elseif val < 0 - res(i) = longVer_p; - end - end - end -end \ No newline at end of file diff --git a/+tests/Main.m b/+tests/Main.m deleted file mode 100644 index 4f14f0a7..00000000 --- a/+tests/Main.m +++ /dev/null @@ -1,5 +0,0 @@ -classdef Main < ... - tests.TestConnection & ... - tests.TestRelationalOperand & ... - tests.TestTls -end \ No newline at end of file diff --git a/.gitignore b/.gitignore index c9a8c43f..93700b4f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ *.m~ mym/ -*.mltbx *.env notebook *getSchema.m @@ -8,4 +7,6 @@ docker-compose.yml .vscode matlab.prf win.* -macos.* \ No newline at end of file +macos.* +*.prj +*.mltbx \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29b..00000000 diff --git a/.travis.yml b/.travis.yml index 8bb0c8ab..cba7addc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ jobs: - <<: *slim env: - MATLAB_VERSION: R2019a - - MYSQL_TAG: 8.0 + - MYSQL_TAG: 8.0.18 - <<: *slim env: - MATLAB_VERSION: R2019a @@ -36,4 +36,8 @@ jobs: - <<: *slim env: - MATLAB_VERSION: R2018b + - MYSQL_TAG: 5.7 + - <<: *slim + env: + - MATLAB_VERSION: R2016b - MYSQL_TAG: 5.7 \ No newline at end of file diff --git a/LNX-docker-compose.yml b/LNX-docker-compose.yml index 062b80af..688bb71d 100644 --- a/LNX-docker-compose.yml +++ b/LNX-docker-compose.yml @@ -21,7 +21,6 @@ services: app: <<: *net environment: - - DISPLAY - MATLAB_LICENSE - MATLAB_USER - DJ_HOST=fakeservices.datajoint.io @@ -35,17 +34,51 @@ services: fakeservices.datajoint.io: condition: service_healthy user: ${MATLAB_UID}:${MATLAB_GID} - working_dir: /src - command: > - /bin/bash -c " - matlab -nodisplay -r \"\ - res=run(tests.Main);\ - disp(res);\ - if all([res.Passed]) exit, else exit(1), end;\ - \"; - " + working_dir: /main + command: + - /bin/bash + - -c + - | + export ORIG_DIR=$$(pwd) + mkdir ~/Documents + cd /src + # package into toolbox, and install + matlab -nodisplay -r " + websave([tempdir 'GHToolbox.mltbx'],\ + ['https://github.com/datajoint/GHToolbox' \ + '/releases/download/' subsref(webread(['https://api.github.com/repos' \ + '/datajoint/GHToolbox' \ + '/releases/latest']),\ + substruct('.', 'tag_name')) \ + '/GHToolbox.mltbx']);\ + matlab.addons.toolbox.installToolbox([tempdir 'GHToolbox.mltbx']);\ + fid = fopen('README.md', 'r');\ + docs = fread(fid, '*char')';\ + fclose(fid);\ + ghtb.package('DataJoint',\ + 'Raphael Guzman',\ + 'raphael.h.guzman@gmail.com',\ + ['Scientific workflow management framework built on top of a ' \ + 'relational database.'],\ + docs,\ + {'.vscode', '.git', '*.env', '.gitignore', '.travis.yml', 'tests',\ + 'docs-parts', 'mym', 'erd.m', '*docker-compose.yml', 'LICENSE.txt',\ + 'matlab.prf', 'package.m', 'README.md'},\ + @() strjoin(arrayfun(@(x) num2str(x),\ + cell2mat(struct2cell(dj.version)),\ + 'uni', false),\ + '.'),\ + {'+dj'});\ + matlab.addons.toolbox.installToolbox('DataJoint.mltbx');\ + cd(getenv('ORIG_DIR'));\ + addpath('tests');\ + res=run(Main);\ + disp(res);\ + if all([res.Passed]) exit, else exit(1), end;\ + " mac_address: $MATLAB_HOSTID volumes: + - ./tests:/main/tests - .:/src networks: main: \ No newline at end of file diff --git a/README.md b/README.md index b8da6eb4..7413c5c2 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,40 @@ +[![View DataJoint on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/63218-datajoint) + DataJoint for MATLAB is a high-level programming interface for relational databases designed to support data processing chains in science labs. DataJoint is built on the foundation of the relational data model and prescribes a consistent method for organizing, populating, and querying data. DataJoint was initially developed in 2009 by Dimitri Yatsenko in [Andreas Tolias' Lab](http://toliaslab.org) for the distributed processing and management of large volumes of data streaming from regular experiments. Starting in 2011, DataJoint has been available as an open-source project adopted by other labs and improved through contributions from several developers. +## Installation + +### (Recommended) Greater than R2016b + +1. Utilize MATLAB built-in GUI i.e. *Top Ribbon -> Add-Ons -> Get Add-Ons* +2. Search and Select `DataJoint` +3. Select *Add from GitHub* + +### Using GHToolbox (FileExchange Community Toolbox) + +1. Install *GHToolbox* using using an appropriate method in https://github.com/datajoint/GHToolbox +2. run: `ghtb.install('datajoint/datajoint-matlab')` + +### Less than R2016b -Running Tests Locally -===================== +1. Utilize MATLAB built-in GUI i.e. *Top Ribbon -> Add-Ons -> Get Add-Ons* +2. Search and Select `DataJoint` +3. Select *Download from GitHub* +4. Save `DataJoint.mltbx` locally +5. Navigate in MATLAB tree browser to saved toolbox file +6. Right-Click and Select *Install* +7. Select *Install* +### From Source + +1. Download `DataJoint.mltbx` locally +2. Navigate in MATLAB tree browser to saved toolbox file +3. Right-Click and Select *Install* +4. Select *Install* + +## Running Tests Locally * Create an `.env` with desired development environment values e.g. ``` sh @@ -24,26 +53,26 @@ MYSQL_TAG=5.7 | Use Case | MATLAB Code | | ---------------------------- | ------------------------------------------------------------------------------ | -| Run all tests | `run(tests.Main)` | -| Run one class of tests | `run(tests.TestTls)` | -| Run one specific test | `runtests('tests.TestTls/testInsecureConn')` | -| Run tests based on test name | `import matlab.unittest.TestSuite;`
`import matlab.unittest.selectors.HasName;`
`import matlab.unittest.constraints.ContainsSubstring;`
`suite = TestSuite.fromClass(?tests.Main, ... `
    `HasName(ContainsSubstring('Conn')));`
`run(suite)`| +| Run all tests | `run(Main)` | +| Run one class of tests | `run(TestTls)` | +| Run one specific test | `runtests('TestTls/testInsecureConn')` | +| Run tests based on test name | `import matlab.unittest.TestSuite;`
`import matlab.unittest.selectors.HasName;`
`import matlab.unittest.constraints.ContainsSubstring;`
`suite = TestSuite.fromClass(?Main, ... `
    `HasName(ContainsSubstring('Conn')));`
`run(suite)`| + +### Launch Jupyter Notebook -Launch Jupyter Notebook ------------------------ * Navigate to `localhost:8888` * Input Jupyter password * Launch a notebook i.e. `New > MATLAB` -Launch MATLAB GUI (supports remote interactive debugger) --------------------------------------------------------- +### Launch MATLAB GUI (supports remote interactive debugger) + * Shell into `datajoint-matlab_app_1` i.e. `docker exec -it datajoint-matlab_app_1 bash` * Launch Matlab by runnning command `matlab` -Launch MATLAB Terminal ----------------------- +### Launch MATLAB Terminal + * Shell into `datajoint-matlab_app_1` i.e. `docker exec -it datajoint-matlab_app_1 bash` * Launch Matlab with no GUI by runnning command `matlab -nodisplay` \ No newline at end of file diff --git a/docs-parts/intro/Releases_lang1.rst b/docs-parts/intro/Releases_lang1.rst index 14d5f353..ea01c4ba 100644 --- a/docs-parts/intro/Releases_lang1.rst +++ b/docs-parts/intro/Releases_lang1.rst @@ -1,3 +1,14 @@ +3.3.2 -- October 15, 2020 +------------------------- +* Bugfix: Add blob validation for insert/update regarding sparse matrices which are not yet supported (#238) PR #241 +* Bugfix: Modify update to allow nullable updates for strings/date (#211) PR #213 +* Bugfix: createSchema had some issues with MySQL8 PR #213 +* Update tests +* Docs: Update example related to virtual class (#199) PR #261 +* Docs: Fix typos (#150, #151) PR #263, PR #262 +* Upgrade packaging and installation to utilize MATLAB Toolbox i.e. `DataJoint.mltbx` PR #285 +* Updated tagging scheme to drop v i.e. `v3.3.2` -> `3.3.2`. This is due to FileExchange GitHub Releases link not recognizing alphanumeric labels. See [MATLAB docs](https://www.mathworks.com/matlabcentral/about/fx/#Why_GitHub). + 3.3.1 -- October 31, 2019 ------------------------- * Ability to create schema without GUI PR #155 diff --git a/local-docker-compose.yml b/local-docker-compose.yml index 288d65c1..fb8652ab 100644 --- a/local-docker-compose.yml +++ b/local-docker-compose.yml @@ -47,18 +47,49 @@ services: - "8888:8888" user: ${MATLAB_UID}:${MATLAB_GID} working_dir: /home/muser/notebooks - command: > - /bin/bash -c " - ## Remove mym - rm -R /src/mym; - ## Set dj path - matlab -nodisplay -r \"\ - addpath('/src');\ - savepath;\ - \"; - ## Interactive Jupyter Notebook environment - jupyter notebook; - " + command: + - /bin/bash + - -c + - | + ORIG_DIR=$$(pwd) + mkdir ~/Documents + cd /src + # package into toolbox, and install + matlab -nodisplay -r " + websave([tempdir 'GHToolbox.mltbx'],\ + ['https://github.com/datajoint/GHToolbox' \ + '/releases/download/' subsref(webread(['https://api.github.com/repos' \ + '/datajoint/GHToolbox' \ + '/releases/latest']),\ + substruct('.', 'tag_name')) \ + '/GHToolbox.mltbx']);\ + matlab.addons.toolbox.installToolbox([tempdir 'GHToolbox.mltbx']);\ + fid = fopen('README.md', 'r');\ + docs = fread(fid, '*char')';\ + fclose(fid);\ + ghtb.package('DataJoint',\ + 'Raphael Guzman',\ + 'raphael.h.guzman@gmail.com',\ + ['Scientific workflow management framework built on top of a ' \ + 'relational database.'],\ + docs,\ + {'.vscode', '.git', '*.env', '.gitignore', '.travis.yml', 'tests',\ + 'docs-parts', 'mym', 'erd.m', '*docker-compose.yml', 'LICENSE.txt',\ + 'matlab.prf', 'package.m', 'README.md'},\ + @() strjoin(arrayfun(@(x) num2str(x),\ + cell2mat(struct2cell(dj.version)),\ + 'uni', false),\ + '.'),\ + {'+dj'});\ + matlab.addons.toolbox.installToolbox('DataJoint.mltbx');\ + cd(tempdir);\ + disp(dj.version);\ + " + cd "$${ORIG_DIR}" + # Copy preferences + cp /tmp/matlab.prf /home/muser/.matlab/${MATLAB_VERSION}/matlab.prf + # Interactive Jupyter Notebook environment + jupyter notebook mac_address: $MATLAB_HOSTID volumes: ## Dev mounts @@ -66,5 +97,6 @@ services: - /tmp/.X11-unix:/tmp/.X11-unix:rw ## Additional mounts may go here # - ./notebook:/home/muser/notebooks + - ./matlab.prf:/tmp/matlab.prf networks: main: \ No newline at end of file diff --git a/setupDJ.m b/setupDJ.m deleted file mode 100644 index 25bb9b07..00000000 --- a/setupDJ.m +++ /dev/null @@ -1,47 +0,0 @@ -function setupDJ(skipPathAddition, force) - - if nargin < 2 - force = false; - end - - persistent INVOKED; - - if ~isempty(INVOKED) && ~force - return - end - - base = fileparts(mfilename('fullpath')); - - if nargin < 1 - skipPathAddition = false; - end - - if ~skipPathAddition - fprintf('Adding DataJoint to the path...\n') - addpath(base) - end - - mymdir = fullfile(base, 'mym'); - % if mym directory missing, download and install - if ~isdir(mymdir) - fprintf('mym missing. Downloading...\n') - target = fullfile(base, 'mym.zip'); - mymURL = 'https://github.com/datajoint/mym/archive/master.zip'; - target = websave(target, mymURL); - if isunix && ~ismac - % on Linux Matlab unzip doesn't work properly so use system unzip - system(sprintf('unzip -o %s -d %s', target, base)) - else - unzip(target, base) - end - % rename extracted mym-master directory to mym - movefile(fullfile(base, 'mym-master'), mymdir) - delete(target) - end - - % run mymSetup.m - fprintf('Setting up mym...\n') - run(fullfile(mymdir, 'mymSetup.m')) - - INVOKED = 1; -end diff --git a/tests/Main.m b/tests/Main.m new file mode 100644 index 00000000..e20b3bfa --- /dev/null +++ b/tests/Main.m @@ -0,0 +1,5 @@ +classdef Main < ... + TestConnection & ... + TestRelationalOperand & ... + TestTls +end \ No newline at end of file diff --git a/+tests/Prep.m b/tests/Prep.m similarity index 95% rename from +tests/Prep.m rename to tests/Prep.m index 47395249..5ce9b088 100644 --- a/+tests/Prep.m +++ b/tests/Prep.m @@ -22,9 +22,7 @@ methods function obj = Prep() % Initialize test_root - test_pkg_details = what('tests'); - [test_root, ~, ~] = fileparts(test_pkg_details.path); - obj.test_root = [test_root '/+tests']; + obj.test_root = [pwd '/tests']; end end methods (TestClassSetup) @@ -32,12 +30,13 @@ function init(testCase) disp('---------------INIT---------------'); clear functions; addpath([testCase.test_root '/test_schemas']); - + dj.set('suppressPrompt', true); + disp(dj.version); curr_conn = dj.conn(testCase.CONN_INFO_ROOT.host, ... testCase.CONN_INFO_ROOT.user, testCase.CONN_INFO_ROOT.password,'',true); % create test users ver = curr_conn.query('select @@version as version').version; - if tests.lib.compareVersions(ver,'5.8') + if compareVersions(ver,'5.8') cmd = {... 'CREATE USER IF NOT EXISTS ''datajoint''@''%%'' ' 'IDENTIFIED BY ''datajoint'';' @@ -97,7 +96,7 @@ function init(testCase) function dispose(testCase) disp('---------------DISP---------------'); warning('off','MATLAB:RMDIR:RemovedFromPath'); - + dj.set('suppressPrompt', true); curr_conn = dj.conn(testCase.CONN_INFO_ROOT.host, ... testCase.CONN_INFO_ROOT.user, testCase.CONN_INFO_ROOT.password, '',true); diff --git a/+tests/TestConnection.m b/tests/TestConnection.m similarity index 98% rename from +tests/TestConnection.m rename to tests/TestConnection.m index 92b113a3..cd42ec3b 100644 --- a/+tests/TestConnection.m +++ b/tests/TestConnection.m @@ -1,4 +1,4 @@ -classdef TestConnection < tests.Prep +classdef TestConnection < Prep % TestConnection tests typical connection scenarios. methods (Test) function TestConnection_testConnection(testCase) diff --git a/+tests/TestRelationalOperand.m b/tests/TestRelationalOperand.m similarity index 98% rename from +tests/TestRelationalOperand.m rename to tests/TestRelationalOperand.m index b88147f0..6e09577f 100644 --- a/+tests/TestRelationalOperand.m +++ b/tests/TestRelationalOperand.m @@ -1,4 +1,4 @@ -classdef TestRelationalOperand < tests.Prep +classdef TestRelationalOperand < Prep % TestRelationalOperand tests relational operations. methods (Test) function TestRelationalOperand_testUpdateDate(testCase) diff --git a/+tests/TestTls.m b/tests/TestTls.m similarity index 89% rename from +tests/TestTls.m rename to tests/TestTls.m index a340afb6..4ed33df8 100644 --- a/+tests/TestTls.m +++ b/tests/TestTls.m @@ -1,4 +1,4 @@ -classdef TestTls < tests.Prep +classdef TestTls < Prep % TestTls tests TLS connection scenarios. methods (Test) function TestTls_testSecureConn(testCase) @@ -47,11 +47,10 @@ function TestTls_testRejectException(testCase) 'djssl', ... '',true,false); testCase.verifyTrue(false); - catch - e = lasterror; - testCase.verifyEqual(e.identifier, 'MySQL:Error'); - testCase.verifyTrue(contains(e.message,... - ["requires secure connection","Access denied"])); %MySQL8,MySQL5 + catch ME + testCase.verifyEqual(ME.identifier, 'MySQL:Error'); + testCase.verifyTrue(contains(ME.message,'requires secure connection') || ... + contains(ME.message,'Access denied')); %MySQL8 or MySQL5 end end function TestTls_testStructException(testCase) diff --git a/+tests/test_schemas/+University/All.m b/tests/test_schemas/+University/All.m similarity index 100% rename from +tests/test_schemas/+University/All.m rename to tests/test_schemas/+University/All.m