Skip to content

Commit e30b60a

Browse files
committed
Disallow None data in output data
1 parent bb61476 commit e30b60a

8 files changed

+22
-20
lines changed

crates/tmc-langs-cli/bindings.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export type Locale = string;
22

33
export type CliOutput = { "output-kind": "output-data" } & OutputData | { "output-kind": "status-update" } & StatusUpdateData | { "output-kind": "notification" } & Notification;
44

5-
export type DataKind = { "output-data-kind": "error", "output-data": { kind: Kind, trace: Array<string>, } } | { "output-data-kind": "validation", "output-data": StyleValidationResult } | { "output-data-kind": "available-points", "output-data": Array<string> } | { "output-data-kind": "exercises", "output-data": Array<string> } | { "output-data-kind": "exercise-packaging-configuration", "output-data": ExercisePackagingConfiguration } | { "output-data-kind": "local-exercises", "output-data": Array<LocalExercise> } | { "output-data-kind": "refresh-result", "output-data": RefreshData } | { "output-data-kind": "test-result", "output-data": RunResult } | { "output-data-kind": "exercise-desc", "output-data": ExerciseDesc } | { "output-data-kind": "updated-exercises", "output-data": Array<UpdatedExercise> } | { "output-data-kind": "exercise-download", "output-data": DownloadOrUpdateCourseExercisesResult } | { "output-data-kind": "combined-course-data", "output-data": CombinedCourseData } | { "output-data-kind": "course-details", "output-data": CourseDetails } | { "output-data-kind": "course-exercises", "output-data": Array<CourseExercise> } | { "output-data-kind": "course-data", "output-data": CourseData } | { "output-data-kind": "courses", "output-data": Array<Course> } | { "output-data-kind": "exercise-details", "output-data": ExerciseDetails } | { "output-data-kind": "submissions", "output-data": Array<Submission> } | { "output-data-kind": "update-result", "output-data": UpdateResult } | { "output-data-kind": "organization", "output-data": Organization } | { "output-data-kind": "organizations", "output-data": Array<Organization> } | { "output-data-kind": "reviews", "output-data": Array<Review> } | { "output-data-kind": "token", "output-data": unknown } | { "output-data-kind": "new-submission", "output-data": NewSubmission } | { "output-data-kind": "submission-feedback-response", "output-data": SubmissionFeedbackResponse } | { "output-data-kind": "submission-finished", "output-data": SubmissionFinished } | { "output-data-kind": "config-value", "output-data": ConfigValue } | { "output-data-kind": "tmc-config", "output-data": TmcConfig } | { "output-data-kind": "compressed-project-hash", "output-data": string } | { "output-data-kind": "submission-sandbox", "output-data": string } | { "output-data-kind": "mooc-course-instances", "output-data": Array<CourseInstance> } | { "output-data-kind": "mooc-exercise-slides", "output-data": Array<TmcExerciseSlide> } | { "output-data-kind": "mooc-exercise-slide", "output-data": TmcExerciseSlide } | { "output-data-kind": "mooc-submission-finished", "output-data": ExerciseTaskSubmissionResult };
5+
export type DataKind = { "output-data-kind": "error", "output-data": { kind: Kind, trace: Array<string>, } } | { "output-data-kind": "validation", "output-data": StyleValidationResult | null } | { "output-data-kind": "available-points", "output-data": Array<string> } | { "output-data-kind": "exercises", "output-data": Array<string> } | { "output-data-kind": "exercise-packaging-configuration", "output-data": ExercisePackagingConfiguration } | { "output-data-kind": "local-exercises", "output-data": Array<LocalExercise> } | { "output-data-kind": "refresh-result", "output-data": RefreshData } | { "output-data-kind": "test-result", "output-data": RunResult } | { "output-data-kind": "exercise-desc", "output-data": ExerciseDesc } | { "output-data-kind": "updated-exercises", "output-data": Array<UpdatedExercise> } | { "output-data-kind": "exercise-download", "output-data": DownloadOrUpdateCourseExercisesResult } | { "output-data-kind": "combined-course-data", "output-data": CombinedCourseData } | { "output-data-kind": "course-details", "output-data": CourseDetails } | { "output-data-kind": "course-exercises", "output-data": Array<CourseExercise> } | { "output-data-kind": "course-data", "output-data": CourseData } | { "output-data-kind": "courses", "output-data": Array<Course> } | { "output-data-kind": "exercise-details", "output-data": ExerciseDetails } | { "output-data-kind": "submissions", "output-data": Array<Submission> } | { "output-data-kind": "update-result", "output-data": UpdateResult } | { "output-data-kind": "organization", "output-data": Organization } | { "output-data-kind": "organizations", "output-data": Array<Organization> } | { "output-data-kind": "reviews", "output-data": Array<Review> } | { "output-data-kind": "token", "output-data": unknown } | { "output-data-kind": "new-submission", "output-data": NewSubmission } | { "output-data-kind": "submission-feedback-response", "output-data": SubmissionFeedbackResponse } | { "output-data-kind": "submission-finished", "output-data": SubmissionFinished } | { "output-data-kind": "config-value", "output-data": ConfigValue } | { "output-data-kind": "tmc-config", "output-data": TmcConfig } | { "output-data-kind": "compressed-project-hash", "output-data": string } | { "output-data-kind": "submission-sandbox", "output-data": string } | { "output-data-kind": "mooc-course-instances", "output-data": Array<CourseInstance> } | { "output-data-kind": "mooc-exercise-slides", "output-data": Array<TmcExerciseSlide> } | { "output-data-kind": "mooc-exercise-slide", "output-data": TmcExerciseSlide } | { "output-data-kind": "mooc-submission-finished", "output-data": ExerciseTaskSubmissionResult };
66

77
export type Kind = "generic" | "forbidden" | "not-logged-in" | "connection-error" | "obsolete-client" | "invalid-token" | { "failed-exercise-download": { completed: Array<ExerciseDownload>, skipped: Array<ExerciseDownload>, failed: Array<[ExerciseDownload, Array<string>]>, } };
88

crates/tmc-langs-cli/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ fn run_app(cli: Cli) -> Result<CliOutput> {
185185

186186
let check_result =
187187
run_checkstyle_write_results(&exercise_path, output_path.as_deref(), locale)?;
188-
CliOutput::finished_with_data("ran checkstyle", check_result.map(DataKind::Validation))
188+
CliOutput::finished_with_data("ran checkstyle", DataKind::Validation(check_result))
189189
}
190190

191191
Command::Clean { exercise_path } => {

crates/tmc-langs-cli/src/output.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ pub enum CliOutput {
3333
}
3434

3535
impl CliOutput {
36-
pub fn finished_with_data(
37-
message: impl Into<String>,
38-
data: impl Into<Option<DataKind>>,
39-
) -> Self {
36+
pub fn finished_with_data(message: impl Into<String>, data: DataKind) -> Self {
4037
Self::OutputData(Box::new(OutputData {
4138
status: Status::Finished,
4239
message: message.into(),
@@ -74,7 +71,7 @@ pub enum DataKind {
7471
kind: Kind,
7572
trace: Vec<String>,
7673
},
77-
Validation(StyleValidationResult),
74+
Validation(Option<StyleValidationResult>),
7875
/// megabytes
7976
// FreeDiskSpace(u64),
8077
AvailablePoints(Vec<String>),
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
22
source: crates/tmc-langs-cli/tests/integration.rs
33
expression: output
4-
input_file: crates/tmc-langs-cli/tests/sample_exercises/make/failing-exercise
4+
input_file: sample_exercises/make/failing-exercise
55
---
66
output-kind: output-data
77
status: finished
88
message: ran checkstyle
99
result: executed-command
10-
data: ~
11-
10+
data:
11+
output-data-kind: validation
12+
output-data: ~
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
22
source: crates/tmc-langs-cli/tests/integration.rs
33
expression: output
4-
input_file: crates/tmc-langs-cli/tests/sample_exercises/make/passing-exercise
4+
input_file: sample_exercises/make/passing-exercise
55
---
66
output-kind: output-data
77
status: finished
88
message: ran checkstyle
99
result: executed-command
10-
data: ~
11-
10+
data:
11+
output-data-kind: validation
12+
output-data: ~
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
---
22
source: crates/tmc-langs-cli/tests/integration.rs
33
expression: output
4-
input_file: crates/tmc-langs-cli/tests/sample_exercises/make/valgrind-failing-exercise
4+
input_file: sample_exercises/make/valgrind-failing-exercise
55
---
66
output-kind: output-data
77
status: finished
88
message: ran checkstyle
99
result: executed-command
10-
data: ~
11-
10+
data:
11+
output-data-kind: validation
12+
output-data: ~

crates/tmc-langs-cli/tests/snapshots/integration__checkstyle@python3__exercise.snap

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ output-kind: output-data
77
status: finished
88
message: ran checkstyle
99
result: executed-command
10-
data: ~
11-
10+
data:
11+
output-data-kind: validation
12+
output-data: ~

crates/tmc-langs-cli/tests/snapshots/integration__checkstyle@r__exercise.snap

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ output-kind: output-data
77
status: finished
88
message: ran checkstyle
99
result: executed-command
10-
data: ~
11-
10+
data:
11+
output-data-kind: validation
12+
output-data: ~

0 commit comments

Comments
 (0)