Эх сурвалжийг харах

Added a link to help contributors with the rules

msmith-techempower 10 жил өмнө
parent
commit
e7bc74454c

+ 10 - 2
toolset/benchmark/framework_test.py

@@ -25,6 +25,8 @@ from utils import header
 from colorama import Fore, Back, Style
 
 class FrameworkTest:
+  specific_rules_url = "http://frameworkbenchmarks.readthedocs.org/en/latest/Project-Information/Framework-Tests/#specific-test-requirements"
+
   headers_template = "-H 'Host: localhost' -H '{accept}' -H 'Connection: keep-alive'"
  
   # Used for test types that require no pipelining or query string params.
@@ -294,17 +296,23 @@ class FrameworkTest:
       def output_result(result, reason, url):
         prefix = Fore.CYAN
         color = Fore.GREEN
+        showRules = False
         if result.upper() == "WARN":
           color = Fore.YELLOW
+          showRules = True
         elif result.upper() == "FAIL":
           color = Fore.RED
+          showRules = True
 
-        out.write(prefix + "   " + color + "%s" + Style.RESET_ALL + " for %s\n" % (result.upper(), url))
-        print prefix + "   " + color + "%s" + Style.RESET_ALL + " for %s" % (result.upper(), url)
+        out.write((prefix + "   " + color + "%s" + Style.RESET_ALL + " for %s\n") % (result.upper(), url))
+        print (prefix + "   " + color + "%s" + Style.RESET_ALL + " for %s") % (result.upper(), url)
         if reason is not None and len(reason) != 0:
           for line in reason.splitlines():
             out.write("     " + line + '\n')
             print "     " + line
+          if showRules:
+            out.write("     See %s" % specific_rules_url);
+            print "     See %s" % specific_rules_url
 
       [output_result(r1,r2,url) for (r1, r2, url) in results]
 

+ 3 - 3
toolset/benchmark/test_types/framework_test_type.py

@@ -63,13 +63,13 @@ class FrameworkTestType:
     # Use -i to output response with headers
     # Don't use -f so that the HTTP response code is ignored.
     # Use -sS to hide progress bar, but show errors.
-    print "Accessing URL %s" % url
+    print "Accessing URL %s:" % url
     self.err.write("Accessing URL %s \n" % url)
     self.out.write("Accessing URL %s \n" % url)
     p = subprocess.Popen(["curl", "-m", "15", "-i", "-sS", url], stderr=PIPE, stdout=PIPE)
     (out, err) = p.communicate()
     self.err.write(err+'\n')
-    self.out.write("Response: \n\"" + out+ "\"\n")
+    self.out.write("Response: \n\"" + out.strip() + "\"\n")
     if p.returncode != 0:
       return None
     return out
@@ -83,7 +83,7 @@ class FrameworkTestType:
     # Get response body
     p = subprocess.Popen(["curl", "-m", "15", "-s", url], stdout=PIPE, stderr=PIPE)
     (out, err) = p.communicate()
-    print "  Response (trimmed to 40 bytes): \"%s\"" % out[:40]
+    print "  Response (trimmed to 40 bytes): \"%s\"" % out.strip()[:40]
     return out
   
   def verify(self, base_url):

+ 2 - 2
toolset/benchmark/test_types/plaintext_type.py

@@ -21,11 +21,11 @@ class PlaintextTestType(FrameworkTestType):
     body = body.lower()
 
     if "hello, world!" not in body:
-      return [('fail', "Could not find 'Hello, World!' in response", url)]
+      return [('fail', """Could not find 'Hello, World!' in response.""", url)]
 
     if len("hello, world!") < len(body):
       return [('warn', """Server is returning %s more bytes than are required.
-        This may negatively affect benchmark performance""" % (len(body) - len("hello, world!")), url)]
+This may negatively affect benchmark performance.""" % (len(body) - len("hello, world!")), url)]
 
     # Ensure required response headers are present
     if any(v.lower() not in full_response.lower() for v in ('Server','Date','Content-Type: text/plain')) \