1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#!/bin/sh
set -C -e -f -u
cd "$AUTOPKGTEST_TMP"
cat > proc.adb <<EOF
with Ada.Command_Line;
with GNATCOLL.Python;
with GNATCOLL.Scripts.Python;
procedure Proc is
use GNATCOLL;
Repo : Scripts.Scripts_Repository;
Language : Scripts.Scripting_Language;
Py : Scripts.Python.Python_Scripting;
Errors : aliased Boolean;
None : Python.PyObject with Unreferenced;
begin
Repo := new Scripts.Scripts_Repository_Record;
Scripts.Python.Register_Python_Scripting (Repo => Repo,
Module => "Test");
Language := Scripts.Lookup_Scripting_Language
(Repo => Repo,
Name => Scripts.Python.Python_Name);
Py := Scripts.Python.Python_Scripting (Language);
None := Py.Run_Command (Command => "print('Hello')",
Need_Output => False,
Errors => Errors'Access);
Py.Destroy;
if Errors then
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end if;
end Proc;
EOF
cat > proj.gpr <<EOF
with "gnatcoll.gpr";
with "gnatcoll_python3.gpr";
project Proj is
for Main use ("proc.adb");
end Proj;
EOF
echo 'Compiling'
gprbuild -v proj.gpr
echo 'Running proc'
output=$(./proc)
echo 'Checking output'
test "$output" = 'Hello'
echo 'OK'
|