modsvaskr 0.1.4 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9da018a3ec7ff9aa0b326ab9ba345da5ae001d20c3a158ccb6e0b00f7a09b71
4
- data.tar.gz: 04f068e2b37bdebe8162365034fb9acfd50c1d664fbba0f2a08c5e6acb929464
3
+ metadata.gz: ec8a78a2351a1b75ce524ec43bc394f32af0ca8f9f8bdcb503227ef61c67a835
4
+ data.tar.gz: 1368b7d37845214a577ce3c90a74d771921c82dd9b6e2b29ea7290c7087c503a
5
5
  SHA512:
6
- metadata.gz: 26e7a236ac7b40df6b3298f02ef6ec9b774e7abee85fa0222af1891423202ae9b76cfbc9e195b34bb311f6f03e48bc35b28d57dd5bbbcf4fdd672917b68b69e0
7
- data.tar.gz: 5503901acf312ce5b509760ee3af77b68262a537727498522cdea69e35f207eac1f1f7fec0868f3173ccb27ba273b590103c4c8171fae2b249c8badaf76f7355
6
+ metadata.gz: 7fcdfcb6474e23a2194c368c8eb77af05b83d8c3ded3f34d9a11ecd7e8decf0bfd33d4d2c07edd2ac0f2ce865004ce8a7b5c0fe4a205a5efb82745d2d8a38d25
7
+ data.tar.gz: cf8b50f20f69992e5830472809bdb356293f3b5d5e5c3410b4a3b996bab5234932162836f5fecf0d563af24ad9fad8cc92cc9dbb186a1458642053c662e82201
@@ -0,0 +1,29 @@
1
+ module Modsvaskr
2
+
3
+ module Encoding
4
+
5
+ # Convert a string to UTF-8
6
+ #
7
+ # Parameters::
8
+ # * *str* (String): The string to convert
9
+ # Result::
10
+ # * String: The converted string
11
+ def self.to_utf8(str)
12
+ orig_encoding = str.encoding
13
+ encoding = nil
14
+ begin
15
+ encoding = %w[
16
+ UTF-8
17
+ Windows-1252
18
+ ISO-8859-1
19
+ ].find { |search_encoding| str.force_encoding(search_encoding).valid_encoding? }
20
+ ensure
21
+ str.force_encoding(orig_encoding)
22
+ end
23
+ raise "Unknown encoding for string #{str[0..127].inspect}" if encoding.nil?
24
+ str.encode('UTF-8', encoding)
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -211,21 +211,23 @@ module Modsvaskr
211
211
  end
212
212
  end
213
213
  # We will start again. Leave some time to interrupt if we want.
214
- unless @config.no_prompt
214
+ if @config.no_prompt
215
+ out 'Start again automatically as no_prompt has been set.'
216
+ else
215
217
  # First, flush stdin of any pending character
216
218
  $stdin.getc while !select([$stdin], nil, nil, 2).nil?
217
- end
218
- out "We are going to start again in #{@game.timeout_interrupt_tests_secs} seconds. Press Enter now to interrupt it."
219
- key_pressed =
220
- begin
221
- Timeout.timeout(@game.timeout_interrupt_tests_secs) { $stdin.gets }
222
- rescue Timeout::Error
223
- nil
219
+ out "We are going to start again in #{@game.timeout_interrupt_tests_secs} seconds. Press Enter now to interrupt it."
220
+ key_pressed =
221
+ begin
222
+ Timeout.timeout(@game.timeout_interrupt_tests_secs) { $stdin.gets }
223
+ rescue Timeout::Error
224
+ nil
225
+ end
226
+ if key_pressed
227
+ log "[ In-game testing #{@game.name} ] - Run interrupted by user."
228
+ # TODO: Remove AutoTest start on load: it has been interrupted by the user, so we should not keep it in case the user launches the game by itself.
229
+ break
224
230
  end
225
- if key_pressed
226
- log "[ In-game testing #{@game.name} ] - Run interrupted by user."
227
- # TODO: Remove AutoTest start on load: it has been interrupted by the user, so we should not keep it in case the user launches the game by itself.
228
- break
229
231
  end
230
232
  end
231
233
  end
@@ -0,0 +1,39 @@
1
+ module Modsvaskr
2
+
3
+ # Mixin adding methods to map directly a tests suite to an in-game tests suite
4
+ # Uses the following methods:
5
+ # * *in_game_tests_suite* -> Symbol: Name of the in-gamer tests suite on which we forward the tests run
6
+ module InGameTestsSuite
7
+
8
+ # Get the list of tests to be run in-game for a given list of test names.
9
+ # [API] - This method is mandatory for tests needing to be run in-game.
10
+ #
11
+ # Parameters::
12
+ # * *tests* (Array<String>): List of test names
13
+ # Result::
14
+ # * Hash<Symbol, Array<String> >: List of in-game test names, per in-game tests suite
15
+ def in_game_tests_for(tests)
16
+ { in_game_tests_suite => tests }
17
+ end
18
+
19
+ # Set statuses based on the result of AutoTest statuses.
20
+ # AutoTest names are case insensitive.
21
+ # [API] - This method is mandatory for tests needing to be run in-game.
22
+ #
23
+ # Parameters::
24
+ # * *tests* (Array<String>): List of test names
25
+ # * *auto_test_statuses* (Hash<Symbol, Hash<String, String> >): In-game test statuses, per in-game test name, per in-game tests suite
26
+ # Result::
27
+ # * Array<[String, String]>: Corresponding list of [test name, test status]
28
+ def parse_auto_tests_statuses_for(tests, auto_test_statuses)
29
+ in_game_test_statuses = auto_test_statuses[in_game_tests_suite] || {}
30
+ tests.map do |test_name|
31
+ test_downcase = test_name.downcase
32
+ _in_game_test, in_game_test_status = in_game_test_statuses.find { |search_in_game_test, _search_in_game_test_status| search_in_game_test.downcase == test_downcase }
33
+ in_game_test_status.nil? ? nil : [test_name, in_game_test_status]
34
+ end.compact
35
+ end
36
+
37
+ end
38
+
39
+ end
@@ -131,14 +131,15 @@ module Modsvaskr
131
131
  in_game_tests.each do |tests_suite, selected_tests|
132
132
  in_game_tests_to_subscribe = @tests_suites[tests_suite].in_game_tests_for(selected_tests)
133
133
  in_game_tests_to_subscribe.each do |in_game_tests_suite, selected_in_game_tests|
134
+ selected_in_game_tests_downcase = selected_in_game_tests.map(&:downcase)
134
135
  in_game_tests_subscriptions[in_game_tests_suite] = [] unless in_game_tests_subscriptions.key?(in_game_tests_suite)
135
136
  in_game_tests_subscriptions[in_game_tests_suite] << {
136
137
  tests_suite: tests_suite,
137
- in_game_tests: selected_in_game_tests,
138
+ in_game_tests: selected_in_game_tests_downcase,
138
139
  selected_tests: selected_tests
139
140
  }
140
141
  merged_in_game_tests[in_game_tests_suite] = [] unless merged_in_game_tests.key?(in_game_tests_suite)
141
- merged_in_game_tests[in_game_tests_suite] = (merged_in_game_tests[in_game_tests_suite] + selected_in_game_tests).uniq
142
+ merged_in_game_tests[in_game_tests_suite] = (merged_in_game_tests[in_game_tests_suite] + selected_in_game_tests_downcase).uniq
142
143
  end
143
144
  end
144
145
  in_game_tests_runner = InGameTestsRunner.new(@config, @game)
@@ -1,9 +1,21 @@
1
+ require 'modsvaskr/in_game_tests_suite'
2
+
1
3
  module Modsvaskr
2
4
 
3
5
  module TestsSuites
4
6
 
5
7
  class ExteriorCell < TestsSuite
6
8
 
9
+ include InGameTestsSuite
10
+
11
+ # Return the in-game tests suite to which we forward the tests to be run
12
+ #
13
+ # Result::
14
+ # * Symbol: In-game tests suite
15
+ def in_game_tests_suite
16
+ :locations
17
+ end
18
+
7
19
  # Discover the list of tests information that could be run.
8
20
  # [API] - This method is mandatory
9
21
  #
@@ -14,7 +26,7 @@ module Modsvaskr
14
26
  # Hash< String, Hash< String, Array<[Integer, Integer]> > >
15
27
  exterior_cells = {}
16
28
  @game.xedit.run_script('DumpInfo', only_once: true)
17
- CSV.read("#{@game.xedit.install_path}/Edit Scripts/Modsvaskr_ExportedDumpInfo.csv", encoding: 'windows-1251:utf-8').each do |row|
29
+ @game.xedit.parse_csv('Modsvaskr_ExportedDumpInfo') do |row|
18
30
  esp_name, record_type = row[0..1]
19
31
  if record_type.downcase == 'cell'
20
32
  cell_type, cell_name, cell_x, cell_y = row[3..6]
