From 09cc28d1e6f74007cfc5db296144678c2e4c51d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Janis=20Da=CC=88hne?= <janis.daehne@informatik.uni-halle.de> Date: Tue, 1 Nov 2022 14:51:38 +0100 Subject: [PATCH] - fixed issue with console colors (now all possible combinations are respected) - added menu link to test syntax --- i18n/en.ts | 1 + i18n/i18nRoot.ts | 1 + src/components/siteSideMenu/menu.tsx | 14 +++++ .../consolePanel/consoleItem.tsx | 51 +++++++++++++++++-- 4 files changed, 64 insertions(+), 3 deletions(-) diff --git a/i18n/en.ts b/i18n/en.ts index 69af2976..5812a318 100644 --- a/i18n/en.ts +++ b/i18n/en.ts @@ -295,6 +295,7 @@ export const lang_en: LangObj = { "Program": "Program", "The test protocol exceeded the character limit and was truncated. However your test can still pass because character limit is only used to limit the memory used to store the test result. New lines characters are counted as 4 characters. There are some characters (~100) reserved for header data and each test protocol line consumes some additional characters (depending on the protocol entry type)." : "The test protocol exceeded the character limit and was truncated. However your test can still pass because character limit is only used to limit the memory used to store the test result. New lines characters are counted as 4 characters. There are some characters (~100) reserved for header data and each test protocol line consumes some additional characters (depending on the protocol entry type).", "Load full output" : "Load full output", + "Test syntax": "Test syntax", "Test content read timeout" : "Test content read timeout", "Exit code mismatch" : "Exit code mismatch", diff --git a/i18n/i18nRoot.ts b/i18n/i18nRoot.ts index b2e1d4aa..527153aa 100644 --- a/i18n/i18nRoot.ts +++ b/i18n/i18nRoot.ts @@ -299,6 +299,7 @@ export interface LangObj { "Program": string "The test protocol exceeded the character limit and was truncated. However your test can still pass because character limit is only used to limit the memory used to store the test result. New lines characters are counted as 4 characters. There are some characters (~100) reserved for header data and each test protocol line consumes some additional characters (depending on the protocol entry type).": string "Load full output": string + "Test syntax": string "Test content read timeout": string "Exit code mismatch": string diff --git a/src/components/siteSideMenu/menu.tsx b/src/components/siteSideMenu/menu.tsx index a0753e50..abc0b1e4 100644 --- a/src/components/siteSideMenu/menu.tsx +++ b/src/components/siteSideMenu/menu.tsx @@ -14,6 +14,7 @@ import {Icon} from "semantic-ui-react"; import {SimpleDividerWithSpace} from "../helpers/simpleDividerWithSpace"; import {SimpleVDivider} from "../helpers/simpleVDivider"; import {getI18n} from "../../../i18n/i18nRoot"; +import {markdownSiteTestSyntaxGuide} from '../../constants' //const css = require('./styles.styl'); @@ -250,6 +251,19 @@ class menu extends React.Component<Props, any> { </div> } + + <div> + <Link to={constants.markdownSiteTestSyntaxGuide} target="_blank" onClick={() => this.linkClicked()}> + <Icon size="huge" name='book'/> + <span> + { + getI18n(this.props.langId,'Test syntax') + } + </span> + </Link> + </div> + + </div> </div> diff --git a/src/components/sites/doExerciseSite/consolePanel/consoleItem.tsx b/src/components/sites/doExerciseSite/consolePanel/consoleItem.tsx index f1e70ac9..e2838558 100644 --- a/src/components/sites/doExerciseSite/consolePanel/consoleItem.tsx +++ b/src/components/sites/doExerciseSite/consolePanel/consoleItem.tsx @@ -228,6 +228,7 @@ const allAsciiColorCodes = Object.keys(asciiColorCodeMap) class consoleItem extends React.Component<Props, any> { + //note that \u001B is sometimes wrongly interpreted as \1xB (which is not the same) (after the test ran) convertConsoleLineToAsciiColoredLine(line: string): ReadonlyArray<JSX.Element> | string { if (line.includes('\\0') === false) { @@ -541,11 +542,14 @@ class consoleItem extends React.Component<Props, any> { } { + //output mismatched (this.props.item.hasOutputMismatched && ( + // false & true + //diff and/but no regex --> show colors !this.props.useDiffIfOutputMismatched - || (this.props.nextItem !== null && startsWith(this.props.nextItem.content, "(regex):")) //if next item is an expected regex then do output without showing diff... (other branch of see bot regex case) + && (this.props.nextItem !== null && startsWith(this.props.nextItem.content, "(regex):")) //if next item is an expected regex then do output without showing diff... (other branch of see bot regex case) ) ) && <div className="error-colored"> @@ -557,6 +561,47 @@ class consoleItem extends React.Component<Props, any> { </div> } { + //output mismatched + (this.props.item.hasOutputMismatched + && + ( + // false & false + //diff and/but no regex --> show colors + !this.props.useDiffIfOutputMismatched + && (this.props.nextItem === null || !startsWith(this.props.nextItem.content, "(regex):")) //if next item is an expected regex then do output without showing diff... (other branch of see bot regex case) + ) + ) && + <div className="error-colored"> + <pre className="mar-null"> + { + this.convertConsoleLineToAsciiColoredLine(contentTransformer(this.props.item.content)) + } + </pre> + </div> + } + { + //output mismatched + (this.props.item.hasOutputMismatched + && + ( + // true & true + //diff and regex --> show normal to see regex + this.props.useDiffIfOutputMismatched + && (this.props.nextItem !== null && startsWith(this.props.nextItem.content, "(regex):")) //if next item is an expected regex then do output without showing diff... (other branch of see bot regex case) + ) + ) && + <div className="error-colored"> + <pre className="mar-null"> + { + contentTransformer(this.props.item.content) + } + </pre> + </div> + } + { + // true & false + //diff and no regex + //--> no ascii color interpretation //diff output, if we use diff output we cannot use regex because this doesn't make sense (this.props.item.hasOutputMismatched && this.props.useDiffIfOutputMismatched && (this.props.nextItem === null || !startsWith(this.props.nextItem.content, "(regex):")) //if next item is an expected regex then do not show diff (because not possible for regex) @@ -653,8 +698,8 @@ class consoleItem extends React.Component<Props, any> { { startsWith(this.props.item.content, "(regex):") - ? contentTransformer(this.props.item.content.substr("(regex):".length)) - : contentTransformer(this.props.item.content) + ? this.convertConsoleLineToAsciiColoredLine(contentTransformer(this.props.item.content.substr("(regex):".length))) + : this.convertConsoleLineToAsciiColoredLine(contentTransformer(this.props.item.content)) } </pre> </div> -- GitLab