-
Notifications
You must be signed in to change notification settings - Fork 726
/
recursive.test.ts
86 lines (70 loc) · 2.94 KB
/
recursive.test.ts
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { Example } from "./example";
import * as asserts from "./asserts";
function getOutputFiles(
configuration: "Debug" | "Release",
framework: string,
publish: boolean,
): string[] {
const publishPart = publish ? "publish/" : "";
return [
// templates
`bin/${configuration}/${framework}/${publishPart}root.json`,
`bin/${configuration}/${framework}/${publishPart}one/one.json`,
`bin/${configuration}/${framework}/${publishPart}one/two/two.json`,
// compiles params
`bin/${configuration}/${framework}/${publishPart}root1.parameters.json`,
`bin/${configuration}/${framework}/${publishPart}root2.parameters.json`,
`bin/${configuration}/${framework}/${publishPart}one/one1.parameters.json`,
`bin/${configuration}/${framework}/${publishPart}one/one2.parameters.json`,
`bin/${configuration}/${framework}/${publishPart}one/two/two1.parameters.json`,
`bin/${configuration}/${framework}/${publishPart}one/two/two2.parameters.json`,
];
}
describe("msbuild", () => {
it("should build a multi-targeting project with recursive copy enabled", () => {
const example = new Example("recursive");
example.cleanProjectDir();
const result = example.build();
expect(result.stderr).toBe("");
// TODO: ADO build for some reason refuses to build net472 when it's included in the array below
// but the same works in GitHub actions. we need to add it back once we figure out why
const targetFrameworks = ["net8.0"];
targetFrameworks.forEach((framework: string): void => {
getOutputFiles("Debug", framework, false).forEach((file) =>
example.expectTemplate(file),
);
});
const cleanResult = example.clean();
expect(cleanResult.stderr).toBe("");
targetFrameworks.forEach((framework: string): void => {
getOutputFiles("Debug", framework, false).forEach((file) =>
example.expectNoFile(file),
);
});
const publishFramework = targetFrameworks[0];
const publishResult = example.publish(publishFramework);
expect(publishResult.stderr).toBe("");
// after publish we should expect build output
// in the Release directory for the chosen framework
getOutputFiles("Release", publishFramework, false).forEach((file) =>
example.expectTemplate(file),
);
// publish dir should be populated with the same content
getOutputFiles("Release", publishFramework, true).forEach((file) =>
example.expectTemplate(file),
);
});
it("should fail if BicepOutputStyle is not set to a valid value", () => {
const example = new Example("recursive-badmode");
example.cleanProjectDir();
const result = example.build(false);
expect(result.status).not.toBe(0);
asserts.expectLinesInLog(result.stdout, [
": error : The BicepOutputStyle property must be set to either 'Flat' or 'Recursive'.",
"0 Warning(s)",
"1 Error(s)",
]);
});
});