Skip to content

Commit

Permalink
Merge pull request #260 from ixcat/issue-228
Browse files Browse the repository at this point in the history
updates for #258 {setupDJ,setupMYM}.m: minver 9.1/2016b, adjust print/error/warnings.
  • Loading branch information
ixcat authored Sep 11, 2020
2 parents e4f6e1c + 3317587 commit de893bc
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 14 deletions.
114 changes: 114 additions & 0 deletions +tests/TestSetupMYM.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@

classdef TestSetupMYM < tests.Prep
% TestSetupMyM tests setupMYM

methods (Test)
function TestSetupMYM_testDefaultInstall(testCase)

[dir, nam, ext] = fileparts(mfilename('fullpath'));
tmym = strcat(dir, '/../', 'mym');

if isdir(tmym)
fprintf('testDefaultInstall: mymdir %s exists. removing\n', ...
tmym);
rmdir(tmym, 's');
end

ms = setupMYM(); % TODO: how properly verify?

end
function TestSetupMYM_testVersionInstallFresh(testCase)
[dir, nam, ext] = fileparts(mfilename('fullpath'));
tmym = strcat(dir, '/../', 'mym');

if isdir(tmym)
fprintf('testVersionInstallFresh: removing mymdir %s\n', ...
tmym);
rmdir(tmym, 's');
end

% TODO: how manage version string?
ms = setupMYM('2.7.2'); % TODO: how properly verify?

testCase.verifyTrue(isdir(tmym));

end
function TestSetupMYM_testVersionInstallStale(testCase)
[dir, nam, ext] = fileparts(mfilename('fullpath'));
tmym = strcat(dir, '/../', 'mym');

if ~isdir(tmym) % XXX: valid? how handle otherwise?
fprintf('testVersionInstallStale: spoofing mymdir %s\n', ...
tmym);
mkdir(tmym);
testCase.verifyTrue(isdir(tmym));
end

% TODO: how manage version string?
ms = setupMYM('2.7.2'); % TODO: how verify fail?

end
function TestSetupMYM_testVersionInstallStaleForce(testCase)
[dir, nam, ext] = fileparts(mfilename('fullpath'));
tmym = strcat(dir, '/../', 'mym');

if ~isdir(tmym) % XXX: valid? how handle otherwise?
fprintf('testVersionInstallStaleForce: spoofing mymdir %s\n', ...
tmym);
mkdir(tmym);
testCase.verifyTrue(isdir(tmym));
end

% TODO: how manage version string?
ms = setupMYM('2.7.2', true); % TODO: how properly verify?

testCase.verifyTrue(isdir(tmym));

end
function TestSetupMYM_testMasterInstallFresh(testCase)
[dir, nam, ext] = fileparts(mfilename('fullpath'));
tmym = strcat(dir, '/../', 'mym');

if isdir(tmym)
fprintf('testMasterInstallFresh: removing mymdir %s\n', ...
tmym);
rmdir(tmym, 's');
end

ms = setupMYM('master'); % TODO: how properly verify

testCase.verifyTrue(isdir(tmym));

end
function TestSetupMYM_testMasterInstallStale(testCase)
[dir, nam, ext] = fileparts(mfilename('fullpath'));
tmym = strcat(dir, '/../', 'mym');

if ~isdir(tmym) % XXX: valid? how handle otherwise?
fprintf('testMasterInstallStale: spoofing mymdir %s\n', ...
tmym);
mkdir(tmym);
testCase.verifyTrue(isdir(tmym));
end

ms = setupMYM('master'); % TODO: how verify fail?

end
function TestSetupMYM_testMasterInstallStaleForce(testCase)
[dir, nam, ext] = fileparts(mfilename('fullpath'));
tmym = strcat(dir, '/../', 'mym');

if ~isdir(tmym) % XXX: valid? how handle otherwise?
fprintf('testMasterInstallStaleForce: spoofing mymdir %s\n', ...
tmym);
mkdir(tmym);
testCase.verifyTrue(isdir(tmym));
end

ms = setupMYM('master'); % TODO: how properly verify

testCase.verifyTrue(isdir(tmym));

end
end
end
16 changes: 9 additions & 7 deletions setupDJ.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,30 @@ function setupDJ(skipPathAddition, force)
return
end

if verLessThan('matlab', '8.6')
error 'MATLAB version 8.6 (R2015b) or greater is required'
if verLessThan('matlab', '9.1')
error('DataJoint:System:UnsupportedMatlabVersion', ...
'MATLAB version 9.1 (R2016b) or greater is required');
end

base = fileparts(mfilename('fullpath'));

if nargin < 1
skipPathAddition = false;
end

if ~skipPathAddition
fprintf('Adding DataJoint to the path...\n')
addpath(base)
fprintf('Adding DataJoint to the path...\n');
addpath(base);
end

setupMYM('master', force);

try
mymVersion = mym('version');
assert(mymVersion.major > 2 || mymVersion.major==2 && mymVersion.minor>=6)
assert(mymVersion.major > 2 || mymVersion.major==2 && mymVersion.minor>=6);
catch
error 'Outdated version of mYm. Please upgrade to version 2.6 or later'
error('DataJoint:System:UnsupportedMyMVersion', ...
'Outdated version of mYm. Please upgrade to version 2.6 or later');
end

INVOKED = 1;
Expand Down
17 changes: 10 additions & 7 deletions setupMYM.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
function setupMYM(version, force)

default_version = 'master'; % else git tag string e.g. '2.7.2'

if nargin < 1
version = 'master';
version = default_version;
elseif nargin < 2
force = false;
end
Expand All @@ -20,9 +22,10 @@ function setupMYM(version, force)
if force
fprintf('force install.. removing %s\n', mymdir);
rmdir(mymdir, 's');
else
fprintf('Warning: mym directory exists. not re-installing.\n');
fprintf(' to override, pass force=true\n');
elseif(~strcmp(version, default_version))
warning('DataJoint:System:setupMyMwarning', ...
['Warning: mym directory exists. not re-installing.\n', ...
' to override, pass force=true\n']);
end
end

Expand Down Expand Up @@ -52,15 +55,15 @@ function setupMYM(version, force)
end

% rename extracted mym-master directory to mym
fprintf('renaming %s to %s\n', extdir, mymdir)
fprintf('renaming %s to %s\n', extdir, mymdir);
movefile(extdir, mymdir);

delete(target);
end

% run mymSetup.m
fprintf('Setting up mym...\n')
run(fullfile(mymdir, 'mymSetup.m'))
fprintf('Setting up mym...\n');
run(fullfile(mymdir, 'mymSetup.m'));

INVOKED = 1;

Expand Down

0 comments on commit de893bc

Please sign in to comment.