Skip to content
Open
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
67 changes: 53 additions & 14 deletions src/components/Solutions/TestResultsTable/TestResultsTableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,40 @@ import { prettyPrintBytes } from '../../helpers/stringFormatters.js';
import exitCodeMapping from '../../helpers/exitCodeMapping.js';
import Icon, { SuccessOrFailureIcon } from '../../icons';

const hasValue = value => value !== null;

const tickOrCrossAndRatioOrValue = (isOK, ratio, value, pretty, multiplier) => (
<span
className={classnames({
'text-center': true,
'text-success': isOK,
'text-danger': !isOK,
'fw-bold': ratio > 0.9,
})}>
<SuccessOrFailureIcon success={isOK} gapRight={1} />
<small>
{hasValue(value) && '('}
{(ratio || ratio === 0) && (
<FormattedNumber value={ratio} style="percent" minimumFractionDigits={1} maximumFactionDigits={3} />
{Boolean(ratio) && (
<>
{value !== null && '('}
<FormattedNumber value={ratio} style="percent" minimumFractionDigits={1} maximumFactionDigits={3} />
{value !== null && ') '}
</>
)}
{hasValue(value) && ') '}
{hasValue(value) && pretty(value * multiplier)}
{value !== null && pretty(value * multiplier)}
</small>
</span>
);

const showTimeResults = (wallTime, wallTimeRatio, wallTimeExceeded, cpuTime, cpuTimeRatio, cpuTimeExceeded) => {
const showWall = Boolean(wallTimeRatio) || (wallTimeExceeded && !cpuTimeExceeded);
const showCpu = Boolean(cpuTimeRatio) || cpuTimeExceeded || !showWall;
const showTimeResults = (
wallTime,
wallTimeRatio,
wallTimeExceeded,
cpuTime,
cpuTimeRatio,
cpuTimeExceeded,
wallTimeLimit,
cpuTimeLimit
) => {
const showCpu = cpuTimeLimit > 0; // || cpuTimeExceeded || !showWall;
const showWall = wallTimeLimit > 0 || (wallTimeExceeded && cpuTimeRatio < 1);
return (
<table className="d-inline-block">
<tbody>
Expand Down Expand Up @@ -76,7 +86,13 @@ const showTimeResults = (wallTime, wallTimeRatio, wallTimeExceeded, cpuTime, cpu
/>
</td>
<td className="text-start p-0 text-nowrap">
{tickOrCrossAndRatioOrValue(wallTimeExceeded === false, wallTimeRatio, wallTime, prettyMs, 1000)}
{tickOrCrossAndRatioOrValue(
wallTimeExceeded === false,
wallTimeLimit > 0 ? wallTimeRatio : undefined,
wallTime,
prettyMs,
1000
)}
</td>
</tr>
)}
Expand All @@ -103,6 +119,8 @@ const TestResultsTableRow = ({
memory,
wallTime,
cpuTime,
wallTimeLimit,
cpuTimeLimit,
exitCode,
exitCodeOk,
exitCodeNative,
Expand Down Expand Up @@ -137,12 +155,22 @@ const TestResultsTableRow = ({
)}
{status === 'SKIPPED' && (
<span className="text-warning">
<FormattedMessage id="app.submissions.testResultsTable.statusSkipped" defaultMessage="SKIPPED" />
<FormattedMessage id="app.submissions.testResultsTable.statusSkipped" defaultMessage="Skipped" />
</span>
)}
{status === 'FAILED' && (
<span className="text-danger">
<FormattedMessage id="app.submissions.testResultsTable.statusFailed" defaultMessage="FAILED" />
{memoryExceeded ? (
<FormattedMessage id="app.submissions.testResultsTable.statusMemoryExceeded" defaultMessage="OOM" />
) : wallTimeExceeded || cpuTimeExceeded ? (
<FormattedMessage id="app.submissions.testResultsTable.statusTimeExceeded" defaultMessage="Timeout" />
) : exitSignal ? (
<FormattedMessage id="app.submissions.testResultsTable.statusSignal" defaultMessage="Signal" />
) : !exitCodeOk ? (
<FormattedMessage id="app.submissions.testResultsTable.statusExitCode" defaultMessage="Run. Error" />
) : (
<FormattedMessage id="app.submissions.testResultsTable.statusFailed" defaultMessage="Failed" />
)}
</span>
)}
</b>
Expand All @@ -152,7 +180,16 @@ const TestResultsTableRow = ({
{tickOrCrossAndRatioOrValue(memoryExceeded === false, memoryRatio, memory, prettyPrintBytes, 1024)}
</td>
<td className="text-center">
{showTimeResults(wallTime, wallTimeRatio, wallTimeExceeded, cpuTime, cpuTimeRatio, cpuTimeExceeded)}
{showTimeResults(
wallTime,
wallTimeRatio,
wallTimeExceeded,
cpuTime,
cpuTimeRatio,
cpuTimeExceeded,
wallTimeLimit,
cpuTimeLimit
)}
</td>

<td className="text-center">
Expand Down Expand Up @@ -257,7 +294,9 @@ TestResultsTableRow.propTypes = {
cpuTimeRatio: PropTypes.number,
memory: PropTypes.number,
wallTime: PropTypes.number,
wallTimeLimit: PropTypes.number,
cpuTime: PropTypes.number,
cpuTimeLimit: PropTypes.number,
exitCode: PropTypes.number,
exitCodeOk: PropTypes.bool,
exitCodeNative: PropTypes.bool,
Expand Down
6 changes: 5 additions & 1 deletion src/locales/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2019,9 +2019,13 @@
"app.submissions.testResultsTable.showLog": "Ukázat log",
"app.submissions.testResultsTable.showLogInModal": "Ukázat v okně",
"app.submissions.testResultsTable.signalTooltip": "Process byl ukončen signálem",
"app.submissions.testResultsTable.statusExitCode": "Běh. chyba",
"app.submissions.testResultsTable.statusFailed": "Chyba",
"app.submissions.testResultsTable.statusMemoryExceeded": "Paměť",
"app.submissions.testResultsTable.statusOK": "OK",
"app.submissions.testResultsTable.statusSignal": "Signál",
"app.submissions.testResultsTable.statusSkipped": "Přeskočeno",
"app.submissions.testResultsTable.statusTimeExceeded": "Čas",
"app.submissions.testResultsTable.timeExceeded": "Naměřený čas spuštění",
"app.submissions.testResultsTable.wallTimeExplain": "Reálný čas (tzv. 'wall-time' měřený systémovými hodinami)",
"app.submitButton.invalid": "Nějaký vstup není validní",
Expand Down Expand Up @@ -2200,4 +2204,4 @@
"recodex-judge-shuffle-all": "Sudí neuspořádaných tokenů a řádků",
"recodex-judge-shuffle-newline": "Sudí neuspořádaných tokenů (ignorující konce řádků)",
"recodex-judge-shuffle-rows": "Sudí neuspořádaných řádků"
}
}
10 changes: 7 additions & 3 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2019,9 +2019,13 @@
"app.submissions.testResultsTable.showLog": "Show log",
"app.submissions.testResultsTable.showLogInModal": "Show in window",
"app.submissions.testResultsTable.signalTooltip": "Process terminated by signal",
"app.submissions.testResultsTable.statusFailed": "FAILED",
"app.submissions.testResultsTable.statusExitCode": "Run. Error",
"app.submissions.testResultsTable.statusFailed": "Failed",
"app.submissions.testResultsTable.statusMemoryExceeded": "OOM",
"app.submissions.testResultsTable.statusOK": "OK",
"app.submissions.testResultsTable.statusSkipped": "SKIPPED",
"app.submissions.testResultsTable.statusSignal": "Signal",
"app.submissions.testResultsTable.statusSkipped": "Skipped",
"app.submissions.testResultsTable.statusTimeExceeded": "Timeout",
"app.submissions.testResultsTable.timeExceeded": "Measured execution time",
"app.submissions.testResultsTable.wallTimeExplain": "Wall time (real-time measured by external clock)",
"app.submitButton.invalid": "Some input is invalid.",
Expand Down Expand Up @@ -2200,4 +2204,4 @@
"recodex-judge-shuffle-all": "Unordered-tokens-and-rows judge",
"recodex-judge-shuffle-newline": "Unordered-tokens judge (ignoring ends of lines)",
"recodex-judge-shuffle-rows": "Unordered-rows judge"
}
}
Loading