From fbf9cf868818edb8e82159d687817a337821fce9 Mon Sep 17 00:00:00 2001 From: "Robert W. Ellenberg" Date: Wed, 17 Apr 2019 18:23:46 -0400 Subject: [PATCH] unit_test: Fix unit tests after saicanon changes The "mock" file just had a few globals that would be clearer to just store in the main test file. --- meson.build | 12 +++++------- unit_tests/interp/test_interp_basics.cc | 3 +++ unit_tests/interp/tests_main.cc | 8 ++++---- unit_tests/mock/mock_sai.cc | 3 --- 4 files changed, 12 insertions(+), 14 deletions(-) delete mode 100644 unit_tests/mock/mock_sai.cc diff --git a/meson.build b/meson.build index 644aae50542..bfe8c02a35e 100644 --- a/meson.build +++ b/meson.build @@ -235,12 +235,9 @@ libsaicanon = shared_module('saicanon', dependencies : [boost_dep, python2_dep, dl_dep, liblinuxcncini_dep, librs274ngc_dep] ) -mock_sai = static_library('mock_sai', - 'unit_tests/mock/mock_sai.cc', - include_directories : [rs274ngc_inc, rs274ngc_external_inc ], - ) +libsaicanon_dep = declare_dependency(include_directories : sai_inc, + link_with : libsaicanon) - test_interp_ex = executable('test_interp', test_interp_srcs, include_directories : [test_interp_inc, rs274ngc_external_inc, unit_test_inc], @@ -249,8 +246,9 @@ test_interp_ex = executable('test_interp', python2_dep, librs274ngc_dep, libpyplugin_dep, - ], - link_with : [librs274ngc, libsaicanon, mock_sai, liblinuxcnchal] + liblinuxcnchal_dep, + libsaicanon_dep, + ] ) test('test_interp', test_interp_ex) diff --git a/unit_tests/interp/test_interp_basics.cc b/unit_tests/interp/test_interp_basics.cc index b3f0671162a..41fee434379 100644 --- a/unit_tests/interp/test_interp_basics.cc +++ b/unit_tests/interp/test_interp_basics.cc @@ -4,6 +4,7 @@ #include #include #include +#include #include using namespace interp_param_global; @@ -79,6 +80,7 @@ TEST_CASE("Interp Basics") SECTION("G55 without rotation") { + REQUIRE_INTERP_OK(test_interp.execute("G20")); REQUIRE_FUZZ(currentX(settings), 0.0); REQUIRE_FUZZ(currentY(settings), 0.0); REQUIRE_FUZZ(currentZ(settings), 0.0); @@ -98,6 +100,7 @@ TEST_CASE("Interp Basics") SECTION("G55 with rotation") { + REQUIRE_INTERP_OK(test_interp.execute("G20")); currentX(settings) = 0.0; // KLUDGE hack in parameters directly to avoid depending on other functions test_interp._setup.parameters[G55_X] = 2; diff --git a/unit_tests/interp/tests_main.cc b/unit_tests/interp/tests_main.cc index b8a939298c2..f0c666b41ce 100644 --- a/unit_tests/interp/tests_main.cc +++ b/unit_tests/interp/tests_main.cc @@ -3,9 +3,11 @@ #include #include -extern Interp *pinterp; -Interp dummy_interp; #include +#include + +int _task = 1; // Dummy this out, not used in unit test +InterpBase *pinterp; // KLUDGE fix missing symbol the ugly way struct _inittab builtin_modules[] = { @@ -14,8 +16,6 @@ struct _inittab builtin_modules[] = { int main (int argc, char * argv[]) { // KLUDGE just to satisfy saicanon dependencies, not used in tests - dummy_interp = Interp(); - pinterp = &dummy_interp; _outfile = fopen("test_interp_canon.log", "w"); PythonPlugin::instantiate(builtin_modules); return Catch::Session().run( argc, argv ); diff --git a/unit_tests/mock/mock_sai.cc b/unit_tests/mock/mock_sai.cc deleted file mode 100644 index 8cf112d1f83..00000000000 --- a/unit_tests/mock/mock_sai.cc +++ /dev/null @@ -1,3 +0,0 @@ -#include -InterpBase *pinterp; -int _task = 0; // control preview behaviour when remapping