Skip to content

Commit d949aa1

Browse files
committed
Add tests to check against clobbering TPOs/framework lists
1 parent a945f83 commit d949aa1

File tree

2 files changed

+351
-1
lines changed

2 files changed

+351
-1
lines changed

dotnet/private/tests/nuget_structure/common.bzl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,50 @@ nuget_structure_test = analysistest.make(
100100
},
101101
)
102102

103+
def _nuget_targeting_pack_overrides_test_impl(ctx):
104+
env = analysistest.begin(ctx)
105+
106+
target_under_test = analysistest.target_under_test(env)
107+
nuget_provider = target_under_test[NuGetInfo]
108+
109+
targeting_pack_overrides = nuget_provider.targeting_pack_overrides
110+
asserts.true(
111+
env,
112+
sorted(ctx.attr.expected_targeting_pack_overrides) == sorted(targeting_pack_overrides),
113+
"\nExpected targeting_pack_overrides:\n{}\nActual targeting_pack_overrides:\n{}".format(ctx.attr.expected_targeting_pack_overrides, targeting_pack_overrides),
114+
)
115+
116+
return analysistest.end(env)
117+
118+
nuget_targeting_pack_overrides_test = analysistest.make(
119+
_nuget_targeting_pack_overrides_test_impl,
120+
attrs = {
121+
"expected_targeting_pack_overrides": attr.string_dict(default = {}),
122+
},
123+
)
124+
125+
def _nuget_framework_list_test_impl(ctx):
126+
env = analysistest.begin(ctx)
127+
128+
target_under_test = analysistest.target_under_test(env)
129+
nuget_provider = target_under_test[NuGetInfo]
130+
131+
framework_list = nuget_provider.framework_list
132+
asserts.true(
133+
env,
134+
sorted(ctx.attr.expected_framework_list) == sorted(framework_list),
135+
"\nExpected framework_list:\n{}\nActual framework_list:\n{}".format(ctx.attr.expected_framework_list, framework_list),
136+
)
137+
138+
return analysistest.end(env)
139+
140+
nuget_framework_list_test = analysistest.make(
141+
_nuget_framework_list_test_impl,
142+
attrs = {
143+
"expected_framework_list": attr.string_dict(default = {}),
144+
},
145+
)
146+
103147
def _nuget_test_wrapper(ctx):
104148
return [ctx.attr.package[0][DotnetAssemblyCompileInfo], ctx.attr.package[0][DotnetAssemblyRuntimeInfo], ctx.attr.package[0][NuGetInfo]]
105149

0 commit comments

Comments
 (0)