@@ -33,7 +45,7 @@ module Modsvaskr
33
45
  # Test only exterior cells that have been changed by mods, and make sure we test the minimum, knowing that each cell loaded in game tests 5x5 cells around
34
46
  vanilla_esps = @game.game_esps
35
47
  vanilla_exterior_cells = vanilla_esps.inject({}) do |merged_worldspaces, esp_name|
36
- merged_worldspaces.merge(exterior_cells[esp_name]) do |worldspace, ext_cells1, ext_cells2|
48
+ merged_worldspaces.merge(exterior_cells[esp_name] || {}) do |worldspace, ext_cells1, ext_cells2|
37
49
  (ext_cells1 + ext_cells2).sort.uniq
38
50
  end
39
51
  end
@@ -75,7 +87,7 @@ module Modsvaskr
75
87
  slice(*(candidate_cell_x - delta_cells..candidate_cell_x + delta_cells)).
76
88
  inject(0) { |sum_cells, (_cur_cell_x, cur_cell_ys)| sum_cells + cur_cell_ys.slice(*(candidate_cell_y - delta_cells..candidate_cell_y + delta_cells)).size }
77
89
  if best_cell_score.nil? || nbr_tested_cells > best_cell_score
78
- nbr_tested_cells = best_cell_score
90
+ best_cell_score = nbr_tested_cells
79
91
  best_cell_x = candidate_cell_x
80
92
  best_cell_y = candidate_cell_y
81
93
  end
@@ -98,30 +110,6 @@ module Modsvaskr
98
110
  tests
99
111
  end
100
112
 
101
- # Get the list of tests to be run in-game for a given list of test names.
102
- # [API] - This method is mandatory for tests needing to be run in-game.
103
- #
104
- # Parameters::
105
- # * *tests* (Array<String>): List of test names
106
- # Result::
107
- # * Hash<Symbol, Array<String> >: List of in-game test names, per in-game tests suite
108
- def in_game_tests_for(tests)
109
- { locations: tests }
110
- end
111
-
112
- # Set statuses based on the result of AutoTest statuses.
113
- # AutoTest names are case insensitive.
114
- # [API] - This method is mandatory for tests needing to be run in-game.
115
- #
116
- # Parameters::
117
- # * *tests* (Array<String>): List of test names
118
- # * *auto_test_statuses* (Hash<Symbol, Array<[String, String]> >): Ordered list of AutoTest [test name, test status], per AutoTest tests suite
119
- # Result::
120
- # * Array<[String, String]>: Corresponding list of [test name, test status]
121
- def parse_auto_tests_statuses_for(tests, auto_test_statuses)
122
- auto_test_statuses.key?(:locations) ? auto_test_statuses[:locations] : []
123
- end
124
-
125
113
  end
126
114
 
127
115
  end
@@ -1,9 +1,21 @@
1
+ require 'modsvaskr/in_game_tests_suite'
2
+
1
3
  module Modsvaskr
2
4
 
3
5
  module TestsSuites
4
6
 
5
7
  class InteriorCell < TestsSuite
6
8
 
9
+ include InGameTestsSuite
10
+
11
+ # Return the in-game tests suite to which we forward the tests to be run
12
+ #
13
+ # Result::
14
+ # * Symbol: In-game tests suite
15
+ def in_game_tests_suite
16
+ :locations
17
+ end
18
+
7
19
  # Discover the list of tests information that could be run.
8
20
  # [API] - This method is mandatory
9
21
  #
@@ -14,7 +26,7 @@ module Modsvaskr
14
26
  # Hash< String, Array<String> >
15
27
  interior_cells = {}
16
28
  @game.xedit.run_script('DumpInfo', only_once: true)
17
- CSV.read("#{@game.xedit.install_path}/Edit Scripts/Modsvaskr_ExportedDumpInfo.csv", encoding: 'windows-1251:utf-8').each do |row|
29
+ @game.xedit.parse_csv('Modsvaskr_ExportedDumpInfo') do |row|
18
30
  esp_name, record_type = row[0..1]
19
31
  if record_type.downcase == 'cell'
20
32
  cell_type, cell_name = row[3..4]
@@ -27,7 +39,7 @@ module Modsvaskr
27
39
  end
28
40
  # Test only interior cells that have been changed by mods
29
41
  vanilla_esps = @game.game_esps
