Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX - test_dccnpath to run in the DCCN cluster #2299

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 30 additions & 21 deletions test/test_dccnpath.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,39 @@
end

%% Alternative1: Test with local files in the present working directory

tmpdir = tempname;
mkdir(fullfile(tmpdir, 'ftp', 'test', 'edf'));
cd(fullfile(tmpdir, 'ftp', 'test', 'edf'));
websave('testAlphaIR20170321-0.edf', 'https://download.fieldtriptoolbox.org/test/edf/testAlphaIR20170321-0.edf');

filename = dccnpath('/home/common/matlab/fieldtrip/data/ftp/test/edf/testAlphaIR20170321-0.edf');
if ~startsWith(filename, tmpdir)
error('dccnpath() does not find the right working directory');
hostname = gethostname();
if ~startsWith(hostname, 'DCCN') && ~startsWith(hostname, 'dccn') % this test applies to external contributors and not for users in the DCCN cluster
tmpdir = tempname;
mkdir(fullfile(tmpdir, 'ftp', 'test', 'edf'));
cd(fullfile(tmpdir, 'ftp', 'test', 'edf'));
websave('testAlphaIR20170321-0.edf', 'https://download.fieldtriptoolbox.org/test/edf/testAlphaIR20170321-0.edf');

filename = dccnpath('/home/common/matlab/fieldtrip/data/ftp/test/edf/testAlphaIR20170321-0.edf');
if ~startsWith(filename, tmpdir)
error('dccnpath() does not find the right working directory');
end

% return to the original directory
cd(origdir);
end

% return to the original directory
cd(origdir);

%% Alternative2: It downloads test data to the local computer, if test data is not already downloaded. It has 6 different tests that are listed below

%% Test1: When ft_default.dccnpath is given by the user, dccnpath() should always select alternative2 (this is not done now)

% ... continue with the temporary copy from the previous test
ft_default.dccnpath = tmpdir;
hostname = gethostname();
if ~startsWith(hostname, 'DCCN') && ~startsWith(hostname, 'dccn') % this test applies to external contributors and not for users in the DCCN cluster
% ... continue with the temporary copy from the previous test
ft_default.dccnpath = tmpdir;

filename = dccnpath('/home/common/matlab/fieldtrip/data/ftp/test/edf/testAlphaIR20170321-0.edf');
if ~startsWith(filename, tmpdir)
error('dccnpath() does not find the right working directory');
end

filename = dccnpath('/home/common/matlab/fieldtrip/data/ftp/test/edf/testAlphaIR20170321-0.edf');
if ~startsWith(filename, tmpdir)
error('dccnpath() does not find the right working directory');
rmdir(ft_default.dccnpath, 's')
end

rmdir(ft_default.dccnpath, 's')

%% Test2: Downloading a file from the HTTPS download server

tmpdir = tempname;
Expand All @@ -79,7 +84,9 @@
error('File exists in the local copy, but dccnpath() can not find it');
end

rmdir(ft_default.dccnpath, 's');
if exist(ft_default.dccnpath,'dir')
rmdir(ft_default.dccnpath, 's');
end

%% Test4: Downloading a folder from the HTTPS download server

Expand All @@ -100,7 +107,9 @@
error('Folder exists in the local copy, but dccnpath() can not find it');
end

rmdir(ft_default.dccnpath, 's');
if exist(ft_default.dccnpath,'dir')
rmdir(ft_default.dccnpath, 's');
end

%% Test6: When ft_default.dccnpath is not specified, then data should be saved automatically to tempdir

Expand Down