Repository navigation
Expand file tree
/
Copy pathvcxproj_item_condition_test.py
More file actions
47 lines (39 loc) · 2.02 KB
/
Copy pathvcxproj_item_condition_test.py
File metadata and controls
47 lines (39 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# python -m pytest vcxproj_item_condition_test.py
#
# Regression coverage for Condition on a ClCompile *project item* itself
# (as opposed to Condition on the item's metadata children, which is a
# different, fully-supported feature -- see applyClCompileChild()).
#
# Microsoft documents that the Visual Studio C++ project system does not
# support Condition on project items: "Conditions aren't supported for
# Project items (that is, item types that are treated as project items by
# rules definitions)." -- see
# https://learn.microsoft.com/en-us/cpp/build/reference/vcxproj-file-structure
#
# This fixture's only <ClCompile> item is Include="foo.cpp"
# Condition="'$(Configuration)'=='Debug'". A discovery/evaluation pass that
# honors that Condition (i.e. treats the item like any other conditioned
# element) drops foo.cpp entirely when evaluating Release|x64 -- but real
# Visual Studio ignores the Condition on the item itself and always includes
# foo.cpp, in both Debug and Release. So foo.cpp must be checked under both
# configurations.
import os
from testutils import cppcheck
__script_dir = os.path.dirname(os.path.abspath(__file__))
def test_vcxproj_item_condition():
args = [
'--project=vcxproj_item_condition/vcxproj_item_condition.vcxproj',
'--no-cppcheck-build-dir',
'--dump'
]
ret, stdout, _ = cppcheck(args, cwd=__script_dir)
assert ret == 0, stdout
# Windows prints native '\' path separators ("Checking foo\main.cpp ...");
# normalize before matching so this passes on every platform (same idiom
# used by test_log() in clang-import_test.py).
normalized_stdout = stdout.replace('\\', '/')
# foo.cpp's Condition is gated on Configuration=='Debug', but Visual
# Studio does not evaluate Condition on project items -- so foo.cpp must
# be checked under BOTH configurations, not just Debug.
assert 'Checking vcxproj_item_condition/foo.cpp Debug|x64' in normalized_stdout, stdout
assert 'Checking vcxproj_item_condition/foo.cpp Release|x64' in normalized_stdout, stdout