feat: build system ready for testsuite using make check
This commit is contained in:
parent
e853249fbf
commit
b9d7dbce1f
2 changed files with 23 additions and 43 deletions
|
|
@ -24,6 +24,12 @@ bin_PROGRAMS = 42sh
|
|||
|
||||
# ================ TESTS ================
|
||||
|
||||
check-local: $(bin_PROGRAMS) # $(check_PROGRAMS)
|
||||
./../testsuite.sh
|
||||
#./../tests/functional/testsuite.sh
|
||||
|
||||
#./testsuite
|
||||
|
||||
# ------------- Unit tests --------------
|
||||
|
||||
check_PROGRAMS = testsuite
|
||||
|
|
@ -36,7 +42,7 @@ testsuite_SOURCES = ../tests/unit/lexer/lexer_tests.c \
|
|||
|
||||
testsuite_CPPFLAGS = $(42sh_CPPFLAGS)
|
||||
|
||||
testsuite_LDADD = $(42sh_LDADD) $(CRITERION_LIBS)
|
||||
testsuite_LDADD = $(42sh_LDADD) -lcriterion
|
||||
|
||||
# ------------- asan debug --------------
|
||||
|
||||
|
|
|
|||
|
|
@ -17,14 +17,20 @@ Test(peek_token, basic_empty)
|
|||
struct iob_context context = { IOB_MODE_CMD, command };
|
||||
iob_init(&context);
|
||||
|
||||
struct lexer_context ctx = { .end_previous_token = NULL,
|
||||
.remaining_chars = 0,
|
||||
.only_digits = false,
|
||||
.previous_token = NULL,
|
||||
.current_token = NULL };
|
||||
|
||||
// test
|
||||
struct token *tok = peek_token();
|
||||
struct token *tok = peek_token(&ctx);
|
||||
|
||||
// expected
|
||||
enum token_type type_expected = TOKEN_EOF;
|
||||
char *string_expected = NULL;
|
||||
|
||||
cr_assert(eq(str, string_expected, tok->data));
|
||||
cr_assert(tok->data == string_expected);
|
||||
cr_assert(type_expected == tok->type);
|
||||
|
||||
free_token(&tok);
|
||||
|
|
@ -37,8 +43,14 @@ Test(peek_token, basic_word)
|
|||
struct iob_context context = { IOB_MODE_CMD, command };
|
||||
iob_init(&context);
|
||||
|
||||
struct lexer_context ctx = { .end_previous_token = NULL,
|
||||
.remaining_chars = 0,
|
||||
.only_digits = false,
|
||||
.previous_token = NULL,
|
||||
.current_token = NULL };
|
||||
|
||||
// test
|
||||
struct token *tok = peek_token();
|
||||
struct token *tok = peek_token(&ctx);
|
||||
|
||||
// expected
|
||||
enum token_type type_expected = TOKEN_WORD;
|
||||
|
|
@ -48,41 +60,3 @@ Test(peek_token, basic_word)
|
|||
cr_assert(type_expected == tok->type);
|
||||
free_token(&tok);
|
||||
}
|
||||
Test(peek_token, basic_words)
|
||||
{
|
||||
// simulates input
|
||||
char command[] = "echo hello there";
|
||||
struct iob_context context = { IOB_MODE_CMD, command };
|
||||
iob_init(&context);
|
||||
|
||||
// ======= echo
|
||||
|
||||
struct token *tok = peek_token();
|
||||
|
||||
enum token_type type_expected = TOKEN_WORD;
|
||||
char string_expected[] = "echo";
|
||||
|
||||
cr_assert(eq(str, string_expected, tok->data));
|
||||
cr_assert(type_expected == tok->type);
|
||||
free_token(&tok);
|
||||
|
||||
// ======= hello
|
||||
|
||||
tok = peek_token();
|
||||
|
||||
char string_expected2[] = "hello";
|
||||
|
||||
cr_assert(eq(str, string_expected2, tok->data));
|
||||
cr_assert(type_expected == tok->type);
|
||||
free_token(&tok);
|
||||
|
||||
// ======= there
|
||||
|
||||
tok = peek_token();
|
||||
|
||||
char string_expected3[] = "there";
|
||||
|
||||
cr_assert(eq(str, string_expected3, tok->data));
|
||||
cr_assert(type_expected == tok->type);
|
||||
free_token(&tok);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue