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 #477 update file watcher library using efsw #482

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@

- some warnings detected by LGTM or VS fixed.

- [#477](http://github.com/Nelson-numerical-software/nelson/issues/477): update files watcher using `efsw`.

- filename and line of last error available in test_run report.

## Bug Fixes:

- [#480](http://github.com/Nelson-numerical-software/nelson/issues/468): A(':') = [] was not managed.


# 0.5.7 (2021-07-24)

## Features:
Expand Down
1 change: 1 addition & 0 deletions CMake/MacOsConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_OSX_ARCHITECTURES "${ARCH}")
set(Boost_NO_SYSTEM_PATHS "TRUE")
set(MAC_FRAMEWORK_FOUNDATION_LIBRARY "-framework Foundation")
set(MAC_FRAMEWORK_CORESERVICES_LIBRARY "-framework CoreServices")
set(MAC_FRAMEWORK_APPKIT_LIBRARY "-framework AppKit")
set(MAC_LAPACKE_LIBRARY -lblas -llapack )
find_package (openblas REQUIRED)
Expand Down
6 changes: 3 additions & 3 deletions THIRDPARTY.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ Microsoft MPI (MS-MPI) is a Microsoft implementation of the Message Passing Inte

> https://www.open-mpi.org/community/license.php

- SimpleFileWatcher
- Entropia File System Watcher

a C++ wrapper for OS file monitoring systems

> https://github.com/apetrone/simplefilewatcher
> https://github.com/SpartanJ/efsw

> https://github.com/apetrone/simplefilewatcher/blob/master/License.txt
> https://github.com/SpartanJ/efsw/blob/master/LICENSE

- Libxml2

Expand Down
2 changes: 1 addition & 1 deletion modules/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../os_functions/src/include
${CMAKE_CURRENT_SOURCE_DIR}/../nelson_manager/src/include
${CMAKE_CURRENT_SOURCE_DIR}/../files_folders_functions/src/include
${CMAKE_CURRENT_SOURCE_DIR}/../i18n/src/include
${CMAKE_CURRENT_SOURCE_DIR}/../i18n/src/include
${CMAKE_CURRENT_SOURCE_DIR}/../string/src/include
${CMAKE_CURRENT_SOURCE_DIR}/../core/src/include/picoSHA2)
# ==============================================================================
Expand Down
2 changes: 1 addition & 1 deletion modules/f2c/etc/startup.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
% LICENCE_BLOCK_END
%=============================================================================
%addgateway(modulepath(nelsonroot(), 'f2c', 'builtin'));
addpath(modulepath(nelsonroot(), 'f2c', 'functions'))
addpath(modulepath(nelsonroot(), 'f2c', 'functions'), '-frozen')
%=============================================================================
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
temp_dest = [TMPDIR, createGUID()];
mkdir(temp_dest);
cd(temp_dest);
R = unzip([nelsonroot(), '/modules/file_archiver/tests/test_zip.zip']);
REF = { [temp_dest, '/test_zip/'], ...
[temp_dest, '/test_zip/dir_1/'], ...
[temp_dest, '/test_zip/dir_1/dir_1_1/'], ...
Expand All @@ -49,6 +48,7 @@
[temp_dest, '/test_zip/file_2.txt'], ...
[temp_dest, '/file_0.txt'], ...
[temp_dest, '/test_zip/1汉字2.PNG']};
R = unzip([nelsonroot(), '/modules/file_archiver/tests/test_zip.zip']);
assert_isequal(R, REF);
for r = R
rr = r{1};
Expand All @@ -64,7 +64,6 @@
rmdir(temp_dest, 's');
%=============================================================================
temp_dest = [TMPDIR, createGUID()];
R = unzip([nelsonroot(), '/modules/file_archiver/tests/test_zip.zip'], temp_dest);
REF = { [temp_dest, '/test_zip/'], ...
[temp_dest, '/test_zip/dir_1/'], ...
[temp_dest, '/test_zip/dir_1/dir_1_1/'], ...
Expand All @@ -79,6 +78,7 @@
[temp_dest, '/test_zip/file_2.txt'], ...
[temp_dest, '/file_0.txt'], ...
[temp_dest, '/test_zip/1汉字2.PNG']};
R = unzip([nelsonroot(), '/modules/file_archiver/tests/test_zip.zip'], temp_dest);
assert_isequal(R, REF);
%=============================================================================
for r = R
Expand Down
61 changes: 61 additions & 0 deletions modules/file_archiver/tests/test_unzip_2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
%=============================================================================
% Copyright (c) 2016-present Allan CORNET (Nelson)
%=============================================================================
% This file is part of the Nelson.
%=============================================================================
% LICENCE_BLOCK_BEGIN
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU Lesser General Public
% License as published by the Free Software Foundation; either
% version 2.1 of the License, or (at your option) any later version.
%
% Alternatively, you can redistribute it and/or
% modify it under the terms of the GNU General Public License as
% published by the Free Software Foundation; either version 2 of
% the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License along with this program. If not, see <http://www.gnu.org/licenses/>.
% LICENCE_BLOCK_END
%=============================================================================
TMPDIR = tempdir();
if ismac()
TMPDIR = ['/private', TMPDIR];
end
%=============================================================================
temp_dest = [TMPDIR, createGUID()];
R = unzip([nelsonroot(), '/modules/file_archiver/tests/test_zip.zip'], temp_dest);
REF = { [temp_dest, '/test_zip/'], ...
[temp_dest, '/test_zip/dir_1/'], ...
[temp_dest, '/test_zip/dir_1/dir_1_1/'], ...
[temp_dest, '/test_zip/dir_1/dir_1_1/file_1_1_1.txt'], ...
[temp_dest, '/test_zip/dir_1/dir_1_1/file_1_1_2.txt'], ...
[temp_dest, '/test_zip/dir_1/dir_1_2/'], ...
[temp_dest, '/test_zip/dir_1/file_1_1.txt'], ...
[temp_dest, '/test_zip/dir_1/file_1_2.txt'], ...
[temp_dest, '/test_zip/dir_2/'], ...
[temp_dest, '/test_zip/dir_2/file_2_1.txt'], ...
[temp_dest, '/test_zip/file_1.txt'], ...
[temp_dest, '/test_zip/file_2.txt'], ...
[temp_dest, '/file_0.txt'], ...
[temp_dest, '/test_zip/1汉字2.PNG']};
assert_isequal(R, REF);
%=============================================================================
for r = R
rr = r{1};
if endsWith(rr, '/')
assert_istrue(isdir(rr));
else
assert_istrue(isfile(rr));
fileinfo = dir(rr);
assert_istrue(fileinfo.bytes > 0);
end
end
cd(tempdir());
rmdir(temp_dest, 's');
%=============================================================================
67 changes: 67 additions & 0 deletions modules/file_archiver/tests/test_zip_1.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
%=============================================================================
% Copyright (c) 2016-present Allan CORNET (Nelson)
%=============================================================================
% This file is part of the Nelson.
%=============================================================================
% LICENCE_BLOCK_BEGIN
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU Lesser General Public
% License as published by the Free Software Foundation; either
% version 2.1 of the License, or (at your option) any later version.
%
% Alternatively, you can redistribute it and/or
% modify it under the terms of the GNU General Public License as
% published by the Free Software Foundation; either version 2 of
% the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License along with this program. If not, see <http://www.gnu.org/licenses/>.
% LICENCE_BLOCK_END
%=============================================================================
assert_isequal(nargin('zip'), -3);
assert_isequal(nargout('zip'), -1);
%=============================================================================
builderFile = [nelsonroot(),'/module_skeleton/builder.m'];
if ~isfile(builderFile)
return
end
%=============================================================================
TMPDIR = tempdir();
if ismac()
TMPDIR = ['/private', TMPDIR];
end
%=============================================================================
DEST_1 = [TMPDIR, 'zip_test_1.zip'];
cd([nelsonroot(), '/module_skeleton'])
R = zip(DEST_1, '*.m');
REF1 = {'builder.m'};
REF2 = {'builder.m', 'loader.m'};
if length(R) == 2
assert_isequal(R, REF2);
else
assert_isequal(R, REF1);
end
assert_istrue(isfile(DEST_1));
%=============================================================================
temp_dest = [TMPDIR, createGUID()];
mkdir(temp_dest);
cd(temp_dest);
R1 = unzip(DEST_1);
REF1 = {[temp_dest, '/builder.m']};
REF2 = {[temp_dest, '/builder.m'] , [temp_dest, '/loader.m']};
if length(R1) == 2
assert_isequal(R1, REF2);
else
assert_isequal(R1, REF1);
end
cd(tempdir());
rmdir(temp_dest, 's');
%=============================================================================
cmd = 'R = zip(DEST_1, ''*.m'', [nelsonroot(), ''/modules_skeleton''])';
assert_checkerror(cmd, _('Invalid root path.'));
%=============================================================================
61 changes: 61 additions & 0 deletions modules/file_archiver/tests/test_zip_2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
%=============================================================================
% Copyright (c) 2016-present Allan CORNET (Nelson)
%=============================================================================
% This file is part of the Nelson.
%=============================================================================
% LICENCE_BLOCK_BEGIN
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU Lesser General Public
% License as published by the Free Software Foundation; either
% version 2.1 of the License, or (at your option) any later version.
%
% Alternatively, you can redistribute it and/or
% modify it under the terms of the GNU General Public License as
% published by the Free Software Foundation; either version 2 of
% the License, or (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License along with this program. If not, see <http://www.gnu.org/licenses/>.
% LICENCE_BLOCK_END
%=============================================================================
builderFile = [nelsonroot(),'/module_skeleton/builder.m'];
if ~isfile(builderFile)
return
end
%=============================================================================
TMPDIR = tempdir();
if ismac()
TMPDIR = ['/private', TMPDIR];
end
%=============================================================================
DEST_2 = [TMPDIR, 'zip_test_2.zip'];
cd([nelsonroot(), '/module_skeleton'])
R = zip(DEST_2, [nelsonroot(), '/module_skeleton/*.m']);
REF1 = {'builder.m'};
REF2 = {'builder.m', 'loader.m'};
if length(R) == 2
assert_isequal(R, REF2);
else
assert_isequal(R, REF1);
end
assert_istrue(isfile(DEST_2));
%=============================================================================
temp_dest = [TMPDIR, createGUID()];
mkdir(temp_dest);
cd(temp_dest);
R2 = unzip(DEST_2);
REF1 = {[temp_dest, '/builder.m']};
REF2 = {[temp_dest, '/builder.m'] , [temp_dest, '/loader.m']};
if length(R2) == 2
assert_isequal(R2, REF2);
else
assert_isequal(R2, REF1);
end
cd(tempdir());
rmdir(temp_dest, 's');
%=============================================================================
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
% License along with this program. If not, see <http://www.gnu.org/licenses/>.
% LICENCE_BLOCK_END
%=============================================================================
assert_isequal(nargin('zip'), -3);
assert_isequal(nargout('zip'), -1);
%=============================================================================
builderFile = [nelsonroot(),'/module_skeleton/builder.m'];
if ~isfile(builderFile)
return
Expand All @@ -36,58 +33,6 @@
TMPDIR = ['/private', TMPDIR];
end
%=============================================================================
DEST_1 = [TMPDIR, 'zip_test_1.zip'];
cd([nelsonroot(), '/module_skeleton'])
R = zip(DEST_1, '*.m');
REF1 = {'builder.m'};
REF2 = {'builder.m', 'loader.m'};
if length(R) == 2
assert_isequal(R, REF2);
else
assert_isequal(R, REF1);
end
assert_istrue(isfile(DEST_1));
%=============================================================================
DEST_2 = [TMPDIR, 'zip_test_2.zip'];
cd([nelsonroot(), '/module_skeleton'])
R = zip(DEST_2, [nelsonroot(), '/module_skeleton/*.m']);
REF1 = {'builder.m'};
REF2 = {'builder.m', 'loader.m'};
if length(R) == 2
assert_isequal(R, REF2);
else
assert_isequal(R, REF1);
end
assert_istrue(isfile(DEST_2));
%=============================================================================
temp_dest = [TMPDIR, createGUID()];
mkdir(temp_dest);
cd(temp_dest);
R1 = unzip(DEST_1);
REF1 = {[temp_dest, '/builder.m']};
REF2 = {[temp_dest, '/builder.m'] , [temp_dest, '/loader.m']};
if length(R1) == 2
assert_isequal(R1, REF2);
else
assert_isequal(R1, REF1);
end
cd(tempdir());
rmdir(temp_dest, 's');
%=============================================================================
temp_dest = [TMPDIR, createGUID()];
mkdir(temp_dest);
cd(temp_dest);
R2 = unzip(DEST_2);
REF1 = {[temp_dest, '/builder.m']};
REF2 = {[temp_dest, '/builder.m'] , [temp_dest, '/loader.m']};
if length(R2) == 2
assert_isequal(R2, REF2);
else
assert_isequal(R2, REF1);
end
cd(tempdir());
rmdir(temp_dest, 's');
%=============================================================================
DEST_3 = [TMPDIR, 'zip_test_3.zip'];
R3 = zip(DEST_3, [nelsonroot(), '/module_skeleton']);
REF = {'module_skeleton/builder.m', ...
Expand Down Expand Up @@ -205,6 +150,3 @@
info = dir(DEST_5);
assert_istrue(info.bytes > 0);
%=============================================================================
cmd = 'R = zip(DEST_1, ''*.m'', [nelsonroot(), ''/modules_skeleton''])';
assert_checkerror(cmd, _('Invalid root path.'));
%=============================================================================
6 changes: 6 additions & 0 deletions modules/files_folders_functions/tests/test_cd.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,9 @@
newDirectory = pwd();
assert_isequal(currentDirectory, newDirectory);
%=============================================================================
temp_dest = [TMPDIR, createGUID()];
mkdir(temp_dest);
cd(temp_dest);
currentDirectory = pwd();
assert_isequal(currentDirectory, temp_dest);
%=============================================================================
9 changes: 6 additions & 3 deletions modules/interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ include_directories(
${Boost_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/src/include
${CMAKE_CURRENT_SOURCE_DIR}/src/grammar
${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/FileWatcher
${CMAKE_CURRENT_SOURCE_DIR}/src/cpp
${CMAKE_CURRENT_SOURCE_DIR}/../nelson_manager/src/include
${CMAKE_CURRENT_SOURCE_DIR}/../types/src/include
${CMAKE_CURRENT_SOURCE_DIR}/../error_manager/src/include
Expand All @@ -46,7 +46,8 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/../profiler/src/include)
# ==============================================================================
file(GLOB INTERPRETER_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/FileWatcher/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/efsw/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/cpp/efsw/platform/posix/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/src/grammar/*.cpp")
# ==============================================================================
add_library(${module_library_name} SHARED ${INTERPRETER_SRC})
Expand All @@ -62,7 +63,9 @@ target_link_libraries(
nlsI18n
nlsOs_functions
nlsProfiler
${BOOST_LIBRARIES})
${BOOST_LIBRARIES}
${MAC_FRAMEWORK_FOUNDATION_LIBRARY}
${MAC_FRAMEWORK_CORESERVICES_LIBRARY})
# ==============================================================================
set_target_properties(
${module_library_name}
Expand Down