require 'fileutils' require 'ostruct' require 'P4' #------------------------------------------------------------------------------ # Configuration #------------------------------------------------------------------------------ # Make sure everything Sinatra is in test mode ENV['RACK_ENV'] = 'test' P4PORT = ENV['P4PORT'] || 'localhost:1666' TMP_FOLDER = File.absolute_path('/tmp/clients', __FILE__) DELETE_CLIENT = !ENV.key?('KEEP_WORKSPACES') CHARSET = ENV['P4CHARSET'] || 'auto' JDOE_USER = 'jdoe' JDOE_PASSWORD = 'johndoe1A!' # This is fairly special configuration for using rack-test # Most apps are tricky to test via mocking. We load the full stack. require 'rspec' require 'rack/test' CONFIG_RU = File.absolute_path('../../config.ru', __FILE__) HELIX_WEB_SERVICES_APP = Rack::Builder.parse_file(CONFIG_RU).first #------------------------------------------------------------------------------ # Helpers #------------------------------------------------------------------------------ # These methods allow you to create temporary clients, etc. for tests that # work with lower-level (i.e. service) objects # # For most methods that interact with the HTTP API, you won't need these. def p4_as_jdoe p4 = P4.new # Make P4Ruby only raise exceptions if there are errors. Warnings # (such as 'no such file(s)' don't get the same treatment. p4.exception_level = P4::RAISE_ERRORS p4.port = P4PORT p4.user = JDOE_USER p4.password = JDOE_PASSWORD p4.charset = CHARSET unless CHARSET.nil? || CHARSET == 'none' p4.connect p4.run_login yield p4 ensure p4.disconnect end def temp_client_as_jdoe(&block) p4_as_jdoe do |p4| unless Dir.exists?(TMP_FOLDER) FileUtils.makedirs(TMP_FOLDER) end name = (0...8).map { (65 + rand(26)).chr }.join root = File.join(TMP_FOLDER, name) Dir.mkdir(root) spec = p4.fetch_client spec._root = root spec._client = name spec._description = 'test client' spec._view = [ "//depot/... //#{name}/depot/...", "//.projects/... //#{name}/.projects/..." ] p4.save_client(spec) p4.client = name p4.run_sync('//...') block.call(p4, root) if DELETE_CLIENT p4.run_client('-d', '-f', name) FileUtils.rmtree(root) end end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#9 | 15622 | tjuricek |
Move source code to 'source/' subdirectory of branch. build/ will remain where it is. |
||
#8 | 15205 | tjuricek | Implemented tests and documentation for depot spec editing. | ||
#7 | 15147 | tjuricek |
Enable submissions by files on stream clients This obeys our earlier rules: notably the local client must not have any local files open for edit. |
||
#6 | 15132 | tjuricek | Provde a basic submit -e mechanism on classic perforce workspaces. | ||
#5 | 15114 | tjuricek | While I'm seeing ticket's files generated for the 'super' user, it's possible that this login in the test suite has 'enabled it's usage'. | ||
#4 | 15110 | tjuricek | Revise changes methods for new p4 connection handling, add server specs, remove model references in client, and update asciidoc documentation. | ||
#3 | 15077 | tjuricek |
Add new 'model' technique, revised branch spec operations, test Auth::Middleware. The Ruby client now does *not* strictly type anything, but extends OpenStruct with helper methods to help deal with inconsistent data formats. See the OpenModel class documentation for more details. The Auth::Middleware class is also *finally* implemented as well. This does not take into account all possible variations of server behavior (yet), but that will happen in follow-up work. |
||
#2 | 15073 | tjuricek | Update Auth::Middleware and add spec | ||
#1 | 15032 | tjuricek |
Starting config and doc revisions. System is now broken while revisions underway. Configuration of the p4d connection is now done via a single HWSSettings middleware object injected into the Rack env. The HWSP4Cleanup middleware now cleans up any p4 injected into the Rack env. The Auth::App class now mostly just contains one method to generate a p4 ticket. /auth/v1/login. Added yard documentation for the main project. Yard docs have been reconfigured to dump into build/ directories. This should probably be done with each release. Hm... The top level rake file contains a task, 'all:doc', to update our documentation. This should probably be run for each checkin. Hm... Specs are now using Rack::Test on top of a 'live' p4d. I'd suggest you still use the p4util mechanism, which now dumps to a /tmp folder, so we can safely add P4IGNORE rules back into your local .p4config file. Old 'perforce' application now called 'helix_versioning_engine'. Removing cache data. Helix Sync may be slow. It may also get axed. We'll see. |