mirror of
https://github.com/louisrubet/rpn
synced 2024-11-16 07:47:26 +01:00
github action for tests
This commit is contained in:
parent
d25c8cefbc
commit
be1f0d54ac
9 changed files with 66 additions and 19 deletions
35
.github/workflows/cmake.yml
vendored
Normal file
35
.github/workflows/cmake.yml
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
name: CMake
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ v2.4.0-devel ]
|
||||
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
functional_and_mem_tests:
|
||||
# runs-on: ubuntu:21.10
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'true'
|
||||
|
||||
- name: Install needed libs
|
||||
run: sudo apt update && sudo apt install -y cmake build-essential libmpfr-dev valgrind
|
||||
|
||||
- name: Configure CMake
|
||||
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||
|
||||
- name: Build
|
||||
run: make -C ${{github.workspace}}/build -j
|
||||
|
||||
- name: Functional tests
|
||||
working-directory: ${{github.workspace}}/test
|
||||
run: ${{github.workspace}}/build/rpn \"all.md\" test
|
||||
|
||||
- name: Memory tests
|
||||
working-directory: ${{github.workspace}}/test
|
||||
run: ./mem_test.sh ${{github.workspace}}/build/rpn
|
5
.gitmodules
vendored
5
.gitmodules
vendored
|
@ -1,9 +1,6 @@
|
|||
[submodule "build/linenoise-ng"]
|
||||
path = build/linenoise-ng
|
||||
url = git@github.com:louisrubet/linenoise-ng.git
|
||||
[submodule "linenoise-ng"]
|
||||
path = linenoise-ng
|
||||
url = git@github.com:louisrubet/linenoise-ng.git
|
||||
url = https://github.com/louisrubet/linenoise-ng.git
|
||||
[submodule "mpreal"]
|
||||
path = mpreal
|
||||
url = https://github.com/advanpix/mpreal
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6a37ee0e9f117bb9950159545ecdbdbba41799bf
|
||||
Subproject commit 3d3d594caf15b75517d9baea1f1860978cad771a
|
|
@ -41,7 +41,7 @@ typedef enum {
|
|||
ret_abort_current_entry,
|
||||
ret_out_of_memory,
|
||||
ret_bad_value,
|
||||
ret_max
|
||||
ret_test_failed
|
||||
} ret_value;
|
||||
|
||||
// base min and max
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <pwd.h>
|
||||
#include <csignal>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <csignal>
|
||||
#include <cerrno>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
@ -162,5 +163,6 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
mpfr_free_cache();
|
||||
|
||||
return ret;
|
||||
if (ret != ret_ok) return EXIT_FAILURE;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -263,11 +263,14 @@ ret_value program::run() {
|
|||
// error: abort prog
|
||||
go_out = true;
|
||||
|
||||
// test error: make rpn return EXIT_FAILURE
|
||||
if (_err == ret_test_failed)
|
||||
ret = ret_test_failed;
|
||||
|
||||
// error: show it
|
||||
if (show_error(_err, _err_context) == ret_deadly) {
|
||||
if (show_error(_err, _err_context) == ret_deadly)
|
||||
// pb showing error -> go out software
|
||||
ret = ret_good_bye;
|
||||
}
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
|
@ -633,7 +636,7 @@ ret_value program::show_error() {
|
|||
vector<string> errorStrings {"ok", "unknown command", "missing operand", "bad operand type",
|
||||
"out of range", "unknown variable", "internal error, aborting", "deadly", "goodbye", "not implemented",
|
||||
"no operation", "syntax error", "division by zero", "runtime error", "aborted current entry", "out of memory",
|
||||
"bad value"};
|
||||
"bad value", "test failed"};
|
||||
// clang-format on
|
||||
// show last recorded error
|
||||
if ((size_t)_err < errorStrings.size())
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include <regex>
|
||||
using namespace std;
|
||||
|
||||
#include "version.h"
|
||||
#include "escape.h"
|
||||
#include "program.hpp"
|
||||
#include "version.h"
|
||||
|
||||
/// @brief write stack in a string, each entry separated between commas
|
||||
///
|
||||
|
@ -34,10 +34,8 @@ void program::test_get_stack(string& stack_is, rpnstack& stk) {
|
|||
/// @param steps_failed failed steps nb
|
||||
///
|
||||
void program::test_show_result(string title, int tests, int tests_failed, int steps, int steps_failed) {
|
||||
//cout << title << ": run " << tests << " tests: " << tests - tests_failed << " passed, ";
|
||||
if (!title.empty())
|
||||
cout << title << ": ";
|
||||
cout <<"run " << tests << " tests: " << tests - tests_failed << " passed, ";
|
||||
if (!title.empty()) cout << title << ": ";
|
||||
cout << "run " << tests << " tests: " << tests - tests_failed << " passed, ";
|
||||
if (tests_failed > 0) cout << FG_RED;
|
||||
cout << tests_failed << " failed";
|
||||
if (tests_failed > 0) cout << COLOR_OFF;
|
||||
|
@ -65,6 +63,12 @@ void program::rpn_test() {
|
|||
cout << endl << "rpn version is " << RPN_VERSION << endl;
|
||||
test(test_filename, total_tests, total_tests_failed, total_steps, total_steps_failed);
|
||||
test_show_result("\nTotal", total_tests, total_tests_failed, total_steps, total_steps_failed);
|
||||
|
||||
// notify to caller that test succeeded or not
|
||||
if (total_tests_failed > 0) {
|
||||
_err = ret_test_failed;
|
||||
_err_context = string("rpn version ") + RPN_VERSION + ", test file " + test_filename;
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief load a test file and run its tests
|
||||
|
|
|
@ -36,9 +36,9 @@
|
|||
|
||||
## entry (5)
|
||||
|
||||
`(0x1234,0x10.10)`
|
||||
`(0x1234,0x1010)`
|
||||
|
||||
-> stack should be (0x1.234p+12,0x1.01p+4)
|
||||
-> stack should be (0x1234,0x1010)
|
||||
|
||||
`del`
|
||||
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
rpn=../debug/rpn
|
||||
if [ -z "${1}" ]
|
||||
then
|
||||
echo "Syntax: ${0} <rpn path>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rpn=${1}
|
||||
|
||||
FG_RED="\033[0;31m"
|
||||
FG_GREEN="\033[0;32m"
|
||||
|
|
Loading…
Reference in a new issue