ATLAS Offline Software
CI_test.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 # This script is designed to be used as a quick runtime ctest in the CI framework
3 # We use python to better handle getting our validation cutfile which should be stable
4 # We will augment the NEvents line in our cutfile to limit the job
5 # This is primarily to catch any runtime changes introduced before they are merged
6 
7 import sys, subprocess, random, os, shlex, ROOT, shutil
8 
9 def CITest(testname, cutfile, cutfilepath, inputfile, sedreplace):
10  """ Templated test to allow extension """
11  print("CI Integration Test :",testname)
12 
13  # -- Settings --
14  cutfilename = cutfile
15  inputfilename = inputfile
16 
17  # -- Move to a unique directory --
18  cwd = os.getcwd()
19  rundir = str(random.randrange(10**8))
20  os.mkdir(rundir)
21  os.chdir(rundir)
22 
23  # -- Get the validation file path from the most recent location --
24 
25  # -- Print the file location for debugging --
26  print("CI Integration Test : Using cutfile %s"%(cutfilepath))
27  print("CI Integration Test : Using inputfile %s"%(inputfilename))
28 
29  # -- Copy the cutfile locally to be updated --
30  shutil.copyfile(cutfilepath, cutfilename)
31 
32  # -- Write the input file path to a temporary file --
33  inputfilepath = open("input.txt","w")
34  inputfilepath.write(inputfilename+"\n")
35  inputfilepath.close()
36 
37  # -- Edit the cutfile to set any provided options --
38  for (old, new) in sedreplace:
39  cmd = "sed -i -e 's/"+old+"/"+new+"/g' %s"%(cutfilename)
40  proc = subprocess.Popen(shlex.split(cmd))
41  proc.wait()
42 
43  # -- Run top-xaod --
44  cmd = "top-xaod %s input.txt"%(cutfilename)
45  proc = subprocess.Popen(shlex.split(cmd))
46  proc.wait()
47 
48  # Return to starting directory
49  os.chdir(cwd)
50 
51  # -- Check the return code and exit this script with that --
52  return proc.returncode
CI_test.CITest
def CITest(testname, cutfile, cutfilepath, inputfile, sedreplace)
Definition: CI_test.py:9
Trk::open
@ open
Definition: BinningType.h:40
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
str
Definition: BTagTrackIpAccessor.cxx:11