Skip to content

Commit

Permalink
Simplified test set up and tear down methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ssun30 authored and ischoegl committed Jul 29, 2023
1 parent 9375e8d commit 4dc301b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 40 deletions.
25 changes: 2 additions & 23 deletions test/matlab_experimental/ctTestPath.m
Expand Up @@ -7,38 +7,17 @@
% run interfaces/matlab_experimental/testpath.m

% get the list of directories on the Matlab path
dirs = regexp(path, ['([^' pathsep ']*)'], 'match');
dirs = split(path, pathsep);

% if 'cantera' is already in the path, remove it
for i = 1:length(dirs)
if strfind(dirs{i}, 'Cantera')
rmpath(dirs{i});
continue;
end
if strfind(dirs{i}, 'cantera')
if contains(dirs{i}, 'CANTERA', 'IgnoreCase', true)
rmpath(dirs{i});
end
end

cantera_root = getenv('CANTERA_ROOT');

% Copy the Cantera shared library from the build directory if necessary
if ispc
libname = 'cantera_shared.dll';
elseif ismac
libname = 'libcantera_shared.dylib';
elseif isunix
libname = 'libcantera_shared.so';
end

copyfile(fullfile(cantera_root, 'build', 'lib', libname), ...
fullfile(cantera_root, 'test', 'matlab_experimental'));

% Add the Cantera toolbox to the Matlab path
addpath(genpath([cantera_root, '/interfaces/matlab_experimental']));
addpath(genpath([cantera_root, '/test/matlab_experimental']));

% Set path to Python module
if strcmp(getenv('PYTHONPATH'), '')
setenv('PYTHONPATH', fullfile(cantera_root, 'build', 'python'))
end
6 changes: 3 additions & 3 deletions test/matlab_experimental/ctTestSetUp.m
Expand Up @@ -7,11 +7,11 @@
rootDir = getenv('CANTERA_ROOT');

if ispc
ctName = '/test/matlab_experimental/cantera_shared.dll';
ctName = '/build/lib/cantera_shared.dll';
elseif ismac
ctname = '/test/matlab_experimental/libcantera_shared.dylib';
ctName = '/build/lib/libcantera_shared.dylib';
elseif isunix
ctname = '/test/matlab_experimental/libcantera_shared.so';
ctName = '/build/lib/libcantera_shared.so';
end
% Load Cantera
if ~libisloaded('libcantera_shared')
Expand Down
15 changes: 1 addition & 14 deletions test/matlab_experimental/ctTestTearDown.m
@@ -1,17 +1,4 @@
clear all

cantera_root = getenv('CANTERA_ROOT');

if ispc
ctName = '/test/matlab_experimental/cantera_shared.dll';
elseif ismac
ctname = '/test/matlab_experimental/libcantera_shared.dylib';
elseif isunix
ctname = '/test/matlab_experimental/libcantera_shared.so';
end

% Unload Cantera and remove temporary library file
% Unload Cantera
unloadlibrary('libcantera_shared');
delete([cantera_root, ctName]);

disp('Cantera has been unloaded');

0 comments on commit 4dc301b

Please sign in to comment.