File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,12 +21,29 @@ import {
2121 */
2222Given ( 'WP is latest WP' , async function ( this : ICustomWorld ) {
2323 const result = await wpWithOutput ( 'core update' ) ;
24- // Acceptable outcomes: already at latest, or successfully updated
25- const success = ! result . failed
26- || result . stdout . includes ( 'WordPress is up to date' )
27- || result . stdout . includes ( 'Success' ) ;
28- if ( ! success ) {
29- throw new Error ( `Failed to update WordPress core: ${ result . stderr } ` ) ;
24+
25+ if ( result . failed ) {
26+ throw new Error (
27+ `Failed to update WordPress core.\nSTDOUT:\n${ result . stdout } \nSTDERR:\n${ result . stderr } `
28+ ) ;
29+ }
30+
31+ const stdout = result . stdout ?? '' ;
32+ const isAlreadyUpToDate = stdout . includes ( 'WordPress is up to date' ) ;
33+ const isUpdateSuccess = stdout . includes ( 'Success' ) ;
34+
35+ if ( ! isAlreadyUpToDate && ! isUpdateSuccess ) {
36+ throw new Error (
37+ `Unexpected output from "wp core update".\nSTDOUT:\n${ stdout } \nSTDERR:\n${ result . stderr } `
38+ ) ;
39+ }
40+
41+ const updateDbResult = await wpWithOutput ( 'core update-db' ) ;
42+
43+ if ( updateDbResult . failed ) {
44+ throw new Error (
45+ `Failed to run "wp core update-db".\nSTDOUT:\n${ updateDbResult . stdout } \nSTDERR:\n${ updateDbResult . stderr } `
46+ ) ;
3047 }
3148} ) ;
3249
You can’t perform that action at this time.
0 commit comments