30
- vanilla_interior_cells = vanilla_esps.map { |esp_name| interior_cells[esp_name] }.flatten.sort.uniq
42
+ vanilla_interior_cells = vanilla_esps.map { |esp_name| interior_cells[esp_name] || [] }.flatten.sort.uniq
31
43
  Hash[interior_cells.
32
44
  map { |esp_name, esp_cells| vanilla_esps.include?(esp_name) ? [] : vanilla_interior_cells & esp_cells }.
33
45
  flatten.
@@ -44,30 +56,6 @@ module Modsvaskr
44
56
  ]
45
57
  end
46
58
 
47
- # Get the list of tests to be run in-game for a given list of test names.
48
- # [API] - This method is mandatory for tests needing to be run in-game.
49
- #
50
- # Parameters::
51
- # * *tests* (Array<String>): List of test names
52
- # Result::
53
- # * Hash<Symbol, Array<String> >: List of in-game test names, per in-game tests suite
54
- def in_game_tests_for(tests)
55
- { locations: tests }
56
- end
57
-
58
- # Set statuses based on the result of AutoTest statuses.
59
- # AutoTest names are case insensitive.
60
- # [API] - This method is mandatory for tests needing to be run in-game.
61
- #
62
- # Parameters::
63
- # * *tests* (Array<String>): List of test names
64
- # * *auto_test_statuses* (Hash<Symbol, Array<[String, String]> >): Ordered list of AutoTest [test name, test status], per AutoTest tests suite
65
- # Result::
66
- # * Array<[String, String]>: Corresponding list of [test name, test status]
67
- def parse_auto_tests_statuses_for(tests, auto_test_statuses)
68
- auto_test_statuses.key?(:locations) ? auto_test_statuses[:locations] : []
69
- end
70
-
71
59
  end
72
60
 
73
61
  end
@@ -1,9 +1,21 @@
1
+ require 'modsvaskr/in_game_tests_suite'
2
+
1
3
  module Modsvaskr
2
4
 
3
5
  module TestsSuites
4
6
 
5
7
  class Npc < TestsSuite
6
8
 
9
+ include InGameTestsSuite
10
+
11
+ # Return the in-game tests suite to which we forward the tests to be run
12
+ #
13
+ # Result::
14
+ # * Symbol: In-game tests suite
15
+ def in_game_tests_suite
16
+ :npcs
17
+ end
18
+
7
19
  # Discover the list of tests information that could be run.
8
20
  # [API] - This method is mandatory
9
21
  #
@@ -12,7 +24,7 @@ module Modsvaskr
12
24
  def discover_tests
13
25
  tests = {}
14
26
  @game.xedit.run_script('DumpInfo', only_once: true)
15
- CSV.read("#{@game.xedit.install_path}/Edit Scripts/Modsvaskr_ExportedDumpInfo.csv", encoding: 'windows-1251:utf-8').each do |row|
27
+ @game.xedit.parse_csv('Modsvaskr_ExportedDumpInfo') do |row|
16
28
  tests["#{row[0].downcase}/#{row[2].to_i(16)}"] = {
17
29
  name: "Take screenshot of #{row[0]} - #{row[3]}"
18
30
  } if row[1].downcase == 'npc_'
@@ -20,30 +32,6 @@ module Modsvaskr
20
32
  tests
21
33
  end
22
34
 
23
- # Get the list of tests to be run in-game for a given list of test names.
24
- # [API] - This method is mandatory for tests needing to be run in-game.
25
- #
26
- # Parameters::
27
- # * *tests* (Array<String>): List of test names
28
- # Result::
29
- # * Hash<Symbol, Array<String> >: List of in-game test names, per in-game tests suite
30
- def in_game_tests_for(tests)
31
- { npcs: tests }
32
- end
33
-
34
- # Set statuses based on the result of AutoTest statuses.
35
- # AutoTest names are case insensitive.
36
- # [API] - This method is mandatory for tests needing to be run in-game.
37
- #
38
- # Parameters::
39
- # * *tests* (Array<String>): List of test names
40
- # * *auto_test_statuses* (Hash<Symbol, Array<[String, String]> >): Ordered list of AutoTest [test name, test status], per AutoTest tests suite
41
- # Result::
42
- # * Array<[String, String]>: Corresponding list of [test name, test status]
43
- def parse_auto_tests_statuses_for(tests, auto_test_statuses)
44
- auto_test_statuses.key?(:npcs) ? auto_test_statuses[:npcs] : []
45
- end
46
-
47
35
  end
48
36
 
49
37
  end
@@ -1,9 +1,21 @@
1
+ require 'modsvaskr/in_game_tests_suite'
2
+
1
3
  module Modsvaskr
2
4
 
