Skip to content

Separate concerns in Program - compilation artifacts are now Executable - #501

Open
gkreitz wants to merge 6 commits into
Kattis:masterfrom
gkreitz:replace_some_program_with_executable
Open

gkreitz wants to merge 6 commits into
Kattis:masterfrom
gkreitz:replace_some_program_with_executable

Conversation

@gkreitz

@gkreitz gkreitz commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

This PR ends up a bit large, but it was hard to split this in a good way.

The main point of this PR is to split the concerns of the old, overloaded Program class, which is the main component of the run module.

Functional changes:

  • After compilation, we check that the build directory only consists of files and directories. Judge systems like Kattis are not guaranteed to handle other objects in build artefacts.

Main points of refactor:

  • Program now represents a program prior to compilation. You cannot run a program, you can only compile it.
  • Executable now represents something you can run (there was an earlier class with this name. It's now gone, and the name has been stolen)
  • We use Executable instead of Program in several places, giving slightly improved handling of some error conditions when key things fail to compile
  • Compiling a Program to different directories actually works now (instead of just pretending to work, due to caching :)
  • The old ProgramError exception is gone - everything is now an error in the compile step
  • Remapping exit status 0 -> 42 (for viva and checktestdata) is now a feature of Executable, making things a bit cleaner

git diff --color-moved may be helpful in reviewing. The large, ugly-looking __run_wait method has simply moved from Program to Executable

…lasses

When compiling, one now gets back an Executable, which can be run.
Program is now an immutable representation of a program (with a
small, thread-safe cache of compilation results).

The old class Executable was no longer needed, so its name was stolen
for the new class.
Symlinks in compilation artifacts is not well supported in judge systems
like Kattis.
A build step creating more esoteric file objects is likely a bug (or
exploitation attempt).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant