Skip to content

Commit

Permalink
[issue1123] Add support for newer versions of VAL.
Browse files Browse the repository at this point in the history
VAL now creates a binary called `Validate` where old versions used lower case `validate`. We now use `Validate` if `validate` is not found on the PATH.
  • Loading branch information
FlorianPommerening authored Oct 12, 2023
1 parent 179418c commit 8b4675b
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions driver/run_components.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import errno
import logging
import os.path
import shutil
import subprocess
import sys

Expand All @@ -11,17 +12,22 @@
from . import util
from .plan_manager import PlanManager

# TODO: We might want to turn translate into a module and call it with "python3 -m translate".
REL_TRANSLATE_PATH = os.path.join("translate", "translate.py")
if os.name == "posix":
REL_SEARCH_PATH = "downward"
VALIDATE = "validate"
BINARY_EXT = ""
elif os.name == "nt":
REL_SEARCH_PATH = "downward.exe"
VALIDATE = "validate.exe"
BINARY_EXT = ".exe"
else:
returncodes.exit_with_driver_unsupported_error("Unsupported OS: " + os.name)

# TODO: We might want to turn translate into a module and call it with "python3 -m translate".
REL_TRANSLATE_PATH = os.path.join("translate", "translate.py")
REL_SEARCH_PATH = f"downward{BINARY_EXT}"
# Older versions of VAL use lower case, newer versions upper case. We prefer the
# older version because this is what our build instructions recommend.
VALIDATE = (shutil.which(f"validate{BINARY_EXT}") or
shutil.which(f"Validate{BINARY_EXT}"))


def get_executable(build, rel_path):
# First, consider 'build' to be a path directly to the binaries.
# The path can be absolute or relative to the current working
Expand Down Expand Up @@ -139,8 +145,11 @@ def run_search(args):


def run_validate(args):
logging.info("Running validate.")
if not VALIDATE:
returncodes.exit_with_driver_input_error(
"Error: Trying to run validate but it was not found on the PATH.")

logging.info("Running validate.")
num_files = len(args.filenames)
if num_files == 1:
task, = args.filenames
Expand All @@ -163,9 +172,6 @@ def run_validate(args):
time_limit=args.validate_time_limit,
memory_limit=args.validate_memory_limit)
except OSError as err:
if err.errno == errno.ENOENT:
returncodes.exit_with_driver_input_error("Error: {} not found. Is it on the PATH?".format(VALIDATE))
else:
returncodes.exit_with_driver_critical_error(err)
returncodes.exit_with_driver_critical_error(err)
else:
return (0, True)

0 comments on commit 8b4675b

Please sign in to comment.