Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new Test mode that enables unittests #68

Open
reeelix opened this issue May 5, 2024 · 3 comments
Open

Create new Test mode that enables unittests #68

reeelix opened this issue May 5, 2024 · 3 comments
Labels
enhancement New feature or request tracking This issue is used to track a specific function or idea but will not be actively worked on

Comments

@reeelix
Copy link
Collaborator

reeelix commented May 5, 2024

A new Test mode should be introduced. It enables a testfile to be read. A testfile containes multiple input-output-definitions, such that the given program is executed on each of the inputs (with a timeout to prevent endless loops), and then its output is compared to the expected output. The results are printed for the user.

A more detailed explanation is available in German:

Beschreibung:

Mit ./alpha_tui test <program> <testfile> kann man ein Testfile einlesen. Das enthält beliebig oft die Kombination aus Memory Layout Vorgabe (wie in einem Memory Config File) und einem expected Output (also eine Auflistung von "Speicherstellen/Registern=Wert", im Endeffekt auch eine Art spezielles Memory Config File) -> das ist jeweils ein Test (der hat zusätzlich noch einen Namen).
Wenn man den command ausführt, wird für jeden Test das Program mit der gegebenen Memory Konfiguration (damit kann man ja Speicherstellen auf gewisse Werte setzen) ausgeführt. Dabei muss es ein Timeout geben (was man mit --timeout auf nen anderen Wert setzen kann). Sobald das Programm auf einer Eingabe terminiert ist, wird jede Zeile des expected outputs mit dem aktuellen Zustand der Register und des Speichers verglichen.

Sobald alle Tests durchgelaufen sind, erhält man für jeden Test die Info, ob er gepassed wurde, gefailed ist, oder getimeoutet.

Darstellung:

Es bietet sich ein neues TUI Layout an. Die Liste der Tests (deren Namen) und ihr Result (vlcht ein farbiges Icon) kann man gut in einer Spalte links darstellen. Dann kann man mit den Pfeiltasten die Tests einzeln auswählen. Immer für den Test, den man gerade ausgewählt hat, wird auf der rechten Seite

Input
------------------------
Output

dargestellt. Output ist dabei jeweils
<Speicherstelle>=<actual value> (expected: <expected value>),
wobei das in den Klammern nur dasteht, wenn die Outputs sich unterschieden haben.
Es gibt dann die Möglichkeit, mit einem Hotkey für den gerade ausgewählten Test direkt das äquivalent zu ./alpha_tui load --memory-layout-file <Temporäre Kopie des Eingabelayouts des aktuellen Tests> <program> zu launchen, um zu debuggen, warum ein Test gefailed ist

@reeelix reeelix added the enhancement New feature or request label May 5, 2024
@reeelix
Copy link
Collaborator Author

reeelix commented May 5, 2024

would be a huge benefit from a didactic point of view, but will be quite some work and require quite a bit of refactoring

@LMH01
Copy link
Owner

LMH01 commented May 5, 2024

Interesting Idea but as you said this will be quite some work. I don't think that this is something that I will implement in the next time.

@LMH01 LMH01 added the tracking This issue is used to track a specific function or idea but will not be actively worked on label May 5, 2024
@LMH01
Copy link
Owner

LMH01 commented Oct 21, 2024

An Idea I just had: Maybe we should have two options for the test output: One option, like you wrote above, where the test result can interactively be viewed in a new TUI interface. The other (less complex to implement) would be to just have the test output print to console.
I don't yet know which mode should be the default when booth are implemented but the one, that is not default should be select able with a new cli parameter, that is only valid for the test mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tracking This issue is used to track a specific function or idea but will not be actively worked on
Projects
None yet
Development

No branches or pull requests

2 participants