Skip to content

Commit

Permalink
INFOPORTAL-6685: Add verbose output in watchdog helper. (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
onatalushko authored Feb 15, 2024
1 parent 3181d9a commit 7f0136d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Drush/Commands/PlaywrightDrushCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ public function checkForWatchdogErrors(int $timestamp, bool $fail_on_notice = FA
'message' => $message ?? '',
'wid' => $entry->wid ?? '',
'type' => $entry->type ?? '',
'severity' => $entry->severity ?? '',
'severity' => RfcLogLevel::getLevels()[$entry->severity] ?? '',
];
}
$result['numberOfErrors'] += 1;
Expand Down
3 changes: 2 additions & 1 deletion tests/helpers/drupal-commands.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export async function cloneNodeByTitle([page, node_type, node_title, new_node_ti
*
* @param timestamp Timestamp from when to look for errors.
* @param fail_on_notice Boolean to change severity level of watchdog errors.
* @param verbose Boolean to verbose output of watchdog errors.
* @returns {Promise<string>} The json result.
*/
export async function checkWatchdogErrors(timestamp, fail_on_notice = false): Promise<number>;
export async function checkWatchdogErrors(timestamp, fail_on_notice = false, verbose = false): Promise<number>;
11 changes: 6 additions & 5 deletions tests/helpers/drupal-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ module.exports = {
*
* @param {Array<{entity_type: String, entity_spec: Object/String, langcode: String, translation: Object/String}>} array
* Content entity type, specification to select entity of this type,
* language to translate into, and all fields to translate.
* language to translate into, and all fields to translate.
* entity_spec must resolve to a single entity ofthe given type and
* can be either an entity label an object containing property field values.
* @return {string} The output of the command run.
Expand All @@ -143,7 +143,7 @@ module.exports = {
entity_spec = JSON.stringify(entity_spec);
// Double quotes cannot be sent as a single command parameter to a
// bash command inside a docker container, so base64-encode the string.
// (The drush command supports this.) UTF8-escape non-ASCII characters
// (The drush command supports this.) UTF8-escape non-ASCII characters
// first, so base64 can deal with them.
entity_spec = entity_spec.replace(/[\u007F-\uFFFF]/g, function(chr) {
return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).slice(-4)
Expand All @@ -167,12 +167,13 @@ module.exports = {
*
* @param timestamp Timestamp from when to look for errors.
* @param fail_on_notice Boolean to change severity level of watchdog errors.
* @param verbose Boolean to verbose output of watchdog errors.
* @returns {Promise<string>} The json result.
*/
checkWatchdogErrors: async (timestamp, fail_on_notice) => {
const result = drush(`test:checkWatchdog "${timestamp}" "${fail_on_notice}" "1"`);
checkWatchdogErrors: async (timestamp, fail_on_notice, verbose = false) => {
const result = drush(`test:checkWatchdog "${timestamp}" "${fail_on_notice}" "${verbose}"`);
const json = JSON.parse(result.toString());
return parseInt(json['numberOfErrors']);
return verbose ? json : parseInt(json['numberOfErrors']);
},

/**
Expand Down

0 comments on commit 7f0136d

Please sign in to comment.