-
Notifications
You must be signed in to change notification settings - Fork 0
Enable GitHub actions cmp tests #1
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "tests": [ | ||
| { | ||
| "name": "just_simple_test", | ||
| "setup": "", | ||
| "run": "CI=1 cmake . && make just_simple_test", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Лучше, наверно, не через окружение (мало ли, будет конфликтовать), а через дефайны комстроки? |
||
| "input": "", | ||
| "output": "", | ||
| "comparison": "included", | ||
| "timeout": 1, | ||
| "points": null | ||
| }, | ||
| { | ||
| "name": "test_using_simple_test", | ||
| "setup": "", | ||
| "run": "CI=1 cmake . && make test_using_simple_test", | ||
| "input": "", | ||
| "output": "", | ||
| "comparison": "included", | ||
| "timeout": 1, | ||
| "points": null | ||
| } | ||
| ] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| name: GitHub Classroom Workflow | ||
|
|
||
| on: [push] | ||
|
|
||
| permissions: | ||
| checks: write | ||
| actions: read | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Test in autograding env | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: education/autograding@v1 | ||
| manual-run: | ||
| name: Test in step env | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - run: cmake . && make all |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,13 +10,16 @@ else() | |
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra-semi -O1 -g -fsanitize=address -fno-omit-frame-pointer") | ||
| endif() | ||
|
|
||
| if(DEFINED ENV{CI}) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Лучше не через ENV управлять, наверное. А также можно попробовать сделать локальную сборку GTest |
||
| message("Skipping gtest part") | ||
| else() | ||
| find_package(GTest REQUIRED) | ||
| include(GoogleTest) | ||
|
|
||
| find_package(GTest REQUIRED) | ||
| include(GoogleTest) | ||
| add_executable(test_using_gtest test_using_gtest.cpp gtest_compatible_test.h) | ||
| target_link_libraries(test_using_gtest GTest::gtest GTest::gtest_main) | ||
| endif() | ||
|
|
||
| add_executable(just_simple_test just_simple_test.cpp simple_test.h) | ||
|
|
||
| add_executable(test_using_simple_test test_using_simple_test.cpp gtest_compatible_test.h simple_test.h) | ||
|
|
||
| add_executable(test_using_gtest test_using_gtest.cpp gtest_compatible_test.h) | ||
| target_link_libraries(test_using_gtest GTest::gtest GTest::gtest_main) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,8 @@ Original repository: https://github.com/nickolaym/simple_test | |
| ## Macros | ||
|
|
||
| ### TEST | ||
| ``` | ||
|
|
||
| ```c++ | ||
| TEST(suite, name, [enabled]) { | ||
| test body goes here; | ||
| } | ||
|
|
@@ -24,7 +25,8 @@ TEST(suite, name, [enabled]) { | |
| - `enabled` is optional bool expression (runtime constant, evaluated before main()) | ||
|
|
||
| introduces auxillary object test_name and function | ||
| ``` | ||
|
|
||
| ```c++ | ||
| void func_name() { | ||
| test body goes here; | ||
| } | ||
|
|
@@ -36,7 +38,8 @@ Please don't catch(...) inside it without special need. | |
| GTest compatibility: if suite or name starts with `DISABLED`, the test will skip. | ||
|
|
||
| ### ASSERT_..., EXPECT_... | ||
| ``` | ||
|
|
||
| ```c++ | ||
| ASSERT_CMP(a, op, b) | ||
| EXPECT_CMP(a, op, b) | ||
| ASSERT_EQ, ASSERT_LT, ASSERT_LE, ... as in GTest | ||
|
|
@@ -72,7 +75,7 @@ So, they should be printable. | |
|
|
||
| To print extra messages if an assetion fails, use following syntax: | ||
|
|
||
| ``` | ||
| ```c++ | ||
| ASSERT_BLABLABLA() << common << C++ << stream << args; | ||
|
|
||
| ASSERTION_FAULT(common, C++, stream, args); | ||
|
|
@@ -82,7 +85,7 @@ Note that if the assertion passes, nothing will evaluate. | |
|
|
||
| ### Show green assertions | ||
|
|
||
| ``` | ||
| ```c++ | ||
| SHOW_GREEN_ASSERTIONS(flag) | ||
| ``` | ||
| where `flag` is boolean | ||
|
|
@@ -98,7 +101,8 @@ See examples in just_simple_test.cpp | |
| Just implementation of `int main()` | ||
|
|
||
| Feel free to call a subsequent function from your `main()` with your fixtures: | ||
| ``` | ||
|
|
||
| ```c++ | ||
| int main(int argc, char** argv) { | ||
| ... | ||
| int result = simple_test::testing_main(argc, argv); | ||
|
|
@@ -109,7 +113,7 @@ int main(int argc, char** argv) { | |
|
|
||
| #### Arguments | ||
|
|
||
| ``` | ||
| ```c++ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Здесь баш, а не C++ |
||
| your_test_application [-h] [--help] [-l] [--list] {patterns} | ||
| ``` | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,8 +9,8 @@ TEST(should_fail, vector_capacity) { | |
| std::vector<int> xs; | ||
| xs.reserve(100500); | ||
| xs.clear(); | ||
| EXPECT_CMP(xs.capacity(), ==, 0) << " ahaha ? ahaha!"; | ||
|
||
| ASSERT_CMP(xs.size(), ==, 1) << " ahaha ? ahaha!"; | ||
| EXPECT_CMP(xs.capacity(), ==, 0ul) << " ahaha ? ahaha!"; | ||
| ASSERT_CMP(xs.size(), ==, 1ul) << " ahaha ? ahaha!"; | ||
| } | ||
|
|
||
| TEST(should_fail, lots_of_failed_expectations) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я сделал семейство заведомо позитивных и заведомо негативных тестовых файлов.
Нужно как-то учесть это в скрипте CI.