Skip to content

Commit

Permalink
require-env: add
Browse files Browse the repository at this point in the history
It's a new directive to run tests only when the given environment
variable is defined.
  • Loading branch information
kou committed Apr 12, 2024
1 parent f4382a6 commit 778b2a1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/grntest/executors/base-executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,19 @@ def execute_directive_finish_benchmark(line, content, options)
@benchmark_result = @noop_benchmark_result
end

def execute_directive_require_env(line, content, options)
env, = options
if env.start_with?("!")
if ENV[env[1..-1]]
omit("require env: #{env}")
end
else
unless ENV[env]
omit("require env: #{env}")
end
end
end

def execute_directive(parser, line, content)
command, *options = Shellwords.split(content)
case command
Expand Down Expand Up @@ -612,6 +625,8 @@ def execute_directive(parser, line, content)
execute_directive_start_benchmark(line, content, options)
when "finish-benchmark"
execute_directive_finish_benchmark(line, content, options)
when "require-env"
execute_directive_require_env(line, content, options)
else
log_input(line)
log_error("#|e| unknown directive: <#{command}>")
Expand Down

0 comments on commit 778b2a1

Please sign in to comment.