From b7b004b2249c922fb447e8ae05698b9ba1b31e88 Mon Sep 17 00:00:00 2001 From: Allan CORNET Date: Sun, 20 Oct 2024 18:31:09 +0200 Subject: [PATCH] Improve test files to be compatible with Sequoia --- .github/workflows/ccpp.yml | 2 +- modules/control_system/tests/test_zero.m | 3 +- modules/graphics/tests/test_axis.m | 13 ++++- modules/gui/src/cpp/NelsonMinimized.cpp | 14 ++++-- modules/ipc/tests/test_ipc_minimize.m | 10 ++-- modules/parallel/tests/bench_rand_parallel.m | 1 + modules/webtools/tests/test_repo.m | 53 +++++++++++++------- 7 files changed, 66 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index f8ebc2286b..35f8e43d7e 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -224,7 +224,7 @@ jobs: python $GITHUB_WORKSPACE/tools/update_version/update_version.py - name: CMake run: | - cmake -DCMAKE_BUILD_TYPE=Release -DWITHOUT_SLICOT_MODULE=ON -G "Unix Makefiles" . + cmake -DCMAKE_BUILD_TYPE=Release -DWITHOUT_SLICOT_MODULE=ON -DWITHOUT_FFTW_MODULE=ON -G "Unix Makefiles" . - name: make run: cmake --build . -- -j$(nproc) - name: get module skeleton diff --git a/modules/control_system/tests/test_zero.m b/modules/control_system/tests/test_zero.m index e4505cb484..4636571c34 100644 --- a/modules/control_system/tests/test_zero.m +++ b/modules/control_system/tests/test_zero.m @@ -19,5 +19,6 @@ sys = ss(A, B, C, D); [z, gain] = zero(sys); assert_isequal(z, zeros(0, 1)); -assert_isequal(gain, 500); +assert_isequal(real(gain), 500); +assert_istrue(imag(gain) < 100*eps); %============================================================================= diff --git a/modules/graphics/tests/test_axis.m b/modules/graphics/tests/test_axis.m index f4d4ecec01..c2b3042150 100644 --- a/modules/graphics/tests/test_axis.m +++ b/modules/graphics/tests/test_axis.m @@ -16,11 +16,20 @@ axis([0 2*pi -1.5 1.5]); lim = axis(); REF = [0 6.2832 -1.5000 1.5000]; -assert_isapprox(lim, REF, 1e-4); +assert_isapprox(lim(1), REF(1), 1e-4); +assert_isapprox(lim(2), REF(2), 1e-4); +assert_isapprox(lim(3), REF(3), 1e-4); +assert_isapprox(lim(4), REF(4), 1e-4); %============================================================================= f = figure(); x = linspace(-10, 10, 200); y = sin(4 * x) ./ exp(0.1 * x); plot(x, y); -axis([-10 10 0 inf]) +axis([-10 10 0 inf]); +lim = axis(); +REF = [-10 10 0 inf]; +assert_isapprox(lim(1), REF(1), 1e-4); +assert_isapprox(lim(2), REF(2), 1e-4); +assert_isapprox(lim(3), REF(3), 1e-4); +assert_istrue(isinf(lim(4))); %============================================================================= diff --git a/modules/gui/src/cpp/NelsonMinimized.cpp b/modules/gui/src/cpp/NelsonMinimized.cpp index 2c74ba065c..f3c69cafa6 100644 --- a/modules/gui/src/cpp/NelsonMinimized.cpp +++ b/modules/gui/src/cpp/NelsonMinimized.cpp @@ -7,6 +7,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later // LICENCE_BLOCK_END //============================================================================= +#include #include "NelsonMinimized.hpp" #include "NelSon_engine_mode.h" #include "QtMainWindow.h" @@ -17,14 +18,17 @@ setNelsonMinimized(bool minimize) { if (NELSON_ENGINE_MODE::GUI == Nelson::NelsonConfiguration::getInstance()->getNelsonEngineMode() && Nelson::NelsonConfiguration::getInstance()->getMainGuiObject()) { - QtMainWindow* NelSonQtMainWindow - = (QtMainWindow*)Nelson::NelsonConfiguration::getInstance()->getMainGuiObject(); + QtMainWindow* nelsonQtMainWindow = static_cast( + Nelson::NelsonConfiguration::getInstance()->getMainGuiObject()); if (minimize) { - NelSonQtMainWindow->setWindowState(Qt::WindowMinimized); + QTimer::singleShot(0, nelsonQtMainWindow, [nelsonQtMainWindow]() { + nelsonQtMainWindow->setWindowState(Qt::WindowMinimized); + }); } else { - NelSonQtMainWindow->setWindowState(Qt::WindowNoState); + QTimer::singleShot(0, nelsonQtMainWindow, + [nelsonQtMainWindow]() { nelsonQtMainWindow->setWindowState(Qt::WindowNoState); }); } - NelSonQtMainWindow->setVisible(true); + nelsonQtMainWindow->setVisible(true); return true; } return false; diff --git a/modules/ipc/tests/test_ipc_minimize.m b/modules/ipc/tests/test_ipc_minimize.m index 1ce3c17895..30712a0e87 100644 --- a/modules/ipc/tests/test_ipc_minimize.m +++ b/modules/ipc/tests/test_ipc_minimize.m @@ -12,10 +12,14 @@ % <--SEQUENTIAL TEST REQUIRED--> %============================================================================= % Gnome and some others platforms do not have 'minimize' concept +% macOs do not have 'minimize' concept too +%============================================================================= +if ~ismac() + ipc(getpid, 'minimize', true); + R = ipc(getpid, 'minimize'); + assert_isequal(R, true) +end %============================================================================= -ipc(getpid, 'minimize', true); -R = ipc(getpid, 'minimize'); -assert_isequal(R, true) ipc(getpid, 'minimize', false); R = ipc(getpid, 'minimize'); assert_isequal(R, false) diff --git a/modules/parallel/tests/bench_rand_parallel.m b/modules/parallel/tests/bench_rand_parallel.m index ecb97eb1f8..a3ad5852e5 100644 --- a/modules/parallel/tests/bench_rand_parallel.m +++ b/modules/parallel/tests/bench_rand_parallel.m @@ -9,6 +9,7 @@ %============================================================================= % <--SEQUENTIAL TEST REQUIRED--> %============================================================================= +A = []; p = str2func('rand'); b = backgroundPool(); NumWorkers = b.NumWorkers; diff --git a/modules/webtools/tests/test_repo.m b/modules/webtools/tests/test_repo.m index 066b8a8517..92ba0572c1 100644 --- a/modules/webtools/tests/test_repo.m +++ b/modules/webtools/tests/test_repo.m @@ -32,6 +32,41 @@ REF_TAGS = {'v0.0.1'; 'v0.0.2'}; assert_isequal(TAGS, REF_TAGS); %============================================================================= +GIT_REPOSITORY = 'https://github.com/nelson-lang/repo_builtin_tests.git'; +LOCAL_DIRECTORY = [tempdir(), 'test_repo', '_', createGUID()]; +if isdir(LOCAL_DIRECTORY) + rmdir(LOCAL_DIRECTORY, 's'); +end +mkdir(LOCAL_DIRECTORY); +repo('clone', GIT_REPOSITORY, LOCAL_DIRECTORY, "", "") +R = dir(LOCAL_DIRECTORY); +assert_isequal(length(R), 6); +REF_NAMES = {'.', '..', '.git', 'LICENSE', 'README.md', 'repo_test.nlf'}; +for k = 1:length(R) + assert_isequal(R(k).name, REF_NAMES{k}); +end +%============================================================================= +if isdir(LOCAL_DIRECTORY) + rmdir(LOCAL_DIRECTORY, 's'); +end +%============================================================================= +% libgit on mac supports less features than libgit2. +if ismac() + return +end +%============================================================================= +GIT_REPOSITORY = 'https://github.com/nelson-lang/repo_builtin_tests.git'; +LOCAL_DIRECTORY = [tempdir(), 'test_repo', '_', createGUID()]; +if isdir(LOCAL_DIRECTORY) + rmdir(LOCAL_DIRECTORY, 's'); +end +mkdir(LOCAL_DIRECTORY); +try + repo('clone', GIT_REPOSITORY, LOCAL_DIRECTORY) +catch ex + skip_testsuite(ex.message) +end +%============================================================================= BRANCHES = repo('branch', LOCAL_DIRECTORY); REF_BRANCHES = {'master'; 'origin/branch_dev'; 'origin/master'}; assert_istrue(any(contains(BRANCHES, REF_BRANCHES))); @@ -69,21 +104,3 @@ rmdir(LOCAL_DIRECTORY, 's'); end %============================================================================= -GIT_REPOSITORY = 'https://github.com/nelson-lang/repo_builtin_tests.git'; -LOCAL_DIRECTORY = [tempdir(), 'test_repo', '_', createGUID()]; -if isdir(LOCAL_DIRECTORY) - rmdir(LOCAL_DIRECTORY, 's'); -end -mkdir(LOCAL_DIRECTORY); -repo('clone', GIT_REPOSITORY, LOCAL_DIRECTORY, "", "") -R = dir(LOCAL_DIRECTORY); -assert_isequal(length(R), 6); -REF_NAMES = {'.', '..', '.git', 'LICENSE', 'README.md', 'repo_test.nlf'}; -for k = 1:length(R) - assert_isequal(R(k).name, REF_NAMES{k}); -end -%============================================================================= -if isdir(LOCAL_DIRECTORY) - rmdir(LOCAL_DIRECTORY, 's'); -end -%=============================================================================