Skip to content

Commit

Permalink
Merge branch 'develop' into feature/ANT-2749
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Feb 19, 2025
2 parents 5fdd9f9 + 98f3a22 commit 8726a5b
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 6 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,38 @@ jobs:
batch-name: adequacy-patch-CSR
os: ${{ matrix.os }}

- name: Run tests introduced in 8.6.0
continue-on-error: true
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: valid-v860
os: ${{ env.os }}

- name: Run tests introduced in 8.7.0
continue-on-error: true
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: valid-v870
os: ${{ env.os }}

- name: Run tests introduced in 9.1.0
continue-on-error: true
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: valid-v910
os: ${{ env.os }}

- name: Run tests introduced in 9.2.0
continue-on-error: true
uses: ./.github/workflows/run-tests
with:
simtest-tag: ${{ env.SIMTEST }}
batch-name: valid-v920
os: ${{ env.os }}

- name: Collect coverage into one XML report
run: |
gcovr --sonarqube --output coverage.xml
Expand Down
2 changes: 1 addition & 1 deletion simtest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "v9.2.0i"
"version": "v9.2.0k"
}
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ sonar.coverage.exclusions=src/ext/**,\
src/tools/**,\
src/ui/**,\
src/libs/fswalker/**,\
src/libs/antares/cleaner/**,\
src/libs/antares/study/cleaner/**,\
src/libs/antares/jit/**,\
src/libs/antares/sys/**,\
src/libs/antares/path/**,\
Expand Down
6 changes: 3 additions & 3 deletions src/libs/antares/study/include/antares/study/parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class Parameters final
*/
bool loadFromFile(const std::filesystem::path& filename, const StudyVersion& version);

//! Load data from an INI file
bool loadFromINI(const IniFile& ini, const StudyVersion& version);

/*!
** \brief Prepare all settings for a simulation
**
Expand Down Expand Up @@ -507,9 +510,6 @@ class Parameters final
Antares::Solver::Optimization::OptimizationOptions optOptions;

private:
//! Load data from an INI file
bool loadFromINI(const IniFile& ini, const StudyVersion& version);

void resetPlayedYears(uint nbOfYears);

//! MC year weight for MC synthesis
Expand Down
6 changes: 5 additions & 1 deletion src/solver/variable/surveyresults/surveyresults.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,11 @@ SurveyResults::SurveyResults(const Data::Study& s, const Yuni::String& o, IResul
digestNonApplicableStatus = new bool*[digestSize];
for (uint i = 0; i < digestSize; i++)
{
digestNonApplicableStatus[i] = new bool[maxVariables]{false};
digestNonApplicableStatus[i] = new bool[maxVariables];
for (uint var = 0; var != maxVariables; ++var)
{
digestNonApplicableStatus[i][var] = false;
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/tests/end-to-end/simple_study/simple-study.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,13 @@ BOOST_FIXTURE_TEST_CASE(scenario_builder, HydroMaxPowerStudy)
tt::tolerance(0.1));
}

BOOST_FIXTURE_TEST_CASE(saving_study, HydroMaxPowerStudy)
{
auto enabledCluster = std::make_shared<ThermalCluster>(area);
enabledCluster->setName("Cluster1");
enabledCluster->enabled = true;
area->thermal.list.addToCompleteList(enabledCluster);

BOOST_CHECK(study->saveToFolder(std::filesystem::temp_directory_path().string()));
}
BOOST_AUTO_TEST_SUITE_END()
20 changes: 20 additions & 0 deletions src/tests/src/libs/antares/study/parameters/parameters-tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,26 @@ BOOST_FIXTURE_TEST_CASE(hydroPmax, Fixture)
BOOST_CHECK(!StringToCompatibilityHydroPmax(p.compatibility.hydroPmax, "abc"));
}

BOOST_AUTO_TEST_CASE(saveLoadGeneralData)
{
IniFile ini;
Parameters parameters;
parameters.reset();
parameters.timeSeriesToGenerate = timeSeriesLoad | timeSeriesHydro | timeSeriesWind
| timeSeriesThermal | timeSeriesSolar | timeSeriesRenewable;

parameters.timeSeriesToRefresh = parameters.timeSeriesToGenerate;
parameters.resultFormat = zipArchive;

parameters.saveToINI(ini);

Parameters loaded;
loaded.loadFromINI(ini, StudyVersion::latest());
BOOST_CHECK_EQUAL(parameters.timeSeriesToGenerate, loaded.timeSeriesToGenerate);
BOOST_CHECK_EQUAL(parameters.timeSeriesToRefresh, loaded.timeSeriesToRefresh);
BOOST_CHECK_EQUAL(parameters.resultFormat, loaded.resultFormat);
}

BOOST_AUTO_TEST_SUITE_END()

void Fixture::writeInvalidFile()
Expand Down
6 changes: 6 additions & 0 deletions src/tests/src/solver/variable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ include(${CMAKE_SOURCE_DIR}/tests/macros.cmake)
add_boost_test(test-intermediate
SRC test_intermediate.cpp
LIBS antares-solver-variable)

add_boost_test(test-surveyresults
SRC test_surveyresults.cpp
LIBS
antares-solver-variable
result_writer)
56 changes: 56 additions & 0 deletions src/tests/src/solver/variable/test_surveyresults.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2007-2024, RTE (https://www.rte-france.com)
* See AUTHORS.txt
* SPDX-License-Identifier: MPL-2.0
* This file is part of Antares-Simulator,
* Adequacy and Performance assessment for interconnected energy networks.
*
* Antares_Simulator is free software: you can redistribute it and/or modify
* it under the terms of the Mozilla Public Licence 2.0 as published by
* the Mozilla Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Antares_Simulator 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
* Mozilla Public Licence 2.0 for more details.
*
* You should have received a copy of the Mozilla Public Licence 2.0
* along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
*/
#define BOOST_TEST_MODULE "test time series"

#define WIN32_LEAN_AND_MEAN

#include <boost/test/unit_test.hpp>

#include "antares/solver/variable/surveyresults.h"
#include "antares/writer/in_memory_writer.h"

using namespace Antares::Solver::Variable;

struct StudyFixture
{
StudyFixture():
study(std::make_unique<Antares::Data::Study>())
{
study->parameters.simulationDays.first = 0;
study->parameters.simulationDays.end = 7;
study->initializeRuntimeInfos();
}

std::unique_ptr<Antares::Data::Study> study;
};

BOOST_AUTO_TEST_SUITE(surveyresults)

BOOST_FIXTURE_TEST_CASE(no_variable_constructor_does_not_throw, StudyFixture)
{
Benchmarking::DurationCollector durationCollector;
Antares::Solver::InMemoryWriter writer(durationCollector);
// At least one area was required to trigger a std::bad_alloc throw
Antares::Data::addAreaToListOfAreas(study->areas, "dummyArea");
BOOST_CHECK_NO_THROW(SurveyResults survey(*study, "out", writer););
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 8726a5b

Please sign in to comment.