Blame tests/p_valac/10-test_valac.sh

843723683 88bc63
#!/bin/bash
843723683 88bc63
843723683 88bc63
# Author: Lz <Lz843723683@163.com>
843723683 88bc63
843723683 673c92
if [ "$centos_ver" -ne "7" ];then
843723683 673c92
        t_Log "Package not included in CentOS $centos_ver => SKIP"
843723683 673c92
        exit 0
843723683 0973b4
fi
843723683 0973b4
843723683 673c92
t_Log "Running $0 - Testing valac by running it with a basic file"
843723683 673c92
843723683 88bc63
# creating source code
843723683 88bc63
FILE='/var/tmp/valac-test.vala'
843723683 88bc63
EXE='/var/tmp/valac-test'
843723683 88bc63
843723683 88bc63
cat > $FILE <
843723683 88bc63
class Demo.HelloWorld : GLib.Object {
843723683 88bc63
public static int main(string[] args)
843723683 88bc63
{
843723683 88bc63
stdout.printf("HelloWorld!\n");
843723683 88bc63
return 0;
843723683 88bc63
}
843723683 88bc63
}
843723683 88bc63
EOF
843723683 88bc63
843723683 88bc63
843723683 88bc63
# Executing valac
843723683 88bc63
valac -o $EXE $FILE
843723683 88bc63
843723683 88bc63
# run EXE
843723683 88bc63
$EXE | grep -q 'HelloWorld'
843723683 88bc63
t_CheckExitStatus $?
843723683 88bc63
843723683 88bc63
# remove files
843723683 88bc63
/bin/rm $FILE
843723683 88bc63
/bin/rm $EXE