17
17
import static org .mockito .Mockito .when ;
18
18
19
19
import java .util .ArrayList ;
20
+ import java .util .HashMap ;
20
21
import java .util .List ;
22
+ import java .util .Map ;
21
23
22
24
import org .eclipse .cdt .cmake .core .properties .CMakeGenerator ;
23
25
import org .eclipse .cdt .cmake .core .properties .ICMakeProperties ;
24
- import org .eclipse .cdt .cmake .core .properties .IOsOverrides ;
25
26
import org .eclipse .cdt .core .CCProjectNature ;
26
27
import org .eclipse .cdt .core .CProjectNature ;
27
28
import org .eclipse .cdt .core .build .IToolChain ;
@@ -57,86 +58,38 @@ public void setup() throws Exception {
57
58
}
58
59
59
60
/**
60
- * Test for {@link IOsOverrides#setGenerator()}.
61
+ * Test for {@link ICMakeProperties#setGenerator()}.
62
+ *
63
+ * This test also verifies that what the ISV overrides in getCMakeProperties is what takes effect.
61
64
*/
62
65
@ Test
63
66
public void getCMakePropertiesTestSetGenerator () throws Exception {
64
- CMakeBuildConfigurationExtended cmBuildConfig = new CMakeBuildConfigurationExtended (buildConfig ,
65
- "cmBuildConfigName" , mockToolchain ) {
67
+ CMakeBuildConfiguration cmBuildConfig = new CMakeBuildConfiguration (buildConfig , "cmBuildConfigName" ,
68
+ mockToolchain ) {
66
69
67
70
@ Override
68
71
public ICMakeProperties getCMakeProperties () {
69
72
ICMakeProperties properties = super .getCMakeProperties ();
70
-
71
- IOsOverrides windowsOverrides = properties .getWindowsOverrides ();
72
- windowsOverrides .setGenerator (CMakeGenerator .NMakeMakefiles );
73
- IOsOverrides linuxOverrides = properties .getLinuxOverrides ();
74
- linuxOverrides .setGenerator (CMakeGenerator .UnixMakefiles );
75
- return properties ;
76
- }
77
- };
78
-
79
- // Call the new method on ICMakeBuildConfiguration to get the default CMake properties.
80
- ICMakeProperties cMakeProperties = cmBuildConfig .getCMakeProperties ();
81
-
82
- // Get overrides for Windows host and check the default value for getGenerator.
83
- IOsOverrides windowsOverrides = cMakeProperties .getWindowsOverrides ();
84
- CMakeGenerator winGenerator = windowsOverrides .getGenerator ();
85
- assertThat (winGenerator , is (CMakeGenerator .NMakeMakefiles ));
86
-
87
- // Get overrides for Linux host and check the default value for getGenerator.
88
- IOsOverrides linuxOverrides = cMakeProperties .getLinuxOverrides ();
89
- CMakeGenerator linuxGenerator = linuxOverrides .getGenerator ();
90
- assertThat (linuxGenerator , is (CMakeGenerator .UnixMakefiles ));
91
- }
92
-
93
- /**
94
- * Test for {@link IOsOverrides#setDefaultGenerator()}. Also tests that {@link ICMakeProperties#reset(boolean)} works as expected.
95
- */
96
- @ Test
97
- public void getCMakePropertiesTestSetDefaultGenerator () throws Exception {
98
- CMakeBuildConfigurationExtended cmBuildConfig = new CMakeBuildConfigurationExtended (buildConfig ,
99
- "cmBuildConfigName" , mockToolchain ) {
100
-
101
- @ Override
102
- public ICMakeProperties getCMakeProperties () {
103
- ICMakeProperties properties = super .getCMakeProperties ();
104
-
105
- IOsOverrides windowsOverrides = properties .getWindowsOverrides ();
106
- windowsOverrides .setDefaultGenerator (CMakeGenerator .NMakeMakefiles );
107
- IOsOverrides linuxOverrides = properties .getLinuxOverrides ();
108
- linuxOverrides .setDefaultGenerator (CMakeGenerator .UnixMakefiles );
109
- // reset(true) causes the CMake generator to be reset to it's default value.
110
- properties .reset (true );
73
+ properties .setGenerator (CMakeGenerator .WatcomWMake );
111
74
return properties ;
112
75
}
113
76
};
114
77
115
78
// Call the new method on ICMakeBuildConfiguration to get the default CMake properties.
116
79
ICMakeProperties cMakeProperties = cmBuildConfig .getCMakeProperties ();
117
-
118
- // Get overrides for Windows host and check the default value for getGenerator.
119
- IOsOverrides windowsOverrides = cMakeProperties .getWindowsOverrides ();
120
- CMakeGenerator winGenerator = windowsOverrides .getGenerator ();
121
- assertThat (winGenerator , is (CMakeGenerator .NMakeMakefiles ));
122
-
123
- // Get overrides for Linux host and check the default value for getGenerator.
124
- IOsOverrides linuxOverrides = cMakeProperties .getLinuxOverrides ();
125
- CMakeGenerator linuxGenerator = linuxOverrides .getGenerator ();
126
- assertThat (linuxGenerator , is (CMakeGenerator .UnixMakefiles ));
80
+ assertThat (cMakeProperties .getGenerator (), is (CMakeGenerator .WatcomWMake ));
127
81
}
128
82
129
83
/**
130
84
* Test for {@link ICMakeProperties#setExtraArguments()}
131
- * This is a different extraArguments to IOsOverrides#setExtraArguments().
132
- * Presumably ICMakeProperties#setExtraArguments() are platform agnostic extra arguments, where as
133
- * IOsOverrides#setExtraArguments() can be set different for Linux and Windows.
85
+ *
86
+ * This test also verifies that what the ISV overrides in getCMakeProperties is what takes effect.
134
87
*/
135
88
@ Test
136
89
public void getCMakePropertiesTestSetExtraArguments () throws Exception {
137
90
// Create a C Build Configuration using the default build config and an arbitrary name
138
- CMakeBuildConfigurationExtended cmBuildConfig = new CMakeBuildConfigurationExtended (buildConfig ,
139
- "cmBuildConfigName" , mockToolchain ) {
91
+ CMakeBuildConfiguration cmBuildConfig = new CMakeBuildConfiguration (buildConfig , "cmBuildConfigName" ,
92
+ mockToolchain ) {
140
93
141
94
@ Override
142
95
public ICMakeProperties getCMakeProperties () {
@@ -153,46 +106,25 @@ public ICMakeProperties getCMakeProperties() {
153
106
}
154
107
155
108
/**
156
- * Test for {@link IOsOverrides#setExtraArguments ()}
109
+ * Test for {@link CMakeBuildConfiguration#getDefaultProperties ()}
157
110
*/
158
111
@ Test
159
- public void getCMakePropertiesTestIOsOverridesSetExtraArguments () throws Exception {
112
+ public void getDefaultProperties () throws Exception {
160
113
// Create a C Build Configuration using the default build config and an arbitrary name
161
- CMakeBuildConfigurationExtended cmBuildConfig = new CMakeBuildConfigurationExtended (buildConfig ,
162
- "cmBuildConfigName" , mockToolchain );
114
+ CMakeBuildConfiguration cmBuildConfig = new CMakeBuildConfiguration (buildConfig , "cmBuildConfigName" ,
115
+ mockToolchain ) {
116
+
117
+ @ Override
118
+ public Map <String , String > getDefaultProperties () {
119
+ var defs = new HashMap <>(super .getDefaultProperties ());
120
+ defs .put (CMAKE_GENERATOR , CMakeGenerator .WatcomWMake .getCMakeName ());
121
+ defs .put (CMAKE_USE_UI_OVERRIDES , "true" );
122
+ return defs ;
123
+ }
124
+ };
163
125
// Call the new method on ICMakeBuildConfiguration to get the default CMake properties.
164
126
ICMakeProperties cMakeProperties = cmBuildConfig .getCMakeProperties ();
165
-
166
- // Get overrides for Windows host and check the default value for getExtraArguments.
167
- IOsOverrides windowsOverrides = cMakeProperties .getWindowsOverrides ();
168
- List <String > winExtraArguments = windowsOverrides .getExtraArguments ();
169
- assertThat (winExtraArguments , contains ("-Dtest0=0" , "-Dtest1=1" ));
170
-
171
- // Get overrides for Linux host and check the default value for getExtraArguments.
172
- IOsOverrides linuxOverrides = cMakeProperties .getLinuxOverrides ();
173
- List <String > linuxExtraArguments = linuxOverrides .getExtraArguments ();
174
- assertThat (linuxExtraArguments , contains ("-DLinuxtest0=0" , "-DLinuxtest1=1" ));
175
- }
176
-
177
- private class CMakeBuildConfigurationExtended extends CMakeBuildConfiguration {
178
-
179
- public CMakeBuildConfigurationExtended (IBuildConfiguration config , String name , IToolChain toolChain ) {
180
- super (config , name , toolChain );
181
- }
182
-
183
- @ Override
184
- public ICMakeProperties getCMakeProperties () {
185
- // get the built-in CDT defaults
186
- ICMakeProperties properties = super .getCMakeProperties ();
187
-
188
- IOsOverrides windowsOverrides = properties .getWindowsOverrides ();
189
- windowsOverrides .setExtraArguments (new ArrayList <>((List .of ("-Dtest0=0" , "-Dtest1=1" ))));
190
-
191
- IOsOverrides linuxOverrides = properties .getLinuxOverrides ();
192
- linuxOverrides .setExtraArguments (new ArrayList <>((List .of ("-DLinuxtest0=0" , "-DLinuxtest1=1" ))));
193
-
194
- return properties ;
195
- }
127
+ assertThat (cMakeProperties .getGenerator (), is (CMakeGenerator .WatcomWMake ));
196
128
}
197
129
198
130
private IProject createCMakeProject () throws Exception {
0 commit comments