Skip to content

Commit

Permalink
Nested suite support; removed old reporting system
Browse files Browse the repository at this point in the history
  • Loading branch information
cegonse committed Sep 10, 2024
1 parent 719e106 commit a7f3e3d
Show file tree
Hide file tree
Showing 13 changed files with 625 additions and 596 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ test_summary.jsonl
test/examples/test_assertions
test/examples/test_chatbot
test/examples/test_description
test/examples/test_nested_suites
test/examples/test_greeting
test/examples/test_money
test/examples/test_parametrized_tests
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ test: all
all: build $(TESTS) run

build:
mkdir -p build && quom src/main.hpp build/cest
mkdir -p build
quom src/main.hpp build/cest
python scripts/remove_duplicated_headers.py build/cest
python scripts/remove_duplicated_once_blocks.py build/cest

run:
@$(RUNFLAGS)
Expand Down
13 changes: 13 additions & 0 deletions scripts/remove_duplicated_headers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import sys

with open(sys.argv[1], 'r') as file:
lines = file.readlines()

includes = [l for l in lines if '#include' in l]
lines_without_includes = [l for l in lines if '#include' not in l]
unique_includes = list(set(includes))

source = '#pragma once\n' + ''.join(unique_includes + lines_without_includes)

with open(sys.argv[1], 'w') as file:
file.write(source)
33 changes: 33 additions & 0 deletions scripts/remove_duplicated_once_blocks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys

with open(sys.argv[1], 'r') as file:
lines = file.readlines()

occurences = []
prev = -1
for i in range(len(lines)):
if '// CEST-ONCE-START' in lines[i]:
prev = i

if '// CEST-ONCE-END' in lines[i]:
occurences.append((prev, i))


deleted_items = 0
if len(occurences) > 1:
for i in range(1, len(occurences)):
first = occurences[i][0]
last = occurences[i][1]

for j in range(first, last + 1):
line_idx = j - deleted_items
del lines[line_idx]
deleted_items = deleted_items + 1

print("Deleting duplicated blocks:")
print(occurences)

source = ''.join(lines)

with open(sys.argv[1], 'w') as file:
file.write(source)
10 changes: 1 addition & 9 deletions src/arg-parser.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
#pragma once
#include "types.hpp"
#include <stdexcept>
#include <string>

namespace cest
{
struct CommandLineOptions
{
bool help;
bool randomize;
unsigned int random_seed;
bool random_seed_present;
bool generate_test_report;
};

CommandLineOptions parseArgs(int argc, const char *argv[])
{
CommandLineOptions options = {0};
Expand Down
5 changes: 5 additions & 0 deletions src/globals.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "types.hpp"

// CEST-ONCE-START
static cest::CestGlobals __cest_globals;
// CEST-ONCE-END
Loading

0 comments on commit a7f3e3d

Please sign in to comment.