Skip to content

Commit 003546c

Browse files
committed
Adding exec targets (goals) in exercise tests configuration.
1 parent 10d90ad commit 003546c

File tree

10 files changed

+106
-39
lines changed

10 files changed

+106
-39
lines changed

src/client.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ import 'ace-builds/src-noconflict/keybinding-vim.js';
4646
*/
4747
const consoleError = console.error; // eslint-disable-line no-console
4848
console.error /* eslint-disable-line no-console */ = (msg, ...rest) => {
49-
if (msg.startsWith('Warning: findDOMNode is deprecated and will be removed in the next major release.')) {
50-
return;
51-
}
52-
if (msg.includes('Support for defaultProps will be removed')) {
53-
return;
49+
if (typeof msg === 'string') {
50+
if (msg.startsWith('Warning: findDOMNode is deprecated and will be removed in the next major release.')) {
51+
return;
52+
}
53+
if (msg.includes('Support for defaultProps will be removed')) {
54+
return;
55+
}
5456
}
5557
consoleError(msg, ...rest);
5658
};

src/components/forms/EditExerciseSimpleConfigForm/EditExerciseSimpleConfigForm.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import SubmitButton from '../SubmitButton';
1313

1414
import EditExerciseSimpleConfigTest from './EditExerciseSimpleConfigTest.js';
1515
import { SUBMIT_BUTTON_MESSAGES } from '../../../helpers/exercise/config.js';
16-
import { ENV_JAVA_ID, ENV_DATA_ONLY_ID, ENV_PROLOG_ID, ENV_HASKELL_ID } from '../../../helpers/exercise/environments.js';
16+
import {
17+
ENV_DATA_ONLY_ID,
18+
ENV_HASKELL_ID,
19+
ENV_JAVA_ID,
20+
ENV_PROLOG_ID,
21+
} from '../../../helpers/exercise/environments.js';
1722
import {
1823
exerciseConfigFormSmartFillAll,
1924
exerciseConfigFormSmartFillInput,

src/components/forms/EditExerciseSimpleConfigForm/EditExerciseSimpleConfigTest.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { FormattedMessage } from 'react-intl';
66
import Button from '../../widgets/TheButton';
77
import Icon from '../../icons';
88
import Confirm from '../../forms/Confirm';
9-
import { ENV_DATA_ONLY_ID, ENV_PROLOG_ID, ENV_HASKELL_ID } from '../../../helpers/exercise/environments.js';
9+
import { ENV_DATA_ONLY_ID, ENV_HASKELL_ID, ENV_PROLOG_ID } from '../../../helpers/exercise/environments.js';
1010

1111
import EditExerciseSimpleConfigTestCompilation from './EditExerciseSimpleConfigTestCompilation.js';
1212
import EditExerciseSimpleConfigTestInputs from './EditExerciseSimpleConfigTestInputs.js';
@@ -26,17 +26,17 @@ const overrides = {
2626
showJudgeBuiltins: false,
2727
showJudgeArgs: false,
2828
},
29-
[ENV_PROLOG_ID]: {
29+
[ENV_HASKELL_ID]: {
3030
showCompilation: false,
31-
showInputsFiles: false,
3231
showArgs: false,
32+
showStringEntryPoint: true,
3333
showOutputFile: false,
3434
showExtraFiles: true,
3535
},
36-
[ENV_HASKELL_ID]: {
36+
[ENV_PROLOG_ID]: {
3737
showCompilation: false,
38+
showInputsFiles: false,
3839
showArgs: false,
39-
showStringEntryPoint: true,
4040
showOutputFile: false,
4141
showExtraFiles: true,
4242
},

src/components/forms/EditExerciseSimpleConfigForm/EditExerciseSimpleConfigTestCompilation.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,23 @@ import Confirm from '../../forms/Confirm';
1414
import Explanation from '../../widgets/Explanation';
1515
import {
1616
ENV_ARDUINO_ID,
17-
ENV_JAVA_ID,
1817
ENV_C_GCC_ID,
1918
ENV_CPP_GCC_ID,
19+
ENV_JAVA_ID,
20+
ENV_MAVEN_ID,
2021
ENV_SYCL_ID,
2122
} from '../../../helpers/exercise/environments.js';
2223

2324
const COMPILER_ARGS_ENVS = [ENV_C_GCC_ID, ENV_CPP_GCC_ID, ENV_ARDUINO_ID, ENV_SYCL_ID];
2425

26+
const validateExecTarget = value =>
27+
!value || value.trim() === '' ? (
28+
<FormattedMessage
29+
id="app.editExerciseConfigForm.validation.execTargetInvalidName"
30+
defaultMessage="Invalid goal name."
31+
/>
32+
) : undefined;
33+
2534
class EditExerciseSimpleConfigTestCompilation extends Component {
2635
constructor(props) {
2736
super(props);
@@ -218,7 +227,9 @@ class EditExerciseSimpleConfigTestCompilation extends Component {
218227
}
219228
readOnly={readOnly}
220229
/>
230+
221231
<br />
232+
222233
{possibleEntryPoints.length > 0 && (
223234
<Field
224235
name={`${test}.entry-point.${env.id}`}
@@ -234,6 +245,38 @@ class EditExerciseSimpleConfigTestCompilation extends Component {
234245
}
235246
/>
236247
)}
248+
249+
{env.id === ENV_MAVEN_ID && (
250+
/*
251+
* A special case for Maven only
252+
*/
253+
<FieldArray
254+
name={`${test}.exec-targets.${env.id}`}
255+
component={ExpandingTextField}
256+
min={1}
257+
maxLength={256}
258+
validateEach={validateExecTarget}
259+
placeholder="exec:java"
260+
readOnly={readOnly}
261+
label={
262+
<>
263+
<FormattedMessage
264+
id="app.editExerciseSimpleConfigTests.execTargets"
265+
defaultMessage="Execution goals:"
266+
/>
267+
<Explanation id={`${test}.exec-targets-explanation`}>
268+
<FormattedMessage
269+
id="app.editExerciseSimpleConfigTests.execTargetsExplanation"
270+
defaultMessage="Maven project goals to be executed. The default is 'exec:java'. At least one goal must be specified."
271+
/>
272+
</Explanation>
273+
</>
274+
}
275+
/>
276+
/*
277+
* End of special case for Maven
278+
*/
279+
)}
237280
</Col>
238281
</Row>
239282
</Container>

src/components/forms/Fields/ExpandingTextField.js

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ import Icon, { AddIcon, CloseIcon } from '../../icons';
1010

1111
const ExpandingTextField = ({
1212
fields = [],
13-
meta: { active, dirty, error, warning },
1413
label = null,
1514
noItems = null,
1615
validateEach,
1716
readOnly = false,
17+
min = 0,
18+
max = 256,
19+
meta, // we just need to exclude this from props
1820
...props
1921
}) => (
2022
<div>
2123
{Boolean(label) && <FormLabel>{label}</FormLabel>}
22-
2324
{fields.map((field, index) => (
2425
<Field
2526
key={index}
@@ -48,33 +49,37 @@ const ExpandingTextField = ({
4849
</Button>
4950
</OverlayTrigger>
5051
) : (
52+
fields.length < max && (
53+
<OverlayTrigger
54+
placement="top"
55+
overlay={
56+
<Tooltip id={Date.now()}>
57+
<FormattedMessage id="app.expandingTextField.tooltip.add" defaultMessage="Append a new item." />
58+
</Tooltip>
59+
}>
60+
<Button onClick={() => fields.push('')} size="xs" noShadow>
61+
<AddIcon fixedWidth />
62+
</Button>
63+
</OverlayTrigger>
64+
)
65+
)}
66+
67+
{fields.length > min && (
5168
<OverlayTrigger
5269
placement="top"
5370
overlay={
5471
<Tooltip id={Date.now()}>
55-
<FormattedMessage id="app.expandingTextField.tooltip.add" defaultMessage="Append a new item." />
72+
<FormattedMessage
73+
id="app.expandingTextField.tooltip.remove"
74+
defaultMessage="Remove this item from the list."
75+
/>
5676
</Tooltip>
5777
}>
58-
<Button onClick={() => fields.push('')} size="xs" noShadow>
59-
<AddIcon fixedWidth />
78+
<Button onClick={() => fields.remove(index)} size="xs" noShadow>
79+
<CloseIcon fixedWidth />
6080
</Button>
6181
</OverlayTrigger>
6282
)}
63-
64-
<OverlayTrigger
65-
placement="top"
66-
overlay={
67-
<Tooltip id={Date.now()}>
68-
<FormattedMessage
69-
id="app.expandingTextField.tooltip.remove"
70-
defaultMessage="Remove this item from the list."
71-
/>
72-
</Tooltip>
73-
}>
74-
<Button onClick={() => fields.remove(index)} size="xs" noShadow>
75-
<CloseIcon fixedWidth />
76-
</Button>
77-
</OverlayTrigger>
7883
</>
7984
)
8085
}
@@ -120,6 +125,8 @@ ExpandingTextField.propTypes = {
120125
noItems: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
121126
validateEach: PropTypes.func,
122127
readOnly: PropTypes.bool,
128+
min: PropTypes.number,
129+
max: PropTypes.number,
123130
};
124131

125132
export default ExpandingTextField;

src/components/forms/Fields/TextField.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as styles from './commonStyles.less';
77

88
const TextField = ({
99
input: { value, ...input },
10-
meta: { active, dirty, error = null, warning = null },
10+
meta: { active, dirty, error = null, warning = null, ...restMeta },
1111
type = 'text',
1212
label = null,
1313
groupClassName = '',

src/helpers/exercise/configSimple.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import { lruMemoize } from 'reselect';
22
import { safeGet, encodeNumId, identity, deepReduce, objectMap, EMPTY_ARRAY } from '../common.js';
33
import {
4+
ENV_ARDUINO_ID,
5+
ENV_C_GCC_ID,
6+
ENV_CPP_GCC_ID,
47
ENV_DATA_ONLY_ID,
8+
ENV_GROOVY_ID,
9+
ENV_HASKELL_ID,
510
ENV_JAVA_ID,
611
ENV_KOTLIN_ID,
7-
ENV_GROOVY_ID,
12+
ENV_MAVEN_ID,
813
ENV_SCALA_ID,
9-
ENV_HASKELL_ID,
10-
ENV_C_GCC_ID,
11-
ENV_CPP_GCC_ID,
12-
ENV_ARDUINO_ID,
1314
ENV_SYCL_ID,
1415
} from './environments.js';
1516

@@ -306,6 +307,7 @@ const _PIPELINE_DEFAULT_VARS_DESCRIPTORS = [
306307
.individualEnvs()
307308
.forCompilation()
308309
.setRuntimeFilter([ENV_C_GCC_ID, ENV_CPP_GCC_ID, ENV_ARDUINO_ID, ENV_SYCL_ID]),
310+
new Variable('exec-targets', 'string[]', ['exec:java']).individualEnvs().setRuntimeFilter([ENV_MAVEN_ID]),
309311
new Variable('entry-point', 'file')
310312
.individualEnvs()
311313
.setPipelineFilter('hasEntryPoint')

src/locales/cs.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@
443443
"app.editExerciseConfigForm.validation.ambiguousEntryPoint": "Některé vstupní body tohoto běhového prostředí byly nastaveny a některé byly ponechány k nastavení studentem při odevzdání, což může být poměrně matoucí.",
444444
"app.editExerciseConfigForm.validation.duplicateFile": "Nalezen duplicitní soubor.",
445445
"app.editExerciseConfigForm.validation.duplicateFileName": "Nalezeno duplicitní jméno. Aliasy vstupních souborů musí být unikátní.",
446+
"app.editExerciseConfigForm.validation.execTargetInvalidName": "Neplatné jméno cíle.",
446447
"app.editExerciseConfigForm.validation.fileDoesNotExist": "Zde byl vybrán neexistující soubor \"{file}\".",
447448
"app.editExerciseConfigForm.validation.noFileSelected": "Prosíme, vyberte soubor.",
448449
"app.editExerciseConfigForm.validation.stdinFileEmpty": "Prosíme, vyberte soubor pro std. vstup.",
@@ -486,6 +487,8 @@
486487
"app.editExerciseSimpleConfigTests.customJudgeBinary": "Spustitelný soubor sudího:",
487488
"app.editExerciseSimpleConfigTests.entryPoint": "Vstupní bod (zaváděcí soubor):",
488489
"app.editExerciseSimpleConfigTests.entryPointLabel": "Identifikátor vstupního bodu:",
490+
"app.editExerciseSimpleConfigTests.execTargets": "Cíle ke spuštění:",
491+
"app.editExerciseSimpleConfigTests.execTargetsExplanation": "Cíle maven projektu ke spuštění. Výchozí cíl je 'exec:java'. Alespoň jeden cíl musí být specifikován.",
489492
"app.editExerciseSimpleConfigTests.executionArguments": "Spouštěcí argumenty:",
490493
"app.editExerciseSimpleConfigTests.expectedOutput": "Očekávaný výstup:",
491494
"app.editExerciseSimpleConfigTests.extraFilesActual": "Přídavný soubor:",
@@ -2158,4 +2161,4 @@
21582161
"recodex-judge-shuffle-all": "Sudí neuspořádaných tokenů a řádků",
21592162
"recodex-judge-shuffle-newline": "Sudí neuspořádaných tokenů (ignorující konce řádků)",
21602163
"recodex-judge-shuffle-rows": "Sudí neuspořádaných řádků"
2161-
}
2164+
}

src/locales/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@
443443
"app.editExerciseConfigForm.validation.ambiguousEntryPoint": "Some entry points of this environment are specified whilst some are left to be specified by the student. This may be quite ambiguous.",
444444
"app.editExerciseConfigForm.validation.duplicateFile": "Duplicate file detected.",
445445
"app.editExerciseConfigForm.validation.duplicateFileName": "Duplicate name detected.",
446+
"app.editExerciseConfigForm.validation.execTargetInvalidName": "Invalid goal name.",
446447
"app.editExerciseConfigForm.validation.fileDoesNotExist": "File \"{file}\" was selected here, but no such file exists.",
447448
"app.editExerciseConfigForm.validation.noFileSelected": "Please select a file.",
448449
"app.editExerciseConfigForm.validation.stdinFileEmpty": "Please, fill in the std. input file.",
@@ -486,6 +487,8 @@
486487
"app.editExerciseSimpleConfigTests.customJudgeBinary": "Custom judge executable:",
487488
"app.editExerciseSimpleConfigTests.entryPoint": "Point of entry (bootstrap file):",
488489
"app.editExerciseSimpleConfigTests.entryPointLabel": "Entry point identifier:",
490+
"app.editExerciseSimpleConfigTests.execTargets": "Execution goals:",
491+
"app.editExerciseSimpleConfigTests.execTargetsExplanation": "Maven project goals to be executed. The default is 'exec:java'. At least one goal must be specified.",
489492
"app.editExerciseSimpleConfigTests.executionArguments": "Execution arguments:",
490493
"app.editExerciseSimpleConfigTests.expectedOutput": "Expected output:",
491494
"app.editExerciseSimpleConfigTests.extraFilesActual": "Extra file:",

src/redux/modules/exerciseConfigs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ export const exerciseConfigFormSmartFillAll = (formName, firstTestId, tests, fil
347347
'entry-point-string', // standalone, used for Haskell
348348
'jar-files',
349349
'compile-args',
350+
'exec-targets',
350351
]);
351352

352353
export const exerciseConfigFormSmartFillInput = (formName, firstTestId, tests, files) =>
@@ -375,6 +376,7 @@ export const exerciseConfigFormSmartFillCompilation = (formName, firstTestId, te
375376
'entry-point',
376377
'jar-files',
377378
'compile-args',
379+
'exec-targets',
378380
]);
379381

380382
export const exerciseConfigFormSmartFillExtraFiles = (formName, firstTestId, tests, files) =>

0 commit comments

Comments
 (0)