bcpm 0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,133 @@
1
+ v0.11. Added pit command.
2
+
3
+ v0.10.20. Teams are sorted when dueling.
4
+
5
+ v0.10.19. Added vm_ram config flag.
6
+
7
+ v0.10.18. Bugfix in rank command.
8
+
9
+ v0.10.17. Added rank command.
10
+
11
+ v0.10.16. Bugfixes in testcase and livecase.
12
+
13
+ v0.10.15. Bugfix in replay.
14
+
15
+ v0.10.14. Duel output improvements.
16
+
17
+ v0.10.13. Added duel_threads config flag and multi-threaded dueling.
18
+
19
+ v0.10.12. More Athena git workarounds.
20
+
21
+ v0.10.11. Made copy support the install scenario.
22
+
23
+ v0.10.10. Workaround old Git on Athena.
24
+
25
+ v0.10.9. Athena bugfixes.
26
+
27
+ v0.10.8. Added duel command.
28
+
29
+ v0.10.7. Custom maps for testing.
30
+
31
+ v0.10.6. Added list.
32
+
33
+ v0.10.5. Added gen:off regen directive.
34
+
35
+ v0.10.4. Bugfix in rewire.
36
+
37
+ v0.10.3. Smarter variable replacement in regen.
38
+
39
+ v0.10.2. Testcase options can use friendlier symbols instead of battlecode engine strings.
40
+
41
+ v0.10.1. Bugfix in config on Ruby 1.8.
42
+
43
+ v0.10. Added regen command.
44
+
45
+ v0.9.16. Added debuglimit config variable.
46
+
47
+ v0.9.15. Added config command.
48
+
49
+ v0.9.14. Bugfix in rewire.
50
+
51
+ v0.9.13. Bugfix in replay.
52
+
53
+ v0.9.12. Added side in test description.
54
+
55
+ v0.9.11. Bugfix in should_throw assertion.
56
+
57
+ v0.9.10. client3d command.
58
+
59
+ v0.9.9. Switched to 2011 Battlecode distribution.
60
+
61
+ v0.9.8. reset command.
62
+
63
+ v0.9.7. Fixes for ruby1.9 and OSX.
64
+
65
+ v0.9.6. match_unit_output assertion.
66
+
67
+ v0.9.5. stub_call turned into stub_member_call and stub_static_call.
68
+
69
+ v0.9.4. Livematch command.
70
+
71
+ v0.9.3. Bugfix in should_not_throw assertion.
72
+
73
+ v0.9.2. Cleanup command.
74
+
75
+ v0.9.1. Guess current directory for player name in some commands.
76
+
77
+ v0.9. Player and tests go in one repository. Simplifies everything!
78
+
79
+ v0.8.9. Improved source code patching approach.
80
+
81
+ v0.8.8. Added .gitignore files to built-in templates.
82
+
83
+ v0.8.7. Bugfix in match output processing for live matches.
84
+
85
+ v0.8.6. Live match testcase option.
86
+
87
+ v0.8.5. Better handling of build errors.
88
+
89
+ v0.8.4. Unified output for match and test commands.
90
+
91
+ v0.8.3. Platform-specific text file open command.
92
+
93
+ v0.8.2. Built-in player & suite templates.
94
+
95
+ v0.8.1. Support for running a single test case.
96
+
97
+ v0.8. Self-update.
98
+
99
+ v0.7.4. Code fragment patching.
100
+
101
+ v0.7.3. Better handling of broken test cases.
102
+
103
+ v0.7.2. Windows compatibility.
104
+
105
+ v0.7.1. Fixed crashes due to invalid paths in test case directives.
106
+
107
+ v0.7. Player source patching.
108
+
109
+ v0.6.3. Bugfix in match replay.
110
+
111
+ v0.6.2. Battlecode options in tests.
112
+
113
+ v0.6.1. Short trace for failed tests.
114
+
115
+ v0.6. Match replay. Failed tests dump replay and output info, to aid debugging.
116
+
117
+ v0.5.3. Improved and bugfixed basic assertions.
118
+
119
+ v0.5.2. Match reuse for faster tests.
120
+
121
+ v0.5.1. Removed Ant garbage from output.
122
+
123
+ v0.5.0. Rudimentary test support.
124
+
125
+ v0.4.1. Configuration tweaks.
126
+
127
+ v0.4. Player templates.
128
+
129
+ v0.3. Runs matches automatically.
130
+
131
+ v0.2. Installs and player repositories.
132
+
133
+ v0.1. Pulls the battlecode distribution from git.
@@ -0,0 +1,23 @@
1
+ CHANGELOG
2
+ Manifest
3
+ README
4
+ Rakefile
5
+ bin/bcpm
6
+ lib/bcpm.rb
7
+ lib/bcpm/cleanup.rb
8
+ lib/bcpm/cli.rb
9
+ lib/bcpm/config.rb
10
+ lib/bcpm/dist.rb
11
+ lib/bcpm/duel.rb
12
+ lib/bcpm/git.rb
13
+ lib/bcpm/match.rb
14
+ lib/bcpm/player.rb
15
+ lib/bcpm/regen.rb
16
+ lib/bcpm/socket.rb
17
+ lib/bcpm/tests/assertion_error.rb
18
+ lib/bcpm/tests/assertions.rb
19
+ lib/bcpm/tests/case_base.rb
20
+ lib/bcpm/tests/environment.rb
21
+ lib/bcpm/tests/suite.rb
22
+ lib/bcpm/tests/test_match.rb
23
+ lib/bcpm/update.rb
data/README ADDED
@@ -0,0 +1,292 @@
1
+ Battlecode (MIT 6.470) package manager.
2
+
3
+ USAGE
4
+
5
+ 1. Make sure you're using the latest tool version.
6
+
7
+ bcpm self
8
+
9
+ 2. Install the Battlecode distribution. Later, use the same command to update the distribution.
10
+
11
+ bcpm dist
12
+
13
+ 3a. Check out a player repository and set it up for development.
14
+
15
+ cd ~/workspace # Your Eclipse workspace.
16
+ bcpm install git@git.pwnb.us:six370/yield.git
17
+
18
+ After executing the commands above, import the project into Eclipse
19
+ (File > Import > Existing Projects into Workspace).
20
+
21
+ 3b. Create a blank player.
22
+
23
+ bcpm new team1337
24
+
25
+ If you go this route, you will have to create the git repositories yourself, and push them.
26
+
27
+ 4. Confirm that the player is installed.
28
+
29
+ bcpm list
30
+ bcpm ls
31
+
32
+ 5a. Switch between the 2D and the 3D client.
33
+
34
+ bcpm set client3d on
35
+ bcpm set +client3d
36
+ bcpm set client3d off
37
+ bcpm set -client3d
38
+
39
+ 5b. Turn the client sound on or off.
40
+
41
+ bcpm set +sound
42
+ bcpm set -sound
43
+
44
+ 6. See all the maps in the distribution.
45
+
46
+ bcpm listmaps
47
+ bcpm lsmaps
48
+
49
+ 7. Run a game against some other player code.
50
+
51
+ bcpm match yield team000 venice
52
+
53
+ # The following command runs the match right away, for maximum enjoyment.
54
+ bcpm livematch yield team000 venice
55
+
56
+ 7b. Game too slow? Increase the JVM memory.
57
+
58
+ bcpm set vm_ram 1024
59
+
60
+ 8. Run a debugging game against some other player code. Debugging games us use bcpm configuration settings instead of production defaults.
61
+
62
+ bcpm debugmatch yield team000 venice
63
+
64
+ 9. Set the number of simultaneous matches. Match the number of physical cores you have.
65
+
66
+ bcpm set match_threads 2
67
+
68
+ 10a. Run a duel between 2 players on multiple maps.
69
+
70
+ bcpm duel yield team000
71
+
72
+ # The following command restricts the duel to a subset of maps.
73
+ bcpm duel yield team000 venice fortress
74
+
75
+ 10b. Pit a player against other players you have installed.
76
+
77
+ bcpm pit yield team000 team001
78
+
79
+ # The following pits against all other installed players.
80
+ bcpm pit yield
81
+
82
+ 10c. Rank players by their total scores in all possible pairwise duels.
83
+
84
+ bcpm rank yield team000 team001
85
+
86
+ # The following ranks all installed players.
87
+ bcpm rank
88
+
89
+ 11a. Show all settings.
90
+
91
+ bcpm config
92
+
93
+ 11b. Change debugging settings
94
+
95
+ bcpm set +noupkeep
96
+ bcpm set -noupkeep
97
+ bcpm set +debugcode
98
+ bcpm set -debugcode
99
+ bcpm set +breakpoints
100
+ bcpm set -breakpoints
101
+ bcpm set debuglimit 1000000 # Maximum number of bytecodes per round in debug_ methods.
102
+
103
+ 12. Run the player's test suite.
104
+
105
+ bcpm test yield
106
+
107
+ 13. Run a single test case in the player's test suite.
108
+
109
+ bcpm case yield win_vs_yield
110
+
111
+ # The following command runs the first match right away, for maximum iterating speed.
112
+ bcpm livecase yield win_vs_yield
113
+
114
+ 14. Replay the last match ran in a test.
115
+
116
+ bcpm replay
117
+
118
+ 15. Copy a distribution map into the test suite, for customization.
119
+
120
+ bcpm copymap venice
121
+
122
+ 16. Remove the installed player. (removing the project folder is not enough!)
123
+
124
+ bcpm uninstall yield
125
+
126
+ 17. Create a new player from an existing template.
127
+
128
+ bcpm copy myplayer git@git.pwnb.us:six370/yield.git
129
+ bcpm copy myplayer git@git.pwnb.us:six370/yield.git branch_or_tag_name
130
+
131
+ You'll need to import the project into Eclipse, and setup a git repository for the player.
132
+
133
+ 18. If bcpm crashes or you abort it, you'll need to clean up the temporaries left behind.
134
+
135
+ bcpm clean
136
+
137
+ 19. Use directed find/replace to unroll loops.
138
+
139
+ bcpm regen bcpm regen src/yield/test/stubs/LoggingStubs.java
140
+
141
+ 20. After winning the competition, remove the players and distribution. Commit and push first!
142
+
143
+ bcpm reset
144
+
145
+
146
+ TESTING
147
+
148
+ The test cases are .rb (Ruby) files in the 'suite' directory. The following example showcases the
149
+ functionality available in a test suite. The suite DSL slightly resembles rspec.
150
+
151
+ # Set the side of the tested player in future matches.
152
+ side :b
153
+
154
+ # Set the opponent for future matches.
155
+ vs 'yield'
156
+
157
+ # Set the map for future matches.
158
+ map 'venice'
159
+
160
+ # Use a custom map from suite/maps.
161
+ suite_map 'venice2'
162
+
163
+ # Disable energon draining. :upkeep is a synonym for 'bc.engine.upkeep'.
164
+ option :upkeep, false
165
+
166
+ # Replace a .java file in the player under test with a .java file in the test suite.
167
+ # Both names are automatically prefixed with the team package ('yield.' in this case).
168
+ replace_class 'RobotPlayer', 'test.players.TestRobotPlayer'
169
+
170
+ # Re-route all calls that look like target.canMove(...) to
171
+ # yield.test.stubs.LoggingStubs.canMoveStub(target, ...)
172
+ stub_member_call 'canMove', 'test.stubs.LoggingStubs.canMoveStub'
173
+
174
+ # Re-route all calls that look like target.wantStubbing(...) to
175
+ # yield.test.stubs.LoggingStubs.wantStubbingStub(...)
176
+ stub_static_call 'wantStubbing', 'test.stubs.LoggingStubs.wantStubbingStub'
177
+
178
+ # Replace the code marked with Stubs.canMove.logo in yield.LoggingStubs with the code marked
179
+ # Stubs.canMove.logoSource in yield.test.stubs.LoggingStubs
180
+ replace_code 'LoggingStubs', 'Stubs.canMove.logo',
181
+ 'test.stubs.LoggingStubs', 'Stubs.canMove.logoSource'
182
+
183
+ # Run a test match to check some conditions.
184
+ match do
185
+ it 'must win in any way' do
186
+ should_win
187
+ end
188
+
189
+ it "shouldn't leak exceptions" do
190
+ should_not_throw
191
+ end
192
+
193
+ it 'should stub the member call' do
194
+ should_match_unit_output(/This should show up/)
195
+ end
196
+
197
+ it 'should stub the static call' do
198
+ should_match_unit_output(/wantStubbing\: this (.*) be printed/) do |unit, match|
199
+ fail 'Static call not stubbed' unless match[1] == 'should'
200
+ end
201
+ end
202
+
203
+ it 'should fail' do
204
+ fail
205
+ end
206
+ end
207
+
208
+ # Reset energon draining option to its default value.
209
+ option 'bc.engine.upkeep', nil
210
+
211
+ To prevent infinite recursion, stubbing should be disabled in the actual stubs. To prevent
212
+ compilation errors, stubbing should also be disabled on the first line of the stubbed method's
213
+ definition. The stub implementation below demonstrates the syntax for stubbing and code replacement.
214
+
215
+ package yield.test.stubs;
216
+
217
+ import battlecode.common.Direction;
218
+ import battlecode.common.RobotController;
219
+
220
+ public class LoggingStubs {
221
+ //$ -stubs
222
+ public static final boolean canMoveStub(RobotController target, Direction where) {
223
+ boolean returnValue = target.canMove(where);
224
+ //$ +mark: Stubs.canMove.logo
225
+ System.out.println("This should not show up");
226
+ //$ -mark: Stubs.canMove.logo
227
+ System.out.println("canMove(" + where.toString() + ") -> " + returnValue);
228
+ return returnValue;
229
+ }
230
+ //$ +stubs
231
+
232
+ public static void markTest() {
233
+ //$ +mark: Stubs.canMove.logoSource
234
+ System.out.println("This should show up");
235
+ //$ -mark: Stubs.canMove.logoSource
236
+ }
237
+ }
238
+
239
+ The code patching directives use very simple implementations based on file copying and regular
240
+ expressions. Following these best practices should help avoid broken builds:
241
+
242
+ * Use Eclipse's "Organize imports" feature to achieve the item below:
243
+ * Class names should be unqualified, and imports should use fully qualified names.
244
+ * Use the same class name (but different package names) in replace_class.
245
+ * A replace_class source class should only depend on classes in other packages.
246
+
247
+
248
+ DIRECTED FIND/REPLACE
249
+
250
+ bcpm regen reads one or more source files and discovers tagged source blocks, then replaces matching
251
+ target blocks while renaming tokens. The example below shows the syntax.
252
+
253
+ System.out.print("Should show numbers 1-3 and letters A-C: ");
254
+ //$ +gen:source Numbers A 1
255
+ System.out.print("A 1 ");
256
+ //$ +gen:off
257
+ // This used to be System.out.print("A 1");
258
+ //$ -gen:off
259
+ //$ -gen:source
260
+ //$ +gen:target Numbers B 2
261
+ //$ -gen:target
262
+ //$ +gen:target Numbers C 3
263
+ System.out.print("A 1 ");
264
+ //$ -gen:target
265
+
266
+
267
+ INSTALLATION
268
+
269
+ On Ubuntu:
270
+
271
+ sudo apt-get install ruby-full rubygems
272
+ sudo gem install rubygems-update
273
+ sudo `gem env | grep 'EXECUTABLE DIRECTORY' | ruby -e "puts gets.split(': ', 2).last"`/update_rubygems
274
+
275
+ On OSX:
276
+
277
+ Get git from http://code.google.com/p/git-osx-installer/
278
+
279
+ On Windows 7+:
280
+
281
+ Get git from http://code.google.com/p/msysgit/downloads/
282
+ Get ruby 1.8.7 (add it to your path) from http://rubyinstaller.org/downloads/
283
+ Get ant from http://code.google.com/p/winant/
284
+
285
+ On everything (skip the 'sudo' prefix on Windows though):
286
+
287
+ sudo gem install rake echoe
288
+ git clone git@git.pwnb.us:six370/bcpm.git
289
+ cd bcpm
290
+ rake install
291
+
292
+ You'll need an administrative shell on Windows.
@@ -0,0 +1,23 @@
1
+ require 'rubygems'
2
+ require 'echoe'
3
+
4
+ Echoe.new('bcpm') do |p|
5
+ p.project = 'bcpm' # rubyforge project
6
+
7
+ p.author = 'Victor Costan'
8
+ p.email = 'victor@costan.us'
9
+ p.summary = 'Battlecode (MIT 6.370) package manager.'
10
+ p.url = 'http://git.pwnb.us/six370'
11
+ p.dependencies = []
12
+ p.development_dependencies = ['echoe >=3.2']
13
+
14
+ p.need_tar_gz = !Gem.win_platform?
15
+ p.need_zip = !Gem.win_platform?
16
+ p.rdoc_pattern =
17
+ /^(lib|bin|tasks|ext)|^BUILD|^README|^CHANGELOG|^TODO|^LICENSE|^COPYING$/
18
+ end
19
+
20
+ if $0 == __FILE__
21
+ Rake.application = Rake::Application.new
22
+ Rake.application.run
23
+ end