Skip to content

Commit

Permalink
test that constants are available in candidates
Browse files Browse the repository at this point in the history
    277 runs, 500 assertions, 26 failures, 0 errors, 0 skips

Apparently there are some kinks to work out.
  • Loading branch information
robbkidd committed Jul 10, 2024
1 parent c3015aa commit 7e2cdf2
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

require 'test_helper'

OLD_SEMCONV_ROOTS = %i[Resource Trace].freeze

describe OpenTelemetry::SemanticConventions do
OLD_SEMCONV_ROOTS
.each do |old_root|
describe "old root #{old_root} has a corresponding SemanticCandidates namespace and constant" do
OpenTelemetry::SemanticConventions
.const_get(old_root)
.constants
.each do |const|
it "(#{const})" do
root_namespace = const.to_s.split('_').first
assert OpenTelemetry::SemanticCandidates.constants.include?(root_namespace.to_sym), "Missing candidate namespace: #{root_namespace}"

candidate_namespace = OpenTelemetry::SemanticCandidates.const_get(root_namespace.to_sym)
assert candidate_namespace.constants.include?(const), "Missing candidate constant: #{const}"
end
end
end
end

OpenTelemetry::SemanticConventions
.constants
.reject { |const| const == :VERSION }
.reject { |root_namespace| OLD_SEMCONV_ROOTS.include?(root_namespace) }
.each do |root_namespace|
describe "stable root (#{root_namespace})" do
OpenTelemetry::SemanticConventions
.const_get(root_namespace)
.constants
.each do |stable_const|
it "(#{stable_const})" do
candidate_namespace = OpenTelemetry::SemanticCandidates.const_get(root_namespace)
assert candidate_namespace.constants.include?(stable_const), "Missing stable constant in candidates: #{stable_const}"
end
end
end
end
end
16 changes: 16 additions & 0 deletions semantic_conventions/test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0

if RUBY_ENGINE == 'ruby'
require 'simplecov'
SimpleCov.start
SimpleCov.minimum_coverage 85
end

require 'minitest/autorun'
require 'pry'

Dir[File.join(File.dirname(__FILE__), '..', 'lib', 'opentelemetry', '**', '*.rb')].sort.each { |file| require file }

0 comments on commit 7e2cdf2

Please sign in to comment.