diff --git a/.gitignore b/.gitignore index 9a8527d336..94846e03a5 100644 --- a/.gitignore +++ b/.gitignore @@ -68,6 +68,8 @@ integration_tests/b1/* integration_tests/b2/* integration_tests/b3/* integration_tests/b4/* +integration_tests/b5/* +integration_tests/b6/* integration_tests/_lpython-tmp-test-* inst/bin/* *.tlog diff --git a/ci/test.xsh b/ci/test.xsh index 50a0649d19..0c842a923a 100644 --- a/ci/test.xsh +++ b/ci/test.xsh @@ -19,3 +19,6 @@ if $WIN != "1": python run_tests.py cd integration_tests python run_tests_new.py -j16 -b llvm cpython c wasm + + if $(uname).strip() == "Linux": + python run_tests_new.py -j16 -b x86 wasm_x86 diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 03acc455c0..64048b6c88 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -70,7 +70,7 @@ macro(RUN) set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}") endif() if (${RUN_FAIL}) - set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) + set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) endif() elseif(KIND STREQUAL "c") add_custom_command( @@ -86,7 +86,7 @@ macro(RUN) set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}") endif() if (${RUN_FAIL}) - set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) + set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) endif() elseif(KIND STREQUAL "cpython") # CPython test @@ -105,7 +105,41 @@ macro(RUN) set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}") endif() if (${RUN_FAIL}) - set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) + set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) + endif() + elseif(KIND STREQUAL "x86") + # x86 test + add_custom_command( + OUTPUT ${name}.x86 + COMMAND lpython --backend x86 ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py -o ${name}.x86 + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py + VERBATIM + ) + add_custom_target(${name} ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${name}.x86) + add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name}.x86) + if (RUN_LABELS) + set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}") + endif() + if (${RUN_FAIL}) + set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) + endif() + elseif(KIND STREQUAL "wasm_x86") + # wasm_to_x86 test + add_custom_command( + OUTPUT ${name}.x86 + COMMAND lpython --backend wasm_x86 ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py -o ${name}.x86 + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${name}.py + VERBATIM + ) + add_custom_target(${name} ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${name}.x86) + add_test(${name} ${CMAKE_CURRENT_BINARY_DIR}/${name}.x86) + if (RUN_LABELS) + set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}") + endif() + if (${RUN_FAIL}) + set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) endif() elseif(KIND STREQUAL "wasm") # wasm test @@ -128,7 +162,7 @@ macro(RUN) set_tests_properties(${name} PROPERTIES LABELS "${RUN_LABELS}") endif() if (${RUN_FAIL}) - set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) + set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE) endif() endif() endif() @@ -152,6 +186,7 @@ RUN(NAME exit_02c FAIL LABELS cpython llvm c) # Test all four backends RUN(NAME print_01 LABELS cpython llvm c wasm) # wasm not yet supports sep and end keywords +RUN(NAME print_03 LABELS x86 wasm_x86) # simple test case specifically for x86 and wasm_x86 # CPython and LLVM RUN(NAME const_01 LABELS cpython llvm c) diff --git a/integration_tests/print_03.py b/integration_tests/print_03.py new file mode 100644 index 0000000000..46f5120a31 --- /dev/null +++ b/integration_tests/print_03.py @@ -0,0 +1,10 @@ +def Main0(): + x: i32 + x = (2+3)*5 + print(x) + print("Hi") + print("Hello") + print((5-2) * 7) + print("Bye") + +Main0() diff --git a/integration_tests/run_tests.sh b/integration_tests/run_tests.sh index b7f1e9daf0..1086f6697a 100755 --- a/integration_tests/run_tests.sh +++ b/integration_tests/run_tests.sh @@ -2,7 +2,7 @@ set -ex -rm -rf b1 b2 b3 b4 +rm -rf b1 b2 b3 b4 b5 b6 # Append "-j4" or "-j" to run in parallel jn=$1 @@ -38,3 +38,19 @@ node -v cmake -DKIND=wasm .. make $jn ctest $jn --output-on-failure +cd .. + +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + mkdir b5 + cd b5 + cmake -DKIND=x86 .. + make $jn + ctest $jn --output-on-failure + cd .. + + mkdir b6 + cd b6 + cmake -DKIND=wasm_x86 .. + make $jn + ctest $jn --output-on-failure +fi diff --git a/integration_tests/run_tests_new.py b/integration_tests/run_tests_new.py index e038e7adf3..12054150f1 100644 --- a/integration_tests/run_tests_new.py +++ b/integration_tests/run_tests_new.py @@ -6,7 +6,7 @@ # Initialization DEFAULT_THREADS_TO_USE = 8 # default no of threads is 8 -SUPPORTED_BACKENDS = ['llvm', 'c', 'wasm', 'cpython'] +SUPPORTED_BACKENDS = ['llvm', 'c', 'wasm', 'cpython', 'x86', 'wasm_x86'] BASE_DIR = os.path.dirname(os.path.realpath(__file__)) LPYTHON_PATH = f"{BASE_DIR}/../src/bin"