KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_job_sch_erc.cpp
Go to the documentation of this file.
1
/*
2
* This program source code file is part of KiCad, a free EDA CAD application.
3
*
4
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, you may find one here:
18
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19
* or you may search the http://www.gnu.org website for the version 2 license,
20
* or you may write to the Free Software Foundation, Inc.,
21
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22
*/
23
24
#include <boost/test/unit_test.hpp>
25
#include <
jobs/job_sch_erc.h
>
26
#include <nlohmann/json.hpp>
27
28
29
BOOST_AUTO_TEST_SUITE
( JobSchErc )
30
31
32
// Regression test for https://gitlab.com/kicad/code/kicad/-/issues/23967
33
// A transient working output path (applied when the configured filename is empty)
34
// must not be serialized back into the jobset file.
35
BOOST_AUTO_TEST_CASE
( WorkingOutputPathNotPersisted )
36
{
37
JOB_SCH_ERC
job;
38
39
BOOST_REQUIRE
( job.
GetConfiguredOutputPath
().IsEmpty() );
40
41
job.
SetWorkingOutputPath
( wxS(
"my-project-erc.rpt"
) );
42
43
nlohmann::json j;
44
job.
ToJson
( j );
45
46
BOOST_CHECK( j.contains(
"output_filename"
) );
47
BOOST_CHECK_EQUAL
( j.value(
"output_filename"
,
"non-empty"
),
""
);
48
BOOST_CHECK( job.
GetConfiguredOutputPath
().IsEmpty() );
49
}
50
51
52
// A configured (user-supplied) output path must round-trip through JSON.
53
BOOST_AUTO_TEST_CASE
( ConfiguredOutputPathPersisted )
54
{
55
JOB_SCH_ERC
job;
56
job.
SetConfiguredOutputPath
( wxS(
"custom-erc.rpt"
) );
57
58
nlohmann::json j;
59
job.
ToJson
( j );
60
61
BOOST_CHECK_EQUAL
( j.value(
"output_filename"
,
""
),
"custom-erc.rpt"
);
62
}
63
64
65
// Setting a configured path after a transient working path was seeded (from a prior run with an
66
// empty filename) must let the new configured path win. Otherwise a user who runs the job once
67
// with an empty filename and then edits the config to supply a real filename will still hit the
68
// stale generated fallback on the next run.
69
BOOST_AUTO_TEST_CASE
( ConfiguredOutputPathOverridesWorkingPath )
70
{
71
JOB_SCH_ERC
job;
72
73
job.
SetWorkingOutputPath
( wxS(
"generated-erc.rpt"
) );
74
job.
SetConfiguredOutputPath
( wxS(
"custom-erc.rpt"
) );
75
76
BOOST_CHECK( job.
GetWorkingOutputPath
().IsEmpty() );
77
BOOST_CHECK( job.
GetFullOutputPath
(
nullptr
) == wxS(
"custom-erc.rpt"
) );
78
}
79
80
81
BOOST_AUTO_TEST_SUITE_END
()
JOB_SCH_ERC
Definition
job_sch_erc.h:26
JOB::SetConfiguredOutputPath
void SetConfiguredOutputPath(const wxString &aPath)
Sets the configured output path for the job, this path is always saved to file.
Definition
job.cpp:157
JOB::GetFullOutputPath
wxString GetFullOutputPath(PROJECT *aProject) const
Returns the full output path for the job, taking into account the configured output path,...
Definition
job.cpp:150
JOB::GetWorkingOutputPath
wxString GetWorkingOutputPath() const
Returns the working output path for the job, if one has been set.
Definition
job.h:246
JOB::GetConfiguredOutputPath
wxString GetConfiguredOutputPath() const
Returns the configured output path for the job.
Definition
job.h:235
JOB::ToJson
virtual void ToJson(nlohmann::json &j) const
Definition
job.cpp:67
JOB::SetWorkingOutputPath
void SetWorkingOutputPath(const wxString &aPath)
Sets a transient output path for the job, it takes priority over the configured output path when GetF...
Definition
job.h:241
job_sch_erc.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
Definition
test_api_enums.cpp:71
BOOST_AUTO_TEST_SUITE
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_REQUIRE
BOOST_REQUIRE(intersection.has_value()==c.ExpectedIntersection.has_value())
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(WorkingOutputPathNotPersisted)
Definition
test_job_sch_erc.cpp:35
BOOST_CHECK_EQUAL
BOOST_CHECK_EQUAL(result, "25.4")
src
qa
tests
common
test_job_sch_erc.cpp
Generated on Sun Apr 26 2026 00:06:58 for KiCad PCB EDA Suite by
1.13.2