Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-bell committed Feb 13, 2025
1 parent 0b0991e commit b9936a3
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 41 deletions.
2 changes: 1 addition & 1 deletion dist/grader/types.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 23 additions & 19 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions src/grader/Grader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ class Grader {
return [
{
name: unit.name,
output: `Faults detected: ${mutantsDetected} / ${maxMutantsToDetect}`,
output_format: 'text',
output: `**Faults detected: ${mutantsDetected} / ${maxMutantsToDetect}**`,
output_format: 'markdown',
score: breakPoint ? breakPoint.pointsToAward : 0,
max_score: unit.breakPoints[0].pointsToAward
}
Expand All @@ -152,11 +152,12 @@ class Grader {
const passingTests = relevantTestResults.filter(
(result) => result.status === 'pass'
).length

return [
{
name: unit.name,
output: `Tests passed: ${passingTests} / ${expectedTests}\n${relevantTestResults.map((result) => `${result.name}: ${result.status}${result.output ? `\n${result.output}` : ''}`).join('\n')}`,
output_format: 'text',
output: `**Tests passed: ${passingTests} / ${expectedTests}**\n${relevantTestResults.map((result) => ` * ${result.name}: ${result.status}${result.output ? '\n```\n' + result.output + '\n```' : ''}`).join('\n')}`,
output_format: 'markdown',
score: passingTests == expectedTests ? unit.points : 0,
max_score: unit.points
}
Expand Down Expand Up @@ -267,10 +268,10 @@ class Grader {
this.logger.log('visible', 'Here are your failing test results:')
for (const result of studentTestResults) {
if (result.status === 'fail') {
mutantFailureAdvice += `\n${result.name}: ${result.status}\n${result.output}\n--------------------------------\n`
mutantFailureAdvice += `\n❌ ${result.name}: **${result.status}**`
mutantFailureAdvice += '```\n' + result.output + '\n```'
this.logger.log('visible', `${result.name}: ${result.status}`)
this.logger.log('visible', result.output)
this.logger.log('visible', '--------------------------------')
}
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/grader/builder/GradleBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export default class GradleBuilder extends Builder {
.map((file: CheckstyleReport) => {
return file.files
.map((f: CheckstyleFile) => {
return `${f.name}: ${f.errors.length} errors:
${f.errors.map((e) => `\t${e.line}: ${e.message}`).join('\n')}`
return ` * ${f.name}: ${f.errors.length} errors:
${f.errors.map((e) => `\t${e.line}: ` + '`' + e.message + '`').join('\n')}`
})
.join('\n')
})
Expand All @@ -43,7 +43,7 @@ export default class GradleBuilder extends Builder {
return {
status: totalErrors > 0 ? 'fail' : 'pass',
output: `Total errors: ${totalErrors}\n${formattedOutput}`,
output_format: 'text'
output_format: 'markdown'
}
}
async test(): Promise<TestResult[]> {
Expand Down
2 changes: 1 addition & 1 deletion src/grader/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function isMutationTestUnit(unit: GradedUnit): unit is MutationTestUnit {
export function isRegularTestUnit(unit: GradedUnit): unit is RegularTestUnit {
return 'tests' in unit && 'testCount' in unit
}
export type OutputFormat = 'text' // TODO also support: | 'ansi' | 'html' | 'markdown';
export type OutputFormat = 'text' | 'ansi' | 'markdown'
export type OutputVisibility =
| 'hidden' // Never shown to students
| 'visible' // Always shown to students
Expand Down
24 changes: 14 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,32 @@ export async function run(): Promise<void> {
`**Status**: ${results.lint.status === 'pass' ? '✅' : '❌'}`
)
core.summary.addDetails('Lint Output', results.lint.output)
core.summary.addHeading('Test Results', 2)
if (results.tests.length > 0) {
core.summary.addHeading('Test Results', 2)
core.summary.addHeading('Summary', 3)
const rows: SummaryTableRow[] = []
rows.push([
{ data: 'Status', header: true },
{ data: 'Part', header: true },
{ data: 'Name', header: true },
{ data: 'Score', header: true }
])
let lastPart = undefined
for (const test of results.tests) {
const icon = test.score === test.max_score ? '✅' : '❌'
rows.push([
icon,
test.part || '',
test.name,
`${test.score}/${test.max_score}`
])
if (test.output) {
core.summary.addDetails(test.name, test.output)
if (test.part !== lastPart && test.part) {
lastPart = test.part
rows.push([{ data: test.part, colspan: '3' }])
}
rows.push([icon, test.name, `${test.score}/${test.max_score}`])
}
core.summary.addTable(rows)
core.summary.addHeading('Test Details', 3)
for (const test of results.tests) {
if (test.output) {
const icon = test.score === test.max_score ? '✅' : '❌'
core.summary.addDetails(icon + test.name, test.output)
}
}
}
await core.summary.write()

Expand Down

0 comments on commit b9936a3

Please sign in to comment.