Actually fix which allocator we're using in the tests.
This commit is contained in:
69
Ink.jai
69
Ink.jai
@@ -167,9 +167,9 @@ run_codegen_test :: (file_path : string, ctx : *Compiler_Context, output_type :
|
|||||||
result : Result;
|
result : Result;
|
||||||
result.path = file_path;
|
result.path = file_path;
|
||||||
|
|
||||||
lex(ctx);
|
lex(ctx, context.allocator);
|
||||||
parse(ctx);
|
parse(ctx, context.allocator);
|
||||||
check(ctx);
|
check(ctx, context.allocator);
|
||||||
|
|
||||||
if ctx.had_error {
|
if ctx.had_error {
|
||||||
result.type = .Failed;
|
result.type = .Failed;
|
||||||
@@ -185,7 +185,7 @@ run_codegen_test :: (ctx : *Compiler_Context, output_type : Output_Type = 0) ->
|
|||||||
result.path = ctx.file.path;
|
result.path = ctx.file.path;
|
||||||
result_text : string;
|
result_text : string;
|
||||||
|
|
||||||
codegen(ctx);
|
codegen(ctx, context.allocator);
|
||||||
|
|
||||||
if ctx.had_error {
|
if ctx.had_error {
|
||||||
result.type = .Failed;
|
result.type = .Failed;
|
||||||
@@ -210,7 +210,7 @@ run_compile_test :: (path : string, output_type : Output_Type = 0) -> Result, Co
|
|||||||
ctx : Compiler_Context;
|
ctx : Compiler_Context;
|
||||||
result : Result;
|
result : Result;
|
||||||
result.path = path;
|
result.path = path;
|
||||||
compile_file(*ctx, path);
|
compile_file(*ctx, path, context.allocator);
|
||||||
|
|
||||||
if ctx.had_error {
|
if ctx.had_error {
|
||||||
result.type = .Failed;
|
result.type = .Failed;
|
||||||
@@ -263,7 +263,7 @@ run_lexer_test :: (file_path : string, ctx : *Compiler_Context, output_type : Ou
|
|||||||
result.type = .Failed;
|
result.type = .Failed;
|
||||||
result_text = report_messages(ctx.messages);
|
result_text = report_messages(ctx.messages);
|
||||||
} else {
|
} else {
|
||||||
result_text = pretty_print_tokens(ctx.tokens, *temp);
|
result_text = pretty_print_tokens(ctx.tokens, context.allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if output_type & .StdOut {
|
if output_type & .StdOut {
|
||||||
@@ -293,16 +293,16 @@ run_parser_test :: (file_path : string, ctx : *Compiler_Context, output_type : O
|
|||||||
}
|
}
|
||||||
|
|
||||||
run_parser_test :: (ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
|
run_parser_test :: (ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
|
||||||
parse(ctx);
|
parse(ctx, context.allocator);
|
||||||
result : Result;
|
result : Result;
|
||||||
result.path = ctx.file.path;
|
result.path = ctx.file.path;
|
||||||
result_text : string;
|
result_text : string;
|
||||||
|
|
||||||
if ctx.had_error {
|
if ctx.had_error {
|
||||||
result.type = .Failed;
|
result.type = .Failed;
|
||||||
result_text = report_messages(ctx.messages,, temp);
|
result_text = report_messages(ctx.messages);
|
||||||
} else {
|
} else {
|
||||||
result_text = pretty_print_ast(ctx.root, *temp);
|
result_text = pretty_print_ast(ctx.root, context.allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if output_type & .StdOut {
|
if output_type & .StdOut {
|
||||||
@@ -321,13 +321,13 @@ run_semantic_analysis_test :: (ctx : *Compiler_Context, output_type : Output_Typ
|
|||||||
result.path = ctx.file.path;
|
result.path = ctx.file.path;
|
||||||
result_text : string;
|
result_text : string;
|
||||||
|
|
||||||
check(ctx);
|
check(ctx, context.allocator);
|
||||||
|
|
||||||
if ctx.had_error {
|
if ctx.had_error {
|
||||||
result.type = .Failed;
|
result.type = .Failed;
|
||||||
result_text = report_messages(ctx.messages);
|
result_text = report_messages(ctx.messages);
|
||||||
} else {
|
} else {
|
||||||
result_text = pretty_print_symbol_table(ctx, temp);
|
result_text = pretty_print_symbol_table(ctx, context.allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
if output_type & .StdOut {
|
if output_type & .StdOut {
|
||||||
@@ -345,8 +345,8 @@ run_semantic_analysis_test :: (file_path : string, ctx : *Compiler_Context, outp
|
|||||||
result : Result;
|
result : Result;
|
||||||
result.path = file_path;
|
result.path = file_path;
|
||||||
|
|
||||||
lex(ctx);
|
lex(ctx, context.allocator);
|
||||||
parse(ctx);
|
parse(ctx, context.allocator);
|
||||||
if ctx.had_error {
|
if ctx.had_error {
|
||||||
result.type = .Failed;
|
result.type = .Failed;
|
||||||
return result;
|
return result;
|
||||||
@@ -366,7 +366,10 @@ make_test_case :: (path : string, stage_flags : Stage_Flags, allocator := contex
|
|||||||
return test_case;
|
return test_case;
|
||||||
}
|
}
|
||||||
|
|
||||||
run_test_new :: (file_path : string, stage_flags : Stage_Flags, results : *[..]Result, output_type : Output_Type = 0) {
|
run_test_new :: (file_path : string, stage_flags : Stage_Flags, results : *[..]Result, output_type : Output_Type = 0, allocator := temp) {
|
||||||
|
new_context := context;
|
||||||
|
new_context.allocator = allocator;
|
||||||
|
push_context new_context {
|
||||||
ctx : Compiler_Context;
|
ctx : Compiler_Context;
|
||||||
|
|
||||||
ctx.file = make_file(*ctx, file_path);
|
ctx.file = make_file(*ctx, file_path);
|
||||||
@@ -408,9 +411,11 @@ run_test_new :: (file_path : string, stage_flags : Stage_Flags, results : *[..]R
|
|||||||
result = run_compile_test(file_path, output_type);
|
result = run_compile_test(file_path, output_type);
|
||||||
record_result(results, result);
|
record_result(results, result);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_Type = 0) {
|
run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_Type = 0, allocator := temp) {
|
||||||
print("%Running test: %......", cyan(), test_case.path);
|
print("%Running test: %......", cyan(), test_case.path);
|
||||||
|
|
||||||
// path 30
|
// path 30
|
||||||
@@ -428,7 +433,7 @@ run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_
|
|||||||
print(" ");
|
print(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
run_test_new(test_case.path, test_case.stage_flags, results, output_type);
|
run_test_new(test_case.path, test_case.stage_flags, results, output_type, allocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
record_result :: (results : *[..]Result, result : Result) {
|
record_result :: (results : *[..]Result, result : Result) {
|
||||||
@@ -446,14 +451,16 @@ run_test_suite :: (using suite : *Test_Suite, output_type : Output_Type = 0) {
|
|||||||
stage : string;
|
stage : string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_arena : Allocator = make_arena(Gigabytes(1));
|
||||||
|
|
||||||
failed_test_paths : [..]Fail_Data;
|
failed_test_paths : [..]Fail_Data;
|
||||||
failed_test_paths.allocator = temp;
|
failed_test_paths.allocator = test_arena;
|
||||||
|
|
||||||
builder : String_Builder;
|
builder : String_Builder;
|
||||||
init_string_builder(*builder,, temp);
|
init_string_builder(*builder,, test_arena);
|
||||||
|
|
||||||
for test_case : test_cases {
|
for test_case : test_cases {
|
||||||
run_test(test_case, *suite.results, output_type);
|
run_test(test_case, *suite.results, output_type, allocator = test_arena);
|
||||||
|
|
||||||
for < suite.results {
|
for < suite.results {
|
||||||
result := suite.results[it_index];
|
result := suite.results[it_index];
|
||||||
@@ -496,10 +503,10 @@ run_test_suite :: (using suite : *Test_Suite, output_type : Output_Type = 0) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print("%\n", builder_to_string(*builder,, temp));
|
print("%\n", builder_to_string(*builder,, test_arena));
|
||||||
}
|
}
|
||||||
|
|
||||||
read_suite :: (file_path : string, suite : *Test_Suite) -> bool {
|
read_suite :: (file_path : string, suite : *Test_Suite, allocator := temp) -> bool {
|
||||||
sc := get_scratch();
|
sc := get_scratch();
|
||||||
defer scratch_end(sc);
|
defer scratch_end(sc);
|
||||||
bytes, ok := read_entire_file(file_path,, sc.allocator);
|
bytes, ok := read_entire_file(file_path,, sc.allocator);
|
||||||
@@ -510,10 +517,18 @@ read_suite :: (file_path : string, suite : *Test_Suite) -> bool {
|
|||||||
|
|
||||||
path := parse_path(file_path,, sc.allocator);
|
path := parse_path(file_path,, sc.allocator);
|
||||||
file_without_extension := split(path.words[path.words.count - 1], ".",, sc.allocator);
|
file_without_extension := split(path.words[path.words.count - 1], ".",, sc.allocator);
|
||||||
suite.name = copy_string(file_without_extension[0],, temp);
|
suite.name = copy_string(file_without_extension[0],, allocator);
|
||||||
split_lines := split(bytes, "\n",, sc.allocator);
|
split_lines := split(bytes, "\n",, sc.allocator);
|
||||||
|
|
||||||
for split_line : split_lines {
|
for split_line : split_lines {
|
||||||
|
if split_line.count == 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if split_line[0] == #char "#" {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
line := split(split_line, " ",, sc.allocator);
|
line := split(split_line, " ",, sc.allocator);
|
||||||
if line[0].count == 0 {
|
if line[0].count == 0 {
|
||||||
continue;
|
continue;
|
||||||
@@ -547,7 +562,7 @@ read_suite :: (file_path : string, suite : *Test_Suite) -> bool {
|
|||||||
stage_flags |= .Compile;
|
stage_flags |= .Compile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
test_case := make_test_case(test_case_path, stage_flags, temp);
|
test_case := make_test_case(test_case_path, stage_flags, allocator);
|
||||||
array_add(*suite.test_cases, test_case);
|
array_add(*suite.test_cases, test_case);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -612,8 +627,10 @@ main :: () {
|
|||||||
|
|
||||||
init_context_allocators();
|
init_context_allocators();
|
||||||
|
|
||||||
|
local_temp := make_arena(Megabytes(128));
|
||||||
|
|
||||||
suites : [..]Test_Suite;
|
suites : [..]Test_Suite;
|
||||||
suites.allocator = temp;
|
suites.allocator = local_temp;
|
||||||
output_type : Output_Type = 0;
|
output_type : Output_Type = 0;
|
||||||
|
|
||||||
Argument_Parse_State :: enum {
|
Argument_Parse_State :: enum {
|
||||||
@@ -626,8 +643,6 @@ main :: () {
|
|||||||
arg_parse_state : Argument_Parse_State;
|
arg_parse_state : Argument_Parse_State;
|
||||||
current_suite : *Test_Suite;
|
current_suite : *Test_Suite;
|
||||||
|
|
||||||
local_temp := make_arena(Megabytes(128));
|
|
||||||
|
|
||||||
path : string;
|
path : string;
|
||||||
|
|
||||||
for i: 1..args.count - 1 {
|
for i: 1..args.count - 1 {
|
||||||
@@ -715,7 +730,7 @@ main :: () {
|
|||||||
suite : Test_Suite;
|
suite : Test_Suite;
|
||||||
suite.results.allocator = local_temp;
|
suite.results.allocator = local_temp;
|
||||||
suite.test_cases.allocator = local_temp;
|
suite.test_cases.allocator = local_temp;
|
||||||
read_suite(path, *suite);
|
read_suite(path, *suite, local_temp);
|
||||||
array_add(*suites, suite);
|
array_add(*suites, suite);
|
||||||
current_suite = *suites[0];
|
current_suite = *suites[0];
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -486,7 +486,7 @@ new_builtin_struct_node :: (ctx : *Compiler_Context, name : string, members : []
|
|||||||
|
|
||||||
source_location.end = brace_token;
|
source_location.end = brace_token;
|
||||||
|
|
||||||
source := builder_to_string(*builder);
|
source := builder_to_string(*builder,, context.allocator);
|
||||||
|
|
||||||
source_location.begin.source = *source.data[source_location.begin.column];
|
source_location.begin.source = *source.data[source_location.begin.column];
|
||||||
source_location.end.source = *source.data[source_location.end.column];
|
source_location.end.source = *source.data[source_location.end.column];
|
||||||
@@ -557,7 +557,7 @@ new_builtin_function_node :: (ctx : *Compiler_Context, name : string, members :
|
|||||||
|
|
||||||
source_location.end = semicolon_tok;
|
source_location.end = semicolon_tok;
|
||||||
|
|
||||||
source := builder_to_string(*builder);
|
source := builder_to_string(*builder,, context.allocator);
|
||||||
|
|
||||||
source_location.begin.source = *source.data[source_location.begin.column];
|
source_location.begin.source = *source.data[source_location.begin.column];
|
||||||
source_location.end.source = *source.data[source_location.end.column];
|
source_location.end.source = *source.data[source_location.end.column];
|
||||||
|
|||||||
BIN
output.tracy
Normal file
BIN
output.tracy
Normal file
Binary file not shown.
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
test/assign_arithmetic_expression.ink semant
|
test/assign_arithmetic_expression.ink semant
|
||||||
test/basic_property_and_return_value.ink semant
|
test/basic_property_and_return_value.ink semant
|
||||||
test/builtin_types.ink semant
|
test/builtin_types.ink semant
|
||||||
|
|||||||
Reference in New Issue
Block a user