makit 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/lib/makit/apache.rb +32 -32
  3. data/lib/makit/cli/clean.rb +14 -14
  4. data/lib/makit/cli/clone.rb +59 -59
  5. data/lib/makit/cli/init.rb +38 -38
  6. data/lib/makit/cli/main.rb +33 -33
  7. data/lib/makit/cli/make.rb +54 -54
  8. data/lib/makit/cli/new.rb +37 -37
  9. data/lib/makit/cli/nuget_cache.rb +38 -38
  10. data/lib/makit/cli/pull.rb +31 -31
  11. data/lib/makit/cli/setup.rb +71 -71
  12. data/lib/makit/cli/work.rb +21 -21
  13. data/lib/makit/command_runner.rb +318 -237
  14. data/lib/makit/commands.rb +21 -21
  15. data/lib/makit/content/default_gitignore.rb +5 -5
  16. data/lib/makit/content/default_rakefile.rb +11 -11
  17. data/lib/makit/content/gem_rakefile.rb +14 -14
  18. data/lib/makit/data.rb +50 -50
  19. data/lib/makit/directories.rb +140 -140
  20. data/lib/makit/directory.rb +153 -120
  21. data/lib/makit/dotnet.rb +83 -75
  22. data/lib/makit/environment.rb +123 -123
  23. data/lib/makit/files.rb +47 -47
  24. data/lib/makit/git.rb +66 -66
  25. data/lib/makit/gitlab_runner.rb +60 -60
  26. data/lib/makit/humanize.rb +89 -89
  27. data/lib/makit/logging.rb +96 -96
  28. data/lib/makit/markdown.rb +75 -75
  29. data/lib/makit/mp/basic_object_mp.rb +16 -16
  30. data/lib/makit/mp/command_request.mp.rb +13 -0
  31. data/lib/makit/mp/project_mp.rb +156 -149
  32. data/lib/makit/mp/string_mp.rb +107 -101
  33. data/lib/makit/nuget.rb +57 -57
  34. data/lib/makit/protoc.rb +61 -61
  35. data/lib/makit/serializer.rb +115 -70
  36. data/lib/makit/storage.rb +131 -131
  37. data/lib/makit/symbols.rb +149 -149
  38. data/lib/makit/tasks.rb +67 -67
  39. data/lib/makit/tree.rb +37 -37
  40. data/lib/makit/v1/makit.v1_pb.rb +5 -5
  41. data/lib/makit/v1/makit.v1_services_pb.rb +25 -25
  42. data/lib/makit/version.rb +12 -12
  43. data/lib/makit/wix.rb +95 -95
  44. data/lib/makit/zip.rb +17 -17
  45. data/lib/makit.rb +243 -243
  46. metadata +4 -39
  47. data/.makit.project.json +0 -4
  48. data/.makit.project.yml +0 -2
  49. data/.rubocop.yml +0 -22
  50. data/.ruby-version +0 -1
  51. data/CHANGELOG.md +0 -8
  52. data/CODE_OF_CONDUCT.md +0 -84
  53. data/LICENSE +0 -21
  54. data/README.md +0 -119
  55. data/Rakefile +0 -200
  56. data/docs/Commands.md +0 -50
  57. data/docs_/Commands.md +0 -166
  58. data/docs_/Minitest.Timeouts.md +0 -332
  59. data/examples/protoc/Rakefile +0 -31
  60. data/examples/rake_default/Rakefile +0 -6
  61. data/examples/rubygem-foo/.gitkeep +0 -0
  62. data/examples/rubygem-foo/Rakefile +0 -3
  63. data/examples/run_mp/Rakefile +0 -8
  64. data/exe/makit +0 -5
  65. data/lib/makit/content/default_gitignore.txt +0 -222
  66. data/lib/makit/content/ruby_gitlab-ci.yml +0 -15
  67. data/lib/makit/v1/makit.v1.proto +0 -103
  68. data/makit.generated.sln +0 -30
  69. data/makit.sln +0 -69
  70. data/pages/.gitignore +0 -5
  71. data/pages/404.html +0 -25
  72. data/pages/Gemfile +0 -33
  73. data/pages/Gemfile.lock +0 -88
  74. data/pages/_config.yml +0 -55
  75. data/pages/_layouts/default.html +0 -1
  76. data/pages/_posts/2024-10-05-welcome-to-jekyll.markdown +0 -29
  77. data/pages/about.markdown +0 -18
  78. data/pages/index.markdown +0 -6
  79. data/sig/makit.rbs +0 -4
  80. data/src/ClassLib/Class1.cs +0 -6
  81. data/src/ClassLib/ClassLib.csproj +0 -13
