193 args = get_parser().parse_args()
194 logging.basicConfig(stream=sys.stdout,
195 format='%(levelname)-8s %(message)s',
196 level=logging.DEBUG if args.verbose else logging.INFO)
197
198 topdir = 'runTrigART'
199 statusfile = 'results/{:s}-status.json'.format(topdir)
200
201
202 if args.rerun_failed or args.summary:
203 status_data = json.load(open(os.path.join(topdir,statusfile)))
204 all_test_results = status_data[topdir]
205 failed_tests = analyse_results(all_test_results)
206 if args.summary:
207 print_summary(all_test_results, failed_tests)
208 return 0
209
210 if args.rerun_failed:
211 scripts = find_scripts(get_patterns(args)+['|'.join(failed_tests)])
212 else:
213 scripts = find_scripts(get_patterns(args))
214
215 logging.info("The following %d tests will be executed: ", len(scripts))
216 for filename in scripts:
217 logging.info(" %s", os.path.basename(filename))
218
219 if len(scripts) > 5*args.maxJobs:
220 if args.maxJobs == 1:
221 logging.warning("You are running %d tests in sequence. This may take "
222 "a long time, consider using -j N option.", len(scripts))
223 else:
224 logging.warning("You are running %d tests with %d parallel jobs. "
225 "This may take a long time.", len(scripts), args.maxJobs)
226
227 if args.dryRun:
228 return 0
229
230 success = True
231 with remember_cwd():
232 prep_dirs(topdir, scripts)
233 os.chdir(topdir)
234 for script_path in scripts:
235 target = 'test/' + os.path.basename(script_path)
236 os.symlink(script_path, target)
237
238
239 commands = [
240 'export ATLAS_LOCAL_ROOT_BASE="${ATLAS_LOCAL_ROOT_BASE:-/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase}"',
241 'source "${ATLAS_LOCAL_ROOT_BASE}"/user/atlasLocalSetup.sh --quiet',
242 'lsetup -q art']
243 art_cmd = 'art.py run --run-all-tests --max-jobs={:d} {:s} . results'.format(args.maxJobs, '-v' if args.verbose else '-q')
244 commands.append(art_cmd)
245 cmd = ' && '.join(commands)
246 logging.info("Executing ART command: %s", art_cmd)
247 subprocess.call(cmd, shell=True)
248 logging.info("ART finished, analysing the results\n")
249
250
251 if not os.path.isfile(statusfile):
252 logging.error("ART status.json file is missing - likely the ART runner failed!")
253 exit(1)
254 with open(statusfile, 'r') as f:
255 status_data = json.load(f)
256 all_test_results = status_data[topdir]
257 if len(all_test_results) != len(scripts):
258 logging.warning("Selected %d tests but ART executed only %d. Please check why some tests did not run!")
259 failed_tests = analyse_results(all_test_results)
260 print_summary(all_test_results, failed_tests)
261 print_failed_ref_comp(all_test_results, failed_tests)
262 if len(failed_tests) > 0:
263 success = False
264
265 if not success:
266 exit(1)
267 else:
268 exit(0)
269
270