Add unit testing for rufunge example scripts
parent
c8aec1aa14
commit
7c4af0626c
12
src/main.cpp
12
src/main.cpp
|
@ -63,7 +63,7 @@ bool run_tests()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main(int n, char **args)
|
||||||
{
|
{
|
||||||
if (!run_tests()) {
|
if (!run_tests()) {
|
||||||
std::cerr << "A test failed!" << std::endl;
|
std::cerr << "A test failed!" << std::endl;
|
||||||
|
@ -72,9 +72,17 @@ int main()
|
||||||
|
|
||||||
std::cerr << "All tests passed!" << std::endl;
|
std::cerr << "All tests passed!" << std::endl;
|
||||||
|
|
||||||
|
if (n < 2) {
|
||||||
|
std::cerr << "USAGE: a path/to/rufunge/file.rf" << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cerr << "Running " << args[1] << std::endl;
|
||||||
|
const char *filepath = args[1];
|
||||||
|
|
||||||
Canvas d;
|
Canvas d;
|
||||||
TEST(d.readFromFile("examples/hello_world2.rf"));
|
if (!d.readFromFile(filepath))
|
||||||
|
return 1;
|
||||||
|
|
||||||
VM vm;
|
VM vm;
|
||||||
vm.init(&d);
|
vm.init(&d);
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
rm -rf /tmp/rufunge
|
||||||
|
mkdir /tmp/rufunge
|
||||||
|
mkdir /tmp/rufunge/examples
|
||||||
|
|
||||||
|
for name in examples/*.rf; do
|
||||||
|
./bin/a $name > /tmp/rufunge/$name.txt
|
||||||
|
|
||||||
|
echo Result for $name:
|
||||||
|
cat /tmp/rufunge/$name.txt
|
||||||
|
|
||||||
|
if cmp --silent $name.txt /tmp/rufunge/$name.txt; then
|
||||||
|
echo "Test passed: $name"
|
||||||
|
else
|
||||||
|
echo "Test failed: $name"
|
||||||
|
exit -1
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in New Issue