Skip to content

Commit

Permalink
test: also test examples
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed Jul 7, 2024
1 parent 474d8b5 commit 18af322
Showing 1 changed file with 45 additions and 6 deletions.
51 changes: 45 additions & 6 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@ def mkdir(path):
print_command(["mkdir", path])
os.makedirs(path, exist_ok=True)

def crunch(input_path, output_path, options=[]):
executable_extension = ["", ".exe"][sys.platform == 'win32']
executable_name = "crunch" + executable_extension

def get_build_dir():
build_dir = "build"
windows_build_dir = os.path.join(build_dir, "Release")
if os.path.exists(windows_build_dir):
build_dir = windows_build_dir
return windows_build_dir
return build_dir

def get_executable_path(executable_name):
executable_extension = ["", ".exe"][sys.platform == 'win32']
executable_name += executable_extension
build_dir = get_build_dir()
return os.path.join(build_dir, executable_name)

executable_path = os.path.join(build_dir, executable_name)
def crunch(input_path, output_path, options=[]):
executable_path = get_executable_path("crunch")
command_list = [executable_path] + options

if input_path:
Expand All @@ -39,6 +44,26 @@ def crunch(input_path, output_path, options=[]):

run(command_list)

def example(num, input_path, output_path, options=[]):
executable_path = get_executable_path("example" + str(num))
command_list = [executable_path]

if (num == 1):
command_list += [options[0]]
options = options[1:]

if input_path:
input_path = convert_path(input_path)
command_list += [input_path]

command_list += options

if output_path:
output_path = convert_path(output_path)
command_list += ["-out", output_path]

run(command_list)

crunch(None, None, ["--help"])

mkdir("build/test/0")
Expand Down Expand Up @@ -99,3 +124,17 @@ def crunch(input_path, output_path, options=[]):

mkdir("build/test/7")
crunch("test/black.jpg", "build/test/7/black.crn")

mkdir("build/test/8")
example(1, "test/unvanquished_64.png", None, ["i"])
example(1, "test/unvanquished_64.png", "build/test/8/unvanquished_64.dds", ["c"])

mkdir("build/test/9")
example(1, "test/unvanquished_64.png", "build/test/9/unvanquished_64.crn", ["c", "-crn"])
example(1, "build/test/8/unvanquished_64.crn", "build/test/9/unvanquished_64.dds", ["d"])

mkdir("build/test/10")
example(2, "build/test/8/unvanquished_64.crn", "build/test/10/unvanquished_64.dds")

mkdir("build/test/11")
example(3, "test/unvanquished_64.png", "build/test/11/unvanquished_64.dds")

0 comments on commit 18af322

Please sign in to comment.