FOSSology  4.4.0
Open Source License Compliance by Open Source Software
fointeg.php
1 #!/usr/bin/php
2 <?php
3 /*
4  SPDX-FileCopyrightText: © 2011 Hewlett-Packard Development Company, L.P.
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
20 /*
21  * Here is the spec:
22  *
23  * fointeg [-a] [-b] [-f] [-h] [-i] [-t] [-u]
24  * -a: run everything, build, install, unit and functional tests
25  * -b: make clean, make
26  * -f: run functional tests (which build/install and run func tests)
27  * -h: this help message
28  * -i: install upstream sources
29  * -t: run unit and functional tests (assumes a make and or a make install have
30  * been done).
31  * -u: run unit tests (make tests, and process results)
32  *
33  * This is what the makefile should call, later, add in --options as well.
34  *
35  * The plan:
36  * - for phpunit, use the xml and junit options
37  * - for simpletest? maybe use phpini? or a naming convention? (I like ini)
38  * - parse the input files as well so you know what files were run, then
39  * compare to the rest of the files in the dir.
40  *
41  * May still have to do a file or mimetype on each file to know how to run it.
42  * (I am assuming that the rest of the files will be shell scripts).
43  *
44  * Take a look at the shell framework that bob and norton want to use.
45  *
46  * ?? Should the different options leave markers so the downstream tasks can
47  * check those to see if a build or ... nevermind.. much better for functional
48  * test to build/install and test.
49  */
50 
51 
52 require_once 'fo_integration.php';
53 
54 $usage = "fointeg [-a] [-b] [-f] [-h] [-i] [-t] [-u]
55  -a: run everything, build, install, unit and functional tests
56  -b: make clean, make
57  -f: run functional tests (which build/install and run func tests)
58  -h: this help message
59  -i: install upstream sources
60  -t: run unit and functional tests
61  -u: run unit tests (make tests, and process results)";
62 
63 $options = getopt('abfhitu');
64 if (empty($options))
65 {
66  echo "$usage\n";
67  exit(0);
68 }
69 if (array_key_exists('h', $options))
70 {
71  echo "$usage\n";
72  exit(0);
73 }
74 if (array_key_exists('a', $options))
75 {
76  echo "-a option is not yet implimented\n";
77  exit(0);
78 }
79 if (array_key_exists('b', $options))
80 {
81  cdStart();
82  try
83  {
84  $Make = new Build(getcwd());
85  }
86  catch (Exception $e)
87  {
88  echo $e;
89  exit(1);
90  }
91 }
92 if (array_key_exists('f', $options))
93 {
94  echo "-f option is not yet implimented\n";
95  exit(0);
96 }
97 if (array_key_exists('i', $options))
98 {
99  echo "-i option is not yet implimented\n";
100  exit(0);
101 }
102 if (array_key_exists('t', $options))
103 {
104  echo "-t option is not yet implimented\n";
105  exit(0);
106 }
107 if (array_key_exists('u', $options))
108 {
109  // new unitTests()....
110 }
111 
118 function cdStart()
119 {
120  $WORKSPACE = NULL;
121 
122  // are we running inside jenkins?
123  if(array_key_exists('WORKSPACE', $_ENV))
124  {
125  $WORKSPACE = $_ENV['WORKSPACE'];
126  }
127  if($WORKSPACE)
128  {
129  if(!chdir($WORKSPACE . "/fossology2.0/fossology/src"))
130  {
131  echo "FATAL! Cannot cd to " . $WORKSPACE . "/fossology2.0/fossology/src";
132  exit(1);
133  }
134  }
135  else
136  {
137  // ?? analyze the path and act accordingly?
138  }
139 } // cdStart
make fossology, check for warnings and errors