Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to test whether a test case compiles or not, and to execute an external app #42

Open
Thecarisma opened this issue Feb 27, 2021 · 2 comments

Comments

@Thecarisma
Copy link
Member

Test compilation

Add magic and an awesome feature where you can test whether a test case compiles or not if it does not output the error message. The compiled source can be any language,
This can be achieved by setting the compilation executable, options for that test case then cester try to execute that with exec or similar function, then capture the output. This should be optional and can be disabled with #define CESTER_IGNORE_COMPILATION_TEST

Sample format

CESTER_COMPILE_TEST(does_this_so_code_compiles, inst, "gcc", "-ansi --pedantic-errors", {
    #include <stdio>
    int main() {
        printf("yahoo\n");
    }
})
CESTER_COMPILE_TEST(does_this_python_code_runs, inst, "python", "", {
    import io
    print("hello python")
})

The first argument is the test case, the second is the test instance, the third is the compiler executable, the fourth is the code to compile (this is converted to string so there should be a way to remove the enclosing { and };

Test execution

cester should be able to test whether a program runs and validates the output is what is expected similar to CESTER_COMPILE_TEST

CESTER_EXECUTE_TEST(execute_program, inst, "program.exe", "--op", {
    cester_assert_program_output_eq(execute_program, "Unknow option --op");
})

the first argument is the test case name, the second is the test instance, the third is the program or full path to the program o execute, the fourth is the argument to send to the program, the last is the test case body

@Thecarisma
Copy link
Member Author

Allow adding paths and set working directory before test case

Proposed format

CESTER_EXECUTE_COMPILER_SET_WORKING_DIR("C:/User/test/");
CESTER_EXECUTE_COMPILER_ADD_PATH("C:/User/test/app1/bin");
CESTER_EXECUTE_COMPILER_ADD_PATH("C:/User/test/app2/bin");
CESTER_EXECUTE_COMPILER_ADD_PATH("C:/program/bin");

@Thecarisma
Copy link
Member Author

in CESTER_TEST_COMPILE test case, allow running the command that output the text to compile, and also extra arg to test the compilation output

E.g.

CESTER_TEST_COMPILE(does_this_python_code_runs, inst, "python", "", {
    import io
    print("hello python")
}, {
    cester_assert_compile_output_eq("hello python");
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant