Simplified test set up and tear down methods

This commit is contained in:
ssun30 2023-07-26 20:35:24 -04:00 committed by Ingmar Schoegl
parent 9375e8dbc7
commit 4dc301b0d7
3 changed files with 6 additions and 40 deletions

View File

@ -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

View File

@ -7,11 +7,11 @@ ctTestPath;
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')

View File

@ -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');