File: python

package info (click to toggle)
libgnatcoll-bindings 25.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,412 kB
  • sloc: ada: 18,696; python: 1,597; ansic: 1,422; cpp: 581; makefile: 147; sh: 114
file content (52 lines) | stat: -rw-r--r-- 1,299 bytes parent folder | download | duplicates (2)
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'