@@ -1,332 +0,0 @@
1
- ### **Setting Timeouts on Minitest Tests**
2
-
3
- To ensure that your tests do not run indefinitely or take too long, you can set timeouts on your Minitest tests. This is particularly useful for catching hanging tests or identifying performance issues.
4
-
5
- There are several ways to set timeouts in Minitest:
6
-
7
- 1. **Using Ruby's `Timeout` Module**
8
- 2. **Using the `minitest-timeout` Gem**
9
- 3. **Using Custom Assertions**
10
-
11
- ---
12
-
13
- #### **1. Using Ruby's `Timeout` Module**
14
-
15
- The standard Ruby library provides a `Timeout` module that can be used to limit the execution time of code blocks.
16
-
17
- **Example:**
18
-
19
- ```ruby
20
- require 'minitest/autorun'
21
- require 'timeout'
22
-
23
- class MyTest < Minitest::Test
24
- def test_with_timeout
25
- Timeout.timeout(5) do
26
- # Test code that should complete within 5 seconds
27
- long_running_operation
28
- end
29
- rescue Timeout::Error
30
- flunk "Test exceeded time limit and was aborted."
31
- end
32
-
33
- private
34
-
35
- def long_running_operation
36
- sleep 10 # Simulates a long-running operation
37
- end
38
- end
39
- ```
40
-
41
- **Explanation:**
42
-
43
- - **`Timeout.timeout(5) do ... end`**: Executes the block and raises a `Timeout::Error` if it takes more than 5 seconds.
44
- - **Rescuing `Timeout::Error`**: Captures the timeout exception and marks the test as failed using `flunk`.
45
-
46
- **Caveats:**
47
-
48
- - The `Timeout` module uses threads to interrupt the execution, which can be unsafe for certain operations, especially IO operations or code that is not thread-safe.
49
- - Using `Timeout` can sometimes lead to unexpected behavior or hard-to-debug issues due to the abrupt interruption.
50
-
51
- ---
52
-
53
- #### **2. Using the `minitest-timeout` Gem**
54
-
55
- The `minitest-timeout` gem provides a cleaner and safer way to set timeouts on tests.
56
-
57
- **Installation:**
58
-
59
- Add the gem to your `Gemfile`:
60
-
61
- ```ruby
62
- gem 'minitest-timeout'
63
- ```
64
-
65
- Then run:
66
-
67
- ```bash
68
- bundle install
69
- ```
70
-
71
- **Usage:**
72
-
73
- ```ruby
74
- # test/test_helper.rb
75
-
76
- require 'minitest/autorun'
77
- require 'minitest/timeout'
78
-
79
- # Set a default timeout for all tests (optional)
80
- Minitest::Timeout.timeout = 5 # seconds
81
- ```
82
-
83
- ```ruby
84
- # test/my_test.rb
85
-
86
- require_relative 'test_helper'
87
-
88
- class MyTest < Minitest::Test
89
- timeout 5 # seconds
90
-
91
- def test_long_running_operation
92
- # This test will fail if it runs longer than 5 seconds
93
- long_running_operation
94
- end
95
-
96
- def test_another_operation
97
- # Override timeout for a specific test
98
- timeout(2)
99
- another_long_running_operation
100
- end
101
-
102
- private
103
-
104
- def long_running_operation
105
- sleep 10
106
- end
107
-
108
- def another_long_running_operation
109
- sleep 3
110
- end
111
- end
112
- ```
113
-
114
- **Explanation:**
115
-
116
- - **`timeout 5` at the class level**: Sets a default timeout of 5 seconds for all tests in the class.
117
- - **`timeout(2)` in a test method**: Overrides the timeout for that specific test.
118
- - **Global Timeout**: You can set a global timeout in the `test_helper.rb` that applies to all tests.
119
-
120
- **Benefits:**
121
-
122
- - **Safe Execution**: The gem ensures that the timeout is handled safely without the drawbacks of the `Timeout` module.
123
- - **Easy Configuration**: Allows setting timeouts at the test, class, or global level.
124
- - **Consistent Behavior**: Provides consistent behavior across different types of tests.
125
-
126
- ---
127
-
128
- #### **3. Using Custom Assertions**
129
-
130
- You can create a custom assertion to check the execution time of your tests.
131
-
132
- **Example:**
133
-
134
- ```ruby
135
- require 'minitest/autorun'
136
-
137
- class MyTest < Minitest::Test
138
- def test_with_custom_timeout
139
- assert_execution_time 5 do
140
- long_running_operation
141
- end
142
- end
143
-
144
- private
145
-
146
- def assert_execution_time(max_seconds, &block)
147
- start_time = Time.now
148
- yield
149
- end_time = Time.now
150
- execution_time = end_time - start_time
151
- assert execution_time <= max_seconds, "Expected execution time to be less than #{max_seconds}s, but was #{execution_time.round(2)}s"
152
- end
153
-
154
- def long_running_operation
155
- sleep 10
156
- end
157
- end
158
- ```
159
-
160
- **Explanation:**
161
-
162
- - **`assert_execution_time`**: A custom assertion method that measures the time taken to execute a block.
163
- - **Usage**: Wrap the code you want to time within the `assert_execution_time` block.
164
- - **Assertion**: Fails the test if the execution time exceeds the specified maximum.
165
-
166
- **Caveats:**
167
-
168
- - This method doesn't interrupt the test if it exceeds the time limit; it only checks after the fact.
169
- - Not suitable if you need to abort the test execution upon exceeding the time limit.
170
-
171
- ---
172
-
173
- ### **Recommendations**
174
-
175
- For most use cases, using the `minitest-timeout` gem is the most effective and safest way to set timeouts on your Minitest tests.
176
-
177
- ---
178
-
179
- ### **Implementing Timeouts in Your Task**
180
-
181
- Given your existing test setup, here's how you might integrate timeouts.
182
-
183
- **Step 1: Install `minitest-timeout` Gem**
184
-
185
- Add to your `Gemfile`:
186
-
187
- ```ruby
188
- gem 'minitest-timeout'
189
- ```
190
-
191
- Run:
192
-
193
- ```bash
194
- bundle install
195
- ```
196
-
197
- **Step 2: Configure Timeout in `test_helper.rb`**
198
-
199
- Create or update your `test_helper.rb`:
200
-
201
- ```ruby
202
- # test/test_helper.rb
203
-
204
- require 'minitest/autorun'
205
- require 'minitest/timeout'
206
-
207
- # Set a global timeout for all tests (e.g., 10 seconds)
208
- Minitest::Timeout.timeout = 10
209
- ```
210
-
211
- **Step 3: Update Your Tests**
212
-
213
- In your test files, you can set timeouts as needed.
214
-
215
- ```ruby
216
- require_relative 'test_helper'
217
-
218
- class WixTest < Minitest::Test
219
- # Set a class-level timeout (overrides global timeout)
220
- timeout 15
221
-
222
- def test_setup_package
223
- # Individual test code
224
- end
225
-
226
- def test_another_method
227
- # Override timeout for this test
228
- timeout(5)
229
- # Test code
230
- end
231
- end
232
- ```
233
-
234
- **Step 4: Run Your Tests**
235
-
236
- Run your tests as usual, and they will fail if any test exceeds the specified timeout.
237
-
238
- ---
239
-
240
- ### **Handling Timeout Failures**
241
-
242
- When a test exceeds the timeout, it will fail with a message indicating that the execution time was exceeded.
243
-
244
- **Example Failure Message:**
245
-
246
- ```
247
- Minitest::Timeout::Error: execution of test took longer than 5 seconds.
248
- ```
249
-
250
- You can handle or customize this behavior if needed.
251
-
252
- ---
253
-
254
- ### **Caveats and Considerations**
255
-
256
- - **Long-Running Setup or Teardown:** If you have setup or teardown methods that might exceed the timeout, consider adjusting the timeout or refactoring the setup code.
257
- - **Thread Safety:** Ensure that your code is thread-safe, especially when using gems that manage timeouts internally.
258
- - **Debugging Timeouts:** If tests fail due to timeouts, investigate whether the code under test is inefficient, has infinite loops, or is waiting on external resources.
259
-
260
- ---
261
-
262
- ### **Alternative Approaches**
263
-
264
- If you prefer not to use external gems, or if you need more control over the timeout behavior, consider the following:
265
-
266
- #### **Using `Timeout` Module with Care**
267
-
268
- While the `Timeout` module can be problematic, it may be acceptable for simple tests.
269
-
270
- **Example:**
271
-
272
- ```ruby
273
- def test_with_timeout
274
- status = :passed
275
- begin
276
- Timeout.timeout(5) do
277
- long_running_operation
278
- end
279
- rescue Timeout::Error
280
- status = :failed
281
- end
282
- assert_equal :passed, status, "Test exceeded time limit and was aborted."
283
- end
284
- ```
285
-
286
- #### **Process Forking**
287
-
288
- For tests that may hang due to external resources or blocking IO, running tests in separate processes can prevent them from affecting the main test suite.
289
-
290
- **Example:**
291
-
292
- ```ruby
293
- def test_with_fork_and_timeout
294
- pid = fork do
295
- long_running_operation
296
- end
297
- begin
298
- Timeout.timeout(5) do
299
- Process.wait(pid)
300
- end
301
- rescue Timeout::Error
302
- Process.kill('TERM', pid)
303
- flunk "Test exceeded time limit and was aborted."
304
- end
305
- end
306
- ```
307
-
308
- **Note:** Process forking is not available on Windows platforms.
309
-
310
- ---
311
-
312
- ### **Conclusion**
313
-
314
- Setting timeouts on your Minitest tests helps ensure that they complete within expected time frames and aids in identifying performance issues or hanging tests. By using the `minitest-timeout` gem, you can easily integrate timeouts into your existing test suite with minimal changes.
315
-
316
- ---
317
-
318
- ### **References**
319
-
320
- - [minitest-timeout GitHub Repository](https://github.com/kamui/minitest-timeout)
321
- - [Ruby Timeout Module Documentation](https://ruby-doc.org/stdlib-2.7.0/libdoc/timeout/rdoc/Timeout.html)
322
- - [Minitest Documentation](https://github.com/seattlerb/minitest)
323
-
324
- ---
325
-
326
- ### **Additional Tips**
327
-
328
- - **Monitoring Test Performance:** Regularly monitor your test suite's performance to catch any tests that are consistently close to the timeout limit.
329
- - **CI/CD Integration:** Ensure that timeouts are appropriately set in continuous integration environments, where resources may differ from local development machines.
330
- - **Adjusting Timeouts:** Be cautious not to set timeouts too low, which could cause false negatives due to variations in execution time.
331
-
332
- By implementing timeouts effectively, you enhance the reliability and efficiency of your test suite.
@@ -1,31 +0,0 @@
1
- require_relative "../../lib/makit"
2
- #require "makit"
3
-
4
- task :setup do
5
- # setup the protoc environment
6
- Makit::Protoc::setup
7
-
8
- # copy the makit.v1.proto file to the current directory
9
- FileUtils.cp(File.join("../../lib/makit/v1", "makit.v1.proto"), ".")
10
-
11
- # create the artifacts directory
12
- FileUtils.mkdir_p("artifacts") unless Dir.exist?("artifacts")
13
- end
14
-
15
- task :generate => [:setup] do
16
- puts ":generate".colorize(:blue)
17
-
18
- puts " generating code from makit.v1.proto".colorize(:green)
19
- "protoc -I . --ruby_out=artifacts makit.v1.proto".run
20
- #"grpc_tools_ruby_protoc -I . --ruby_out=artifacts --grpc_out=artifacts makit.v1.proto".run
21
- end
22
-
23
- task :test do
24
- runner = Makit::CommandRunner.new
25
- command = runner.run(runner.parse_command_request("git --version"))
26
-
27
- puts "command type: #{command.class}"
28
- puts "command proto name: #{command.name}"
29
- end
30
-
31
- task :default => [:setup, :generate]
@@ -1,6 +0,0 @@
1
- require "makit"
2
-
3
- task :default do
4
- puts "default task"
5
- Makit::PROJECT.save_as(".makit.project.json") unless File.exist?(".makit.project.json")
6
- end
File without changes
@@ -1,3 +0,0 @@
1
- require_relative "../../lib/makit"
2
-
3
- task :default
@@ -1,8 +0,0 @@
1
- require "makit"
2
-
3
- task :default do
4
- "git --version".run
5
- "bogus --version".run({ exit_on_error: false })
6
- "docker --version".run({ exit_on_error: false })
7
- "makit --version".run({ exit_on_error: false })
8
- end
data/exe/makit DELETED
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "makit"
5
- Makit::Cli::MainCommand.run(ARGV)
@@ -1,222 +0,0 @@
1
- # General
2
- [Aa]rtifacts/
3
- [Ii]ntermediate/
4
- [Gg]enerated/
5
- third_party/
6
-
7
- # Ruby
8
- *.gem
9
- *.rbc
10
- /.config
11
- /coverage/
12
- /InstalledFiles
13
- /pkg/
14
- /spec/reports/
15
- /spec/examples.txt
16
- /test/tmp/
17
- /test/version_tmp/
18
- /tmp/
19
- /.yardoc/
20
- /_yardoc/
21
- /doc/
22
- /rdoc/
23
- /.bundle/
24
- /vendor/bundle
25
- /lib/bundler/man/
26
- .rvmrc
27
-
28
- # Rust
29
- /target/
30
- Cargo.lock
31
- **/*.rs.bk
32
- /target
33
- /Cargo.lock
34
-
35
- # DotNet
36
- *.rsuser
37
- *.suo
38
- *.user
39
- *.userosscache
40
- *.sln.docstates
41
- *.txt
42
- *.userprefs
43
- BenchmarkDotNet.Artifacts/
44
- [Dd]ebug/
45
- [Dd]ebugPublic/
46
- [Rr]elease/
47
- [Rr]eleases/
48
- x64/
49
- x86/
50
- [Aa][Rr][Mm]/
51
- [Aa][Rr][Mm]64/
52
- bld/
53
- [Bb]in/
54
- [Oo]bj/
55
- [Ll]og/
56
- [Aa]rtifacts/
57
- .vs/
58
- Generated\ Files/
59
- [Tt]est[Rr]esult*/
60
- [Bb]uild[Ll]og.*
61
- *.VisualState.xml
62
- TestResult.xml
63
- [Dd]ebugPS/
64
- [Rr]eleasePS/
65
- dlldata.c
66
- BenchmarkDotNet.Artifacts/
67
-
68
- project.lock.json
69
- project.fragment.lock.json
70
- artifacts/
71
- StyleCopReport.xml
72
- *_i.c
73
- *_p.c
74
- *_h.h
75
- *.ilk
76
- *.meta
77
- *.obj
78
- *.iobj
79
- *.pch
80
- *.pdb
81
- *.ipdb
82
- *.pgc
83
- *.pgd
84
- *.rsp
85
- *.sbr
86
- *.tlb
87
- *.tli
88
- *.tlh
89
- *.tmp
90
- *.tmp_proj
91
- *_wpftmp.csproj
92
- *.log
93
- *.vspscc
94
- *.vssscc
95
- .builds
96
- *.pidb
97
- *.svclog
98
- *.scc
99
- _Chutzpah*
100
- ipch/
101
- *.aps
102
- *.ncb
103
- *.opendb
104
- *.opensdf
105
- *.sdf
106
- *.cachefile
107
- *.VC.db
108
- *.VC.VC.opendb
109
- *.psess
110
- *.vsp
111
- *.vspx
112
- *.sap
113
- *.e2e
114
- $tf/
115
- *.gpState
116
- _ReSharper*/
117
- *.[Rr]e[Ss]harper
118
- *.DotSettings.user
119
- .JustCode
120
- _TeamCity*
121
- *.dotCover
122
- .axoCover/*
123
- !.axoCover/settings.json
124
- *.coverage
125
- *.coveragexml
126
- _NCrunch_*
127
- .*crunch*.local.xml
128
- nCrunchTemp_*
129
- *.mm.*
130
- AutoTest.Net/
131
- .sass-cache/
132
- [Ee]xpress/
133
- DocProject/buildhelp/
134
- DocProject/Help/*.HxT
135
- DocProject/Help/*.HxC
136
- DocProject/Help/*.hhc
137
- DocProject/Help/*.hhk
138
- DocProject/Help/*.hhp
139
- DocProject/Help/Html2
140
- DocProject/Help/html
141
- publish/
142
- *.[Pp]ublish.xml
143
- *.azurePubxml
144
- *.pubxml
145
- *.publishproj
146
- PublishScripts/
147
- *.nupkg
148
- **/[Pp]ackages/*
149
- !**/[Pp]ackages/build/
150
- *.nuget.props
151
- *.nuget.targets
152
- csx/
153
- *.build.csdef
154
- ecf/
155
- rcf/
156
- AppPackages/
157
- BundleArtifacts/
158
- Package.StoreAssociation.xml
159
- _pkginfo.txt
160
- *.appx
161
- *.[Cc]ache
162
- # but keep track of directories ending in .cache
163
- !*.[Cc]ache/
164
- ClientBin/
165
- ~$*
166
- *~
167
- *.dbmdl
168
- *.dbproj.schemaview
169
- *.jfm
170
- *.pfx
171
- *.publishsettings
172
- orleans.codegen.cs
173
- **/wwwroot/lib/
174
- Generated_Code/
175
- _UpgradeReport_Files/
176
- Backup*/
177
- UpgradeLog*.XML
178
- UpgradeLog*.htm
179
- ServiceFabricBackup/
180
- *.rptproj.bak
181
- *.mdf
182
- *.ldf
183
- *.ndf
184
- *.rdl.data
185
- *.bim.layout
186
- *.bim_*.settings
187
- *.rptproj.rsuser
188
- FakesAssemblies/
189
- *.GhostDoc.xml
190
- .ntvs_analysis.dat
191
- node_modules/
192
- *.plg
193
- *.opt
194
- *.vbw
195
- **/*.HTMLClient/GeneratedArtifacts
196
- **/*.DesktopClient/GeneratedArtifacts
197
- **/*.DesktopClient/ModelManifest.xml
198
- **/*.Server/GeneratedArtifacts
199
- **/*.Server/ModelManifest.xml
200
- _Pvt_Extensions
201
- .paket/paket.exe
202
- paket-files/
203
- .fake/
204
- .idea/
205
- *.sln.iml
206
- .cr/personal
207
- __pycache__/
208
- *.pyc
209
- tools/**
210
- !tools/packages.config
211
- *.tss
212
- *.jmconfig
213
- *.btp.cs
214
- *.btm.cs
215
- *.odx.cs
216
- *.xsd.cs
217
- OpenCover/
218
- ASALocalRun/
219
- *.binlog
220
- *.nvuser
221
- .mfractor/
222
- .localhistory/
@@ -1,15 +0,0 @@
1
- image: image: ruby:3.2.3
2
-
3
- before_script:
4
- - pwd
5
- - git --version
6
- - ruby --version
7
- - gem install rake bundler
8
- - rake --version
9
- - gem install bundler -v 2.5.10
10
- - bundle install
11
-
12
- example_job:
13
- script:
14
- - ruby -r minitest/autorun test/test_makit.rb
15
- - bundle exec rake