Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(592)

Side by Side Diff: pydir/buildatts.py

Issue 659513005: Allow conditional lit tests in Subzero, based on build flags. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python2
2
3 import argparse
4 import os
5 import sys
6
7 from utils import shellcmd
8
9 def getBuildAttributes(Filename):
Jim Stichnoth 2014/10/15 03:16:37 Hmm, I don't know what our name capitalization sty
Karl 2014/10/15 20:12:31 Done.
10 Filename += ".build_atts"
11 if not os.path.isfile(Filename):
12 return []
13 f = open(Filename, 'r')
Jim Stichnoth 2014/10/15 03:16:37 with open(Filename, 'r') as f: return f.read().s
Karl 2014/10/15 20:12:32 Done.
14 kinds = f.read().split()
15 f.close()
16 return kinds
17
18 def hasBuildAttributes(Filename, Attributes):
Jim Stichnoth 2014/10/15 03:16:37 These functions ought to have docstrings.
Karl 2014/10/15 20:12:32 Done.
19 BuildAtts = getBuildAttributes(Filename)
20 for Att in Attributes:
Jim Stichnoth 2014/10/15 03:16:36 return set(Attributes) <= set(BuildAtts)
Karl 2014/10/15 20:12:32 Done.
21 if Att not in BuildAtts:
22 return False
23 return True
24
25 def main():
26 """Run check on corresponding ice executable .kind file to see if
Jim Stichnoth 2014/10/15 03:16:37 What is a .kind file? llvm2ice executable?
Karl 2014/10/15 20:12:31 Simplified python script to just be checking if a
27 'minimal' is specified. If so, quits and completes with success.
28 Otherwise, runs shell command on remainder of line.
29 """
30 argparser = argparse.ArgumentParser(
31 description=' ' + main.__doc__,
32 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
33 argparser.add_argument(
34 '--llvm2ice', required=False, default='./llvm2ice', metavar='LLVM2ICE',
35 help="Subzero translator 'llvm2ice'")
36 argparser.add_argument('--att', required=False, default=[],
37 action='append',
38 help='Look for executable build attributes')
39 argparser.add_argument('--echo-cmd', required=False,
40 action='store_true',
41 help='Trace command that run in separate shell')
Jim Stichnoth 2014/10/15 03:16:37 commands
Karl 2014/10/15 20:12:32 Done.
42 argparser.add_argument('cmd', nargs=argparse.REMAINDER,
43 help='Remaining arguments are run in a separate shell')
44
45 args = argparser.parse_args()
46
47 # Quit early if no command to run.
48 if args.cmd is None:
Jim Stichnoth 2014/10/15 03:16:37 if not args.cmd: (would this work?)
Karl 2014/10/15 20:12:32 Done.
49 return
Jim Stichnoth 2014/10/15 03:16:37 Should an explicit zero or nonzero value be return
Karl 2014/10/15 20:12:32 Done.
50
51 # Quit early if the executable doesn't support expected build attributes.
52 if not hasBuildAttributes(args.llvm2ice, args.att):
53 return
54
55 stdout_result = shellcmd(args.cmd, echo=args.echo_cmd)
56 if not args.echo_cmd:
57 sys.stdout.write(stdout_result)
58
59 if __name__ == '__main__':
60 main()
OLDNEW
« Makefile.standalone ('K') | « Makefile.standalone ('k') | tests_lit/lit.cfg » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698