|
12 | 12 | -- Setup |
13 | 13 | --- |
14 | 14 |
|
15 | | - local wks, prj |
16 | | - |
17 | | - function suite.setup() |
18 | | - wks = workspace("MyWorkspace") |
19 | | - configurations { "Debug", "Release" } |
20 | | - platforms { "x86", "x86_64" } |
21 | | - |
22 | | - prj = project "MyProject1" |
23 | | - usage "PUBLIC" |
24 | | - defines { "PROJECT_1_PUBLIC" } |
25 | | - usage "INTERFACE" |
26 | | - defines { "PROJECT_1_INTERFACE" } |
27 | | - usage "PRIVATE" |
28 | | - defines { "PROJECT_1_PRIVATE" } |
29 | | - end |
| 15 | + local wks, prj |
| 16 | + |
| 17 | + function suite.setup() |
| 18 | + wks = workspace("MyWorkspace") |
| 19 | + configurations { "Debug", "Release" } |
| 20 | + platforms { "x86", "x86_64" } |
| 21 | + |
| 22 | + prj = project "MyProject1" |
| 23 | + usage "PUBLIC" |
| 24 | + defines { "PROJECT_1_PUBLIC" } |
| 25 | + usage "INTERFACE" |
| 26 | + defines { "PROJECT_1_INTERFACE" } |
| 27 | + usage "PRIVATE" |
| 28 | + defines { "PROJECT_1_PRIVATE" } |
| 29 | + end |
| 30 | + |
30 | 31 |
|
31 | 32 | --- |
32 | 33 | -- Tests to ensure that the PUBLIC and PRIVATE usages are correctly applied to the owning project |
33 | 34 | --- |
34 | | - function suite.singleproject_checkusages() |
35 | | - p.oven.bake() |
| 35 | + function suite.singleproject_checkusages() |
| 36 | + p.oven.bake() |
| 37 | + |
| 38 | + local cfg = test.getconfig(prj, "Debug", "x86") |
| 39 | + test.contains({ "PROJECT_1_PUBLIC", "PROJECT_1_PRIVATE" }, cfg.defines) |
| 40 | + test.excludes({ "PROJECT_1_INTERFACE" }, cfg.defines) |
| 41 | + end |
36 | 42 |
|
37 | | - local cfg = test.getconfig(prj, "Debug", "x86") |
38 | | - test.isequal({ "PROJECT_1_PUBLIC", "PROJECT_1_PRIVATE" }, cfg.defines) -- Interface defines should not be included |
39 | | - end |
40 | 43 |
|
41 | 44 | --- |
42 | 45 | -- Tests to ensure that the PUBLIC and INTERFACE usages are correctly applied to the dependent project |
43 | 46 | --- |
44 | | - function suite.twoprojects_withdependency() |
45 | | - prj2 = project "MyProject2" |
46 | | - usage "PUBLIC" |
47 | | - defines { "PROJECT_2_PUBLIC" } |
48 | | - usage "INTERFACE" |
49 | | - defines { "PROJECT_2_INTERFACE" } |
50 | | - usage "PRIVATE" |
51 | | - defines { "PROJECT_2_PRIVATE" } |
52 | | - |
53 | | - uses { "MyProject1" } |
| 47 | + function suite.twoprojects_withdependency() |
| 48 | + prj2 = project "MyProject2" |
| 49 | + usage "PUBLIC" |
| 50 | + defines { "PROJECT_2_PUBLIC" } |
| 51 | + usage "INTERFACE" |
| 52 | + defines { "PROJECT_2_INTERFACE" } |
| 53 | + usage "PRIVATE" |
| 54 | + defines { "PROJECT_2_PRIVATE" } |
| 55 | + |
| 56 | + uses { "MyProject1" } |
| 57 | + |
| 58 | + p.oven.bake() |
54 | 59 |
|
55 | | - p.oven.bake() |
| 60 | + local cfg = test.getconfig(prj2, "Debug", "x86") |
56 | 61 |
|
57 | | - local cfg = test.getconfig(prj2, "Debug", "x86") |
| 62 | + test.contains({ "PROJECT_2_PUBLIC", "PROJECT_1_PUBLIC", "PROJECT_1_INTERFACE", "PROJECT_2_PRIVATE" }, cfg.defines) |
| 63 | + test.excludes({ "PROJECT_1_PRIVATE" }, cfg.defines) |
| 64 | + end |
58 | 65 |
|
59 | | - -- Order is important here, as the test treats different order as a failure |
60 | | - -- However, the order of the defines is not important in the actual implementation |
61 | | - test.isequal({ "PROJECT_2_PUBLIC", "PROJECT_1_PUBLIC", "PROJECT_1_INTERFACE", "PROJECT_2_PRIVATE" }, cfg.defines) -- Interface defines should not be included |
62 | | - end |
63 | 66 |
|
64 | 67 | --- |
65 | 68 | -- Tests to ensure that the PUBLIC and INTERFACE usages are correctly applied to the dependent project via a transitve dependency |
66 | 69 | --- |
67 | | - function suite.multipleprojects_transitivedependency() |
68 | | - prj2 = project "MyProject2" |
69 | | - usage "PUBLIC" |
70 | | - defines { "PROJECT_2_PUBLIC" } |
71 | | - uses { "MyProject1" } |
72 | | - usage "INTERFACE" |
73 | | - defines { "PROJECT_2_INTERFACE" } |
74 | | - usage "PRIVATE" |
75 | | - defines { "PROJECT_2_PRIVATE" } |
76 | | - |
77 | | - prj3 = project "MyProject3" |
78 | | - uses { "MyProject2" } |
79 | | - defines { "PROJECT_3" } |
| 70 | + function suite.multipleprojects_transitivedependency() |
| 71 | + prj2 = project "MyProject2" |
| 72 | + usage "PUBLIC" |
| 73 | + defines { "PROJECT_2_PUBLIC" } |
| 74 | + uses { "MyProject1" } |
| 75 | + usage "INTERFACE" |
| 76 | + defines { "PROJECT_2_INTERFACE" } |
| 77 | + usage "PRIVATE" |
| 78 | + defines { "PROJECT_2_PRIVATE" } |
80 | 79 |
|
81 | | - p.oven.bake() |
| 80 | + prj3 = project "MyProject3" |
| 81 | + uses { "MyProject2" } |
| 82 | + defines { "PROJECT_3" } |
82 | 83 |
|
83 | | - local cfg = test.getconfig(prj3, "Debug", "x86") |
| 84 | + p.oven.bake() |
| 85 | + |
| 86 | + local cfg = test.getconfig(prj3, "Debug", "x86") |
| 87 | + |
| 88 | + test.isequal({ "PROJECT_3", "PROJECT_1_PUBLIC", "PROJECT_1_INTERFACE", "PROJECT_2_PUBLIC", "PROJECT_2_INTERFACE" }, cfg.defines) |
| 89 | + test.excludes({ "PROJECT_1_PRIVATE", "PROJECT_2_PRIVATE" }, cfg.defines) |
| 90 | + end |
84 | 91 |
|
85 | | - -- Order is important here, as the test treats different order as a failure |
86 | | - -- However, the order of the defines is not important in the actual implementation |
87 | | - test.isequal({ "PROJECT_3", "PROJECT_1_PUBLIC", "PROJECT_1_INTERFACE", "PROJECT_2_PUBLIC", "PROJECT_2_INTERFACE" }, cfg.defines) |
88 | | - end |
89 | 92 |
|
90 | 93 | --- |
91 | | --- Test to ensure that usages with custom names |
| 94 | +-- Test to ensure that usages with custom names are correctly applied to the dependent project |
92 | 95 | --- |
93 | | - function suite.twoprojects_customname() |
94 | | - prj2 = project "MyProject2" |
95 | | - uses { "Custom" } |
96 | | - usage "Custom" |
97 | | - defines { "MY_CUSTOM_USAGE" } |
| 96 | + function suite.twoprojects_customname() |
| 97 | + prj2 = project "MyProject2" |
| 98 | + uses { "Custom" } |
| 99 | + usage "Custom" |
| 100 | + defines { "MY_CUSTOM_USAGE" } |
98 | 101 |
|
99 | | - p.oven.bake() |
| 102 | + p.oven.bake() |
100 | 103 |
|
101 | | - local cfg = test.getconfig(prj2, "Debug", "x86") |
| 104 | + local cfg = test.getconfig(prj2, "Debug", "x86") |
102 | 105 |
|
103 | | - -- Order is important here, as the test treats different order as a failure |
104 | | - -- However, the order of the defines is not important in the actual implementation |
105 | | - test.isequal({ "MY_CUSTOM_USAGE" }, cfg.defines) |
106 | | - end |
| 106 | + test.contains({ "MY_CUSTOM_USAGE" }, cfg.defines) |
| 107 | + end |
107 | 108 |
|
108 | 109 |
|
109 | | - function suite.multipleprojects_customname_transitive() |
110 | | - prj2 = project "MyProject2" |
111 | | - usage "Custom" |
112 | | - defines { "MY_CUSTOM_USAGE" } |
113 | | - |
114 | | - prj3 = project "MyProject3" |
115 | | - usage "Custom2" |
116 | | - uses { "Custom" } |
| 110 | +--- |
| 111 | +-- Test to ensure that usages with custom names are correctly applied to the dependent project via a transitve dependency |
| 112 | +--- |
| 113 | + function suite.multipleprojects_customname_transitive() |
| 114 | + prj2 = project "MyProject2" |
| 115 | + usage "Custom" |
| 116 | + defines { "MY_CUSTOM_USAGE" } |
117 | 117 |
|
118 | | - prj4 = project "MyProject4" |
119 | | - uses { "Custom2" } |
| 118 | + prj3 = project "MyProject3" |
| 119 | + usage "Custom2" |
| 120 | + uses { "Custom" } |
120 | 121 |
|
121 | | - p.oven.bake() |
| 122 | + prj4 = project "MyProject4" |
| 123 | + uses { "Custom2" } |
122 | 124 |
|
123 | | - local cfg = test.getconfig(prj4, "Debug", "x86") |
| 125 | + p.oven.bake() |
124 | 126 |
|
125 | | - -- Order is important here, as the test treats different order as a failure |
126 | | - -- However, the order of the defines is not important in the actual implementation |
127 | | - test.isequal({ "MY_CUSTOM_USAGE" }, cfg.defines) -- Interface defines should not be included |
128 | | - end |
| 127 | + local cfg = test.getconfig(prj4, "Debug", "x86") |
129 | 128 |
|
| 129 | + test.contains({ "MY_CUSTOM_USAGE" }, cfg.defines) |
| 130 | + end |
130 | 131 |
|
131 | | - function suite.twoprojects_noprojectinheritance() |
132 | | - -- Ensure that no variables come in from the default project scope |
133 | 132 |
|
134 | | - prj2 = project "MyProject2" |
135 | | - defines { "IMPLICIT_PRIVATE_DEFINE" } |
136 | | - usage "PUBLIC" |
137 | | - defines { "PROJECT_2_PUBLIC" } |
| 133 | +--- |
| 134 | +-- Test to ensure that usages do not inherit from the default project scope |
| 135 | +--- |
| 136 | + function suite.twoprojects_noprojectinheritance() |
| 137 | + prj2 = project "MyProject2" |
| 138 | + defines { "IMPLICIT_PRIVATE_DEFINE" } |
| 139 | + usage "PUBLIC" |
| 140 | + defines { "PROJECT_2_PUBLIC" } |
138 | 141 |
|
139 | | - prj3 = project "MyProject3" |
140 | | - uses { "MyProject2" } |
| 142 | + prj3 = project "MyProject3" |
| 143 | + uses { "MyProject2" } |
141 | 144 |
|
142 | | - p.oven.bake() |
| 145 | + p.oven.bake() |
143 | 146 |
|
144 | | - local cfg = test.getconfig(prj3, "Debug", "x86") |
| 147 | + local cfg = test.getconfig(prj3, "Debug", "x86") |
145 | 148 |
|
146 | | - -- Ensure that the implicit scope's define is not included |
147 | | - test.isequal({ "PROJECT_2_PUBLIC" }, cfg.defines) |
148 | | - end |
| 149 | + test.contains({ "PROJECT_2_PUBLIC" }, cfg.defines) |
| 150 | + test.excludes({ "IMPLICIT_PRIVATE_DEFINE" }, cfg.defines) |
| 151 | + end |
0 commit comments