@@ -12,6 +12,7 @@ const fatalMuPlugin = join(root, "fatal-bootstrap.php")
1212const recipePath = join ( root , "recipe.json" )
1313const artifactsPath = join ( root , "artifacts" )
1414const exitArtifactsPath = join ( root , "exit-artifacts" )
15+ const parseArtifactsPath = join ( root , "parse-artifacts" )
1516
1617try {
1718 await writeFile ( fatalMuPlugin , `<?php\ntrigger_error('PHPUnit bootstrap fixture token: ${ secret } ', E_USER_ERROR);\n` )
6566 const exitDiagnostic = await readFile ( join ( exitArtifactsPath , exitRuntimeDirectory , "files" , "phpunit" , ".pg-test-result.txt" ) , "utf8" )
6667 assert . match ( exitDiagnostic , / S T A G E _ D I E : b o o t s t r a p : P H P U n i t b o o t s t r a p e x i t f i x t u r e t o k e n : \[ r e d a c t e d \] / )
6768 assert . doesNotMatch ( exitDiagnostic , new RegExp ( secret ) )
69+
70+ await writeFile ( recipePath , `${ JSON . stringify ( {
71+ schema : "wp-codebox/workspace-recipe/v1" ,
72+ runtime : { backend : "wordpress-playground" , wp : "6.5" , blueprint : { steps : [ ] } } ,
73+ inputs : { mounts : [ ] } ,
74+ workflow : {
75+ steps : [ { command : "wordpress.phpunit" , args : [ "plugin-slug=bootstrap-failure-fixture" , "code=<?php function malformed(" ] } ] ,
76+ } ,
77+ } ) } \n`)
78+ const parseOutput = await runFailedRecipe ( parseArtifactsPath )
79+ assert . equal ( parseOutput . success , false , JSON . stringify ( parseOutput ) )
80+ const parseMessage = parseOutput . error ?. message ?? ""
81+ assert . match ( parseMessage , / w o r d p r e s s \. p h p u n i t s t r u c t u r e d d i a g n o s t i c s / )
82+ assert . match ( parseMessage , / P a r s e E r r o r / )
83+
84+ const parseLatest = JSON . parse ( await readFile ( join ( parseArtifactsPath , "latest-runtime.json" ) , "utf8" ) ) as { paths ?: { runtimeDirectory ?: string } }
85+ const parseRuntimeDirectory = parseLatest . paths ?. runtimeDirectory
86+ assert . ok ( parseRuntimeDirectory , "malformed recipe must retain a runtime artifact directory" )
87+ const parseDiagnostic = await readFile ( join ( parseArtifactsPath , parseRuntimeDirectory , "files" , "phpunit" , ".pg-test-result.txt" ) , "utf8" )
88+ assert . match ( parseDiagnostic , / S T A G E _ F A I L : b o o t s t r a p : P a r s e E r r o r / )
6889} finally {
6990 await rm ( root , { recursive : true , force : true } )
7091}
0 commit comments