Skip to content

Commit 6969da7

Browse files
committed
[API] Test Runner
Refactors skip test exception to be resuable Skips a test and logs exception when there's a YAML error
1 parent 1b62754 commit 6969da7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

elasticsearch-api/api-spec-testing/test_file.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ def initialize(file_name, client, features_to_skip = [])
4949
@client = client
5050
begin
5151
documents = YAML.load_stream(File.new(file_name))
52+
rescue Psych::SyntaxError => e
53+
raise e unless e.message.include?('found unexpected \':\'')
54+
55+
message = "Exception found when parsing YAML in #{file_name}: #{e.message}"
56+
logger.error message
57+
raise SkipTestsException, message
5258
rescue StandardError => e
5359
logger.error e
5460
logger.error "Filename : #{@name}"
@@ -64,7 +70,7 @@ def skip_entire_test_file?
6470
@skip = @setup['setup']&.select { |a| a['skip'] }
6571
return false if @skip.empty?
6672

67-
raise SkipTestsException if skip_version?(@client, @skip.first['skip'])
73+
raise SkipTestsException, "Skipping #{file} due to 'skip all'." if skip_version?(@client, @skip.first['skip'])
6874
end
6975

7076
def skip_version?(client, skip_definition)

elasticsearch-api/spec/elasticsearch/api/rest_api_yaml_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
REST_API_YAML_FILES.each do |file|
3131
begin
3232
test_file = Elasticsearch::RestAPIYAMLTests::TestFile.new(file, ADMIN_CLIENT, REST_API_YAML_SKIP_FEATURES)
33-
rescue SkipTestsException => _e
33+
rescue SkipTestsException => e
3434
# If the test file has a `skip` at the top level that applies to this
3535
# version of Elasticsearch, continue with the next text.
36-
LOGGER.info "Skipping #{file} due to 'skip all'."
36+
LOGGER.info e.message
3737
next
3838
end
3939

0 commit comments

Comments
 (0)