@@ -202,6 +202,14 @@ func merge(a, b map[string]string) map[string]string {
202
202
}
203
203
204
204
func (t * Test ) MakeRun (ctx * Context ) (Tx , error ) {
205
+
206
+ // we don't support running C tests - assert this so we can
207
+ // troubleshoot if we try to run a C test
208
+ if t .IsC () {
209
+ fmt .Printf ("ERROR - UNEXPECTED - Running C test: %s\n " , t .Path )
210
+ os .Exit (1 )
211
+ }
212
+
205
213
t .Env = merge (ctx .Env , t .Env )
206
214
settings := merge (ctx .Settings , t .Settings )
207
215
settings ["newrelic.appname" ] = t .Name
@@ -214,6 +222,47 @@ func (t *Test) MakeRun(ctx *Context) (Tx, error) {
214
222
}
215
223
}
216
224
225
+ // Make a copy of settings to avoid mutating the original map
226
+ // Need to adjust settings to opcache
227
+ phpSettings := make (map [string ]string , len (settings ))
228
+ setOPCacheEnable := true
229
+ setOPCacheEnableCLI := true
230
+ var php_executable string
231
+ if t .IsWeb () {
232
+ php_executable = ctx .CGI
233
+ } else {
234
+ php_executable = ctx .PHP
235
+ }
236
+ for k , v := range settings {
237
+ phpSettings [k ] = v
238
+
239
+ // see if settings affect opcache config
240
+ // if so then we will not set config below
241
+ if k == "opcache.enable" {
242
+ setOPCacheEnable = false
243
+ } else if k == "opcache.enable_cli" {
244
+ setOPCacheEnableCLI = false
245
+ }
246
+ }
247
+ if ctx .UseOPCache {
248
+ if ! ctx .OPCacheModuleLoaded [php_executable ] {
249
+ phpSettings ["zend_extension" ] = "opcache.so"
250
+ }
251
+ if setOPCacheEnable {
252
+ phpSettings ["opcache.enable" ] = "1"
253
+ }
254
+ if setOPCacheEnableCLI {
255
+ phpSettings ["opcache.enable_cli" ] = "1"
256
+ }
257
+ } else {
258
+ if setOPCacheEnable {
259
+ phpSettings ["opcache.enable" ] = "0"
260
+ }
261
+ if setOPCacheEnableCLI {
262
+ phpSettings ["opcache.enable_cli" ] = "0"
263
+ }
264
+ }
265
+
217
266
// Make a copy of t.PhpModules and remove any entries containing "opcache.so"
218
267
// if opcache.so is loaded by default
219
268
//
@@ -222,28 +271,21 @@ func (t *Test) MakeRun(ctx *Context) (Tx, error) {
222
271
// 2. Web test and php-cgi has opcache.so loaded by default - remove any PHPMODULE spec for opcache.so
223
272
// 3. PHP test and php has opcache.so loaded by default - remove any PHPMODULE spec for opcache.so
224
273
phpModulesCopy := make (map [string ]string )
225
- if ! t .IsC () {
226
- if (t .IsWeb () && ctx .OPCacheModuleLoaded [ctx .CGI ]) ||
227
- (ctx .OPCacheModuleLoaded [ctx .PHP ]) {
228
- for k , v := range t .PhpModules {
229
- if ! strings .Contains (v , "opcache.so" ) {
230
- phpModulesCopy [k ] = v
231
- }
274
+ if (t .IsWeb () && ctx .OPCacheModuleLoaded [ctx .CGI ]) ||
275
+ (ctx .OPCacheModuleLoaded [ctx .PHP ]) {
276
+ for k , v := range t .PhpModules {
277
+ if ! strings .Contains (v , "opcache.so" ) {
278
+ phpModulesCopy [k ] = v
232
279
}
233
280
}
234
- } else {
235
- fmt .Printf ("ERROR - UNEXPECTED - Running C test: %s\n " , t .Path )
236
- os .Exit (1 )
237
281
}
238
- settings = merge (settings , phpModulesCopy )
239
282
240
- if t .IsC () {
241
- return CTx (ScriptFile (t .Path ), t .Env , settings , headers , ctx )
242
- }
283
+ phpSettings = merge (phpSettings , phpModulesCopy )
284
+
243
285
if t .IsWeb () {
244
- return CgiTx (ScriptFile (t .Path ), t .Env , settings , headers , ctx )
286
+ return CgiTx (ScriptFile (t .Path ), t .Env , phpSettings , headers , ctx )
245
287
}
246
- return PhpTx (ScriptFile (t .Path ), t .Env , settings , ctx )
288
+ return PhpTx (ScriptFile (t .Path ), t .Env , phpSettings , ctx )
247
289
}
248
290
249
291
func (t * Test ) MakeSkipIf (ctx * Context ) (Tx , error ) {
0 commit comments