Skip to content

Commit caa892a

Browse files
committed
Updated expected results for SOME_CONFIG config in helloworld_test.py
1 parent 578a18e commit caa892a

File tree

2 files changed

+39
-26
lines changed

2 files changed

+39
-26
lines changed

test/cli/helloworld_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def test_addon_relative_path():
107107
filename = os.path.join('helloworld', 'main.c')
108108
assert ret == 0, stdout
109109
assert stdout == ('Checking %s ...\n'
110-
'Checking %s: SOME_CONFIG...\n' % (filename, filename))
110+
'Checking %s: SOME_CONFIG=SOME_CONFIG...\n' % (filename, filename))
111111
assert stderr == ('[%s:5]: (error) Division by zero.\n'
112112
'[%s:4]: (style) misra violation (use --rule-texts=<file> to get proper output)\n' % (filename, filename))
113113

@@ -125,7 +125,7 @@ def test_addon_with_gui_project(tmp_path):
125125
assert ret == 0, stdout
126126
assert stdout.strip().split('\n') == [
127127
'Checking %s ...' % filename,
128-
'Checking %s: SOME_CONFIG...' % filename
128+
'Checking %s: SOME_CONFIG=SOME_CONFIG...' % filename
129129
]
130130
assert stderr == ('[%s:5]: (error) Division by zero.\n'
131131
'[%s:4]: (style) misra violation (use --rule-texts=<file> to get proper output)\n' % (filename, filename))

test/testpreprocessor.cpp

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ class TestPreprocessor : public TestFixture {
333333
TEST_CASE(getConfigsU5);
334334
TEST_CASE(getConfigsU6);
335335
TEST_CASE(getConfigsU7);
336-
TEST_CASE(getConfigsIssue14317);
337336

338-
TEST_CASE(getCodeIssue14317);
337+
TEST_CASE(getConfigsAndCodeIssue14317);
338+
TEST_CASE(getConfigsMostGeneralConfigIssue14317);
339339

340340
TEST_CASE(if_sizeof);
341341

@@ -2403,31 +2403,20 @@ class TestPreprocessor : public TestFixture {
24032403
ASSERT_EQUALS("\nY\n", getConfigsStr(code, "-DX"));
24042404
}
24052405

2406-
void getConfigsIssue14317() {
2406+
void getConfigsAndCodeIssue14317() {
24072407
const char filedata[] = "bool test() {\n"
2408-
"return\n"
2409-
"#if defined(isless)\n"
2410-
"0 != isless(1.0, 2.0)\n"
2411-
"#else\n"
2412-
"0\n"
2413-
"#endif\n"
2414-
";\n"
2415-
"}\n";
2408+
"return\n"
2409+
"#if defined(isless)\n"
2410+
"0 != isless(1.0, 2.0)\n"
2411+
"#else\n"
2412+
"0\n"
2413+
"#endif\n"
2414+
";\n"
2415+
"}\n";
2416+
// Test getConfigsStr()
24162417
ASSERT_EQUALS("\nisless=isless\n", getConfigsStr(filedata));
2417-
}
2418-
2419-
void getCodeIssue14317() {
2420-
// Handling include guards..
2421-
const char filedata[] = "bool test() {\n"
2422-
"return\n"
2423-
"#if defined(isless)\n"
2424-
"0 != isless(1.0, 2.0)\n"
2425-
"#else\n"
2426-
"0\n"
2427-
"#endif\n"
2428-
";\n"
2429-
"}\n";
24302418

2419+
// Test getcode()
24312420
// Preprocess => actual result..
24322421
const std::map<std::string, std::string> actual = getcode(settings0, *this, filedata);
24332422

@@ -2437,6 +2426,30 @@ class TestPreprocessor : public TestFixture {
24372426
ASSERT_EQUALS("bool test ( ) {\nreturn\n\n0 != $isless ( 1.0 , 2.0 )\n\n\n\n;\n}", actual.at("isless=isless"));
24382427
}
24392428

2429+
void getConfigsMostGeneralConfigIssue14317() {
2430+
// Verifies that the most general X (out of X=X and X) and Y=Y is returned
2431+
// For Z: First Z=Z is added to ret, then the ifndef else branch replaces Z=Z with the more general Z
2432+
const char filedata[] = "#ifdef X\n"
2433+
"print(X);\n"
2434+
"#endif\n"
2435+
"#if X\n"
2436+
"print(X+1);\n"
2437+
"#endif\n"
2438+
"#if defined(Y)\n"
2439+
"print(Y);\n"
2440+
"#endif\n"
2441+
"#ifdef Z\n"
2442+
"print(Z);\n"
2443+
"#endif\n"
2444+
"#ifndef Z\n"
2445+
"print(Z+1);\n"
2446+
"#else\n"
2447+
"print(Z+2);\n"
2448+
"#endif\n";
2449+
// Test getConfigsStr()
2450+
ASSERT_EQUALS("\nX\nY=Y\nZ\n", getConfigsStr(filedata));
2451+
}
2452+
24402453
void if_sizeof() { // #4071
24412454
const char code[] = "#if sizeof(unsigned short) == 2\n"
24422455
"Fred & Wilma\n"

0 commit comments

Comments
 (0)