diff --git a/.github/workflows/run-googletest.yml b/.github/workflows/run-googletest.yml index ee2446e9e..4e1219559 100644 --- a/.github/workflows/run-googletest.yml +++ b/.github/workflows/run-googletest.yml @@ -16,6 +16,8 @@ jobs: matrix: # Use windows-2019 instead of windows-latest to avoid using Mingw-w64 os: [ubuntu-latest, macos-latest, windows-2019] + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v3 diff --git a/.gitignore b/.gitignore index 31abdb600..1f4b5aa51 100644 --- a/.gitignore +++ b/.gitignore @@ -97,6 +97,7 @@ src/tmp.def #Testing files tests/test_plan/FIMS_Integration_Test_Plan.log +tests/integration/FIMS-deterministic-inputs/ #vignettes inst/doc diff --git a/CMakeLists.txt b/CMakeLists.txt index 90355a991..64d98dd30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,11 @@ EXECUTE_PROCESS( MESSAGE(STATUS "R_HOME is ${R_HOME}") +EXECUTE_PROCESS( + COMMAND R "--slave" "--no-save" "-e" "remotes::install_local(upgrade = 'always')") +EXECUTE_PROCESS( + COMMAND R "--slave" "--no-save" "-e" "FIMS:::setup_gtest()") + # Enable testing for current directory and below enable_testing() diff --git a/R/setup_gtest.R b/R/setup_gtest.R index 1d4e39f5e..fe59f44de 100644 --- a/R/setup_gtest.R +++ b/R/setup_gtest.R @@ -25,7 +25,7 @@ setup_gtest <- function() { # write json file outputname <- paste0("C", c_case, "_om_output", i_iter, ".json") inputname <- paste0("C", c_case, "_om_input", i_iter, ".json") - json_folder <- file.path("tests", "integration", "inputs", "FIMS-deterministic") + json_folder <- file.path("tests", "integration", "FIMS-deterministic-inputs") if (!dir.exists(json_folder)) dir.create(json_folder) jsonlite::write_json( x = om_output, path = file.path(json_folder, outputname), diff --git a/tests/gtest/integration_test_fixture.cpp b/tests/gtest/integration_test_fixture.cpp deleted file mode 100644 index e286b7baf..000000000 --- a/tests/gtest/integration_test_fixture.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include -#include "../integration/third_party/rapidjson/document.h" -#include "../integration/integration_class.hpp" - -#include "population_dynamics/population/population.hpp" - -namespace { - -// Use test fixture to reuse the same configuration of objects for -// several different tests. To use a test fixture, derive a class -// from testing::Test. -class PopulationIntegrationTestFixture : public testing::Test { - // Make members protected and they can be accessed from - // sub-classes. - protected: - // Use SetUp function to prepare the objects for each test. - // Use override in C++11 to make sure SetUp (e.g., not Setup with - // a lowercase u) is spelled - // correctly. - void SetUp() override { - std::stringstream ss; - for (uint32_t i = 0; i < this->ncases_m; i++) { - for (uint32_t j = 0; j < this->ninput_files_m; j++) { - ss.str(""); - ss << "../integration/inputs/C" << i << "/om_input" << j + 1 << ".json"; - rapidjson::Document input; - rapidjson::Document output; - this->ReadJson(ss.str(), input); - - - ss.str(""); - ss << "inputs/C" << i << "/om_output" << j + 1 << ".json"; - // this->ReadJson(ss.str(), output); - - fims::Population pop; - - - - if (!this->ConfigurePopulationModel(pop, input)) { - good = false; - } - - if (!this->RunModelLoop(pop, input)) { - good = false; - } - if (!this->CheckModelOutput(pop, output)) { - good = false; - } - } - } - - // Virtual void TearDown() will be called after each test is - // run. It needs to be defined if there is clearup work to - // do. Otherwise, it does not need to be provided. - virtual void TearDown() {} - - fims::Population population; - - // Use default values from the Li et al., 2021 - // https://github.com/Bai-Li-NOAA/Age_Structured_Stock_Assessment_Model_Comparison/blob/master/R/save_initial_input.R - int id_g = 0; - int nyears = 30; - int nseasons = 1; - int nages = 12; - int nfleets = 2; // one survey fleet and one fishing fleet -}; diff --git a/tests/gtest/integration_test_population.cpp b/tests/gtest/integration_test_population.cpp index d3656aea9..6cc83a5cd 100644 --- a/tests/gtest/integration_test_population.cpp +++ b/tests/gtest/integration_test_population.cpp @@ -29,12 +29,12 @@ namespace ss.str(""); // GoogleTest operates in the folder with executables "build/tests/gtest" // so we have to go up three directories to get into FIMS folder - ss << "../../../tests/integration/inputs/FIMS-deterministic/C" <