ADD: test bash script.
parent
0795eb5d9f
commit
690122ea4a
|
@ -0,0 +1,36 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
OK=0
|
||||||
|
TOTAL=0
|
||||||
|
|
||||||
|
for file in `find . -name "*.gri" -exec basename {} \;`
|
||||||
|
do
|
||||||
|
echo -en "\e[34m$file ... \e[0m"
|
||||||
|
|
||||||
|
MSG="$(grino $file 2>&1 > /dev/null)"
|
||||||
|
RES=$?
|
||||||
|
|
||||||
|
if [ "$RES" == "0" ]
|
||||||
|
then
|
||||||
|
echo -e "ok"
|
||||||
|
OK=$(($OK + 1))
|
||||||
|
else
|
||||||
|
echo "ko"
|
||||||
|
echo -e "\t\e[31m$MSG\e[0m"
|
||||||
|
fi
|
||||||
|
|
||||||
|
TOTAL=$(($TOTAL + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
echo
|
||||||
|
|
||||||
|
if [ $OK -eq $TOTAL ]
|
||||||
|
then
|
||||||
|
echo -e "\e[32m=== $OK/$TOTAL tests passed ! ===\e[0m"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
FAILURE=$(($TOTAL - $OK))
|
||||||
|
|
||||||
|
echo -e "\e[31m=== $FAILURE/$TOTAL tests failed ===\e[0m"
|
||||||
|
exit -1
|
104
src/main.cpp
104
src/main.cpp
|
@ -11,48 +11,7 @@
|
||||||
#include "src/SymTable.hpp"
|
#include "src/SymTable.hpp"
|
||||||
#include "Loader.hpp"
|
#include "Loader.hpp"
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
void run(char** argv, bool debug_mode)
|
||||||
{
|
|
||||||
bool debug_mode = false;
|
|
||||||
|
|
||||||
static struct option options[] = {
|
|
||||||
{"help", no_argument, 0, 'h'},
|
|
||||||
{"version", no_argument, 0, 'v'},
|
|
||||||
{"debug", no_argument, 0, 'd'},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
int option_index = 0;
|
|
||||||
|
|
||||||
int c = getopt_long(argc, argv, "hvd", options, &option_index);
|
|
||||||
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case 'h': {
|
|
||||||
std::cout << "Usage: grino [OPTION]... source" << std::endl;
|
|
||||||
std::cout << "OPTIONS:" << std::endl;
|
|
||||||
std::cout << "\t" << "-d, --debug, "
|
|
||||||
<< "activate debug mode" << std::endl;
|
|
||||||
|
|
||||||
std::cout << "\t" << "-h, --help, "
|
|
||||||
<< "show this message" << std::endl;
|
|
||||||
std::cout << "\t" << "-v, --version, "
|
|
||||||
<< "show grino version" << std::endl;
|
|
||||||
exit(0);
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case 'v': {
|
|
||||||
std::cout << "grino version: " << GRINO_VERSION << std::endl;
|
|
||||||
std::cout << "License: " << "GPLv3 or later (see LICENSE)"<< std::endl;
|
|
||||||
exit(0);
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case 'd': {
|
|
||||||
debug_mode = true;
|
|
||||||
} break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (optind < argc)
|
|
||||||
{
|
{
|
||||||
std::string source;
|
std::string source;
|
||||||
{
|
{
|
||||||
|
@ -101,5 +60,66 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
bool debug_mode = false;
|
||||||
|
|
||||||
|
static struct option options[] = {
|
||||||
|
{"help", no_argument, 0, 'h'},
|
||||||
|
{"version", no_argument, 0, 'v'},
|
||||||
|
{"debug", no_argument, 0, 'd'},
|
||||||
|
{0, 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
int option_index = 0;
|
||||||
|
|
||||||
|
int c = getopt_long(argc, argv, "hvd", options, &option_index);
|
||||||
|
|
||||||
|
switch (c)
|
||||||
|
{
|
||||||
|
case 'h': {
|
||||||
|
std::cout << "Usage: grino [OPTION]... source" << std::endl;
|
||||||
|
std::cout << "OPTIONS:" << std::endl;
|
||||||
|
std::cout << "\t" << "-d, --debug, "
|
||||||
|
<< "activate debug mode" << std::endl;
|
||||||
|
|
||||||
|
std::cout << "\t" << "-h, --help, "
|
||||||
|
<< "show this message" << std::endl;
|
||||||
|
std::cout << "\t" << "-v, --version, "
|
||||||
|
<< "show grino version" << std::endl;
|
||||||
|
exit(0);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case 'v': {
|
||||||
|
std::cout << "grino version: " << GRINO_VERSION << std::endl;
|
||||||
|
std::cout << "License: " << "GPLv3 or later (see LICENSE)"<< std::endl;
|
||||||
|
exit(0);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case 'd': {
|
||||||
|
debug_mode = true;
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (optind < argc)
|
||||||
|
{
|
||||||
|
if (debug_mode)
|
||||||
|
{
|
||||||
|
run(argv, debug_mode);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
run(argv, debug_mode);
|
||||||
|
}
|
||||||
|
catch(std::exception const& err)
|
||||||
|
{
|
||||||
|
std::cerr << err.what() << std::endl;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue