1 # -*- coding: utf-8 -*-
3 #-------------------------------------------------------------------------
7 # Copyright (c) 2016 Google Inc.
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
21 #-------------------------------------------------------------------------
26 sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "scripts", "verify"))
28 from package import getPackageDescription
32 def verifyGitStatusFiles (package):
35 if len(package.gitStatus) > 1:
36 messages.append(error(package.basePath, "Exactly one git status file must be present, found %s" % len(package.gitStatus)))
38 messages += verifyGitStatus(package)
42 def verifyGitLogFiles (package):
45 if len(package.gitLog) > 1:
46 messages.append(error(package.basePath, "Exactly one git log file must be present, found %s" % len(package.gitLog)))
48 messages += verifyGitLog(package)
52 def verifyTestLogs (package, mustpass):
55 for testLogFile in package.testLogs:
56 messages += verifyTestLog(os.path.join(package.basePath, testLogFile), mustpass)
58 if len(package.testLogs) == 0:
59 messages.append(error(package.basePath, "No test log files found"))
63 def verifyPackage (package, mustpass):
66 messages += verifyStatement(package)
67 messages += verifyGitStatusFiles(package)
68 messages += verifyGitLogFiles(package)
69 messages += verifyPatches(package)
70 messages += verifyTestLogs(package, mustpass)
72 for item in package.otherItems:
73 messages.append(warning(os.path.join(package.basePath, item), "Unknown file"))
77 if __name__ == "__main__":
78 if len(sys.argv) != 3:
79 print "%s: [extracted submission package] [mustpass]" % sys.argv[0]
82 packagePath = os.path.normpath(sys.argv[1])
83 mustpassPath = sys.argv[2]
84 package = getPackageDescription(packagePath)
85 mustpass = readMustpass(mustpassPath)
86 messages = verifyPackage(package, mustpass)
88 errors = [m for m in messages if m.type == ValidationMessage.TYPE_ERROR]
89 warnings = [m for m in messages if m.type == ValidationMessage.TYPE_WARNING]
91 for message in messages:
97 print "Found %d validation errors and %d warnings!" % (len(errors), len(warnings))
99 elif len(warnings) > 0:
100 print "Found %d warnings, manual review required" % len(warnings)
103 print "All validation checks passed"