Merge pull request #33 from birth-software/integral-tests
Divide tests between standalone and integral
This commit is contained in:
commit
4dc6bea055
56
ci.sh
56
ci.sh
@ -6,24 +6,67 @@ zig build -Duse_llvm=$nativity_use_llvm
|
||||
failed_test_count=0
|
||||
passed_test_count=0
|
||||
test_directory_name=test
|
||||
test_directory=$test_directory_name/*
|
||||
total_test_count=$(ls 2>/dev/null -Ubad1 -- test/* | wc -l)
|
||||
standalone_test_directory=$test_directory_name/standalone
|
||||
standalone_test_directory_files=$standalone_test_directory/*
|
||||
integral_test_directory=$test_directory_name/integral
|
||||
integral_test_directory_files=$integral_test_directory/*
|
||||
standalone_test_count=$(ls 2>/dev/null -Ubad1 -- $standalone_test_directory/* | wc -l)
|
||||
integral_test_count=$(ls 2>/dev/null -Ubad1 -- $integral_test_directory/* | wc -l)
|
||||
total_test_count=$(($standalone_test_count + $integral_test_count))
|
||||
|
||||
ran_test_count=0
|
||||
test_i=1
|
||||
passed_compilation_count=0
|
||||
failed_compilation_count=0
|
||||
failed_compilations=()
|
||||
failed_tests=()
|
||||
my_current_directory=$(pwd)
|
||||
nat_compiler=$my_current_directory/zig-out/bin/nat
|
||||
|
||||
for dir in $test_directory
|
||||
for standalone_test_case in $standalone_test_directory_files
|
||||
do
|
||||
MY_TESTNAME=${dir##*/}
|
||||
zig build run -Duse_llvm=$nativity_use_llvm -- $dir/main.nat
|
||||
STANDALONE_TEST_NAME=${standalone_test_case##*/}
|
||||
$nat_compiler $standalone_test_case/main.nat
|
||||
|
||||
if [[ "$?" == "0" ]]; then
|
||||
passed_compilation_count=$(($passed_compilation_count + 1))
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
nat/$MY_TESTNAME
|
||||
nat/$STANDALONE_TEST_NAME
|
||||
|
||||
if [[ "$?" == "0" ]]; then
|
||||
passed_test_count=$(($passed_test_count + 1))
|
||||
result="\e[32mPASSED\e[0m"
|
||||
else
|
||||
failed_test_count=$(($failed_test_count + 1))
|
||||
result="\e[31mFAILED\e[0m"
|
||||
failed_tests+=("$test_i. $STANDALONE_TEST_NAME")
|
||||
fi
|
||||
|
||||
ran_test_count=$(($ran_test_count + 1))
|
||||
else
|
||||
result="\e[31mOS NOT SUPPORTED\e[0m"
|
||||
fi
|
||||
else
|
||||
failed_compilation_count=$(($failed_compilation_count + 1))
|
||||
result="\e[31mCOMPILATION FAILURE\e[0m"
|
||||
failed_compilations+=("$test_i. $STANDALONE_TEST_NAME")
|
||||
fi
|
||||
|
||||
echo -e "[$test_i/$total_test_count] [$result] $STANDALONE_TEST_NAME"
|
||||
|
||||
test_i=$(($test_i + 1))
|
||||
done
|
||||
|
||||
for integral_test_case in $integral_test_directory_files
|
||||
do
|
||||
MY_TESTNAME=${integral_test_case##*/}
|
||||
cd test/integral/$MY_TESTNAME
|
||||
$nat_compiler
|
||||
|
||||
if [[ "$?" == "0" ]]; then
|
||||
passed_compilation_count=$(($passed_compilation_count + 1))
|
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
nat/src
|
||||
|
||||
if [[ "$?" == "0" ]]; then
|
||||
passed_test_count=$(($passed_test_count + 1))
|
||||
@ -47,6 +90,7 @@ do
|
||||
echo -e "[$test_i/$total_test_count] [$result] $MY_TESTNAME"
|
||||
|
||||
test_i=$(($test_i + 1))
|
||||
cd $my_current_directory
|
||||
done
|
||||
|
||||
printf "\n"
|
||||
|
27
test/integral/first/build.nat
Normal file
27
test/integral/first/build.nat
Normal file
@ -0,0 +1,27 @@
|
||||
const std = #import("std");
|
||||
const assert = std.assert;
|
||||
const Executable = std.build.Executable;
|
||||
|
||||
const main = fn () s32 {
|
||||
const argument_count = std.start.argument_count;
|
||||
const argument_values = std.start.argument_values;
|
||||
assert(ok = argument_count == 3);
|
||||
|
||||
const executable = Executable{
|
||||
.target = .{
|
||||
.cpu = .x86_64,
|
||||
.os = .linux,
|
||||
.abi = .gnu,
|
||||
},
|
||||
.main_source_path = "src/main.nat",
|
||||
};
|
||||
|
||||
const compiler_path = argument_values[2];
|
||||
|
||||
if (executable.compile(compiler_path)) {
|
||||
return 0;
|
||||
} else {
|
||||
std.print(bytes = "Executable failed to compile!\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
3
test/integral/first/src/main.nat
Normal file
3
test/integral/first/src/main.nat
Normal file
@ -0,0 +1,3 @@
|
||||
const main = fn () s32 {
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user