Verified Commit 536ec174 authored by Jakob Moser's avatar Jakob Moser
Browse files

Only check last entry for expected (system-executed) verification command

Previous entries contain commands executed by the user, so they obviously won't contain the system-executed verification command. That is not an issue.
parent 1025fec1
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -284,14 +284,16 @@ class ExerciseExecutionContext {
                commandPromise.then(async () => {
                    const terminalContents = getTerminalContents()

                    if (command && terminalContents.at(-1).input !== command) {
                        // If a command was given to be executed, verify that it was executed
                        throw new Error(`Could not find expected verification command '${command}' in terminal.`)
                    }

                    // We start by assuming the result was a failure...
                    let result = false

                    // ... then, check every entry in the terminal (starting from the last) to see if we can be convinced otherwise
                    for(const entry of terminalContents.toReversed()) {
                        if (command && entry.input !== command) {
                            throw new Error("Could not find expected input in terminal")
                        }

                        // Poor man's switch-case: depending on the "typeof param", a different verification predicate is chosen
                        const predicate = {