FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
fointeg.php
1 #!/usr/bin/php
2 <?php
3 /*
4  Copyright (C) 2011 Hewlett-Packard Development Company, L.P.
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  version 2 as published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
31 /*
32  * Here is the spec:
33  *
34  * fointeg [-a] [-b] [-f] [-h] [-i] [-t] [-u]
35  * -a: run everything, build, install, unit and functional tests
36  * -b: make clean, make
37  * -f: run functional tests (which build/install and run func tests)
38  * -h: this help message
39  * -i: install upstream sources
40  * -t: run unit and functional tests (assumes a make and or a make install have
41  * been done).
42  * -u: run unit tests (make tests, and process results)
43  *
44  * This is what the makefile should call, later, add in --options as well.
45  *
46  * The plan:
47  * - for phpunit, use the xml and junit options
48  * - for simpletest? maybe use phpini? or a naming convention? (I like ini)
49  * - parse the input files as well so you know what files were run, then
50  * compare to the rest of the files in the dir.
51  *
52  * May still have to do a file or mimetype on each file to know how to run it.
53  * (I am assuming that the rest of the files will be shell scripts).
54  *
55  * Take a look at the shell framework that bob and norton want to use.
56  *
57  * ?? Should the different options leave markers so the downstream tasks can
58  * check those to see if a build or ... nevermind.. much better for functional
59  * test to build/install and test.
60  */
61 
62 
63 require_once 'fo_integration.php';
64 
65 $usage = "fointeg [-a] [-b] [-f] [-h] [-i] [-t] [-u]
66  -a: run everything, build, install, unit and functional tests
67  -b: make clean, make
68  -f: run functional tests (which build/install and run func tests)
69  -h: this help message
70  -i: install upstream sources
71  -t: run unit and functional tests
72  -u: run unit tests (make tests, and process results)";
73 
74 $options = getopt('abfhitu');
75 if (empty($options))
76 {
77  echo "$usage\n";
78  exit(0);
79 }
80 if (array_key_exists('h', $options))
81 {
82  echo "$usage\n";
83  exit(0);
84 }
85 if (array_key_exists('a', $options))
86 {
87  echo "-a option is not yet implimented\n";
88  exit(0);
89 }
90 if (array_key_exists('b', $options))
91 {
92  cdStart();
93  try
94  {
95  $Make = new Build(getcwd());
96  }
97  catch (Exception $e)
98  {
99  echo $e;
100  exit(1);
101  }
102 }
103 if (array_key_exists('f', $options))
104 {
105  echo "-f option is not yet implimented\n";
106  exit(0);
107 }
108 if (array_key_exists('i', $options))
109 {
110  echo "-i option is not yet implimented\n";
111  exit(0);
112 }
113 if (array_key_exists('t', $options))
114 {
115  echo "-t option is not yet implimented\n";
116  exit(0);
117 }
118 if (array_key_exists('u', $options))
119 {
120  // new unitTests()....
121 }
122 
129 function cdStart()
130 {
131  $WORKSPACE = NULL;
132 
133  // are we running inside jenkins?
134  if(array_key_exists('WORKSPACE', $_ENV))
135  {
136  $WORKSPACE = $_ENV['WORKSPACE'];
137  }
138  if($WORKSPACE)
139  {
140  if(!chdir($WORKSPACE . "/fossology2.0/fossology/src"))
141  {
142  echo "FATAL! Cannot cd to " . $WORKSPACE . "/fossology2.0/fossology/src";
143  exit(1);
144  }
145  }
146  else
147  {
148  // ?? analyze the path and act accordingly?
149  }
150 } // cdStart
151 ?>
make fossology, check for warnings and errors