Debian Codegraph @

debian/tests/python

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