diff options
Diffstat (limited to 'report')
-rwxr-xr-x | report | 56 |
1 files changed, 27 insertions, 29 deletions
@@ -6,13 +6,16 @@ this script is used to validate and report statistics on the blacklist entries - it currently detects syntax errors, missing tags, unknown tags, missing descriptions, - duplicate entries for a single package (partitioning them as identical or differing), - and will fail if any of those conditions are unmet + it currently detects syntax errors, missing and unknown bug references, + missing and unknown reason tags, missing descriptions, and duplicate entries + any of the above discrepancies will cause the validation to fail + it also detects entries with no replacement, although that is not an error it optionally creates a JSON file with the results, which can be the input to the post_fsd_wiki.phantomjs script + +is not an error =end @@ -36,9 +39,8 @@ DBG_EXPECTED_TEST_RESULTS = "##--------- expected results -----------## ##--- "# entries found: 32 # # [ @entries_malformed , #\n" + "# well-formed: 22 # # @entries_refs_unknown , #\n" + "# malformed: 10 # # @entries_tags_unknown , #\n" + - "# entries lacking bug reference: 2 # # @entries_duplicated ] #\n" + + "# entries lacking bug reference: 3 # # @entries_duplicated ] #\n" + "# no bug reference: 2 # ##-------------------------##\n" + -# per 'blacklist-testdata.txt' "# no bug reference id: 2 #\n" + "# entries lacking tag: 1 #\n" + "# entries lacking description: 1 #\n" + @@ -48,9 +50,7 @@ DBG_EXPECTED_TEST_RESULTS = "##--------- expected results -----------## ##--- "# duplicate entries: 2 #\n" + "# identical: 1 #\n" + "# differing: 1 #\n" + - "##--------------------------------------##\n" -# malformed: 10 # # @entries_tags_unknown , # - + "##--------------------------------------##\n" # per 'blacklist-testdata.txt' ## DEBUG end ## @@ -59,13 +59,12 @@ require 'set' # NOTE: acceptable entry syntax per SYNTAX doc => -# ORIGINAL_PACKAGE:LIBRE_REPLACEMENT:REF:REF_ID:TAG:SHORT_DESCRIPTION +# ORIGINAL_PACKAGE!LIBRE_REPLACEMENT!REF!REF_ID!TAG!SHORT_DESCRIPTION ALL_BLACKLIST_FILES = [ 'blacklist.txt' , 'your-freedom_emu-blacklist.txt' , 'your-privacy-blacklist.txt' ] BLACKLIST_FILES = (File.exist? ARGV.first.to_s) ? [ ARGV.first ] : ALL_BLACKLIST_FILES -# ENTRIES_REGEX = /^[^:\[\]#]+:[^:\[\]]*:(debian|fedora|fsf|parabola|savannah|sv)?:[^:\[\]]*:\w*([^\d:]+:.*|\[[^:]+:.*|[^:]*)$/ -# REASON_TAGS_REGEX = /^\[([^\]]*)\] *(.*)/ -ENTRIES_REGEX = /^[^:#]+:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*$/ # TODO: ref, ref_id, tag, and desc should be required -REASON_TAGS_REGEX = /^([^\]]*)/ +# TODO: empty ref, ref_id, tag, or desc is deprecated - they will be mandatory eventually +# ENTRIES_REGEX = /^[^!#]+![^!]*![^!]+![^!]+![^!]+![^!]+$/ # TODO: this is the desired regex after the deprecation period +ENTRIES_REGEX = /^[^!#]+![^!]*![^!]*![^!]*![^!]*![^!]*$/ # TODO: this is the desired regex during the deprecation period RAW_ENTRY_KEY = :raw_blacklist_entry PACKAGE_NAME_KEY = :original_package # syntax field 0 REPLACEMENT_KEY = :libre_replacement # syntax field 1 @@ -98,8 +97,6 @@ def reset_state @entries_no_desc = [] @entries_refs_unknown = [] @entries_tags_unknown = [] - @refs_unknown = Set[] - @tags_unknown = Set[] @entries_unreplaced = nil # deferred @entries_duplicated = nil # deferred @entries_identical = {} @@ -118,14 +115,14 @@ DBG_TEST_DATA line ; eval DBG_DEBUGGER_EVAL ; @entries_malformed << line && next unless line.match ENTRIES_REGEX @entries_acceptable << (entry = {}) - tokens = (line.split ':') + tokens = (line.split '!') entry[RAW_ENTRY_KEY ] = line entry[PACKAGE_NAME_KEY] = (tokens.shift ).gsub(/\s+/ , '') entry[REPLACEMENT_KEY ] = (tokens.shift ).gsub(/\s+/ , '') entry[REFERENCE_KEY ] = (tokens.shift ).gsub(/\s+/ , '') entry[REFERENCE_ID_KEY] = (tokens.shift ).gsub(/\s+/ , '') entry[REASON_TAGS_KEY ] = (tokens.shift ).gsub(/\s+/ , '').split '|' - entry[DESCRIPTION_KEY ] = (tokens.join ':').gsub(/\s+/ , '') + entry[DESCRIPTION_KEY ] = (tokens.join '!').gsub(/\s+/ , '') DBG_TOKENS tokens end @@ -146,15 +143,13 @@ DBG_ENTRY entry entry_ref_unknown = [ entry_ref ] - ACCEPTABLE_REFS - [ '' ] entry_tags_unknown = entry_tags - ACCEPTABLE_TAGS - entry_freqs[entry_name] = (entry_freqs[entry_name] ||= 0) + 1 - @entries_no_ref << entry if entry_ref .empty? - @entries_no_refid << entry if entry_ref_id .empty? - @entries_no_tag << entry if entry_tags .empty? - @entries_no_desc << entry if entry_desc .empty? - @entries_refs_unknown << entry unless entry_ref_unknown .empty? - @entries_tags_unknown << entry unless entry_tags_unknown.empty? - @refs_unknown.merge entry_ref_unknown - @tags_unknown.merge entry_tags_unknown + entry_freqs[entry_name] = (entry_freqs[entry_name] ||= 0) + 1 + @entries_no_ref << entry if entry_ref .empty? + @entries_no_refid << entry if entry_ref_id .empty? + @entries_no_tag << entry if entry_tags .empty? + @entries_no_desc << entry if entry_desc .empty? + @entries_refs_unknown << entry unless entry_ref_unknown .empty? + @entries_tags_unknown << entry unless entry_tags_unknown.empty? end @entries_unreplaced = @entries_acceptable.select { | entry | entry[REPLACEMENT_KEY].empty? } @@ -219,7 +214,7 @@ def print_report input_filename if DO_PRINT_STATS all_entries = @entries_acceptable + @entries_malformed - all_no_ref = @refs_unknown.merge @tags_unknown + all_no_ref = (@entries_no_ref + @entries_no_refid).uniq print "#{REPORT_SEPARATOR}#{input_filename} stats:\n" print " entries found: #{ (all_entries ).size }\n" @@ -243,12 +238,15 @@ DBG_EXPECTED input_filename end def validate input_filename + # TODO: empty ref, ref_id, tag, or desc is deprecated - they will be mandatory eventually + # TODO: these are the desired strict validations after the deprecation period validations = [ '@entries_malformed' , '@entries_no_ref' , '@entries_refs_unknown' , '@entries_no_refid' , '@entries_no_tag' , '@entries_tags_unknown' , '@entries_no_desc' , - '@entries_duplicated' ] # TODO: ref, ref_id, tag, and desc should be required + '@entries_duplicated' ] + # TODO: these are the current validations during the deprecation period validations = [ '@entries_malformed' , '@entries_refs_unknown' , - '@entries_tags_unknown' , '@entries_duplicated' ] # TODO: ref, ref_id, tag, and desc should be required + '@entries_tags_unknown' , '@entries_duplicated' ] validations.each { | var_name | @errors << var_name unless (eval var_name).empty? } end |