added test for accepting a file as input

This commit is contained in:
Sven Vogel 2024-05-04 15:33:20 +02:00
parent 01cf8345a0
commit f7a3faad2e
4 changed files with 53 additions and 1 deletions

View File

@ -6,4 +6,5 @@ set(CTEST_BINARY_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
# Provide test to run here or include another CMakeLists.txt
add_subdirectory(logging)
add_subdirectory(logging)
add_subdirectory(input_file)

View File

@ -0,0 +1,9 @@
include(CTest)
# ------------------------------------------------------- #
# CTEST 1
# test if the program accepts a file as input
add_test(NAME input_file_check
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/check
COMMAND python ${GEMSTONE_TEST_DIR}/input_file/test_input_file.py ${GEMSTONE_TEST_DIR}/input_file/test.gem)

View File

@ -0,0 +1,6 @@
import "std.io"
fun main {
print("Hello, World!!!")
}

View File

@ -0,0 +1,36 @@
import os.path
import subprocess
import sys
import logging
from logging import info
def check_accept():
info("testing handling of input file...")
logging.basicConfig(level=logging.INFO)
test_file_name = sys.argv[1]
p = subprocess.run(["./gsc", test_file_name], capture_output=True, text=True)
assert p.returncode == 0
def check_abort():
info("testing handling of missing input file...")
logging.basicConfig(level=logging.INFO)
p = subprocess.run("./gsc", capture_output=True, text=True)
assert p.returncode == 1
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
info("check if binary exists...")
assert os.path.exists("./gsc")
check_accept()
check_abort()