3
5
  module TestsSuites
4
6
 
5
7
  class NpcHead < TestsSuite
6
8
 
9
+ include InGameTestsSuite
10
+
11
+ # Return the in-game tests suite to which we forward the tests to be run
12
+ #
13
+ # Result::
14
+ # * Symbol: In-game tests suite
15
+ def in_game_tests_suite
16
+ :npcshead
17
+ end
18
+
7
19
  # Discover the list of tests information that could be run.
8
20
  # [API] - This method is mandatory
9
21
  #
@@ -12,7 +24,7 @@ module Modsvaskr
12
24
  def discover_tests
13
25
  tests = {}
14
26
  @game.xedit.run_script('DumpInfo', only_once: true)
15
- CSV.read("#{@game.xedit.install_path}/Edit Scripts/Modsvaskr_ExportedDumpInfo.csv", encoding: 'windows-1251:utf-8').each do |row|
27
+ @game.xedit.parse_csv('Modsvaskr_ExportedDumpInfo') do |row|
16
28
  tests["#{row[0].downcase}/#{row[2].to_i(16)}"] = {
17
29
  name: "Take head screenshot of #{row[0]} - #{row[3]}"
18
30
  } if row[1].downcase == 'npc_'
@@ -20,30 +32,6 @@ module Modsvaskr
20
32
  tests
21
33
  end
22
34
 
23
- # Get the list of tests to be run in-game for a given list of test names.
24
- # [API] - This method is mandatory for tests needing to be run in-game.
25
- #
26
- # Parameters::
27
- # * *tests* (Array<String>): List of test names
28
- # Result::
29
- # * Hash<Symbol, Array<String> >: List of in-game test names, per in-game tests suite
30
- def in_game_tests_for(tests)
31
- { npcshead: tests }
32
- end
33
-
34
- # Set statuses based on the result of AutoTest statuses.
35
- # AutoTest names are case insensitive.
36
- # [API] - This method is mandatory for tests needing to be run in-game.
37
- #
38
- # Parameters::
39
- # * *tests* (Array<String>): List of test names
40
- # * *auto_test_statuses* (Hash<Symbol, Array<[String, String]> >): Ordered list of AutoTest [test name, test status], per AutoTest tests suite
41
- # Result::
42
- # * Array<[String, String]>: Corresponding list of [test name, test status]
43
- def parse_auto_tests_statuses_for(tests, auto_test_statuses)
44
- auto_test_statuses.key?(:npcshead) ? auto_test_statuses[:npcshead] : []
45
- end
46
-
47
35
  end
48
36
 
49
37
  end
@@ -1,5 +1,5 @@
1
1
  module Modsvaskr
2
2
 
3
- VERSION = '0.1.4'
3
+ VERSION = '0.1.9'
4
4
 
5
5
  end
@@ -1,3 +1,4 @@
1
+ require 'modsvaskr/encoding'
1
2
  require 'modsvaskr/run_cmd'
2
3
 
3
4
  module Modsvaskr
@@ -47,6 +48,17 @@ module Modsvaskr
47
48
  end
48
49
  end
49
50
 
51
+ # Parse a CSV that has been dumped by a previous run of xEdit
52
+ #
53
+ # Parameters::
54
+ # * *csv* (String): Name of the CSV file (from Edit Scripts), without .csv
55
+ # * *row_block* (Proc): Code called for each CSV row
56
+ # Parameters::
57
+ # * *row* (Array<String>): CSV row
58
+ def parse_csv(csv, &row_block)
59
+ CSV.parse(Encoding.to_utf8(File.read("#{install_path}/Edit Scripts/#{csv}.csv", mode: 'rb'))).each(&row_block)
60
+ end
61
+
50
62
  end
51
63
 
52
64
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modsvaskr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-20 00:00:00.000000000 Z
11
+ date: 2021-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses_menu
@@ -104,9 +104,11 @@ extra_rdoc_files: []
104
104
  files:
105
105
  - bin/modsvaskr
106
106
  - lib/modsvaskr/config.rb
107
+ - lib/modsvaskr/encoding.rb
107
108
  - lib/modsvaskr/game.rb
108
109
  - lib/modsvaskr/games/skyrim_se.rb
109
110
  - lib/modsvaskr/in_game_tests_runner.rb
111
+ - lib/modsvaskr/in_game_tests_suite.rb
110
112
  - lib/modsvaskr/logger.rb
111
113
  - lib/modsvaskr/run_cmd.rb
112
114
  - lib/modsvaskr/tests_runner.rb