judges 0.53.6 → 0.53.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +20 -20
  3. data/features/test.feature +2 -2
  4. data/judges.gemspec +2 -2
  5. data/lib/judges/commands/push.rb +3 -3
  6. data/lib/judges/commands/upload.rb +13 -11
  7. data/lib/judges.rb +1 -1
  8. metadata +1 -39
  9. data/.0pdd.yml +0 -8
  10. data/.gitattributes +0 -7
  11. data/.github/workflows/actionlint.yml +0 -25
  12. data/.github/workflows/codecov.yml +0 -27
  13. data/.github/workflows/copyrights.yml +0 -19
  14. data/.github/workflows/eslint.yml +0 -20
  15. data/.github/workflows/markdown-lint.yml +0 -23
  16. data/.github/workflows/pdd.yml +0 -19
  17. data/.github/workflows/rake.yml +0 -28
  18. data/.github/workflows/reuse.yml +0 -19
  19. data/.github/workflows/typos.yml +0 -19
  20. data/.github/workflows/xcop.yml +0 -19
  21. data/.github/workflows/yamllint.yml +0 -19
  22. data/.gitignore +0 -12
  23. data/.pdd +0 -7
  24. data/.rubocop.yml +0 -53
  25. data/.rultor.yml +0 -37
  26. data/renovate.json +0 -6
  27. data/test/commands/test_download.rb +0 -127
  28. data/test/commands/test_eval.rb +0 -28
  29. data/test/commands/test_import.rb +0 -40
  30. data/test/commands/test_inspect.rb +0 -44
  31. data/test/commands/test_join.rb +0 -38
  32. data/test/commands/test_print.rb +0 -146
  33. data/test/commands/test_pull.rb +0 -77
  34. data/test/commands/test_push.rb +0 -79
  35. data/test/commands/test_test.rb +0 -217
  36. data/test/commands/test_trim.rb +0 -31
  37. data/test/commands/test_update.rb +0 -282
  38. data/test/commands/test_upload.rb +0 -119
  39. data/test/test__helper.rb +0 -45
  40. data/test/test_bin.rb +0 -26
  41. data/test/test_categories.rb +0 -33
  42. data/test/test_impex.rb +0 -35
  43. data/test/test_judge.rb +0 -114
  44. data/test/test_judges.rb +0 -137
  45. data/test/test_options.rb +0 -88
  46. data/test/test_to_rel.rb +0 -24
data/test/test_bin.rb DELETED
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require_relative 'test__helper'
7
-
8
- # Test.
9
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
10
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
11
- # License:: MIT
12
- class TestBin < Minitest::Test
13
- def test_simple_run
14
- ENV.store('GLI_TESTING', 'yes')
15
- load File.join(__dir__, '../bin/judges')
16
- before = $stdout
17
- begin
18
- $stdout = StringIO.new
19
- JudgesGLI.run(['--version'])
20
- s = $stdout.string
21
- ensure
22
- $stdout = before
23
- end
24
- assert_includes(s, Judges::VERSION, s)
25
- end
26
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require_relative '../lib/judges'
7
- require_relative '../lib/judges/categories'
8
- require_relative 'test__helper'
9
-
10
- # Test.
11
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
12
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
13
- # License:: MIT
14
- class TestCategories < Minitest::Test
15
- def test_basic
16
- cats = Judges::Categories.new(%w[foo bar], ['bad'])
17
- assert(cats.ok?(%w[foo other]))
18
- assert(cats.ok?(%w[other more bar]))
19
- refute(cats.ok?(%w[bad other]))
20
- refute(cats.ok?(['other']))
21
- refute(cats.ok?('hey'))
22
- refute(cats.ok?(nil))
23
- end
24
-
25
- def test_all_enabled
26
- cats = Judges::Categories.new([], ['bad'])
27
- assert(cats.ok?(nil))
28
- assert(cats.ok?('hey'))
29
- assert(cats.ok?(%w[foo other]))
30
- assert(cats.ok?(%w[other more bar]))
31
- refute(cats.ok?(%w[bad other]))
32
- end
33
- end
data/test/test_impex.rb DELETED
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'loog'
7
- require 'tmpdir'
8
- require_relative '../lib/judges'
9
- require_relative '../lib/judges/impex'
10
- require_relative 'test__helper'
11
-
12
- # Test.
13
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
14
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
15
- # License:: MIT
16
- class TestImpex < Minitest::Test
17
- def test_basic
18
- Dir.mktmpdir do |d|
19
- f = File.join(d, 'foo.rb')
20
- impex = Judges::Impex.new(Loog::NULL, f)
21
- impex.import(strict: false)
22
- impex.export(Factbase.new)
23
- end
24
- end
25
-
26
- def test_strict_import
27
- Dir.mktmpdir do |d|
28
- f = File.join(d, 'x.rb')
29
- impex = Judges::Impex.new(Loog::NULL, f)
30
- impex.import(strict: false)
31
- impex.export(Factbase.new)
32
- impex.import
33
- end
34
- end
35
- end
data/test/test_judge.rb DELETED
@@ -1,114 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'factbase'
7
- require 'loog'
8
- require 'tmpdir'
9
- require_relative '../lib/judges'
10
- require_relative '../lib/judges/judge'
11
- require_relative 'test__helper'
12
-
13
- # Test.
14
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
15
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
16
- # License:: MIT
17
- class TestJudge < Minitest::Test
18
- def test_basic_run
19
- Dir.mktmpdir do |d|
20
- save_it(File.join(d, "#{File.basename(d)}.rb"), '$fb.insert')
21
- judge = Judges::Judge.new(d, nil, Loog::NULL)
22
- fb = Factbase.new
23
- judge.run(fb, {}, {}, {})
24
- assert_equal(1, fb.size)
25
- end
26
- end
27
-
28
- def test_run_isolated
29
- Dir.mktmpdir do |d|
30
- save_it(File.join(d, "#{File.basename(d)}.rb"), '$fb.insert')
31
- judge = Judges::Judge.new(d, nil, Loog::NULL)
32
- fb1 = Factbase.new
33
- judge.run(fb1, {}, {}, {})
34
- assert_equal(1, fb1.size)
35
- fb2 = Factbase.new
36
- judge.run(fb2, {}, {}, {})
37
- assert_equal(1, fb2.size)
38
- end
39
- end
40
-
41
- def test_passes_local_vars_between_tests
42
- Dir.mktmpdir do |d|
43
- save_it(
44
- File.join(d, "#{File.basename(d)}.rb"),
45
- '
46
- $local[:foo] = 42 if $local[:foo].nil?
47
- $local[:foo] = $local[:foo] + 1
48
- '
49
- )
50
- judge = Judges::Judge.new(d, nil, Loog::NULL)
51
- local = {}
52
- judge.run(Factbase.new, {}, local, {})
53
- judge.run(Factbase.new, {}, local, {})
54
- judge.run(Factbase.new, {}, local, {})
55
- assert_equal(45, local[:foo])
56
- end
57
- end
58
-
59
- def test_sets_judge_value_correctly
60
- Dir.mktmpdir do |d|
61
- j = 'this_is_it'
62
- dir = File.join(d, j)
63
- save_it(File.join(dir, "#{j}.rb"), '$loog.info("judge=" + $judge)')
64
- log = Loog::Buffer.new
65
- Judges::Judge.new(dir, nil, log).run(Factbase.new, {}, {}, {})
66
- assert_includes(log.to_s, "judge=#{j}")
67
- end
68
- end
69
-
70
- def test_sets_start_value_correctly
71
- Dir.mktmpdir do |d|
72
- j = 'this_is_it'
73
- dir = File.join(d, j)
74
- save_it(File.join(dir, "#{j}.rb"), '$loog.info("start=#{$start}")')
75
- log = Loog::Buffer.new
76
- time = Time.now
77
- Judges::Judge.new(dir, nil, log, start: time).run(Factbase.new, {}, {}, {})
78
- assert_includes(log.to_s, "start=#{time}")
79
- end
80
- end
81
-
82
- def test_with_broken_ruby_syntax
83
- assert_raises(StandardError) do
84
- Dir.mktmpdir do |d|
85
- dir = File.join(d, 'judges')
86
- save_it(File.join(dir, "#{File.basename(d)}.rb"), 'this$is$broken$syntax')
87
- judge = Judges::Judge.new(dir, lib, Loog::NULL)
88
- judge.run(Factbase.new, {}, {}, {})
89
- end
90
- end
91
- end
92
-
93
- def test_with_runtime_ruby_error
94
- assert_raises(StandardError) do
95
- Dir.mktmpdir do |d|
96
- dir = File.join(d, 'judges')
97
- save_it(File.join(dir, "#{File.basename(d)}.rb"), 'a < 1')
98
- judge = Judges::Judge.new(dir, lib, Loog::NULL)
99
- judge.run(Factbase.new, {}, {}, {})
100
- end
101
- end
102
- end
103
-
104
- def test_with_standard_error
105
- assert_raises(StandardError) do
106
- Dir.mktmpdir do |d|
107
- dir = File.join(d, 'judges')
108
- save_it(File.join(dir, "#{File.basename(d)}.rb"), 'raise "intentional"')
109
- judge = Judges::Judge.new(dir, lib, Loog::NULL)
110
- judge.run(Factbase.new, {}, {}, {})
111
- end
112
- end
113
- end
114
- end
data/test/test_judges.rb DELETED
@@ -1,137 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require 'loog'
7
- require 'tmpdir'
8
- require_relative '../lib/judges'
9
- require_relative '../lib/judges/judges'
10
- require_relative 'test__helper'
11
-
12
- # Test.
13
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
14
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
15
- # License:: MIT
16
- class TestJudges < Minitest::Test
17
- def test_basic
18
- Dir.mktmpdir do |d|
19
- dir = File.join(d, 'foo')
20
- save_it(File.join(dir, 'foo.rb'), 'hey')
21
- save_it(File.join(dir, 'something.yml'), "---\nfoo: 42")
22
- found = 0
23
- Judges::Judges.new(d, nil, Loog::NULL).each do |p|
24
- assert_equal('foo.rb', p.script)
25
- found += 1
26
- assert_equal('something.yml', File.basename(p.tests.first))
27
- end
28
- assert_equal(1, found)
29
- end
30
- end
31
-
32
- def test_shuffles_them
33
- Dir.mktmpdir do |d|
34
- names = %w[apple banana blueberry mellon orange papaya pear strawberry].sort
35
- names.each do |n|
36
- dir = File.join(d, n)
37
- save_it(File.join(dir, "#{n}.rb"), 'puts 1')
38
- end
39
- list = Judges::Judges.new(d, nil, Loog::NULL, shuffle: 'b').each.to_a
40
- assert_equal('banana', list[1].name)
41
- assert_equal('blueberry', list[2].name)
42
- refute_equal(names.join(' '), list.map(&:name).join(' '))
43
- list = Judges::Judges.new(d, nil, Loog::NULL, shuffle: '').each.to_a
44
- assert_equal(names.join(' '), list.map(&:name).join(' '))
45
- end
46
- end
47
-
48
- def test_shuffles_and_boosts
49
- Dir.mktmpdir do |d|
50
- names = %w[red blue green black orange pink yellow].sort
51
- names.each do |n|
52
- dir = File.join(d, n)
53
- save_it(File.join(dir, "#{n}.rb"), 'puts 1')
54
- end
55
- list = Judges::Judges.new(d, nil, Loog::NULL, shuffle: '', boost: ['yellow']).each.to_a
56
- assert_equal('yellow', list[0].name)
57
- end
58
- end
59
-
60
- def test_keeps_them_all
61
- colors = %w[blue orange yellow black white pink magenta]
62
- ['', 'b', 'ye'].each do |pfx|
63
- Dir.mktmpdir do |d|
64
- names = colors.sort
65
- names.each do |n|
66
- dir = File.join(d, n)
67
- save_it(File.join(dir, "#{n}.rb"), 'puts 1')
68
- end
69
- after = Judges::Judges.new(d, nil, Loog::NULL, shuffle: pfx).each.to_a.map(&:name)
70
- assert_equal(names.size, after.size)
71
- names.each { |n| assert_includes(after, n, "#{n.inspect} is missing, with #{pfx.inspect}") }
72
- after.each { |n| assert_includes(names, n, "#{n.inspect} is extra, with #{pfx.inspect}") }
73
- end
74
- end
75
- end
76
-
77
- def test_get_one
78
- Dir.mktmpdir do |d|
79
- save_it(File.join(d, 'boo/boo.rb'), 'hey')
80
- j = Judges::Judges.new(d, nil, Loog::NULL).get('boo')
81
- assert_equal('boo.rb', j.script)
82
- end
83
- end
84
-
85
- def test_list_only_direct_subdirs
86
- Dir.mktmpdir do |d|
87
- save_it(File.join(d, 'first/first.rb'), '')
88
- save_it(File.join(d, 'second/second.rb'), '')
89
- save_it(File.join(d, 'second/just-file.rb'), '')
90
- save_it(File.join(d, 'wrong.rb'), '')
91
- save_it(File.join(d, 'another/wrong/wrong.rb'), '')
92
- save_it(File.join(d, 'bad/hello.rb'), '')
93
- list = Judges::Judges.new(d, nil, Loog::NULL).each.to_a
94
- assert_equal(2, list.size)
95
- end
96
- end
97
-
98
- def test_list_with_empty_dir
99
- Dir.mktmpdir do |d|
100
- save_it(File.join(d, 'wrong.rb'), '')
101
- save_it(File.join(d, 'another/wrong/wrong.rb'), '')
102
- save_it(File.join(d, 'bad/hello.rb'), '')
103
- list = Judges::Judges.new(d, nil, Loog::NULL).each.to_a
104
- assert_empty(list)
105
- end
106
- end
107
-
108
- def test_demotes_judges
109
- Dir.mktmpdir do |d|
110
- names = %w[alpha beta gamma delta epsilon].sort
111
- names.each do |n|
112
- dir = File.join(d, n)
113
- save_it(File.join(dir, "#{n}.rb"), 'puts 1')
114
- end
115
- list = Judges::Judges.new(d, nil, Loog::NULL, demote: %w[beta delta]).each.to_a
116
- result = list.map(&:name)
117
- assert_equal(%w[alpha epsilon gamma beta delta], result)
118
- end
119
- end
120
-
121
- def test_boost_and_demote_together
122
- Dir.mktmpdir do |d|
123
- names = %w[one two three four five six].sort
124
- names.each do |n|
125
- dir = File.join(d, n)
126
- save_it(File.join(dir, "#{n}.rb"), 'puts 1')
127
- end
128
- list = Judges::Judges.new(d, nil, Loog::NULL, boost: %w[six two], demote: %w[one four]).each.to_a
129
- result = list.map(&:name)
130
- assert_equal('six', result[0])
131
- assert_equal('two', result[1])
132
- demoted = result[-2..]
133
- assert_includes(demoted, 'one')
134
- assert_includes(demoted, 'four')
135
- end
136
- end
137
- end
data/test/test_options.rb DELETED
@@ -1,88 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require_relative '../lib/judges'
7
- require_relative '../lib/judges/options'
8
- require_relative 'test__helper'
9
-
10
- # Test.
11
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
12
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
13
- # License:: MIT
14
- class TestOptions < Minitest::Test
15
- def test_basic
16
- opts = Judges::Options.new(['token=a77', 'max=42'])
17
- assert_equal('a77', opts.token)
18
- assert_equal(42, opts.max)
19
- end
20
-
21
- def test_stips_spaces
22
- opts = Judges::Options.new([' token=a77 ', 'max = 42'])
23
- assert_equal('a77', opts.token)
24
- assert_equal(42, opts.max)
25
- end
26
-
27
- def test_case_insensitive
28
- opts = Judges::Options.new(['aBcDeF=1', 'aBCDEf=2'])
29
- assert_equal(2, opts.abcdef)
30
- end
31
-
32
- def test_with_nil
33
- opts = Judges::Options.new(nil)
34
- assert_nil(opts.foo)
35
- assert_empty(opts)
36
- end
37
-
38
- def test_with_empty_string
39
- opts = Judges::Options.new(' ')
40
- assert_nil(opts.foo)
41
- assert_empty(opts, opts)
42
- end
43
-
44
- def test_with_empty_strings
45
- opts = Judges::Options.new(['', nil])
46
- assert_nil(opts.foo)
47
- assert_empty(opts)
48
- end
49
-
50
- def test_with_string
51
- opts = Judges::Options.new('a=1,b=42')
52
- assert_equal(1, opts.a)
53
- assert_equal(42, opts.b)
54
- end
55
-
56
- def test_with_hash
57
- opts = Judges::Options.new('foo' => 42, 'bar' => 'hello')
58
- assert_equal(42, opts.foo)
59
- assert_equal('hello', opts.Bar)
60
- assert_nil(opts.xxx)
61
- end
62
-
63
- def test_with_nil_values
64
- opts = Judges::Options.new('foo' => nil)
65
- assert_nil(opts.foo)
66
- end
67
-
68
- def test_converts_to_string
69
- opts = Judges::Options.new('foo' => 44, 'bar' => 'long-string-maybe-secret')
70
- s = opts.to_s
71
- assert_includes(s, 'FOO → 44 (Integer)', s)
72
- assert_includes(s, '"long****************cret"', s)
73
- end
74
-
75
- def test_merge
76
- left = Judges::Options.new(['a = 1', 'b = 4'])
77
- right = Judges::Options.new(['a = 44', 'c = 3'])
78
- opts = left + right
79
- assert_equal(44, opts.a)
80
- assert_equal(3, opts.c)
81
- end
82
-
83
- def test_merge_by_symbols
84
- opts = Judges::Options.new(a: 42) + Judges::Options.new(b: 7)
85
- assert_equal(42, opts.a, opts)
86
- assert_equal(7, opts.b, opts)
87
- end
88
- end
data/test/test_to_rel.rb DELETED
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Yegor Bugayenko
4
- # SPDX-License-Identifier: MIT
5
-
6
- require_relative '../lib/judges'
7
- require_relative '../lib/judges/to_rel'
8
- require_relative 'test__helper'
9
-
10
- # Test.
11
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
12
- # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
13
- # License:: MIT
14
- class TestToRel < Minitest::Test
15
- def test_simple_mapping
16
- n = File.absolute_path(File.join('.', 'lib/../lib/commands/update.rb'))
17
- assert_equal('lib/commands/update.rb', n.to_rel)
18
- end
19
-
20
- def test_maps_dir_name
21
- n = File.absolute_path(File.join('.', 'lib/../lib/judges/commands'))
22
- assert_equal('lib/judges/commands/', n.to_rel)
23
- end
24
- end