diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..7331d0b2 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,30 @@ +# source: +# https://github.com/marketplace/actions/python-action + +name: tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-and-analyze: + runs-on: ubuntu-latest + + steps: + - run: | + echo "Install required dependencies" + sudo apt-get update + sudo apt-get install python3 + + - run: | + echo "Run, Build Application using scripts" + python3 -c " + scripts = ['tests/run_tests.py'] + for script in scripts: + with open(script, 'r') as file: + exec(file.read())" diff --git a/tests/T_queue_tests.c b/tests/T_queue_tests.c index 944798ce..de185824 100644 --- a/tests/T_queue_tests.c +++ b/tests/T_queue_tests.c @@ -185,8 +185,11 @@ int main(void) { {wraparound_test, "wraparound test"}, {for_each_and_copy_test, "for each and copy test"}}; printf(__FILE_NAME__ ":\n"); + bool overall_res = true; for (size_t i = 0; i < sizeof(bool_f_arr) / sizeof(bool_f_plus); i++) { - printf(" [%s] %s\n", bool_f_arr[i].func() ? GREEN "true" OFF : RED "false" OFF, bool_f_arr[i].desc); + bool res = bool_f_arr[i].func(); + overall_res &= res; + printf(" [%s] %s\n", res ? GREEN "true" OFF : RED "false" OFF, bool_f_arr[i].desc); } - return 0; + return overall_res ? 0 : 1; } diff --git a/tests/T_stack_tests.c b/tests/T_stack_tests.c index b54d3f57..485f783d 100644 --- a/tests/T_stack_tests.c +++ b/tests/T_stack_tests.c @@ -131,8 +131,11 @@ int main(void) { {million_elements_test, "million elements test"}, {for_each_and_copy_test, "for each and copy test"}}; printf(__FILE_NAME__ ":\n"); + bool overall_res = true; for (size_t i = 0; i < sizeof(bool_f_arr) / sizeof(bool_f_plus); i++) { - printf(" [%s] %s\n", bool_f_arr[i].func() ? GREEN "true" OFF : RED "false" OFF, bool_f_arr[i].desc); + bool res = bool_f_arr[i].func(); + overall_res &= res; + printf(" [%s] %s\n", res ? GREEN "true" OFF : RED "false" OFF, bool_f_arr[i].desc); } - return 0; + return overall_res ? 0 : 1; } diff --git a/tests/ll_queue_tests.c b/tests/ll_queue_tests.c index 23c7b037..ec380675 100644 --- a/tests/ll_queue_tests.c +++ b/tests/ll_queue_tests.c @@ -146,8 +146,11 @@ int main(void) { {million_elements_test, "million elements test"}, {for_each_and_copy_test, "for each and copy test"}}; printf(__FILE_NAME__ ":\n"); + bool overall_res = true; for (size_t i = 0; i < sizeof(bool_f_arr) / sizeof(bool_f_plus); i++) { - printf(" [%s] %s\n", bool_f_arr[i].func() ? GREEN "true" OFF : RED "false" OFF, bool_f_arr[i].desc); + bool res = bool_f_arr[i].func(); + overall_res &= res; + printf(" [%s] %s\n", res ? GREEN "true" OFF : RED "false" OFF, bool_f_arr[i].desc); } - return 0; + return overall_res ? 0 : 1; } diff --git a/tests/ll_stack_tests.c b/tests/ll_stack_tests.c index 2f3c26d9..2f2d928c 100644 --- a/tests/ll_stack_tests.c +++ b/tests/ll_stack_tests.c @@ -124,8 +124,11 @@ int main(void) { {million_elements_test, "million elements test"}, {for_each_and_copy_test, "for each and copy test"}}; printf(__FILE_NAME__ ":\n"); + bool overall_res = true; for (size_t i = 0; i < sizeof(bool_f_arr) / sizeof(bool_f_plus); i++) { - printf(" [%s] %s\n", bool_f_arr[i].func() ? GREEN "true" OFF : RED "false" OFF, bool_f_arr[i].desc); + bool res = bool_f_arr[i].func(); + overall_res &= res; + printf(" [%s] %s\n", res ? GREEN "true" OFF : RED "false" OFF, bool_f_arr[i].desc); } - return 0; + return overall_res ? 0 : 1; } diff --git a/tests/run_tests.py b/tests/run_tests.py index c80c65ee..19216c35 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -12,9 +12,11 @@ for name in glob.glob("./*_tests.c"): s = pathlib.Path(name).stem if os.system(f"gcc -Wall -Wextra -I{include_dir} -o {bin_dir}/{s}.bin ../src-alt/*/*.c {s}.c") != 0: - exit(1); + exit(1) +overall_res = True for name in glob.glob("./*_tests.c"): s = pathlib.Path(name).stem - os.system(f"../bin/{s}.bin") + overall_res &= os.system(f"../bin/{s}.bin") == 0 +exit(0 if overall_res else 1) diff --git a/tests/strmap_tests.c b/tests/strmap_tests.c index d3157810..75383bdd 100644 --- a/tests/strmap_tests.c +++ b/tests/strmap_tests.c @@ -262,8 +262,11 @@ int main(void) { {million_elements_test, "million elements test"}, {for_each_and_copy_test, "for each and copy test"}}; printf(__FILE_NAME__ ":\n"); + bool overall_res = true; for (size_t i = 0; i < sizeof(bool_f_arr) / sizeof(bool_f_plus); i++) { - printf(" [%s] %s\n", bool_f_arr[i].func() ? GREEN "true" OFF : RED "false" OFF, bool_f_arr[i].desc); + bool res = bool_f_arr[i].func(); + overall_res &= res; + printf(" [%s] %s\n", res ? GREEN "true" OFF : RED "false" OFF, bool_f_arr[i].desc); } - return 0; + return overall_res ? 0 : 1; }