Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Test output (fixes #38) #39

Merged
merged 2 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function testSuccessWhere (description, {
content
}) {
return deferOrRunWrap(() => {
logger.debug(`Tests -- testSuccessWhere ${description}`)
logger.info(`Test success where -- ${description}`)
return new TaskTest({
description,
shouldRun: true,
Expand All @@ -27,7 +27,7 @@ export function testStopWhere (description, {
content
}) {
return deferOrRunWrap(() => {
logger.debug(`Tests -- testStopWhere ${description}`)
logger.info(`Test stop where -- ${description}`)
return new TaskTest({
description,
shouldStop: true,
Expand All @@ -45,7 +45,7 @@ export function testErrorWhere (description, {
content
}) {
return deferOrRunWrap(() => {
logger.debug(`Tests -- testErrorWhere ${description}`)
logger.info(`Test error where -- ${description}`)
return new TaskTest({
description,
shouldError: true,
Expand Down
15 changes: 8 additions & 7 deletions lib/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ function prettyPrintJournal(journal, logger) {
let lineIndex = 0
const output = []
while (lineIndex < lines.length) {
// collect lines with identical subject name values
// collect lines with identical subject name and id values
const fromLineIndex = lineIndex
let toLineIndex = lineIndex
const line = lines[lineIndex]
for (let i = lineIndex; i < lines.length; i++) {
const nextLine = lines[i]
if (nextLine.name !== line.name) break
if (nextLine.name !== line.name || nextLine.id !== line.id) break
toLineIndex = i
}
// print a grouped summary of the above lines with a single common subject line
Expand All @@ -66,6 +66,7 @@ function prettyPrintJournal(journal, logger) {
output.push(`${subjectTable}\n${propertyChangeTable}\n`)
lineIndex = toLineIndex + 1
}
if (!output.length) return logger.info(`No changes where made`)
logger.info(`Summary of changes:\n\n${output.join('\n')}`)
}

Expand Down Expand Up @@ -343,17 +344,17 @@ export default class Task {

static async runTests ({ cwd = process.cwd(), logger }) {
for (const task of Task.clonedItems) {
logger.info(`Task -- Testing: ${task.description}`)
logger.info(`Testing -- ${task.description}`)
for (const test of task.tests) {
const {
// description,
shouldRun,
shouldStop,
shouldError,
fromPlugins,
originalFromPlugins,
toPlugins,
content
fromPlugins = [],
originalFromPlugins = [],
toPlugins = [],
content = []
} = test()
const journal = new Journal({
logger,
Expand Down
8 changes: 5 additions & 3 deletions lib/TaskTest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import _ from 'lodash'

export default class TaskTest {
constructor ({
description = '',
Expand All @@ -12,8 +14,8 @@ export default class TaskTest {
this.shouldStop = shouldStop
this.shouldRun = shouldRun
this.shouldError = shouldError
this.fromPlugins = fromPlugins
this.toPlugins = toPlugins
this.content = content
this.fromPlugins = _.cloneDeep(fromPlugins)
this.toPlugins = _.cloneDeep(toPlugins)
this.content = _.cloneDeep(content)
}
}