How to use build method in ng-mocks

Best JavaScript code snippet using ng-mocks

manifest.bzl

Source:manifest.bzl Github

copy

Full Screen

1manifest = {2 "org_golang_x_tools": {3 "@bazel_gazelle//third_party:org_golang_x_tools/present/BUILD.bazel.in": "present/BUILD.bazel",4 "@bazel_gazelle//third_party:org_golang_x_tools/benchmark/parse/BUILD.bazel.in": "benchmark/parse/BUILD.bazel",5 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/present/BUILD.bazel.in": "cmd/present/BUILD.bazel",6 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/fiximports/testdata/src/titanic.biz/foo/BUILD.bazel.in": "cmd/fiximports/testdata/src/titanic.biz/foo/BUILD.bazel",7 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/fiximports/testdata/src/titanic.biz/bar/BUILD.bazel.in": "cmd/fiximports/testdata/src/titanic.biz/bar/BUILD.bazel",8 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/fiximports/testdata/src/new.com/one/BUILD.bazel.in": "cmd/fiximports/testdata/src/new.com/one/BUILD.bazel",9 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/fiximports/testdata/src/fruit.io/pear/BUILD.bazel.in": "cmd/fiximports/testdata/src/fruit.io/pear/BUILD.bazel",10 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/fiximports/testdata/src/fruit.io/banana/BUILD.bazel.in": "cmd/fiximports/testdata/src/fruit.io/banana/BUILD.bazel",11 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/fiximports/testdata/src/fruit.io/orange/BUILD.bazel.in": "cmd/fiximports/testdata/src/fruit.io/orange/BUILD.bazel",12 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/fiximports/testdata/src/old.com/one/BUILD.bazel.in": "cmd/fiximports/testdata/src/old.com/one/BUILD.bazel",13 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/fiximports/BUILD.bazel.in": "cmd/fiximports/BUILD.bazel",14 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/gorename/BUILD.bazel.in": "cmd/gorename/BUILD.bazel",15 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/calls/BUILD.bazel.in": "cmd/guru/testdata/src/calls/BUILD.bazel",16 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/implements-methods-json/BUILD.bazel.in": "cmd/guru/testdata/src/implements-methods-json/BUILD.bazel",17 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/whicherrs/BUILD.bazel.in": "cmd/guru/testdata/src/whicherrs/BUILD.bazel",18 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/referrers-json/BUILD.bazel.in": "cmd/guru/testdata/src/referrers-json/BUILD.bazel",19 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/alias/BUILD.bazel.in": "cmd/guru/testdata/src/alias/BUILD.bazel",20 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/pointsto/BUILD.bazel.in": "cmd/guru/testdata/src/pointsto/BUILD.bazel",21 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/implements/BUILD.bazel.in": "cmd/guru/testdata/src/implements/BUILD.bazel",22 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/what-json/BUILD.bazel.in": "cmd/guru/testdata/src/what-json/BUILD.bazel",23 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/softerrs/BUILD.bazel.in": "cmd/guru/testdata/src/softerrs/BUILD.bazel",24 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/implements-json/BUILD.bazel.in": "cmd/guru/testdata/src/implements-json/BUILD.bazel",25 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/imports/BUILD.bazel.in": "cmd/guru/testdata/src/imports/BUILD.bazel",26 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/describe/BUILD.bazel.in": "cmd/guru/testdata/src/describe/BUILD.bazel",27 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/pointsto-json/BUILD.bazel.in": "cmd/guru/testdata/src/pointsto-json/BUILD.bazel",28 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/freevars/BUILD.bazel.in": "cmd/guru/testdata/src/freevars/BUILD.bazel",29 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/describe-json/BUILD.bazel.in": "cmd/guru/testdata/src/describe-json/BUILD.bazel",30 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/implements-methods/BUILD.bazel.in": "cmd/guru/testdata/src/implements-methods/BUILD.bazel",31 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/lib/BUILD.bazel.in": "cmd/guru/testdata/src/lib/BUILD.bazel",32 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/lib/sublib/BUILD.bazel.in": "cmd/guru/testdata/src/lib/sublib/BUILD.bazel",33 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/what/BUILD.bazel.in": "cmd/guru/testdata/src/what/BUILD.bazel",34 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/peers/BUILD.bazel.in": "cmd/guru/testdata/src/peers/BUILD.bazel",35 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/main/BUILD.bazel.in": "cmd/guru/testdata/src/main/BUILD.bazel",36 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/definition-json/BUILD.bazel.in": "cmd/guru/testdata/src/definition-json/BUILD.bazel",37 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/calls-json/BUILD.bazel.in": "cmd/guru/testdata/src/calls-json/BUILD.bazel",38 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/referrers/BUILD.bazel.in": "cmd/guru/testdata/src/referrers/BUILD.bazel",39 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/reflection/BUILD.bazel.in": "cmd/guru/testdata/src/reflection/BUILD.bazel",40 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/testdata/src/peers-json/BUILD.bazel.in": "cmd/guru/testdata/src/peers-json/BUILD.bazel",41 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/BUILD.bazel.in": "cmd/guru/BUILD.bazel",42 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/guru/serial/BUILD.bazel.in": "cmd/guru/serial/BUILD.bazel",43 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/toolstash/BUILD.bazel.in": "cmd/toolstash/BUILD.bazel",44 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/compilebench/BUILD.bazel.in": "cmd/compilebench/BUILD.bazel",45 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/goyacc/testdata/expr/BUILD.bazel.in": "cmd/goyacc/testdata/expr/BUILD.bazel",46 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/goyacc/BUILD.bazel.in": "cmd/goyacc/BUILD.bazel",47 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/ssadump/BUILD.bazel.in": "cmd/ssadump/BUILD.bazel",48 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/stringer/testdata/BUILD.bazel.in": "cmd/stringer/testdata/BUILD.bazel",49 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/stringer/BUILD.bazel.in": "cmd/stringer/BUILD.bazel",50 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/html2article/BUILD.bazel.in": "cmd/html2article/BUILD.bazel",51 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/gotype/BUILD.bazel.in": "cmd/gotype/BUILD.bazel",52 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/heapview/BUILD.bazel.in": "cmd/heapview/BUILD.bazel",53 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/heapview/internal/core/BUILD.bazel.in": "cmd/heapview/internal/core/BUILD.bazel",54 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/godoc/BUILD.bazel.in": "cmd/godoc/BUILD.bazel",55 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/godex/BUILD.bazel.in": "cmd/godex/BUILD.bazel",56 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/bundle/testdata/src/initial/BUILD.bazel.in": "cmd/bundle/testdata/src/initial/BUILD.bazel",57 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/bundle/testdata/src/domain.name/importdecl/BUILD.bazel.in": "cmd/bundle/testdata/src/domain.name/importdecl/BUILD.bazel",58 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/bundle/BUILD.bazel.in": "cmd/bundle/BUILD.bazel",59 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/gomvpkg/BUILD.bazel.in": "cmd/gomvpkg/BUILD.bazel",60 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/tip/BUILD.bazel.in": "cmd/tip/BUILD.bazel",61 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/goimports/BUILD.bazel.in": "cmd/goimports/BUILD.bazel",62 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/go-contrib-init/BUILD.bazel.in": "cmd/go-contrib-init/BUILD.bazel",63 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/callgraph/testdata/src/pkg/BUILD.bazel.in": "cmd/callgraph/testdata/src/pkg/BUILD.bazel",64 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/callgraph/BUILD.bazel.in": "cmd/callgraph/BUILD.bazel",65 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/eg/BUILD.bazel.in": "cmd/eg/BUILD.bazel",66 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/getgo/BUILD.bazel.in": "cmd/getgo/BUILD.bazel",67 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/getgo/server/BUILD.bazel.in": "cmd/getgo/server/BUILD.bazel",68 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/benchcmp/BUILD.bazel.in": "cmd/benchcmp/BUILD.bazel",69 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/stress/BUILD.bazel.in": "cmd/stress/BUILD.bazel",70 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/digraph/BUILD.bazel.in": "cmd/digraph/BUILD.bazel",71 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/cover/testdata/BUILD.bazel.in": "cmd/cover/testdata/BUILD.bazel",72 "@bazel_gazelle//third_party:org_golang_x_tools/cmd/cover/BUILD.bazel.in": "cmd/cover/BUILD.bazel",73 "@bazel_gazelle//third_party:org_golang_x_tools/go/gcexportdata/BUILD.bazel.in": "go/gcexportdata/BUILD.bazel",74 "@bazel_gazelle//third_party:org_golang_x_tools/go/types/typeutil/BUILD.bazel.in": "go/types/typeutil/BUILD.bazel",75 "@bazel_gazelle//third_party:org_golang_x_tools/go/buildutil/BUILD.bazel.in": "go/buildutil/BUILD.bazel",76 "@bazel_gazelle//third_party:org_golang_x_tools/go/internal/gccgoimporter/BUILD.bazel.in": "go/internal/gccgoimporter/BUILD.bazel",77 "@bazel_gazelle//third_party:org_golang_x_tools/go/gccgoexportdata/BUILD.bazel.in": "go/gccgoexportdata/BUILD.bazel",78 "@bazel_gazelle//third_party:org_golang_x_tools/go/ssa/ssautil/BUILD.bazel.in": "go/ssa/ssautil/BUILD.bazel",79 "@bazel_gazelle//third_party:org_golang_x_tools/go/ssa/BUILD.bazel.in": "go/ssa/BUILD.bazel",80 "@bazel_gazelle//third_party:org_golang_x_tools/go/ssa/interp/BUILD.bazel.in": "go/ssa/interp/BUILD.bazel",81 "@bazel_gazelle//third_party:org_golang_x_tools/go/vcs/BUILD.bazel.in": "go/vcs/BUILD.bazel",82 "@bazel_gazelle//third_party:org_golang_x_tools/go/loader/testdata/BUILD.bazel.in": "go/loader/testdata/BUILD.bazel",83 "@bazel_gazelle//third_party:org_golang_x_tools/go/loader/BUILD.bazel.in": "go/loader/BUILD.bazel",84 "@bazel_gazelle//third_party:org_golang_x_tools/go/ast/astutil/BUILD.bazel.in": "go/ast/astutil/BUILD.bazel",85 "@bazel_gazelle//third_party:org_golang_x_tools/go/gcimporter15/testdata/versions/BUILD.bazel.in": "go/gcimporter15/testdata/versions/BUILD.bazel",86 "@bazel_gazelle//third_party:org_golang_x_tools/go/gcimporter15/BUILD.bazel.in": "go/gcimporter15/BUILD.bazel",87 "@bazel_gazelle//third_party:org_golang_x_tools/go/pointer/testdata/BUILD.bazel.in": "go/pointer/testdata/BUILD.bazel",88 "@bazel_gazelle//third_party:org_golang_x_tools/go/pointer/BUILD.bazel.in": "go/pointer/BUILD.bazel",89 "@bazel_gazelle//third_party:org_golang_x_tools/go/callgraph/cha/BUILD.bazel.in": "go/callgraph/cha/BUILD.bazel",90 "@bazel_gazelle//third_party:org_golang_x_tools/go/callgraph/BUILD.bazel.in": "go/callgraph/BUILD.bazel",91 "@bazel_gazelle//third_party:org_golang_x_tools/go/callgraph/rta/BUILD.bazel.in": "go/callgraph/rta/BUILD.bazel",92 "@bazel_gazelle//third_party:org_golang_x_tools/go/callgraph/static/BUILD.bazel.in": "go/callgraph/static/BUILD.bazel",93 "@bazel_gazelle//third_party:org_golang_x_tools/playground/BUILD.bazel.in": "playground/BUILD.bazel",94 "@bazel_gazelle//third_party:org_golang_x_tools/playground/socket/BUILD.bazel.in": "playground/socket/BUILD.bazel",95 "@bazel_gazelle//third_party:org_golang_x_tools/godoc/BUILD.bazel.in": "godoc/BUILD.bazel",96 "@bazel_gazelle//third_party:org_golang_x_tools/godoc/vfs/BUILD.bazel.in": "godoc/vfs/BUILD.bazel",97 "@bazel_gazelle//third_party:org_golang_x_tools/godoc/vfs/zipfs/BUILD.bazel.in": "godoc/vfs/zipfs/BUILD.bazel",98 "@bazel_gazelle//third_party:org_golang_x_tools/godoc/vfs/gatefs/BUILD.bazel.in": "godoc/vfs/gatefs/BUILD.bazel",99 "@bazel_gazelle//third_party:org_golang_x_tools/godoc/vfs/httpfs/BUILD.bazel.in": "godoc/vfs/httpfs/BUILD.bazel",100 "@bazel_gazelle//third_party:org_golang_x_tools/godoc/vfs/mapfs/BUILD.bazel.in": "godoc/vfs/mapfs/BUILD.bazel",101 "@bazel_gazelle//third_party:org_golang_x_tools/godoc/analysis/BUILD.bazel.in": "godoc/analysis/BUILD.bazel",102 "@bazel_gazelle//third_party:org_golang_x_tools/godoc/util/BUILD.bazel.in": "godoc/util/BUILD.bazel",103 "@bazel_gazelle//third_party:org_golang_x_tools/godoc/static/BUILD.bazel.in": "godoc/static/BUILD.bazel",104 "@bazel_gazelle//third_party:org_golang_x_tools/godoc/redirect/BUILD.bazel.in": "godoc/redirect/BUILD.bazel",105 "@bazel_gazelle//third_party:org_golang_x_tools/imports/BUILD.bazel.in": "imports/BUILD.bazel",106 "@bazel_gazelle//third_party:org_golang_x_tools/blog/BUILD.bazel.in": "blog/BUILD.bazel",107 "@bazel_gazelle//third_party:org_golang_x_tools/blog/atom/BUILD.bazel.in": "blog/atom/BUILD.bazel",108 "@bazel_gazelle//third_party:org_golang_x_tools/container/intsets/BUILD.bazel.in": "container/intsets/BUILD.bazel",109 "@bazel_gazelle//third_party:org_golang_x_tools/refactor/satisfy/BUILD.bazel.in": "refactor/satisfy/BUILD.bazel",110 "@bazel_gazelle//third_party:org_golang_x_tools/refactor/rename/BUILD.bazel.in": "refactor/rename/BUILD.bazel",111 "@bazel_gazelle//third_party:org_golang_x_tools/refactor/eg/BUILD.bazel.in": "refactor/eg/BUILD.bazel",112 "@bazel_gazelle//third_party:org_golang_x_tools/refactor/importgraph/BUILD.bazel.in": "refactor/importgraph/BUILD.bazel",113 "@bazel_gazelle//third_party:org_golang_x_tools/cover/BUILD.bazel.in": "cover/BUILD.bazel",114 }...

Full Screen

Full Screen

batchbuild.py

Source:batchbuild.py Github

copy

Full Screen

...54 self.cmake_log_path = os.path.join( work_dir, 'batchbuild_cmake.log' )55 self.build_log_path = os.path.join( work_dir, 'batchbuild_build.log' )56 self.cmake_succeeded = False57 self.build_succeeded = False58 def execute_build(self):59 print('Build %s' % self.desc)60 self._make_new_work_dir( )61 self.cmake_succeeded = self._generate_makefiles( )62 if self.cmake_succeeded:63 self.build_succeeded = self._build_using_makefiles( )64 return self.build_succeeded65 def _generate_makefiles(self):66 print(' Generating makefiles: ', end=' ')67 cmd = ['cmake'] + self.desc.cmake_args( ) + [os.path.abspath( self.source_dir )]68 succeeded = self._execute_build_subprocess( cmd, self.desc.env(), self.cmake_log_path )69 print('done' if succeeded else 'FAILED')70 return succeeded71 def _build_using_makefiles(self):72 print(' Building:', end=' ')73 cmd = ['cmake', '--build', self.work_dir]74 if self.desc.build_type:75 cmd += ['--config', self.desc.build_type]76 succeeded = self._execute_build_subprocess( cmd, self.desc.env(), self.build_log_path )77 print('done' if succeeded else 'FAILED')78 return succeeded79 def _execute_build_subprocess(self, cmd, env, log_path):80 process = subprocess.Popen( cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=self.work_dir,81 env=env )82 stdout, _ = process.communicate( )83 succeeded = (process.returncode == 0)84 with open( log_path, 'wb' ) as flog:85 log = ' '.join( cmd ) + '\n' + stdout + '\nExit code: %r\n' % process.returncode86 flog.write( fix_eol( log ) )87 return succeeded88 def _make_new_work_dir(self):89 if os.path.isdir( self.work_dir ):90 print(' Removing work directory', self.work_dir)91 shutil.rmtree( self.work_dir, ignore_errors=True )92 if not os.path.isdir( self.work_dir ):93 os.makedirs( self.work_dir )94def fix_eol( stdout ):95 """Fixes wrong EOL produced by cmake --build on Windows (\r\r\n instead of \r\n).96 """97 return re.sub( '\r*\n', os.linesep, stdout )98def load_build_variants_from_config( config_path ):99 with open( config_path, 'rb' ) as fconfig:100 data = json.load( fconfig )101 variants = data[ 'cmake_variants' ]102 build_descs_by_axis = collections.defaultdict( list )103 for axis in variants:104 axis_name = axis["name"]105 build_descs = []106 if "generators" in axis:107 for generator_data in axis["generators"]:108 for generator in generator_data["generator"]:109 build_desc = BuildDesc( generator=generator,110 prepend_envs=generator_data.get("env_prepend") )111 build_descs.append( build_desc )112 elif "variables" in axis:113 for variables in axis["variables"]:114 build_desc = BuildDesc( variables=variables )115 build_descs.append( build_desc )116 elif "build_types" in axis:117 for build_type in axis["build_types"]:118 build_desc = BuildDesc( build_type=build_type )119 build_descs.append( build_desc )120 build_descs_by_axis[axis_name].extend( build_descs )121 return build_descs_by_axis122def generate_build_variants( build_descs_by_axis ):123 """Returns a list of BuildDesc generated for the partial BuildDesc for each axis."""124 axis_names = list(build_descs_by_axis.keys())125 build_descs = []126 for axis_name, axis_build_descs in list(build_descs_by_axis.items()):127 if len(build_descs):128 # for each existing build_desc and each axis build desc, create a new build_desc129 new_build_descs = []130 for prototype_build_desc, axis_build_desc in itertools.product( build_descs, axis_build_descs):131 new_build_descs.append( prototype_build_desc.merged_with( axis_build_desc ) )132 build_descs = new_build_descs133 else:134 build_descs = axis_build_descs135 return build_descs136HTML_TEMPLATE = string.Template('''<html>137<head>138 <title>$title</title>139 <style type="text/css">140 td.failed {background-color:#f08080;}141 td.ok {background-color:#c0eec0;}142 </style>143</head>144<body>145<table border="1">146<thead>147 <tr>148 <th>Variables</th>149 $th_vars150 </tr>151 <tr>152 <th>Build type</th>153 $th_build_types154 </tr>155</thead>156<tbody>157$tr_builds158</tbody>159</table>160</body></html>''')161def generate_html_report( html_report_path, builds ):162 report_dir = os.path.dirname( html_report_path )163 # Vertical axis: generator164 # Horizontal: variables, then build_type165 builds_by_generator = collections.defaultdict( list )166 variables = set()167 build_types_by_variable = collections.defaultdict( set )168 build_by_pos_key = {} # { (generator, var_key, build_type): build }169 for build in builds:170 builds_by_generator[build.desc.generator].append( build )171 var_key = tuple(sorted(build.desc.variables))172 variables.add( var_key )173 build_types_by_variable[var_key].add( build.desc.build_type )174 pos_key = (build.desc.generator, var_key, build.desc.build_type)175 build_by_pos_key[pos_key] = build176 variables = sorted( variables )177 th_vars = []178 th_build_types = []179 for variable in variables:180 build_types = sorted( build_types_by_variable[variable] )181 nb_build_type = len(build_types_by_variable[variable])182 th_vars.append( '<th colspan="%d">%s</th>' % (nb_build_type, cgi.escape( ' '.join( variable ) ) ) )183 for build_type in build_types:184 th_build_types.append( '<th>%s</th>' % cgi.escape(build_type) )185 tr_builds = []186 for generator in sorted( builds_by_generator ):187 tds = [ '<td>%s</td>\n' % cgi.escape( generator ) ]188 for variable in variables:189 build_types = sorted( build_types_by_variable[variable] )190 for build_type in build_types:191 pos_key = (generator, variable, build_type)192 build = build_by_pos_key.get(pos_key)193 if build:194 cmake_status = 'ok' if build.cmake_succeeded else 'FAILED'195 build_status = 'ok' if build.build_succeeded else 'FAILED'196 cmake_log_url = os.path.relpath( build.cmake_log_path, report_dir )197 build_log_url = os.path.relpath( build.build_log_path, report_dir )198 td = '<td class="%s"><a href="%s" class="%s">CMake: %s</a>' % (199 build_status.lower(), cmake_log_url, cmake_status.lower(), cmake_status)200 if build.cmake_succeeded:201 td += '<br><a href="%s" class="%s">Build: %s</a>' % (202 build_log_url, build_status.lower(), build_status)203 td += '</td>'204 else:205 td = '<td></td>'206 tds.append( td )207 tr_builds.append( '<tr>%s</tr>' % '\n'.join( tds ) )208 html = HTML_TEMPLATE.substitute(209 title='Batch build report',210 th_vars=' '.join(th_vars),211 th_build_types=' '.join( th_build_types),212 tr_builds='\n'.join( tr_builds ) )213 with open( html_report_path, 'wt' ) as fhtml:214 fhtml.write( html )215 print('HTML report generated in:', html_report_path)216def main():217 usage = r"""%prog WORK_DIR SOURCE_DIR CONFIG_JSON_PATH [CONFIG2_JSON_PATH...]218Build a given CMake based project located in SOURCE_DIR with multiple generators/options.dry_run219as described in CONFIG_JSON_PATH building in WORK_DIR.220Example of call:221python devtools\batchbuild.py e:\buildbots\jsoncpp\build . devtools\agent_vmw7.json222"""223 from optparse import OptionParser224 parser = OptionParser(usage=usage)225 parser.allow_interspersed_args = True226# parser.add_option('-v', '--verbose', dest="verbose", action='store_true',227# help="""Be verbose.""")228 parser.enable_interspersed_args()229 options, args = parser.parse_args()230 if len(args) < 3:231 parser.error( "Missing one of WORK_DIR SOURCE_DIR CONFIG_JSON_PATH." )232 work_dir = args[0]233 source_dir = args[1].rstrip('/\\')234 config_paths = args[2:]235 for config_path in config_paths:236 if not os.path.isfile( config_path ):237 parser.error( "Can not read: %r" % config_path )238 # generate build variants239 build_descs = []240 for config_path in config_paths:241 build_descs_by_axis = load_build_variants_from_config( config_path )242 build_descs.extend( generate_build_variants( build_descs_by_axis ) )243 print('Build variants (%d):' % len(build_descs))244 # assign build directory for each variant245 if not os.path.isdir( work_dir ):246 os.makedirs( work_dir )247 builds = []248 with open( os.path.join( work_dir, 'matrix-dir-map.txt' ), 'wt' ) as fmatrixmap:249 for index, build_desc in enumerate( build_descs ):250 build_desc_work_dir = os.path.join( work_dir, '%03d' % (index+1) )251 builds.append( BuildData( build_desc, build_desc_work_dir, source_dir ) )252 fmatrixmap.write( '%s: %s\n' % (build_desc_work_dir, build_desc) )253 for build in builds:254 build.execute_build()255 html_report_path = os.path.join( work_dir, 'batchbuild-report.html' )256 generate_html_report( html_report_path, builds )257 print('Done')258if __name__ == '__main__':...

Full Screen

Full Screen

fetch_build_test.py

Source:fetch_build_test.py Github

copy

Full Screen

1# Copyright 2014 The Chromium Authors. All rights reserved.2# Use of this source code is governed by a BSD-style license that can be3# found in the LICENSE file.4"""Unit tests for the fetch_builds module."""5import errno6import unittest7# The third-party mock module is expected to be available in PYTHONPATH.8import mock9import fetch_build10# The tests below test private functions (W0212).11# Some methods don't reference self because they use the mock module (R0201).12# pylint: disable=R0201,W021213class FetchBuildTest(unittest.TestCase):14 def setUp(self):15 # Mocks of the os and bisect_utils modules are used in the methods below.16 cloud_storage_patcher = mock.patch('fetch_build.cloud_storage')17 self.mock_cloud_storage = cloud_storage_patcher.start()18 self.addCleanup(cloud_storage_patcher.stop)19 @mock.patch('fetch_build.os.path.exists')20 def test_FetchFromCloudStorage_FileFound(self, mock_os_path_exists):21 self.mock_cloud_storage.Exists.return_value = True22 mock_os_path_exists.return_value = True23 local_path = fetch_build.FetchFromCloudStorage(24 'my_bucket', 'remote/foo.zip', 'local')25 self.assertEqual('local/foo.zip', local_path)26 self.mock_cloud_storage.Get.assert_called_with(27 'my_bucket', 'remote/foo.zip', 'local/foo.zip')28 def test_FetchFromCloudStorage_FileNotFound(self):29 self.mock_cloud_storage.Exists.return_value = False30 local_path = fetch_build.FetchFromCloudStorage(31 'my_bucket', 'remote/foo.zip', 'local')32 self.assertIsNone(local_path)33 self.assertFalse(self.mock_cloud_storage.Get.called)34class BuildArchiveTest(unittest.TestCase):35 def test_CreatePerfBuildArchive(self):36 archive = fetch_build.BuildArchive.Create(fetch_build.PERF_BUILDER)37 self.assertEqual('chrome-perf', archive.BucketName())38 self.assertTrue(isinstance(archive, fetch_build.PerfBuildArchive))39 def test_CreateFullBuildArchive(self):40 archive = fetch_build.BuildArchive.Create(fetch_build.FULL_BUILDER)41 archive._platform = 'linux'42 self.assertEqual('chromium-linux-archive', archive.BucketName())43 self.assertTrue(isinstance(archive, fetch_build.FullBuildArchive))44 def test_BuildArchive_NonExistentType(self):45 self.assertRaises(46 NotImplementedError, fetch_build.BuildArchive.Create, 'other')47 def test_FullBuildArchive_Linux(self):48 archive = fetch_build.FullBuildArchive()49 archive._platform = 'linux'50 self.assertEqual('chromium-linux-archive', archive.BucketName())51 self.assertEqual(52 'chromium.linux/Linux Builder/full-build-linux_1234567890abcdef.zip',53 archive.FilePath('1234567890abcdef'))54 def test_FullBuildArchive_Android(self):55 archive = fetch_build.FullBuildArchive()56 archive._platform = 'android'57 self.assertEqual('chromium-android', archive.BucketName())58 self.assertEqual(59 'android_main_rel/full-build-linux_1234567890abcdef.zip',60 archive.FilePath('1234567890abcdef'))61 def test_FullBuildArchive_Linux_BuilderName(self):62 archive = fetch_build.FullBuildArchive()63 archive._platform = 'linux'64 self.assertEqual('linux_full_bisect_builder', archive.GetBuilderName())65 def test_FullBuildArchive_Windows_BuildTime(self):66 archive = fetch_build.FullBuildArchive()67 archive._platform = 'win'68 self.assertEqual(14400, archive.GetBuilderBuildTime())69 def test_PerfBuildArchive_Linux(self):70 archive = fetch_build.PerfBuildArchive()71 archive._platform = 'linux'72 self.assertEqual('chrome-perf', archive.BucketName())73 self.assertEqual(74 'Linux Builder/full-build-linux_1234567890abcdef.zip',75 archive.FilePath('1234567890abcdef'))76 def test_PerfBuildArchive_Android(self):77 archive = fetch_build.PerfBuildArchive()78 archive._platform = 'android'79 self.assertEqual('chrome-perf', archive.BucketName())80 self.assertEqual(81 'android_perf_rel/full-build-linux_123456.zip',82 archive.FilePath('123456'))83 def test_PerfBuildArchive_AndroidArm64(self):84 archive = fetch_build.PerfBuildArchive()85 archive._platform = 'android_arm64'86 self.assertEqual('chrome-perf', archive.BucketName())87 self.assertEqual(88 'android_perf_rel_arm64/full-build-linux_123456.zip',89 archive.FilePath('123456'))90 def test_PerfBuildArchive_64BitWindows(self):91 archive = fetch_build.PerfBuildArchive(target_arch='x64')92 archive._platform = 'win64'93 self.assertEqual('chrome-perf', archive.BucketName())94 self.assertEqual(95 'Win x64 Builder/full-build-win32_123456.zip',96 archive.FilePath('123456'))97 def test_PerfBuildArchive_WithDepsPatchSha(self):98 archive = fetch_build.PerfBuildArchive()99 archive._platform = 'linux'100 self.assertEqual(101 'Linux Builder/full-build-linux_123456'102 '_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.zip',103 archive.FilePath(123456, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'))104 def test_PerfBuildArchive_64BitWindows_BuilderName(self):105 archive = fetch_build.PerfBuildArchive()106 archive._platform = 'win64'107 self.assertEqual('winx64_bisect_builder', archive.GetBuilderName())108 def test_PerfBuildArchive_64BitWindows_BuildTime(self):109 archive = fetch_build.PerfBuildArchive()110 archive._platform = 'win64'111 self.assertEqual(14400, archive.GetBuilderBuildTime())112 def test_PerfBuildArchive_Windows_BuilderName(self):113 archive = fetch_build.PerfBuildArchive()114 archive._platform = 'win'115 self.assertEqual('win_perf_bisect_builder', archive.GetBuilderName())116 def test_PerfBuildArchive_Windows_BuildTime(self):117 archive = fetch_build.PerfBuildArchive()118 archive._platform = 'win'119 self.assertEqual(14400, archive.GetBuilderBuildTime())120 def test_PerfBuildArchive_Linux_BuilderName(self):121 archive = fetch_build.PerfBuildArchive()122 archive._platform = 'linux'123 self.assertEqual('linux_perf_bisect_builder', archive.GetBuilderName())124 def test_PerfBuildArchive_Linux_BuildTime(self):125 archive = fetch_build.PerfBuildArchive()126 archive._platform = 'linux'127 self.assertEqual(14400, archive.GetBuilderBuildTime())128 def test_PerfBuildArchive_Android_BuilderName(self):129 archive = fetch_build.PerfBuildArchive()130 archive._platform = 'android'131 self.assertEqual('android_perf_bisect_builder', archive.GetBuilderName())132 def test_PerfBuildArchive_Android_BuildTime(self):133 archive = fetch_build.PerfBuildArchive()134 archive._platform = 'android'135 self.assertEqual(14400, archive.GetBuilderBuildTime())136 def test_PerfBuildArchive_Mac_BuilderName(self):137 archive = fetch_build.PerfBuildArchive()138 archive._platform = 'mac'139 self.assertEqual('mac_perf_bisect_builder', archive.GetBuilderName())140 def test_PerfBuildArchive_mac_BuildTime(self):141 archive = fetch_build.PerfBuildArchive()142 archive._platform = 'mac'143 self.assertEqual(14400, archive.GetBuilderBuildTime())144 def test_GetBuildBotUrl_Perf(self):145 self.assertEqual(146 fetch_build.PERF_TRY_SERVER_URL,147 fetch_build.GetBuildBotUrl(fetch_build.PERF_BUILDER))148 def test_GetBuildBotUrl_full(self):149 self.assertEqual(150 fetch_build.LINUX_TRY_SERVER_URL,151 fetch_build.GetBuildBotUrl(fetch_build.FULL_BUILDER))152class UnzipTest(unittest.TestCase):153 def setUp(self):154 # Mocks of the os and bisect_utils modules are used in the methods below.155 os_patcher = mock.patch('fetch_build.os')156 self.mock_os = os_patcher.start()157 self.addCleanup(os_patcher.stop)158 bisect_utils_patcher = mock.patch('fetch_build.bisect_utils')159 self.mock_bisect_utils = bisect_utils_patcher.start()160 self.addCleanup(bisect_utils_patcher.stop)161 @mock.patch('fetch_build._MakeDirectory')162 @mock.patch('fetch_build._UnzipUsingCommand')163 def test_Unzip_Linux(self, mock_UnzipUsingCommand, mock_MakeDirectory):164 self.mock_bisect_utils.IsLinuxHost.return_value = True165 self.mock_bisect_utils.IsMacHost.return_value = False166 self.mock_bisect_utils.IsWindowsHost.return_value = False167 fetch_build.Unzip('x.zip', 'out_dir', verbose=False)168 mock_MakeDirectory.assert_called_with('out_dir')169 mock_UnzipUsingCommand.assert_called_with(170 ['unzip', '-o'], 'x.zip', 'out_dir')171 @mock.patch('fetch_build._MakeDirectory')172 @mock.patch('fetch_build._UnzipUsingZipFile')173 def test_Unzip_Mac_LargeFile(174 self, mock_UnzipUsingZipFile, mock_MakeDirectory):175 # The zipfile module is used to unzip on mac when the file is > 4GB.176 self.mock_bisect_utils.IsLinuxHost.return_value = False177 self.mock_bisect_utils.IsMacHost.return_value = True178 self.mock_bisect_utils.IsWindowsHost.return_value = False179 self.mock_os.path.getsize.return_value = 2 ** 33 # 8GB180 fetch_build.Unzip('x.zip', 'out_dir', verbose=False)181 mock_MakeDirectory.assert_called_with('out_dir')182 mock_UnzipUsingZipFile.assert_called_with('x.zip', 'out_dir', False)183 def test_UnzipUsingCommand(self):184 # The _UnzipUsingCommand function should move to the output185 # directory and run the command with the file's absolute path.186 self.mock_os.path.abspath.return_value = '/foo/some/path/x.zip'187 self.mock_os.getcwd.return_value = 'curr_dir'188 self.mock_bisect_utils.RunProcess.return_value = 0189 fetch_build._UnzipUsingCommand(['unzip'], 'x.zip', 'out_dir')190 self.mock_os.chdir.assert_has_calls(191 [mock.call('out_dir'), mock.call('curr_dir')])192 self.mock_bisect_utils.RunProcess.assert_called_with(193 ['unzip', '/foo/some/path/x.zip'])194 def test_MakeDirectory(self):195 # _MakeDirectory uses os.makedirs.196 fetch_build._MakeDirectory('some/path')197 self.mock_os.makedirs.assert_called_with('some/path')198 def test_MakeDirectory_RaisesError(self):199 self.mock_os.makedirs.side_effect = OSError()200 self.assertRaises(OSError, fetch_build._MakeDirectory, 'some/path')201 def test_MakeDirectory_NoErrorIfDirectoryAlreadyExists(self):202 already_exists = OSError()203 already_exists.errno = errno.EEXIST204 self.mock_os.makedirs.side_effect = already_exists205 fetch_build._MakeDirectory('some/path')206 @mock.patch('fetch_build.shutil')207 def test_RemoveDirectoryTree(self, mock_shutil):208 # _RemoveDirectoryTree uses shutil.rmtree.209 fetch_build._RemoveDirectoryTree('some/path')210 mock_shutil.rmtree.assert_called_with('some/path')211if __name__ == '__main__':...

Full Screen

Full Screen

runbuilds.py

Source:runbuilds.py Github

copy

Full Screen

...139 Q(state=BuildRequest.REQ_CANCELLING) &140 ~Q(environment=None)):141 br.environment.lock = BuildEnvironment.LOCK_FREE142 br.environment.save()143 def runbuild(self):144 try:145 self.cleanup()146 except Exception as e:147 logger.warning("runbuilds: cleanup exception %s" % str(e))148 try:149 self.archive()150 except Exception as e:151 logger.warning("runbuilds: archive exception %s" % str(e))152 try:153 self.schedule()154 except Exception as e:155 logger.warning("runbuilds: schedule exception %s" % str(e))156 def handle(self, **options):157 pidfile_path = os.path.join(os.environ.get("BUILDDIR", "."),158 ".runbuilds.pid")159 with open(pidfile_path, 'w') as pidfile:160 pidfile.write("%s" % os.getpid())161 self.runbuild()162 signal.signal(signal.SIGUSR1, lambda sig, frame: None)163 while True:164 signal.pause()...

Full Screen

Full Screen

test_most_recent_builds_states.py

Source:test_most_recent_builds_states.py Github

copy

Full Screen

1#! /usr/bin/env python32#3# BitBake Toaster Implementation4#5# SPDX-License-Identifier: GPL-2.0-only6#7# Copyright (C) 2013-2016 Intel Corporation8#9from django.core.urlresolvers import reverse10from django.utils import timezone11from tests.browser.selenium_helpers import SeleniumTestCase12from tests.browser.selenium_helpers_base import Wait13from orm.models import Project, Build, Task, Recipe, Layer, Layer_Version14from bldcontrol.models import BuildRequest15class TestMostRecentBuildsStates(SeleniumTestCase):16 """ Test states update correctly in most recent builds area """17 def _create_build_request(self):18 project = Project.objects.get_or_create_default_project()19 now = timezone.now()20 build = Build.objects.create(project=project, build_name='fakebuild',21 started_on=now, completed_on=now)22 return BuildRequest.objects.create(build=build, project=project,23 state=BuildRequest.REQ_QUEUED)24 def _create_recipe(self):25 """ Add a recipe to the database and return it """26 layer = Layer.objects.create()27 layer_version = Layer_Version.objects.create(layer=layer)28 return Recipe.objects.create(name='foo', layer_version=layer_version)29 def _check_build_states(self, build_request):30 recipes_to_parse = 1031 url = reverse('all-builds')32 self.get(url)33 build = build_request.build34 base_selector = '[data-latest-build-result="%s"] ' % build.id35 # build queued; check shown as queued36 selector = base_selector + '[data-build-state="Queued"]'37 element = self.wait_until_visible(selector)38 self.assertRegexpMatches(element.get_attribute('innerHTML'),39 'Build queued', 'build should show queued status')40 # waiting for recipes to be parsed41 build.outcome = Build.IN_PROGRESS42 build.recipes_to_parse = recipes_to_parse43 build.recipes_parsed = 044 build_request.state = BuildRequest.REQ_INPROGRESS45 build_request.save()46 self.get(url)47 selector = base_selector + '[data-build-state="Parsing"]'48 element = self.wait_until_visible(selector)49 bar_selector = '#recipes-parsed-percentage-bar-%s' % build.id50 bar_element = element.find_element_by_css_selector(bar_selector)51 self.assertEqual(bar_element.value_of_css_property('width'), '0px',52 'recipe parse progress should be at 0')53 # recipes being parsed; check parse progress54 build.recipes_parsed = 555 build.save()56 self.get(url)57 element = self.wait_until_visible(selector)58 bar_element = element.find_element_by_css_selector(bar_selector)59 recipe_bar_updated = lambda driver: \60 bar_element.get_attribute('style') == 'width: 50%;'61 msg = 'recipe parse progress bar should update to 50%'62 element = Wait(self.driver).until(recipe_bar_updated, msg)63 # all recipes parsed, task started, waiting for first task to finish;64 # check status is shown as "Tasks starting..."65 build.recipes_parsed = recipes_to_parse66 build.save()67 recipe = self._create_recipe()68 task1 = Task.objects.create(build=build, recipe=recipe,69 task_name='Lionel')70 task2 = Task.objects.create(build=build, recipe=recipe,71 task_name='Jeffries')72 self.get(url)73 selector = base_selector + '[data-build-state="Starting"]'74 element = self.wait_until_visible(selector)75 self.assertRegexpMatches(element.get_attribute('innerHTML'),76 'Tasks starting', 'build should show "tasks starting" status')77 # first task finished; check tasks progress bar78 task1.order = 179 task1.save()80 self.get(url)81 selector = base_selector + '[data-build-state="In Progress"]'82 element = self.wait_until_visible(selector)83 bar_selector = '#build-pc-done-bar-%s' % build.id84 bar_element = element.find_element_by_css_selector(bar_selector)85 task_bar_updated = lambda driver: \86 bar_element.get_attribute('style') == 'width: 50%;'87 msg = 'tasks progress bar should update to 50%'88 element = Wait(self.driver).until(task_bar_updated, msg)89 # last task finished; check tasks progress bar updates90 task2.order = 291 task2.save()92 self.get(url)93 element = self.wait_until_visible(selector)94 bar_element = element.find_element_by_css_selector(bar_selector)95 task_bar_updated = lambda driver: \96 bar_element.get_attribute('style') == 'width: 100%;'97 msg = 'tasks progress bar should update to 100%'98 element = Wait(self.driver).until(task_bar_updated, msg)99 def test_states_to_success(self):100 """101 Test state transitions in the recent builds area for a build which102 completes successfully.103 """104 build_request = self._create_build_request()105 self._check_build_states(build_request)106 # all tasks complete and build succeeded; check success state shown107 build = build_request.build108 build.outcome = Build.SUCCEEDED109 build.save()110 selector = '[data-latest-build-result="%s"] ' \111 '[data-build-state="Succeeded"]' % build.id112 element = self.wait_until_visible(selector)113 def test_states_to_failure(self):114 """115 Test state transitions in the recent builds area for a build which116 completes in a failure.117 """118 build_request = self._create_build_request()119 self._check_build_states(build_request)120 # all tasks complete and build succeeded; check fail state shown121 build = build_request.build122 build.outcome = Build.FAILED123 build.save()124 selector = '[data-latest-build-result="%s"] ' \125 '[data-build-state="Failed"]' % build.id126 element = self.wait_until_visible(selector)127 def test_states_cancelling(self):128 """129 Test that most recent build area updates correctly for a build130 which is cancelled.131 """132 url = reverse('all-builds')133 build_request = self._create_build_request()134 build = build_request.build135 # cancel the build136 build_request.state = BuildRequest.REQ_CANCELLING137 build_request.save()138 self.get(url)139 # check cancelling state140 selector = '[data-latest-build-result="%s"] ' \141 '[data-build-state="Cancelling"]' % build.id142 element = self.wait_until_visible(selector)143 self.assertRegexpMatches(element.get_attribute('innerHTML'),144 'Cancelling the build', 'build should show "cancelling" status')145 # check cancelled state146 build.outcome = Build.CANCELLED147 build.save()148 self.get(url)149 selector = '[data-latest-build-result="%s"] ' \150 '[data-build-state="Cancelled"]' % build.id151 element = self.wait_until_visible(selector)152 self.assertRegexpMatches(element.get_attribute('innerHTML'),...

Full Screen

Full Screen

request_build.py

Source:request_build.py Github

copy

Full Screen

1# Copyright 2014 The Chromium Authors. All rights reserved.2# Use of this source code is governed by a BSD-style license that can be3# found in the LICENSE file.4"""This module contains functionality for starting build try jobs via HTTP.5This includes both sending a request to start a job, and also related code6for querying the status of the job.7This module can be either run as a stand-alone script to send a request to a8builder, or imported and used by calling the public functions below.9"""10import json11import urllib212# URL template for fetching JSON data about builds.13BUILDER_JSON_URL = ('%(server_url)s/json/builders/%(bot_name)s/builds/'14 '%(build_num)s?as_text=1&filter=0')15# URL template for displaying build steps.16BUILDER_HTML_URL = '%(server_url)s/builders/%(bot_name)s/builds/%(build_num)s'17# Status codes that can be returned by the GetBuildStatus method18# From buildbot.status.builder.19# See: http://docs.buildbot.net/current/developer/results.html20SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION, RETRY, TRYPENDING = range(7)21OK = (SUCCESS, WARNINGS) # These indicate build is complete.22FAILED = (FAILURE, EXCEPTION, SKIPPED) # These indicate build failure.23PENDING = (RETRY, TRYPENDING) # These indicate in progress or in pending queue.24class ServerAccessError(Exception):25 def __str__(self):26 return '%s\nSorry, cannot connect to server.' % self.args[0]27def _IsBuildRunning(build_data):28 """Checks whether the build is in progress on buildbot.29 Presence of currentStep element in build JSON indicates build is in progress.30 Args:31 build_data: A dictionary with build data, loaded from buildbot JSON API.32 Returns:33 True if build is in progress, otherwise False.34 """35 current_step = build_data.get('currentStep')36 if (current_step and current_step.get('isStarted') and37 current_step.get('results') is None):38 return True39 return False40def _IsBuildFailed(build_data):41 """Checks whether the build failed on buildbot.42 Sometime build status is marked as failed even though compile and packaging43 steps are successful. This may happen due to some intermediate steps of less44 importance such as gclient revert, generate_telemetry_profile are failed.45 Therefore we do an addition check to confirm if build was successful by46 calling _IsBuildSuccessful.47 Args:48 build_data: A dictionary with build data, loaded from buildbot JSON API.49 Returns:50 True if revision is failed build, otherwise False.51 """52 if (build_data.get('results') in FAILED and53 not _IsBuildSuccessful(build_data)):54 return True55 return False56def _IsBuildSuccessful(build_data):57 """Checks whether the build succeeded on buildbot.58 We treat build as successful if the package_build step is completed without59 any error i.e., when results attribute of the this step has value 0 or 160 in its first element.61 Args:62 build_data: A dictionary with build data, loaded from buildbot JSON API.63 Returns:64 True if revision is successfully build, otherwise False.65 """66 if build_data.get('steps'):67 for item in build_data.get('steps'):68 # The 'results' attribute of each step consists of two elements,69 # results[0]: This represents the status of build step.70 # See: http://docs.buildbot.net/current/developer/results.html71 # results[1]: List of items, contains text if step fails, otherwise empty.72 if (item.get('name') == 'package_build' and73 item.get('isFinished') and74 item.get('results')[0] in OK):75 return True76 return False77def _FetchBuilderData(builder_url):78 """Fetches JSON data for the all the builds from the try server.79 Args:80 builder_url: A try server URL to fetch builds information.81 Returns:82 A dictionary with information of all build on the try server.83 """84 data = None85 try:86 url = urllib2.urlopen(builder_url)87 except urllib2.URLError as e:88 print ('urllib2.urlopen error %s, waterfall status page down.[%s]' % (89 builder_url, str(e)))90 return None91 if url is not None:92 try:93 data = url.read()94 except IOError as e:95 print 'urllib2 file object read error %s, [%s].' % (builder_url, str(e))96 return data97def _GetBuildData(buildbot_url):98 """Gets build information for the given build id from the try server.99 Args:100 buildbot_url: A try server URL to fetch build information.101 Returns:102 A dictionary with build information if build exists, otherwise None.103 """104 builds_json = _FetchBuilderData(buildbot_url)105 if builds_json:106 return json.loads(builds_json)107 return None108def GetBuildStatus(build_num, bot_name, server_url):109 """Gets build status from the buildbot status page for a given build number.110 Args:111 build_num: A build number on try server to determine its status.112 bot_name: Name of the bot where the build information is scanned.113 server_url: URL of the buildbot.114 Returns:115 A pair which consists of build status (SUCCESS, FAILED or PENDING) and a116 link to build status page on the waterfall.117 """118 results_url = None119 if build_num:120 # Get the URL for requesting JSON data with status information.121 buildbot_url = BUILDER_JSON_URL % {122 'server_url': server_url,123 'bot_name': bot_name,124 'build_num': build_num,125 }126 build_data = _GetBuildData(buildbot_url)127 if build_data:128 # Link to build on the buildbot showing status of build steps.129 results_url = BUILDER_HTML_URL % {130 'server_url': server_url,131 'bot_name': bot_name,132 'build_num': build_num,133 }134 if _IsBuildFailed(build_data):135 return (FAILED, results_url)136 elif _IsBuildSuccessful(build_data):137 return (OK, results_url)138 return (PENDING, results_url)139def GetBuildNumFromBuilder(build_reason, bot_name, server_url):140 """Gets build number on build status page for a given 'build reason'.141 This function parses the JSON data from buildbot page and collects basic142 information about the all the builds, and then uniquely identifies the build143 based on the 'reason' attribute in the JSON data about the build.144 The 'reason' attribute set is when a build request is posted, and it is used145 to identify the build on status page.146 Args:147 build_reason: A unique build name set to build on try server.148 bot_name: Name of the bot where the build information is scanned.149 server_url: URL of the buildbot.150 Returns:151 A build number as a string if found, otherwise None.152 """153 buildbot_url = BUILDER_JSON_URL % {154 'server_url': server_url,155 'bot_name': bot_name,156 'build_num': '_all',157 }158 builds_json = _FetchBuilderData(buildbot_url)159 if builds_json:160 builds_data = json.loads(builds_json)161 for current_build in builds_data:162 if builds_data[current_build].get('reason') == build_reason:163 return builds_data[current_build].get('number')...

Full Screen

Full Screen

build.py

Source:build.py Github

copy

Full Screen

...6from distutils.util import get_platform7def show_compilers():8 from distutils.ccompiler import show_compilers9 show_compilers()10class build(Command):11 description = "build everything needed to install"12 user_options = [13 ('build-base=', 'b',14 "base directory for build library"),15 ('build-purelib=', None,16 "build directory for platform-neutral distributions"),17 ('build-platlib=', None,18 "build directory for platform-specific distributions"),19 ('build-lib=', None,20 "build directory for all distribution (defaults to either " +21 "build-purelib or build-platlib"),22 ('build-scripts=', None,23 "build directory for scripts"),24 ('build-temp=', 't',...

Full Screen

Full Screen

clean.py

Source:clean.py Github

copy

Full Screen

1"""distutils.command.clean2Implements the Distutils 'clean' command."""3# contributed by Bastian Kleineidam <calvin@cs.uni-sb.de>, added 2000-03-184import os5from distutils.core import Command6from distutils.dir_util import remove_tree7from distutils import log8class clean(Command):9 description = "clean up temporary files from 'build' command"10 user_options = [11 ('build-base=', 'b',12 "base build directory (default: 'build.build-base')"),13 ('build-lib=', None,14 "build directory for all modules (default: 'build.build-lib')"),15 ('build-temp=', 't',16 "temporary build directory (default: 'build.build-temp')"),17 ('build-scripts=', None,18 "build directory for scripts (default: 'build.build-scripts')"),19 ('bdist-base=', None,20 "temporary directory for built distributions"),21 ('all', 'a',22 "remove all build output, not just temporary by-products")23 ]24 boolean_options = ['all']25 def initialize_options(self):26 self.build_base = None27 self.build_lib = None28 self.build_temp = None29 self.build_scripts = None30 self.bdist_base = None31 self.all = None32 def finalize_options(self):33 self.set_undefined_options('build',34 ('build_base', 'build_base'),35 ('build_lib', 'build_lib'),36 ('build_scripts', 'build_scripts'),37 ('build_temp', 'build_temp'))38 self.set_undefined_options('bdist',39 ('bdist_base', 'bdist_base'))40 def run(self):41 # remove the build/temp.<plat> directory (unless it's already42 # gone)43 if os.path.exists(self.build_temp):44 remove_tree(self.build_temp, dry_run=self.dry_run)45 else:46 log.debug("'%s' does not exist -- can't clean it",47 self.build_temp)48 if self.all:49 # remove build directories50 for directory in (self.build_lib,51 self.bdist_base,52 self.build_scripts):53 if os.path.exists(directory):54 remove_tree(directory, dry_run=self.dry_run)55 else:56 log.warn("'%s' does not exist -- can't clean it",57 directory)58 # just for the heck of it, try to remove the base build directory:59 # we might have emptied it right now, but if not we don't care60 if not self.dry_run:61 try:62 os.rmdir(self.build_base)63 log.info("removing '%s'", self.build_base)64 except OSError:...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { MockBuilder, MockRender } from 'ng-mocks';2import { AppModule } from './app.module';3import { AppComponent } from './app.component';4describe('AppComponent', () => {5 beforeEach(() => MockBuilder(AppComponent, AppModule));6 it('should create the app', () => {7 const fixture = MockRender(AppComponent);8 const app = fixture.debugElement.componentInstance;9 expect(app).toBeTruthy();10 });11});12import { MockBuilder, MockRender, MockInstance } from 'ng-mocks';13import { AppModule } from './app.module';14import { AppComponent } from './app.component';15import { DataService } from './data.service';16describe('AppComponent', () => {17 beforeEach(() => MockBuilder(AppComponent, AppModule));18 it('should create the app', () => {19 const dataService = MockInstance(DataService, 'get', () => 'mocked data');20 const fixture = MockRender(AppComponent);21 const app = fixture.debugElement.componentInstance;22 expect(app).toBeTruthy();23 expect(dataService.get()).toEqual('mocked data');24 });25});26import { MockBuilder, MockRender, MockComponent } from 'ng-mocks';27import { AppModule } from './app.module';28import { AppComponent } from './app.component';29import { MockedComponent } from './mocked.component';30describe('AppComponent', () => {31 beforeEach(() => MockBuilder(AppComponent, AppModule));32 it('should create the app', () => {33 const mockedComponent = MockComponent(MockedComponent);34 const fixture = MockRender(AppComponent);35 const app = fixture.debugElement.componentInstance;36 expect(app).toBeTruthy();37 expect(mockedComponent).toBeTruthy();38 });39});40import { MockBuilder, MockRender, MockDirective } from 'ng-mocks';41import { AppModule } from './app.module';42import {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { MockBuilder, MockRender } from 'ng-mocks';2import { MyComponent } from './my.component';3import { MyModule } from './my.module';4describe('MyComponent', () => {5 beforeEach(() => MockBuilder(MyComponent, MyModule));6 it('renders the component', () => {7 const fixture = MockRender(MyComponent);8 expect(fixture.point.componentInstance).toBeDefined();9 });10});11import { MockBuilder } from 'ng-mocks';12describe('MyComponent', () => {13 beforeEach(() => MockBuilder(MyComponent, MyModule));14});15import { MockRender } from 'ng-mocks';16describe('MyComponent', () => {17 it('renders the component', () => {18 const fixture = MockRender(MyComponent);19 expect(fixture.point.componentInstance).toBeDefined();20 });21});22import { MockInstance } from 'ng-mocks';23describe('MyComponent', () => {24 it('gets an instance of the service', () => {25 const instance = MockInstance(MyComponent, MyService);26 expect(instance).toBeDefined();27 });28});29import { MockProvider } from 'ng-mocks';30describe('MyComponent

Full Screen

Using AI Code Generation

copy

Full Screen

1import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';2import { AppComponent } from './app.component';3import { AppModule } from './app.module';4describe('AppComponent', () => {5 beforeEach(() => MockBuilder(AppComponent, AppModule));6 it('should create the app', () => {7 const fixture = MockRender(AppComponent);8 const app = ngMocks.findInstance(AppComponent);9 expect(app).toBeTruthy();10 });11 it(`should have as title 'ng-mocks'`, () => {12 const fixture = MockRender(AppComponent);13 const app = ngMocks.findInstance(AppComponent);14 expect(app.title).toEqual('ng-mocks');15 });16 it('should render title in a h1 tag', () => {17 const fixture = MockRender(AppComponent);18 const compiled = fixture.nativeElement;19 expect(compiled.querySelector('h1').textContent).toContain(20 );21 });22});23import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';24import { AppComponent } from './app.component';25import { AppModule } from './app.module';26describe('AppComponent', () => {27 beforeEach(() => MockBuilder(AppComponent, AppModule));28 it('should create the app', () => {29 const fixture = MockRender(AppComponent);30 const app = ngMocks.findInstance(AppComponent);31 expect(app).toBeTruthy();32 });33 it(`should have as title 'ng-mocks'`, () => {34 const fixture = MockRender(AppComponent);35 const app = ngMocks.findInstance(AppComponent);36 expect(app.title).toEqual('ng-mocks');37 });38 it('should render title in a h1 tag', () => {39 const fixture = MockRender(AppComponent);40 const compiled = fixture.nativeElement;41 expect(compiled.querySelector('h1').textContent).toContain(42 );43 });44});45import { NgModule } from '@angular/core';46import { BrowserModule } from '@angular/platform-browser';47import { AppComponent } from './app.component';48@NgModule({49 imports: [BrowserModule],50})51export class AppModule {}

Full Screen

Using AI Code Generation

copy

Full Screen

1import { build } from 'ng-mocks';2import { AppComponent } from './app.component';3describe('AppComponent', () => {4 it('should create the app', () => {5 const fixture = build(AppComponent);6 const app = fixture.componentInstance;7 expect(app).toBeTruthy();8 });9});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { MockBuilder, MockRender } from 'ng-mocks';2import { AppModule } from './app.module';3import { AppComponent } from './app.component';4import { MockService } from './mock.service';5describe('AppComponent', () => {6 beforeEach(() => MockBuilder(AppComponent, AppModule, MockService));7 it('should create the app', () => {8 const fixture = MockRender(AppComponent);9 const app = fixture.point.componentInstance;10 expect(app).toBeTruthy();11 });12});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { mockComponent } from 'ng-mocks';2import { MyComponent } from './my.component';3describe('MyComponent', () => {4 it('should create', () => {5 const component = mockComponent(MyComponent);6 expect(component).toBeTruthy();7 });8});9import { mockService } from 'ng-mocks';10import { MyService } from './my.service';11describe('MyService', () => {12 it('should create', () => {13 const service = mockService(MyService);14 expect(service).toBeTruthy();15 });16});17import { mockDirective } from 'ng-mocks';18import { MyDirective } from './my.directive';19describe('MyDirective', () => {20 it('should create', () => {21 const directive = mockDirective(MyDirective);22 expect(directive).toBeTruthy();23 });24});25import { mockPipe } from 'ng-mocks';26import { MyPipe } from './my.pipe';27describe('MyPipe', () => {28 it('should create', () => {29 const pipe = mockPipe(MyPipe);30 expect(pipe).toBeTruthy();31 });32});33import { mockModule } from 'ng-mocks';34import { MyModule } from './my.module';35describe('MyModule', () => {36 it('should create', () => {37 const module = mockModule(My

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('ng-mocks', () => {2 beforeEach(() => {3 TestBed.configureTestingModule({4 imports: [NgxsModule.forRoot([CounterState]), NgxsReduxDevtoolsPluginModule.forRoot()]5 });6 });7 it('should be able to get the state', () => {8 const store = TestBed.inject(Store);9 expect(store.selectSnapshot(CounterState)).toEqual({ count: 0 });10 });11});12import { MockStore } from 'ngxs-mock-store';13describe('ng-mocks', () => {14 let store: MockStore;15 beforeEach(() => {16 TestBed.configureTestingModule({17 imports: [NgxsModule.forRoot([CounterState]), NgxsReduxDevtoolsPluginModule.forRoot()]18 });19 store = TestBed.inject(MockStore);20 });21 it('should be able to get the state', () => {22 expect(store.selectSnapshot(CounterState)).toEqual({ count: 0 });23 });24});25import { MockStore } from 'ngxs-mock-store';26describe('ng-mocks', () => {27 let store: MockStore;28 beforeEach(() => {29 TestBed.configureTestingModule({30 imports: [NgxsModule.forRoot([CounterState]), NgxsReduxDevtoolsPluginModule.forRoot()]31 });32 store = TestBed.inject(MockStore);33 store.mockState(CounterState, { count: 5 });34 });35 it('should be able to get the state',

Full Screen

Using AI Code Generation

copy

Full Screen

1const mock = ngMocks.build(MyComponent);2const mock = ngMocks.find(MyComponent);3const mock = ngMocks.formatHtml(MyComponent);4const mock = ngMocks.findInstance(MyComponent);5const mock = ngMocks.findInstance(MyComponent);6const mock = ngMocks.find(MyComponent);7const mock = ngMocks.formatHtml(MyComponent);8const mock = ngMocks.findInstance(MyComponent);9const mock = ngMocks.findInstance(MyComponent);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ng-mocks automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful