def console(input_): parser = argparse.ArgumentParser() # Set the -d and -s options as exclusive, since it's silly to call for diff # and then call for only summary excGroup1 = parser.add_mutually_exclusive_group() excGroup1.add_argument( "-d", "--diff", action="store_true", help="Only display the differences between multiple " "result files" ) excGroup1.add_argument( "-s", "--summary", action="store_true", help="Only display the summary, not the individual " "test results" ) parser.add_argument("-l", "--list", action="store", help="Use test results from a list file") parser.add_argument( "results", metavar="<Results Path(s)>", nargs="+", help="Space seperated paths to at least one results " "file" ) args = parser.parse_args(input_) # Throw an error if -d/--diff is called, but only one results file is # provided if args.diff and len(args.results) < 2: parser.error("-d/--diff cannot be specified unless two or more " "results files are specified") # make list of results if args.list: args.results.extend(core.parse_listfile(args.list)) # Generate the output output = summary.Summary(args.results) output.generate_text(args.diff, args.summary)
def console(input_): """Combine files in a tests/ directory into a single results file.""" unparsed = parsers.parse_config(input_)[1] # Adding the parent is necessary to get the help options parser = argparse.ArgumentParser(parents=[parsers.CONFIG]) # Set the -d and -s options as exclusive, since it's silly to call for diff # and then call for only summary excGroup1 = parser.add_mutually_exclusive_group() excGroup1.add_argument( "-d", "--diff", action="store_const", const="diff", dest='mode', help="Only display the differences between multiple " "result files") excGroup1.add_argument("-s", "--summary", action="store_const", const="summary", dest='mode', help="Only display the summary, not the individual " "test results") excGroup1.add_argument("-i", "--incomplete", action="store_const", const="incomplete", dest='mode', help="Only display tests that are incomplete.") excGroup1.add_argument("-p", "--problems", action="store_const", const="problems", dest='mode', help="Only display tests that had problems.") parser.add_argument("-l", "--list", action="store", help="Use test results from a list file") parser.add_argument("results", metavar="<Results Path(s)>", nargs="+", help="Space separated paths to at least one results " "file") args = parser.parse_args(unparsed) # Throw an error if -d/--diff is called, but only one results file is # provided if args.mode == 'diff' and len(args.results) < 2: parser.error('-d/--diff cannot be specified unless two or more ' 'results files are specified') # make list of results if args.list: args.results.extend(core.parse_listfile(args.list)) # Generate the output summary.console(args.results, args.mode or 'all')
def html(input_): # Make a copy of the status text list and add all. This is used as the # argument list for -e/--exclude statuses = set(str(s) for s in status.ALL) statuses.add("all") parser = argparse.ArgumentParser() parser.add_argument("-o", "--overwrite", action="store_true", help="Overwrite existing directories") parser.add_argument( "-l", "--list", action="store", help="Load a newline seperated list of results. These " "results will be prepended to any Results " "specified on the command line", ) parser.add_argument( "-e", "--exclude-details", default=[], action="append", choices=statuses, help="Optionally exclude the generation of HTML pages " "for individual test pages with the status(es) " "given as arguments. This speeds up HTML " "generation, but reduces the info in the HTML " "pages. May be used multiple times", ) parser.add_argument("summaryDir", metavar="<Summary Directory>", help="Directory to put HTML files in") parser.add_argument("resultsFiles", metavar="<Results Files>", nargs="*", help="Results files to include in HTML") args = parser.parse_args(input_) # If args.list and args.resultsFiles are empty, then raise an error if not args.list and not args.resultsFiles: raise parser.error("Missing required option -l or <resultsFiles>") # Convert the exclude_details list to status objects, without this using # the -e option will except if args.exclude_details: # If exclude-results has all, then change it to be all if "all" in args.exclude_details: args.exclude_details = status.ALL else: args.exclude_details = frozenset(status.status_lookup(i) for i in args.exclude_details) # if overwrite is requested delete the output directory if path.exists(args.summaryDir) and args.overwrite: shutil.rmtree(args.summaryDir) # If the requested directory doesn't exist, create it or throw an error core.checkDir(args.summaryDir, not args.overwrite) # Merge args.list and args.resultsFiles if args.list: args.resultsFiles.extend(core.parse_listfile(args.list)) # Create the HTML output output = summary.Summary(args.resultsFiles) output.generate_html(args.summaryDir, args.exclude_details)
def main(): parser = argparse.ArgumentParser() parser.add_argument("-o", "--overwrite", action="store_true", help="Overwrite existing directories") parser.add_argument("-l", "--list", action="store", help="Load a newline seperated list of results. These " "results will be prepended to any Results " "specified on the command line") parser.add_argument("-e", "--exclude-details", default=[], action="append", choices=['skip', 'pass', 'warn', 'crash' 'fail', 'all'], help="Optionally exclude the generation of HTML pages " "for individual test pages with the status(es) " "given as arguments. This speeds up HTML " "generation, but reduces the info in the HTML " "pages. May be used multiple times") parser.add_argument("summaryDir", metavar="<Summary Directory>", help="Directory to put HTML files in") parser.add_argument("resultsFiles", metavar="<Results Files>", nargs="*", help="Results files to include in HTML") args = parser.parse_args() # If args.list and args.resultsFiles are empty, then raise an error if not args.list and not args.resultsFiles: raise parser.error("Missing required option -l or <resultsFiles>") # Convert the exclude_details list to status objects, without this using # the -e option will except if args.exclude_details: # If exclude-results has all, then change it to be all if 'all' in args.exclude_details: args.exclude_details = [status.Skip(), status.Pass(), status.Warn(), status.Crash(), status.Fail()] else: args.exclude_details = [status.status_lookup(i) for i in args.exclude_details] # if overwrite is requested delete the output directory if path.exists(args.summaryDir) and args.overwrite: shutil.rmtree(args.summaryDir) # If the requested directory doesn't exist, create it or throw an error checkDir(args.summaryDir, not args.overwrite) # Merge args.list and args.resultsFiles if args.list: args.resultsFiles.extend(parse_listfile(args.list)) # Create the HTML output output = summary.Summary(args.resultsFiles) output.generate_html(args.summaryDir, args.exclude_details)
def test_parse_listfile_return(self, tmpdir): """core.parse_listfile(): returns a list-like object. Given a file with a newline separated list of results, parse_listfile should return a list of files with no whitespace. """ f = tmpdir.join('test.list') f.write("/tmp/foo\n/tmp/bar\n") results = core.parse_listfile(six.text_type(f)) assert isinstance(results, collections.Container)
def console(input_): """Combine files in a tests/ directory into a single results file.""" unparsed = parsers.parse_config(input_)[1] # Adding the parent is necessary to get the help options parser = argparse.ArgumentParser(parents=[parsers.CONFIG]) # Set the -d and -s options as exclusive, since it's silly to call for diff # and then call for only summary excGroup1 = parser.add_mutually_exclusive_group() excGroup1.add_argument("-d", "--diff", action="store_const", const="diff", dest='mode', help="Only display the differences between multiple " "result files") excGroup1.add_argument("-s", "--summary", action="store_const", const="summary", dest='mode', help="Only display the summary, not the individual " "test results") excGroup1.add_argument("-i", "--incomplete", action="store_const", const="incomplete", dest='mode', help="Only display tests that are incomplete.") excGroup1.add_argument("-p", "--problems", action="store_const", const="problems", dest='mode', help="Only display tests that had problems.") parser.add_argument("-l", "--list", action="store", help="Use test results from a list file") parser.add_argument("results", metavar="<Results Path(s)>", nargs="+", help="Space separated paths to at least one results " "file") args = parser.parse_args(unparsed) # Throw an error if -d/--diff is called, but only one results file is # provided if args.mode == 'diff' and len(args.results) < 2: parser.error('-d/--diff cannot be specified unless two or more ' 'results files are specified') # make list of results if args.list: args.results.extend(core.parse_listfile(args.list)) # Generate the output summary.console(args.results, args.mode or 'all')
def test_parse_listfile_return(): """core.parse_listfile(): returns a list-like object Given a file with a newline seperated list of results, parse_listfile should return a list of files with no whitespace """ contents = "/tmp/foo\n/tmp/bar\n" with utils.tempfile(contents) as tfile: results = core.parse_listfile(tfile) nt.ok_(isinstance(results, collections.Container))
def test_parse_listfile_return(): """ Test that parse_listfile returns a container Given a file with a newline seperated list of results, parse_listfile should return a list of files with no whitespace """ contents = "/tmp/foo\n/tmp/bar\n" with utils.with_tempfile(contents) as tfile: results = core.parse_listfile(tfile) assert isinstance(results, collections.Container)
def test_parse_listfile_return(): """core.parse_listfile(): returns a list-like object Given a file with a newline seperated list of results, parse_listfile should return a list of files with no whitespace """ contents = "/tmp/foo\n/tmp/bar\n" with utils.tempfile(contents) as tfile: results = core.parse_listfile(tfile) assert isinstance(results, collections.Container)
def test_parse_listfile_tilde(): """ Test that parse_listfile properly expands tildes According to the python docs for python 2.7 (http://docs.python.org/2/library/os.path.html#module-os.path), both os.path.expanduser and os.path.expandvars work on both *nix systems (Linux, *BSD, OSX) and Windows. """ contents = "~/foo\n" with utils.with_tempfile(contents) as tfile: results = core.parse_listfile(tfile) assert results[0] == os.path.expandvars("$HOME/foo")
def test_parse_listfile_tilde(): """core.parse_listfile(): tildes (~) are properly expanded. According to the python docs for python 2.7 (http://docs.python.org/2/library/os.path.html#module-os.path), both os.path.expanduser and os.path.expandvars work on both *nix systems (Linux, *BSD, OSX) and Windows. """ contents = "~/foo\n" with utils.tempfile(contents) as tfile: results = core.parse_listfile(tfile) assert results[0] == os.path.expandvars("$HOME/foo")
def test_parse_listfile_tilde(): """core.parse_listfile(): tildes (~) are properly expanded. According to the python docs for python 2.7 (http://docs.python.org/2/library/os.path.html#module-os.path), both os.path.expanduser and os.path.expandvars work on both *nix systems (Linux, *BSD, OSX) and Windows. """ contents = "~/foo\n" expected = os.path.expandvars("$HOME/foo") with utils.nose.tempfile(contents) as tfile: results = core.parse_listfile(tfile) nt.eq_(results[0], expected, msg='expected: {} but got: {}'.format(expected, results[0]))
def test_parse_listfile_whitespace(self, tmpdir): """parse_listfile should remove various kinds of trailing whitespace. It is important it doesn't touch whitespace in lines, however. """ f = tmpdir.join('test.list') f.write(textwrap.dedent("""\ space between tab\t space newline """)) results = core.parse_listfile(six.text_type(f)) assert results[0] == 'space between' assert results[1] == 'tab' assert results[2] == 'space' assert results[3] == 'newline'
def test_parse_listfile_tilde(): """core.parse_listfile(): tildes (~) are properly expanded. According to the python docs for python 2.7 (http://docs.python.org/2/library/os.path.html#module-os.path), both os.path.expanduser and os.path.expandvars work on both *nix systems (Linux, *BSD, OSX) and Windows. """ contents = "~/foo\n" expected = os.path.expandvars("$HOME/foo") with utils.tempfile(contents) as tfile: results = core.parse_listfile(tfile) nt.eq_(results[0], expected, msg='expected: {} but got: {}'.format(expected, results[0]))
def test_parse_listfile_tilde_posix(self, tmpdir): """core.parse_listfile(): tildes (~) are properly expanded. According to the python docs for python 2.7 (http://docs.python.org/2/library/os.path.html#module-os.path), both os.path.expanduser and os.path.expandvars work on both *nix systems (Linux, *BSD, OSX) and Windows. """ if os.name == 'posix': expected = os.path.expandvars('$HOME') else: expected = os.path.expandvars('%USERPROFILE%') expected = os.path.normpath(os.path.join(expected, 'foo')) f = tmpdir.join('test.list') f.write("~/foo\n") results = core.parse_listfile(six.text_type(f)) assert os.path.normpath(results[0]) == expected
def test_parse_listfile_whitespace(self, tmpdir): """parse_listfile should remove various kinds of trailing whitespace. It is important it doesn't touch whitespace in lines, however. """ f = tmpdir.join('test.list') f.write(textwrap.dedent("""\ space between tab\t space newline """)) results = core.parse_listfile(str(f)) assert results[0] == 'space between' assert results[1] == 'tab' assert results[2] == 'space' assert results[3] == 'newline'
def test_parse_listfile_whitespace(): """ Test that parse_listfile remove whitespace """ contents = "/tmp/foo\n/tmp/foo \n/tmp/foo\t\n" with utils.with_tempfile(contents) as tfile: results = core.parse_listfile(tfile) yld = check_whitespace # Test for newlines yld.description = "Test that trailing newlines are removed by " "parse_listfile" yield yld, results[0], "/tmp/foo", "Trailing newline not removed!" # test for normal spaces yld.description = "Test that trailing spaces are removed by parse_listfile" yield yld, results[1], "/tmp/foo", "Trailing spaces not removed!" # test for tabs yld.description = "Test that trailing tabs are removed by parse_listfile" yield yld, results[2], "/tmp/foo", "Trailing tab not removed!"
def console(input_): parser = argparse.ArgumentParser() # Set the -d and -s options as exclusive, since it's silly to call for diff # and then call for only summary excGroup1 = parser.add_mutually_exclusive_group() excGroup1.add_argument( "-d", "--diff", action="store_true", help="Only display the differences between multiple " "result files") excGroup1.add_argument("-s", "--summary", action="store_true", help="Only display the summary, not the individual " "test results") parser.add_argument("-l", "--list", action="store", help="Use test results from a list file") parser.add_argument("results", metavar="<Results Path(s)>", nargs="+", help="Space seperated paths to at least one results " "file") args = parser.parse_args(input_) # Throw an error if -d/--diff is called, but only one results file is # provided if args.diff and len(args.results) < 2: parser.error('-d/--diff cannot be specified unless two or more ' 'results files are specified') # make list of results if args.list: args.results.extend(core.parse_listfile(args.list)) # Generate the output output = summary.Summary(args.results) output.generate_text(args.diff, args.summary)
def test_parse_listfile_whitespace(): """ Test that parse_listfile remove whitespace """ contents = "/tmp/foo\n/tmp/foo \n/tmp/foo\t\n" with utils.with_tempfile(contents) as tfile: results = core.parse_listfile(tfile) yld = check_whitespace # Test for newlines yld.description = ("Test that trailing newlines are removed by " "parse_listfile") yield yld, results[0], "/tmp/foo", "Trailing newline not removed!" # test for normal spaces yld.description = "Test that trailing spaces are removed by parse_listfile" yield yld, results[1], "/tmp/foo", "Trailing spaces not removed!" # test for tabs yld.description = "Test that trailing tabs are removed by parse_listfile" yield yld, results[2], "/tmp/foo", "Trailing tab not removed!"
def html(input_): # Make a copy of the status text list and add all. This is used as the # argument list for -e/--exclude statuses = set(str(s) for s in status.ALL) statuses.add('all') """Combine files in a tests/ directory into a single results file.""" unparsed = parsers.parse_config(input_)[1] # Adding the parent is necissary to get the help options parser = argparse.ArgumentParser(parents=[parsers.CONFIG]) parser.add_argument("-o", "--overwrite", action="store_true", help="Overwrite existing directories") parser.add_argument("-l", "--list", action="store", help="Load a newline separated list of results. These " "results will be prepended to any Results " "specified on the command line") parser.add_argument("-e", "--exclude-details", default=[], action="append", choices=statuses, help="Optionally exclude the generation of HTML pages " "for individual test pages with the status(es) " "given as arguments. This speeds up HTML " "generation, but reduces the info in the HTML " "pages. May be used multiple times") parser.add_argument("summaryDir", metavar="<Summary Directory>", help="Directory to put HTML files in") parser.add_argument("resultsFiles", metavar="<Results Files>", nargs="*", help="Results files to include in HTML") args = parser.parse_args(unparsed) # If args.list and args.resultsFiles are empty, then raise an error if not args.list and not args.resultsFiles: raise parser.error("Missing required option -l or <resultsFiles>") # Convert the exclude_details list to status objects, without this using # the -e option will except if args.exclude_details: # If exclude-results has all, then change it to be all if 'all' in args.exclude_details: args.exclude_details = status.ALL else: args.exclude_details = frozenset( status.status_lookup(i) for i in args.exclude_details) # if overwrite is requested delete the output directory if path.exists(args.summaryDir) and args.overwrite: shutil.rmtree(args.summaryDir) # If the requested directory doesn't exist, create it or throw an error try: core.check_dir(args.summaryDir, not args.overwrite) except exceptions.PiglitException: raise exceptions.PiglitFatalError( '{} already exists.\n' 'use -o/--overwrite if you want to overwrite it.'.format( args.summaryDir)) # Merge args.list and args.resultsFiles if args.list: args.resultsFiles.extend(core.parse_listfile(args.list)) # Create the HTML output summary.html(args.resultsFiles, args.summaryDir, args.exclude_details)
def setup_class(cls): contents = "/tmp/foo\n/tmp/foo \n/tmp/foo\t\n" with utils.tempfile(contents) as tfile: cls.results = core.parse_listfile(tfile)
def html(input_): # Make a copy of the status text list and add all. This is used as the # argument list for -e/--exclude statuses = set(str(s) for s in status.ALL) statuses.add('all') parser = argparse.ArgumentParser() parser.add_argument("-o", "--overwrite", action="store_true", help="Overwrite existing directories") parser.add_argument("-l", "--list", action="store", help="Load a newline seperated list of results. These " "results will be prepended to any Results " "specified on the command line") parser.add_argument("-e", "--exclude-details", default=[], action="append", choices=statuses, help="Optionally exclude the generation of HTML pages " "for individual test pages with the status(es) " "given as arguments. This speeds up HTML " "generation, but reduces the info in the HTML " "pages. May be used multiple times") parser.add_argument("summaryDir", metavar="<Summary Directory>", help="Directory to put HTML files in") parser.add_argument("resultsFiles", metavar="<Results Files>", nargs="*", help="Results files to include in HTML") args = parser.parse_args(input_) # If args.list and args.resultsFiles are empty, then raise an error if not args.list and not args.resultsFiles: raise parser.error("Missing required option -l or <resultsFiles>") # Convert the exclude_details list to status objects, without this using # the -e option will except if args.exclude_details: # If exclude-results has all, then change it to be all if 'all' in args.exclude_details: args.exclude_details = status.ALL else: args.exclude_details = frozenset( status.status_lookup(i) for i in args.exclude_details) # if overwrite is requested delete the output directory if path.exists(args.summaryDir) and args.overwrite: shutil.rmtree(args.summaryDir) # If the requested directory doesn't exist, create it or throw an error core.checkDir(args.summaryDir, not args.overwrite) # Merge args.list and args.resultsFiles if args.list: args.resultsFiles.extend(core.parse_listfile(args.list)) # Create the HTML output output = summary.Summary(args.resultsFiles) output.generate_html(args.summaryDir, args.exclude_details)