Skip to content

Commit

Permalink
Fix rake code
Browse files Browse the repository at this point in the history
  • Loading branch information
yeetengangIntel committed Apr 15, 2024
1 parent 566036d commit 8d46ad0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions spec/need_kconfig_format_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
def check_config_name(name)
# Check if config name format is valid:
# 1. not start with CONFIG_
return !name.to_s.start_with?("CONFIG_")
!name.to_s.start_with?('CONFIG_')
end

def check_config_value(value)
# Check if value format is valid:
# 1. only contain n, m, y or nothing
# 2. only contain i386, x86_64, or nothing
allowed_chars = /^(n|m|y|i386|x86_64|)$/
return value.match?(allowed_chars) || value.empty?
value.match?(allowed_chars) || value.empty?
end

def preprocess_yaml_file(file_path)
yaml_content = ''

File.open(file_path, 'r') do |file|
file.each_line do |line|
# Skip lines containing conditional directives
Expand Down Expand Up @@ -45,7 +45,7 @@ def load_yaml_with_conditionals(file_path)
next if yaml_data.nil?

kconfig_section = yaml_data['need_kconfig']

next if kconfig_section.nil?

it file do
Expand All @@ -54,13 +54,13 @@ def load_yaml_with_conditionals(file_path)
expect(check_config_name(var_name)).to be_truthy
elsif kconfig_section.is_a?(Array)
kconfig_section.each do |config|
var_name, var_val = config.is_a?(String) ? [config.split(':').map(&:strip)[0], ""] : [config.keys[0], config.values[0]]
var_name, var_val = config.is_a?(String) ? [config.split(':').map(&:strip)[0], ''] : [config.keys[0], config.values[0]]
conditions = check_config_name(var_name) && check_config_value(var_val)
expect(conditions).to be_truthy
end
end
end
rescue Psych::SyntaxError => e
rescue Psych::SyntaxError
# Expecting need_kconfig will be put in yaml file, so files like include/md/raid_level will be skipped
next
end
Expand Down

0 comments on commit 8d46ad0

Please sign in to comment.