Skip to content

Commit c551ca4

Browse files
authored
Feature project tests (#9)
Add project for tests management
1 parent 8a74d48 commit c551ca4

17 files changed

+234
-50
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ If both are specified, the values in the test scenario file are adopted.
282282
- [Customize configurations](https://github.com/AsaiYusuke/6502_test_executor/blob/master/example/test/ok/customize.configurations.test.json)
283283
- [Skip test (ignore)](https://github.com/AsaiYusuke/6502_test_executor/blob/master/example/test/ok/skip.test.json)
284284
- [Complex evaluation](https://github.com/AsaiYusuke/6502_test_executor/blob/master/example/test/ok/evaluation.test.json)
285+
- [Project for tests](https://github.com/AsaiYusuke/6502_test_executor/blob/master/example/test/ok/project/project.test.json)
285286
- [Grouping](https://github.com/AsaiYusuke/6502_test_executor/blob/master/example/test/ok/group.test.json)
286287
- [Definitions](https://github.com/AsaiYusuke/6502_test_executor/blob/master/example/test/ok/definitions.test.json)
287288

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"$schema": "../../../../schema/project.schema.json",
3+
"tests": [
4+
{
5+
"target": {
6+
"start": {
7+
"label": "check_collision"
8+
}
9+
},
10+
"cases": {
11+
"test 1-1": {
12+
"setup": {},
13+
"expected": {}
14+
},
15+
"test 1-2": {
16+
"setup": {},
17+
"expected": {}
18+
}
19+
}
20+
},
21+
{
22+
"target": {
23+
"start": {
24+
"label": "check_collision"
25+
}
26+
},
27+
"cases": {
28+
"test 2-1": {
29+
"setup": {},
30+
"expected": {}
31+
},
32+
"test 2-2": {
33+
"setup": {},
34+
"expected": {}
35+
}
36+
}
37+
},
38+
{
39+
"file": "sub_testcase.test.json"
40+
}
41+
]
42+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "../../../../schema/testcase.schema.json",
3+
"target": {
4+
"start": {
5+
"label": "check_collision"
6+
}
7+
},
8+
"cases": {
9+
"sub test 1": {
10+
"setup": {},
11+
"expected": {}
12+
}
13+
}
14+
}

include/emulation/debug_info.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class debug_info
4646
public:
4747
debug_info(args_parser *args, json config);
4848
string get_path();
49-
void activate_line_coverage(uint16_t address);
49+
void add_line_coverage(uint16_t address);
5050
string get_source_line(uint16_t address);
5151
bool has_address(string label);
5252
string get_label(uint16_t address);

include/emulation/debug_source_line.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ class debug_source_line
1010
int file_id;
1111
int segment_id;
1212
int line_number;
13-
bool cover;
13+
int cover;
1414

1515
public:
1616
debug_source_line(int _file_id, int _segment_id, int _line_number);
1717
int get_file_id();
1818
int get_segment_id();
1919
int get_line_number();
20-
bool is_cover();
21-
void set_cover();
20+
int get_cover();
21+
void add_cover();
2222
};

include/emulation/emulation_devices.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ class emulation_devices
1818
cpu_device *cpu;
1919
memory_device *memory;
2020
vector<runtime_error_result> errors;
21-
debug_info *debug;
2221

2322
public:
24-
emulation_devices(args_parser *args, json config);
23+
emulation_devices(args_parser *args, json config, debug_info *debug);
2524
void clear(condition_register_pc *pc, vector<uint8_t> stack);
2625
cpu_device *get_cpu();
2726
memory_device *get_memory();
@@ -33,6 +32,5 @@ class emulation_devices
3332
void add_error_result(runtime_error_type type, string message);
3433
vector<runtime_error_result> get_filtered_errors(vector<runtime_error_type> types);
3534

36-
void save_coverage();
3735
void print();
3836
};

include/test/test.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ class test
1414
{
1515
private:
1616
args_parser *args;
17+
debug_info *debug;
1718
emulation_devices *device;
18-
json test_scinario;
19+
vector<json> test_scinarios;
1920

20-
void traverse(test_total_result &total_result, json testcase, string path);
21-
test_result do_test(string id, json testcase);
21+
json read_json(string path);
22+
void traverse(test_total_result &total_result, json test_target, json test_template, json testcase, string path);
23+
test_result do_test(string id, json test_target, json test_template, json testcase);
2224
void print_call_stack();
2325

2426
public:

include/test/test_total_result.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ class test_total_result
1515
map<test_result_type, int> test_result_map;
1616

1717
public:
18-
test_total_result(emulation_devices *_device, args_parser *_args, int _total);
18+
test_total_result(emulation_devices *_device, args_parser *_args);
1919
void add_and_print_result(test_result result);
2020
bool is_success();
21+
void set_total(int total);
2122
void print_summary();
2223
};

include/util/test_detect.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#include "nlohmann/json.hpp"
4+
5+
using namespace std;
6+
7+
using json = nlohmann::json;
8+
9+
class test_detect
10+
{
11+
private:
12+
static bool key_type_check(string key, json::value_t type, json value);
13+
14+
public:
15+
static bool is_project(json value);
16+
static bool is_file_reference(json value);
17+
};

schema/project.schema.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"$schema": "http://json-schema.org/schema",
3+
"type": "object",
4+
"additionalProperties": false,
5+
"properties": {
6+
"$schema": {
7+
"type": "string"
8+
},
9+
"tests": {
10+
"type": "array",
11+
"minItems": 1,
12+
"items": {
13+
"type": "object",
14+
"additionalProperties": false,
15+
"properties": {
16+
"target": true,
17+
"cases": true,
18+
"definitions": true,
19+
"config": true,
20+
"file": {
21+
"type": "string"
22+
}
23+
},
24+
"if": {
25+
"properties": {
26+
"file": {
27+
"type": "null"
28+
}
29+
}
30+
},
31+
"then": {
32+
"allOf": [
33+
{
34+
"$ref": "testcase.schema.json"
35+
}
36+
]
37+
},
38+
"else": {
39+
"properties": {
40+
"target": false,
41+
"cases": false,
42+
"definitions": false,
43+
"config": false
44+
}
45+
}
46+
47+
}
48+
}
49+
}
50+
}

0 commit comments

Comments
 (0)