Skip to content

Commit

Permalink
Change to license enforcement
Browse files Browse the repository at this point in the history
* Bye bye: Freeloaders
  • Loading branch information
mbj committed Apr 2, 2022
1 parent 8d20fff commit e0337e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 42 deletions.
27 changes: 5 additions & 22 deletions lib/mutant/cli/command/environment/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ class Environment
class Run < self
NAME = 'run'
SHORT_DESCRIPTION = 'Run code analysis'
SLEEP = 60
SUBCOMMANDS = EMPTY_ARRAY

UNLICENSED = <<~MESSAGE.lines.freeze
Soft fail, continuing in #{SLEEP} seconds
Next major version will enforce the license
See https://github.com/mbj/mutant#licensing
You are using mutant unlicensed.
See https://github.com/mbj/mutant#licensing to aquire a license.
Note: Its free for opensource use, which is recommended for trials.
MESSAGE

NO_TESTS_MESSAGE = <<~'MESSAGE'
Expand All @@ -40,7 +40,7 @@ def zombie?
private

def action
soft_fail(License.call(world))
License.call(world)
.bind { bootstrap }
.bind(&method(:validate_tests))
.bind(&Runner.public_method(:call))
Expand All @@ -62,23 +62,6 @@ def from_result(result)
Either::Left.new('Uncovered mutations detected, exiting nonzero!')
end
end

def soft_fail(result)
result.either(
lambda do |message|
stderr = world.stderr
stderr.puts(message)
UNLICENSED.each { |line| stderr.puts(unlicensed(line)) }
world.kernel.sleep(SLEEP)
Either::Right.new(nil)
end,
->(_subscription) { Either::Right.new(nil) }
)
end

def unlicensed(message)
"[Mutant-License-Error]: #{message}"
end
end # Run
end # Environment
end # Command
Expand Down
23 changes: 3 additions & 20 deletions spec/unit/mutant/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -716,30 +716,13 @@ def self.main_body
include_context 'environment'

context 'on invalid license' do
let(:expected_exit) { true }
let(:license_result) { left('license-error') }
let(:expected_exit) { false }
let(:license_result) { left('license-error') }

let(:expected_events) do
[
license_validation_event,
[:stderr, :puts, 'license-error'],
[:stderr, :puts, "[Mutant-License-Error]: Soft fail, continuing in 60 seconds\n"],
[:stderr, :puts, "[Mutant-License-Error]: Next major version will enforce the license\n"],
[:stderr, :puts, "[Mutant-License-Error]: See https://github.com/mbj/mutant#licensing\n"],
[:sleep, 60],
[
:load_config_file,
world
],
[
:bootstrap,
world,
bootstrap_config.inspect
],
[
:runner,
env.inspect
]
[:stderr, :puts, 'license-error']
]
end

Expand Down

0 comments on commit e0337e7

Please sign in to comment.