Browse Source

metadata fix (#4049)

Nate 7 years ago
parent
commit
1917ac7a03

+ 0 - 0
frameworks/FSharp/Zebra/.gitignore → frameworks/FSharp/zebra/.gitignore


+ 0 - 0
frameworks/FSharp/Zebra/README.md → frameworks/FSharp/zebra/README.md


+ 2 - 4
frameworks/FSharp/Zebra/benchmark_config.json → frameworks/FSharp/zebra/benchmark_config.json

@@ -21,9 +21,7 @@
         "display_name": "Zebra, Dapper",
         "display_name": "Zebra, Dapper",
         "notes": "",
         "notes": "",
         "versus": "aspcore"
         "versus": "aspcore"
-      }
-    },
-    {
+      },
       "simple": {
       "simple": {
         "plaintext_url": "/plaintext",
         "plaintext_url": "/plaintext",
         "json_url": "/json",
         "json_url": "/json",
@@ -45,4 +43,4 @@
       }
       }
     }
     }
   ]
   ]
-}
+}

+ 0 - 0
frameworks/FSharp/Zebra/src/App/App.fsproj → frameworks/FSharp/zebra/src/App/App.fsproj


+ 0 - 0
frameworks/FSharp/Zebra/src/App/Buffer.fs → frameworks/FSharp/zebra/src/App/Buffer.fs


+ 0 - 0
frameworks/FSharp/Zebra/src/App/Composition.fs → frameworks/FSharp/zebra/src/App/Composition.fs


+ 0 - 0
frameworks/FSharp/Zebra/src/App/Encoding.fs → frameworks/FSharp/zebra/src/App/Encoding.fs


+ 0 - 0
frameworks/FSharp/Zebra/src/App/ExecNodes.fs → frameworks/FSharp/zebra/src/App/ExecNodes.fs


+ 0 - 0
frameworks/FSharp/Zebra/src/App/Middleware.fs → frameworks/FSharp/zebra/src/App/Middleware.fs


+ 0 - 0
frameworks/FSharp/Zebra/src/App/Parsers.fs → frameworks/FSharp/zebra/src/App/Parsers.fs


+ 0 - 0
frameworks/FSharp/Zebra/src/App/Program.fs → frameworks/FSharp/zebra/src/App/Program.fs


+ 0 - 0
frameworks/FSharp/Zebra/src/App/RouteNode.fs → frameworks/FSharp/zebra/src/App/RouteNode.fs


+ 0 - 0
frameworks/FSharp/Zebra/src/App/Router.fs → frameworks/FSharp/zebra/src/App/Router.fs


+ 0 - 0
frameworks/FSharp/Zebra/src/App/State.fs → frameworks/FSharp/zebra/src/App/State.fs


+ 0 - 0
frameworks/FSharp/Zebra/src/App/TemplateEngine.fs → frameworks/FSharp/zebra/src/App/TemplateEngine.fs


+ 0 - 0
frameworks/FSharp/Zebra/zebra-simple.dockerfile → frameworks/FSharp/zebra/zebra-simple.dockerfile


+ 0 - 0
frameworks/FSharp/Zebra/zebra.dockerfile → frameworks/FSharp/zebra/zebra.dockerfile


+ 28 - 23
toolset/utils/metadata.py

@@ -191,7 +191,7 @@ class Metadata:
             for test_name, test_keys in test.iteritems():
             for test_name, test_keys in test.iteritems():
                 # Validates and normalizes the benchmark_config entry
                 # Validates and normalizes the benchmark_config entry
                 test_keys = Metadata.validate_test(test_name, test_keys,
                 test_keys = Metadata.validate_test(test_name, test_keys,
-                                                   directory)
+                                                   config['framework'], directory)
 
 
                 # Map test type to a parsed FrameworkTestType object
                 # Map test type to a parsed FrameworkTestType object
                 runTests = dict()
                 runTests = dict()
@@ -257,7 +257,7 @@ class Metadata:
             f.write(all_tests_json)
             f.write(all_tests_json)
 
 
     @staticmethod
     @staticmethod
-    def validate_test(test_name, test_keys, directory):
+    def validate_test(test_name, test_keys, framework_name, directory):
         """
         """
         Validate and normalizes benchmark config values for this test based on a schema
         Validate and normalizes benchmark config values for this test based on a schema
         """
         """
@@ -345,41 +345,46 @@ class Metadata:
         def get_test_val(k):
         def get_test_val(k):
             return test_keys.get(k, "none").lower()
             return test_keys.get(k, "none").lower()
 
 
-        def throw_incorrect_key(k):
+        def throw_incorrect_key(k, acceptable_values, descriptors):
             msg = (
             msg = (
-                "Invalid `%s` value specified for test \"%s\" in framework \"%s\"; suggestions:\n"
-                % (k, test_name, test_keys['framework']))
-            helpinfo = ('\n').join([
-                "  `%s` -- %s" % (v, desc)
-                for (v, desc) in zip(acceptable_values, descriptors)
-            ])
-            fullerr = msg + helpinfo + "\n"
-            raise Exception(fullerr)
+                "`%s` is a required key for test \"%s\" in framework \"%s\"\n"
+                % (k, test_name, framework_name))
+            if acceptable_values:
+                msg = (
+                    "Invalid `%s` value specified for test \"%s\" in framework \"%s\"; suggestions:\n"
+                    % (k, test_name, framework_name))
+                helpinfo = ('\n').join([
+                    "  `%s` -- %s" % (v, desc)
+                    for (v, desc) in zip(acceptable_values, descriptors)
+                ])
+                msg = msg + helpinfo + "\n"
+
+            raise Exception(msg)
 
 
         # Check values of keys against schema
         # Check values of keys against schema
         for key in schema.keys():
         for key in schema.keys():
             val = get_test_val(key)
             val = get_test_val(key)
             test_keys[key] = val
             test_keys[key] = val
+            acceptable_values = None
+            descriptors = None
+
+            if 'allowed' in schema[key]:
+                allowed = schema[key].get('allowed', [])
+                acceptable_values, descriptors = zip(*allowed)
+                acceptable_values = [a.lower() for a in acceptable_values]
 
 
             if val == "none":
             if val == "none":
                 # incorrect if key requires a value other than none
                 # incorrect if key requires a value other than none
                 if schema[key].get('required', False):
                 if schema[key].get('required', False):
-                    throw_incorrect_key(key)
+                    throw_incorrect_key(key, acceptable_values, descriptors)
                 # certain keys are only required if another key is not none
                 # certain keys are only required if another key is not none
                 if 'required_with' in schema[key]:
                 if 'required_with' in schema[key]:
-                    if get_test_val(schema[key]['required_with']) == "none":
-                        continue
-                    else:
-                        throw_incorrect_key(key)
+                    if get_test_val(schema[key]['required_with']) != "none":
+                        throw_incorrect_key(key, acceptable_values, descriptors)
 
 
             # if we're here, the key needs to be one of the "allowed" values
             # if we're here, the key needs to be one of the "allowed" values
-            if 'allowed' in schema[key]:
-                allowed = schema[key].get('allowed', [])
-                acceptable_values, descriptors = zip(*allowed)
-                acceptable_values = [a.lower() for a in acceptable_values]
-
-                if val not in acceptable_values:
-                    throw_incorrect_key(key)
+            elif acceptable_values and val not in acceptable_values:
+                throw_incorrect_key(key, acceptable_values, descriptors)
 
 
         return test_keys
         return test_keys