|
KiCad PCB EDA Suite
|
#include <boost/test/unit_test.hpp>#include <qa_utils/file_utils.h>#include <qa_utils/env_var_utils.h>#include <atomic>#include <optional>#include <thread>#include <vector>#include <wx/filename.h>#include <wx/utils.h>#include <common.h>#include <env_paths.h>#include <env_vars.h>#include <jobs/job_export_pcb_stats.h>#include <pgm_base.h>#include <settings/environment.h>#include <title_block.h>Go to the source code of this file.
Classes | |
| struct | ExpandTextVarsFixture |
| Test fixture for ExpandTextVars tests. More... | |
Macros | |
| #define | BOOST_TEST_NO_MAIN |
Functions | |
| BOOST_AUTO_TEST_CASE (AssertionsRemainAvailableOnlyDuringRuleChecks) | |
| BOOST_AUTO_TEST_CASE (SimpleVariable) | |
| BOOST_AUTO_TEST_CASE (MultipleVariables) | |
| BOOST_AUTO_TEST_CASE (EscapedVariable) | |
| BOOST_AUTO_TEST_CASE (EscapedThenRegularVariable) | |
| BOOST_AUTO_TEST_CASE (RegularThenEscapedVariable) | |
| BOOST_AUTO_TEST_CASE (EscapedInsideMathExpression) | |
| BOOST_AUTO_TEST_CASE (EscapedInsideVariableReference) | |
| BOOST_AUTO_TEST_CASE (MultipleEscapedInMathExpression) | |
| BOOST_AUTO_TEST_CASE (EscapedAtInExpression) | |
| BOOST_AUTO_TEST_CASE (ConsecutiveEscaped) | |
| BOOST_AUTO_TEST_CASE (BackslashBeforeVariableIsEscape) | |
| BOOST_AUTO_TEST_CASE (ForwardSlashBeforeVariableExpands) | |
| BOOST_AUTO_TEST_CASE (BackslashSeparatorBeforeVarExpands) | |
| BOOST_AUTO_TEST_CASE (MultipleVarsAfterBackslashSeparators) | |
| BOOST_AUTO_TEST_CASE (ForwardSlashPathUnchanged) | |
| BOOST_AUTO_TEST_CASE (NonVariableBackslashesArePreserved) | |
| BOOST_AUTO_TEST_CASE (BackslashPathSeparatorBeforeTextVar) | |
| BOOST_AUTO_TEST_CASE (BackslashPathSeparatorBeforeMultipleTextVars) | |
| BOOST_AUTO_TEST_CASE (TextVarNotFirstInFilename) | |
| BOOST_AUTO_TEST_CASE (OverlappingPrefix_NormalizePicksLongestPrefix) | |
| Regression tests for overlapping-prefix environment variables. | |
| BOOST_AUTO_TEST_CASE (ParallelResolveTextVarsWithMathExpressions) | |
| Regression test for KiCad GitLab issue #23962. | |
| BOOST_AUTO_TEST_CASE (ExpandsNestedReferences) | |
| BOOST_AUTO_TEST_CASE (UndefinedReferenceLeavesLiteralMarker) | |
| BOOST_AUTO_TEST_CASE (UserVarIsNotTreatedAsVersionedLibraryDir) | |
| BOOST_AUTO_TEST_CASE (LegacyVersionedVarStillResolvesToCurrentDir) | |
| BOOST_AUTO_TEST_CASE (DeprecatedUnversionedAliasStillResolves) | |
| BOOST_AUTO_TEST_CASE (IsVersionedEnvVarPredicate) | |
| #define BOOST_TEST_NO_MAIN |
Definition at line 21 of file test_expand_text_vars.cpp.
| BOOST_AUTO_TEST_CASE | ( | AssertionsRemainAvailableOnlyDuringRuleChecks | ) |
Definition at line 73 of file test_expand_text_vars.cpp.
References BOOST_AUTO_TEST_CASE(), BOOST_CHECK_EQUAL(), empty(), ExpandTextVars(), FOR_CANVAS, FOR_ERC_DRC, and RAW_VALUE.
| BOOST_AUTO_TEST_CASE | ( | BackslashBeforeVariableIsEscape | ) |
Definition at line 212 of file test_expand_text_vars.cpp.
References ExpandTextVars(), INTERNAL, and result.
| BOOST_AUTO_TEST_CASE | ( | BackslashPathSeparatorBeforeMultipleTextVars | ) |
Definition at line 306 of file test_expand_text_vars.cpp.
References path, JOB::ResolveOutputPath(), result, TITLE_BLOCK::SetComment(), TITLE_BLOCK::SetRevision(), and JOB::SetTitleBlock().
| BOOST_AUTO_TEST_CASE | ( | BackslashPathSeparatorBeforeTextVar | ) |
Definition at line 285 of file test_expand_text_vars.cpp.
References BOOST_AUTO_TEST_CASE(), path, JOB::ResolveOutputPath(), result, TITLE_BLOCK::SetRevision(), and JOB::SetTitleBlock().
| BOOST_AUTO_TEST_CASE | ( | BackslashSeparatorBeforeVarExpands | ) |
Definition at line 237 of file test_expand_text_vars.cpp.
References BOOST_AUTO_TEST_CASE(), ExpandTextVars(), INTERNAL, NormalizeFilePathForTextVars(), path, and result.
| BOOST_AUTO_TEST_CASE | ( | ConsecutiveEscaped | ) |
Definition at line 191 of file test_expand_text_vars.cpp.
References BOOST_CHECK_EQUAL(), ExpandTextVars(), INTERNAL, and result.
| BOOST_AUTO_TEST_CASE | ( | DeprecatedUnversionedAliasStillResolves | ) |
Definition at line 544 of file test_expand_text_vars.cpp.
References BOOST_CHECK_EQUAL(), ExpandEnvVarSubstitutions(), and ENV_VAR::GetVersionedEnvVarName().
| BOOST_AUTO_TEST_CASE | ( | EscapedAtInExpression | ) |
Definition at line 181 of file test_expand_text_vars.cpp.
References ExpandTextVars(), INTERNAL, and result.
| BOOST_AUTO_TEST_CASE | ( | EscapedInsideMathExpression | ) |
Definition at line 128 of file test_expand_text_vars.cpp.
References ExpandTextVars(), INTERNAL, and result.
| BOOST_AUTO_TEST_CASE | ( | EscapedInsideVariableReference | ) |
Definition at line 147 of file test_expand_text_vars.cpp.
References ExpandTextVars(), INTERNAL, and result.
| BOOST_AUTO_TEST_CASE | ( | EscapedThenRegularVariable | ) |
Definition at line 109 of file test_expand_text_vars.cpp.
References ExpandTextVars(), INTERNAL, and result.
| BOOST_AUTO_TEST_CASE | ( | EscapedVariable | ) |
Definition at line 101 of file test_expand_text_vars.cpp.
References ExpandTextVars(), INTERNAL, and result.
| BOOST_AUTO_TEST_CASE | ( | ExpandsNestedReferences | ) |
Definition at line 467 of file test_expand_text_vars.cpp.
References BOOST_AUTO_TEST_CASE(), BOOST_CHECK_EQUAL(), ExpandEnvVarSubstitutions(), and expected.
| BOOST_AUTO_TEST_CASE | ( | ForwardSlashBeforeVariableExpands | ) |
Definition at line 222 of file test_expand_text_vars.cpp.
References ExpandTextVars(), INTERNAL, and result.
| BOOST_AUTO_TEST_CASE | ( | ForwardSlashPathUnchanged | ) |
Definition at line 259 of file test_expand_text_vars.cpp.
References ExpandTextVars(), INTERNAL, NormalizeFilePathForTextVars(), path, and result.
| BOOST_AUTO_TEST_CASE | ( | IsVersionedEnvVarPredicate | ) |
Definition at line 566 of file test_expand_text_vars.cpp.
References ENV_VAR::IsVersionedEnvVar().
| BOOST_AUTO_TEST_CASE | ( | LegacyVersionedVarStillResolvesToCurrentDir | ) |
Definition at line 523 of file test_expand_text_vars.cpp.
References BOOST_CHECK_EQUAL(), BOOST_REQUIRE(), ExpandEnvVarSubstitutions(), and ENV_VAR::GetVersionedEnvVarName().
| BOOST_AUTO_TEST_CASE | ( | MultipleEscapedInMathExpression | ) |
Definition at line 159 of file test_expand_text_vars.cpp.
References BOOST_CHECK_EQUAL(), ExpandTextVars(), INTERNAL, and result.
| BOOST_AUTO_TEST_CASE | ( | MultipleVariables | ) |
Definition at line 94 of file test_expand_text_vars.cpp.
References ExpandTextVars(), INTERNAL, and result.
| BOOST_AUTO_TEST_CASE | ( | MultipleVarsAfterBackslashSeparators | ) |
Definition at line 250 of file test_expand_text_vars.cpp.
References ExpandTextVars(), INTERNAL, NormalizeFilePathForTextVars(), path, and result.
| BOOST_AUTO_TEST_CASE | ( | NonVariableBackslashesArePreserved | ) |
Definition at line 270 of file test_expand_text_vars.cpp.
References NormalizeFilePathForTextVars(), and path.
| BOOST_AUTO_TEST_CASE | ( | OverlappingPrefix_NormalizePicksLongestPrefix | ) |
Regression tests for overlapping-prefix environment variables.
Reproduces the scenario from a KiCad V10 bug report where users set both a versioned package path and a narrower user library path that is a descendant of the package path, e.g.
KICAD10_3RD_PARTY = /tmp/kicadlib KICAD_USER_LIB = /tmp/kicadlib/V10
Creating a symbol library at ${KICAD_USER_LIB}/symbols/test.kicad_sym round-trips through NormalizePath (at InsertRow time) and ExpandEnvVarSubstitutions (at plugin CreateLibrary time). If the round-trip loses fidelity, the plugin tries to open a malformed path and fails with a generic "Could not create the library file" error.
Definition at line 356 of file test_expand_text_vars.cpp.
References BOOST_CHECK_EQUAL(), KI_TEST::SCOPED_TEMP_DIR::CreateChildDirStr(), expected, normalized(), NormalizePath(), KI_TEST::SCOPED_TEMP_DIR::PathStr(), and Pgm().
| BOOST_AUTO_TEST_CASE | ( | ParallelResolveTextVarsWithMathExpressions | ) |
Regression test for KiCad GitLab issue #23962.
ResolveTextVars and ExpandTextVars used a function-local static EXPRESSION_EVALUATOR shared across all threads. CONNECTION_GRAPH evaluates schematic labels in parallel via a thread pool and label text may contain @{...} expressions, which caused the shared evaluator's internal ERROR_COLLECTOR vector to be mutated concurrently, leading to heap corruption and a segfault inside std::vector::clear.
This test hammers ResolveTextVars from many threads to make the race observable, primarily under TSan. It also serves as a smoke test that no thread crashes.
Definition at line 394 of file test_expand_text_vars.cpp.
References BOOST_AUTO_TEST_CASE(), BOOST_CHECK_EQUAL(), ResolveTextVars(), and result.
| BOOST_AUTO_TEST_CASE | ( | RegularThenEscapedVariable | ) |
Definition at line 118 of file test_expand_text_vars.cpp.
References ExpandTextVars(), INTERNAL, and result.
| BOOST_AUTO_TEST_CASE | ( | SimpleVariable | ) |
Definition at line 87 of file test_expand_text_vars.cpp.
References ExpandTextVars(), INTERNAL, and result.
| BOOST_AUTO_TEST_CASE | ( | TextVarNotFirstInFilename | ) |
Definition at line 326 of file test_expand_text_vars.cpp.
References path, JOB::ResolveOutputPath(), result, TITLE_BLOCK::SetRevision(), and JOB::SetTitleBlock().
| BOOST_AUTO_TEST_CASE | ( | UndefinedReferenceLeavesLiteralMarker | ) |
Definition at line 482 of file test_expand_text_vars.cpp.
References BOOST_CHECK_EQUAL(), and ExpandEnvVarSubstitutions().
| BOOST_AUTO_TEST_CASE | ( | UserVarIsNotTreatedAsVersionedLibraryDir | ) |
Definition at line 498 of file test_expand_text_vars.cpp.
References BOOST_CHECK_EQUAL(), ExpandEnvVarSubstitutions(), and ENV_VAR::GetVersionedEnvVarName().