hiptest-publisher-fork 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +295 -0
- data/LICENSE +21 -0
- data/README.md +265 -0
- data/bin/hiptest-publisher +47 -0
- data/config/i18n-tasks.yml +137 -0
- data/config/locales/en.yml +250 -0
- data/lib/config/behat.conf +44 -0
- data/lib/config/behave.conf +40 -0
- data/lib/config/csharp-nunit.conf +15 -0
- data/lib/config/cucumber-groovy.conf +40 -0
- data/lib/config/cucumber-java.conf +24 -0
- data/lib/config/cucumber-javascript.conf +23 -0
- data/lib/config/cucumber-ruby.conf +22 -0
- data/lib/config/cucumber-typescript.conf +41 -0
- data/lib/config/cucumber_legacy-groovy.conf +40 -0
- data/lib/config/cucumber_legacy-java.conf +24 -0
- data/lib/config/cucumber_legacy-typescript.conf +41 -0
- data/lib/config/groovy-spock.conf +25 -0
- data/lib/config/java-espresso.conf +15 -0
- data/lib/config/java-junit.conf +21 -0
- data/lib/config/java-testng.conf +15 -0
- data/lib/config/javascript-codeceptjs.conf +23 -0
- data/lib/config/javascript-jasmine.conf +12 -0
- data/lib/config/javascript-mocha.conf +12 -0
- data/lib/config/javascript-protractor.conf +12 -0
- data/lib/config/javascript-qunit.conf +12 -0
- data/lib/config/jbehave.conf +24 -0
- data/lib/config/php-phpunit.conf +14 -0
- data/lib/config/python-unittest.conf +13 -0
- data/lib/config/robotframework.conf +13 -0
- data/lib/config/ruby-minitest.conf +11 -0
- data/lib/config/ruby-rspec.conf +11 -0
- data/lib/config/seleniumide.conf +12 -0
- data/lib/config/specflow.conf +25 -0
- data/lib/config/swift-xctest.conf +18 -0
- data/lib/hiptest-publisher/cli_options_checker.rb +270 -0
- data/lib/hiptest-publisher/client.rb +326 -0
- data/lib/hiptest-publisher/export_cache.rb +85 -0
- data/lib/hiptest-publisher/file_writer.rb +30 -0
- data/lib/hiptest-publisher/formatters/console_formatter.rb +101 -0
- data/lib/hiptest-publisher/formatters/diff_displayer.rb +173 -0
- data/lib/hiptest-publisher/formatters/reporter.rb +74 -0
- data/lib/hiptest-publisher/handlebars_helper.rb +314 -0
- data/lib/hiptest-publisher/i18n.rb +5 -0
- data/lib/hiptest-publisher/indexers/actionword_indexer.rb +32 -0
- data/lib/hiptest-publisher/indexers/library_actionword_indexer.rb +32 -0
- data/lib/hiptest-publisher/node_modifiers/actionword_uniq_renamer.rb +39 -0
- data/lib/hiptest-publisher/node_modifiers/add_all.rb +21 -0
- data/lib/hiptest-publisher/node_modifiers/call_arguments_adder.rb +46 -0
- data/lib/hiptest-publisher/node_modifiers/datatable_fixer.rb +32 -0
- data/lib/hiptest-publisher/node_modifiers/gherkin_adder.rb +252 -0
- data/lib/hiptest-publisher/node_modifiers/items_orderer.rb +33 -0
- data/lib/hiptest-publisher/node_modifiers/parameter_type_adder.rb +141 -0
- data/lib/hiptest-publisher/node_modifiers/parent_adder.rb +18 -0
- data/lib/hiptest-publisher/nodes.rb +601 -0
- data/lib/hiptest-publisher/nodes_walker.rb +34 -0
- data/lib/hiptest-publisher/options_parser.rb +826 -0
- data/lib/hiptest-publisher/project_grapher.rb +94 -0
- data/lib/hiptest-publisher/render_context_maker.rb +194 -0
- data/lib/hiptest-publisher/renderer.rb +52 -0
- data/lib/hiptest-publisher/renderer_addons/behave_addon.rb +23 -0
- data/lib/hiptest-publisher/renderer_addons/gherkin_addon.rb +59 -0
- data/lib/hiptest-publisher/renderer_addons/groovy_spock_addon.rb +34 -0
- data/lib/hiptest-publisher/renderer_addons/robot_framework_addon.rb +42 -0
- data/lib/hiptest-publisher/renderer_addons.rb +4 -0
- data/lib/hiptest-publisher/signature_differ.rb +105 -0
- data/lib/hiptest-publisher/signature_exporter.rb +56 -0
- data/lib/hiptest-publisher/string.rb +76 -0
- data/lib/hiptest-publisher/utils.rb +39 -0
- data/lib/hiptest-publisher/version_checker.rb +41 -0
- data/lib/hiptest-publisher/xml_parser.rb +407 -0
- data/lib/hiptest-publisher.rb +261 -0
- data/lib/templates/behat/actionword.hbs +8 -0
- data/lib/templates/behat/actionwords/parameter.hbs +1 -0
- data/lib/templates/behat/actionwords.hbs +16 -0
- data/lib/templates/behat/library.hbs +16 -0
- data/lib/templates/behat/libraryactionword.hbs +8 -0
- data/lib/templates/behat/parameter.hbs +1 -0
- data/lib/templates/behave/actionword.hbs +4 -0
- data/lib/templates/behave/actionwords.hbs +12 -0
- data/lib/templates/behave/library.hbs +7 -0
- data/lib/templates/behave/libraryactionword.hbs +4 -0
- data/lib/templates/behave/nullliteral.hbs +1 -0
- data/lib/templates/common/_gherkin_pattern.hbs +1 -0
- data/lib/templates/common/_gherkin_typed_pattern.hbs +1 -0
- data/lib/templates/common/booleanliteral.hbs +1 -0
- data/lib/templates/common/dataset.hbs +0 -0
- data/lib/templates/common/datatable.hbs +3 -0
- data/lib/templates/common/empty.hbs +0 -0
- data/lib/templates/common/nullliteral.hbs +1 -0
- data/lib/templates/common/numericliteral.hbs +1 -0
- data/lib/templates/common/stringliteral.hbs +1 -0
- data/lib/templates/common/symbol.hbs +1 -0
- data/lib/templates/common/unaryexpression.hbs +1 -0
- data/lib/templates/common/variable.hbs +1 -0
- data/lib/templates/csharp/_body.hbs +5 -0
- data/lib/templates/csharp/_item_as_function.hbs +8 -0
- data/lib/templates/csharp/_scenario.hbs +8 -0
- data/lib/templates/csharp/actionword.hbs +1 -0
- data/lib/templates/csharp/actionwords.hbs +10 -0
- data/lib/templates/csharp/argument.hbs +1 -0
- data/lib/templates/csharp/assign.hbs +1 -0
- data/lib/templates/csharp/binaryexpression.hbs +1 -0
- data/lib/templates/csharp/call.hbs +2 -0
- data/lib/templates/csharp/dataset.hbs +4 -0
- data/lib/templates/csharp/dict.hbs +1 -0
- data/lib/templates/csharp/field.hbs +1 -0
- data/lib/templates/csharp/folder.hbs +22 -0
- data/lib/templates/csharp/ifthen.hbs +7 -0
- data/lib/templates/csharp/index.hbs +1 -0
- data/lib/templates/csharp/list.hbs +1 -0
- data/lib/templates/csharp/nullliteral.hbs +1 -0
- data/lib/templates/csharp/parameter.hbs +1 -0
- data/lib/templates/csharp/parenthesis.hbs +1 -0
- data/lib/templates/csharp/property.hbs +1 -0
- data/lib/templates/csharp/scenario.hbs +1 -0
- data/lib/templates/csharp/scenarios.hbs +20 -0
- data/lib/templates/csharp/single_scenario.hbs +16 -0
- data/lib/templates/csharp/single_test.hbs +15 -0
- data/lib/templates/csharp/step.hbs +1 -0
- data/lib/templates/csharp/stringliteral.hbs +1 -0
- data/lib/templates/csharp/tag.hbs +1 -0
- data/lib/templates/csharp/template.hbs +1 -0
- data/lib/templates/csharp/test.hbs +1 -0
- data/lib/templates/csharp/tests.hbs +15 -0
- data/lib/templates/csharp/variable.hbs +1 -0
- data/lib/templates/csharp/while.hbs +4 -0
- data/lib/templates/cucumber/actionword.hbs +5 -0
- data/lib/templates/cucumber/actionwords.hbs +5 -0
- data/lib/templates/cucumber/groovy/step-definitions/_gherkin_pattern.hbs +1 -0
- data/lib/templates/cucumber/groovy/step-definitions/actionword.hbs +5 -0
- data/lib/templates/cucumber/groovy/step-definitions/actionwords.hbs +11 -0
- data/lib/templates/cucumber/groovy/step-definitions/library.hbs +11 -0
- data/lib/templates/cucumber/groovy/step-definitions/libraryactionword.hbs +5 -0
- data/lib/templates/cucumber/groovy/step-definitions/parameter.hbs +1 -0
- data/lib/templates/cucumber/java/actionword.hbs +6 -0
- data/lib/templates/cucumber/java/actionwords/parameter.hbs +1 -0
- data/lib/templates/cucumber/java/actionwords.hbs +12 -0
- data/lib/templates/cucumber/java/parameter.hbs +1 -0
- data/lib/templates/cucumber/javascript/_after_hook.hbs +4 -0
- data/lib/templates/cucumber/javascript/_before_hook.hbs +4 -0
- data/lib/templates/cucumber/javascript/actionword.hbs +6 -0
- data/lib/templates/cucumber/javascript/actionwords.hbs +8 -0
- data/lib/templates/cucumber/parameter.hbs +1 -0
- data/lib/templates/cucumber/typescript/_after_hook.hbs +4 -0
- data/lib/templates/cucumber/typescript/_before_hook.hbs +4 -0
- data/lib/templates/cucumber/typescript/actionword.hbs +5 -0
- data/lib/templates/cucumber/typescript/actionwords.hbs +10 -0
- data/lib/templates/cucumber/typescript/library.hbs +12 -0
- data/lib/templates/cucumber/typescript/libraryactionword.hbs +5 -0
- data/lib/templates/cucumber_legacy/groovy/step-definitions/actionword.hbs +5 -0
- data/lib/templates/cucumber_legacy/groovy/step-definitions/actionwords.hbs +10 -0
- data/lib/templates/cucumber_legacy/groovy/step-definitions/library.hbs +10 -0
- data/lib/templates/cucumber_legacy/groovy/step-definitions/libraryactionword.hbs +5 -0
- data/lib/templates/cucumber_legacy/java/actionword.hbs +6 -0
- data/lib/templates/cucumber_legacy/java/actionwords.hbs +12 -0
- data/lib/templates/cucumber_legacy/typescript/actionword.hbs +5 -0
- data/lib/templates/cucumber_legacy/typescript/libraryactionword.hbs +5 -0
- data/lib/templates/gherkin/_call.hbs +5 -0
- data/lib/templates/gherkin/_gherkin_text.hbs +1 -0
- data/lib/templates/gherkin/_scenario.hbs +18 -0
- data/lib/templates/gherkin/_scenario_outline_title.hbs +1 -0
- data/lib/templates/gherkin/argument.hbs +1 -0
- data/lib/templates/gherkin/call.hbs +1 -0
- data/lib/templates/gherkin/dataset.hbs +1 -0
- data/lib/templates/gherkin/datatable.hbs +2 -0
- data/lib/templates/gherkin/folder.hbs +10 -0
- data/lib/templates/gherkin/inlined_uids/_scenario_outline_title.hbs +1 -0
- data/lib/templates/gherkin/java/single_scenario.hbs +1 -0
- data/lib/templates/gherkin/parameter.hbs +1 -0
- data/lib/templates/gherkin/scenarios.hbs +3 -0
- data/lib/templates/gherkin/single_scenario.hbs +1 -0
- data/lib/templates/gherkin/single_test.hbs +3 -0
- data/lib/templates/gherkin/step.hbs +1 -0
- data/lib/templates/gherkin/stringliteral.hbs +1 -0
- data/lib/templates/gherkin/tag.hbs +1 -0
- data/lib/templates/gherkin/template.hbs +1 -0
- data/lib/templates/groovy/_body.hbs +8 -0
- data/lib/templates/groovy/_desc.hbs +5 -0
- data/lib/templates/groovy/_scenario.hbs +10 -0
- data/lib/templates/groovy/_steps.hbs +4 -0
- data/lib/templates/groovy/_test.hbs +4 -0
- data/lib/templates/groovy/actionword.hbs +2 -0
- data/lib/templates/groovy/actionwords.hbs +7 -0
- data/lib/templates/groovy/assign.hbs +1 -0
- data/lib/templates/groovy/call.hbs +2 -0
- data/lib/templates/groovy/dataset.hbs +1 -0
- data/lib/templates/groovy/datatable.hbs +2 -0
- data/lib/templates/groovy/dict.hbs +1 -0
- data/lib/templates/groovy/folder.hbs +18 -0
- data/lib/templates/groovy/index.hbs +1 -0
- data/lib/templates/groovy/libraries.hbs +9 -0
- data/lib/templates/groovy/library.hbs +8 -0
- data/lib/templates/groovy/libraryactionword.hbs +2 -0
- data/lib/templates/groovy/list.hbs +1 -0
- data/lib/templates/groovy/nullliteral.hbs +1 -0
- data/lib/templates/groovy/parameter.hbs +1 -0
- data/lib/templates/groovy/property.hbs +1 -0
- data/lib/templates/groovy/scenario.hbs +1 -0
- data/lib/templates/groovy/scenarios.hbs +10 -0
- data/lib/templates/groovy/single_scenario.hbs +9 -0
- data/lib/templates/groovy/single_test.hbs +10 -0
- data/lib/templates/groovy/template.hbs +1 -0
- data/lib/templates/groovy/test.hbs +1 -0
- data/lib/templates/groovy/tests.hbs +10 -0
- data/lib/templates/java/_body.hbs +5 -0
- data/lib/templates/java/_item_as_function.hbs +8 -0
- data/lib/templates/java/_scenario.hbs +7 -0
- data/lib/templates/java/actionword.hbs +1 -0
- data/lib/templates/java/actionwords.hbs +8 -0
- data/lib/templates/java/argument.hbs +1 -0
- data/lib/templates/java/assign.hbs +1 -0
- data/lib/templates/java/binaryexpression.hbs +1 -0
- data/lib/templates/java/call.hbs +2 -0
- data/lib/templates/java/dataset.hbs +3 -0
- data/lib/templates/java/dict.hbs +1 -0
- data/lib/templates/java/espresso/_scenario.hbs +8 -0
- data/lib/templates/java/espresso/dataset.hbs +4 -0
- data/lib/templates/java/espresso/folder.hbs +29 -0
- data/lib/templates/java/espresso/scenarios.hbs +23 -0
- data/lib/templates/java/espresso/single_scenario.hbs +24 -0
- data/lib/templates/java/espresso/single_test.hbs +22 -0
- data/lib/templates/java/espresso/tests.hbs +23 -0
- data/lib/templates/java/field.hbs +1 -0
- data/lib/templates/java/folder.hbs +18 -0
- data/lib/templates/java/ifthen.hbs +7 -0
- data/lib/templates/java/index.hbs +1 -0
- data/lib/templates/java/libraries.hbs +9 -0
- data/lib/templates/java/library.hbs +7 -0
- data/lib/templates/java/libraryactionword.hbs +1 -0
- data/lib/templates/java/list.hbs +1 -0
- data/lib/templates/java/nullliteral.hbs +1 -0
- data/lib/templates/java/parameter.hbs +1 -0
- data/lib/templates/java/parenthesis.hbs +1 -0
- data/lib/templates/java/property.hbs +1 -0
- data/lib/templates/java/scenario.hbs +1 -0
- data/lib/templates/java/scenarios.hbs +11 -0
- data/lib/templates/java/single_scenario.hbs +12 -0
- data/lib/templates/java/single_test.hbs +11 -0
- data/lib/templates/java/step.hbs +1 -0
- data/lib/templates/java/stringliteral.hbs +1 -0
- data/lib/templates/java/tag.hbs +1 -0
- data/lib/templates/java/template.hbs +1 -0
- data/lib/templates/java/test.hbs +1 -0
- data/lib/templates/java/testng/_scenario.hbs +8 -0
- data/lib/templates/java/testng/dataset.hbs +4 -0
- data/lib/templates/java/testng/folder.hbs +19 -0
- data/lib/templates/java/testng/scenarios.hbs +16 -0
- data/lib/templates/java/testng/single_scenario.hbs +12 -0
- data/lib/templates/java/testng/single_test.hbs +11 -0
- data/lib/templates/java/testng/tests.hbs +16 -0
- data/lib/templates/java/tests.hbs +11 -0
- data/lib/templates/java/variable.hbs +1 -0
- data/lib/templates/java/while.hbs +4 -0
- data/lib/templates/javascript/_body.hbs +10 -0
- data/lib/templates/javascript/_item_as_function.hbs +3 -0
- data/lib/templates/javascript/_item_as_hash_key.hbs +3 -0
- data/lib/templates/javascript/_module_declaration.hbs +5 -0
- data/lib/templates/javascript/_scenario.hbs +4 -0
- data/lib/templates/javascript/actionword.hbs +1 -0
- data/lib/templates/javascript/actionwords.hbs +4 -0
- data/lib/templates/javascript/argument.hbs +1 -0
- data/lib/templates/javascript/assign.hbs +1 -0
- data/lib/templates/javascript/binaryexpression.hbs +1 -0
- data/lib/templates/javascript/call.hbs +2 -0
- data/lib/templates/javascript/codeceptjs/actionword.hbs +5 -0
- data/lib/templates/javascript/codeceptjs/actionwords.hbs +9 -0
- data/lib/templates/javascript/dataset.hbs +3 -0
- data/lib/templates/javascript/dict.hbs +1 -0
- data/lib/templates/javascript/es6/actionwords.hbs +4 -0
- data/lib/templates/javascript/field.hbs +1 -0
- data/lib/templates/javascript/folder.hbs +14 -0
- data/lib/templates/javascript/ifthen.hbs +7 -0
- data/lib/templates/javascript/index.hbs +1 -0
- data/lib/templates/javascript/jasmine/_before_each.hbs +3 -0
- data/lib/templates/javascript/jasmine/_scenario.hbs +8 -0
- data/lib/templates/javascript/jasmine/dataset.hbs +3 -0
- data/lib/templates/javascript/jasmine/folder.hbs +11 -0
- data/lib/templates/javascript/jasmine/scenarios.hbs +8 -0
- data/lib/templates/javascript/jasmine/single_scenario.hbs +6 -0
- data/lib/templates/javascript/jasmine/single_test.hbs +6 -0
- data/lib/templates/javascript/jasmine/tests.hbs +8 -0
- data/lib/templates/javascript/list.hbs +1 -0
- data/lib/templates/javascript/mocha/_before_each.hbs +4 -0
- data/lib/templates/javascript/mocha/folder.hbs +11 -0
- data/lib/templates/javascript/nullliteral.hbs +1 -0
- data/lib/templates/javascript/parameter.hbs +1 -0
- data/lib/templates/javascript/parenthesis.hbs +1 -0
- data/lib/templates/javascript/project.hbs +2 -0
- data/lib/templates/javascript/property.hbs +1 -0
- data/lib/templates/javascript/scenario.hbs +1 -0
- data/lib/templates/javascript/scenarios.hbs +8 -0
- data/lib/templates/javascript/single_scenario.hbs +6 -0
- data/lib/templates/javascript/single_test.hbs +6 -0
- data/lib/templates/javascript/step.hbs +1 -0
- data/lib/templates/javascript/tag.hbs +1 -0
- data/lib/templates/javascript/template.hbs +1 -0
- data/lib/templates/javascript/test.hbs +1 -0
- data/lib/templates/javascript/tests.hbs +8 -0
- data/lib/templates/javascript/while.hbs +5 -0
- data/lib/templates/jbehave/_scenario.hbs +9 -0
- data/lib/templates/jbehave/actionwords/parameter.hbs +1 -0
- data/lib/templates/jbehave/call.hbs +5 -0
- data/lib/templates/jbehave/folder.hbs +16 -0
- data/lib/templates/jbehave/single_test.hbs +3 -0
- data/lib/templates/jbehave/steps/_gherkin_pattern.hbs +1 -0
- data/lib/templates/jbehave/steps/actionword.hbs +6 -0
- data/lib/templates/jbehave/steps/actionwords.hbs +18 -0
- data/lib/templates/php/_body.hbs +9 -0
- data/lib/templates/php/_item_as_function.hbs +3 -0
- data/lib/templates/php/_scenario.hbs +4 -0
- data/lib/templates/php/_setup.hbs +4 -0
- data/lib/templates/php/actionword.hbs +1 -0
- data/lib/templates/php/actionwords.hbs +9 -0
- data/lib/templates/php/argument.hbs +1 -0
- data/lib/templates/php/assign.hbs +1 -0
- data/lib/templates/php/binaryexpression.hbs +1 -0
- data/lib/templates/php/call.hbs +2 -0
- data/lib/templates/php/dataset.hbs +3 -0
- data/lib/templates/php/dict.hbs +1 -0
- data/lib/templates/php/field.hbs +1 -0
- data/lib/templates/php/folder.hbs +17 -0
- data/lib/templates/php/ifthen.hbs +7 -0
- data/lib/templates/php/index.hbs +1 -0
- data/lib/templates/php/libraries.hbs +11 -0
- data/lib/templates/php/library.hbs +20 -0
- data/lib/templates/php/libraryactionword.hbs +1 -0
- data/lib/templates/php/list.hbs +1 -0
- data/lib/templates/php/nullliteral.hbs +1 -0
- data/lib/templates/php/parameter.hbs +1 -0
- data/lib/templates/php/parenthesis.hbs +1 -0
- data/lib/templates/php/project.hbs +2 -0
- data/lib/templates/php/property.hbs +1 -0
- data/lib/templates/php/scenario.hbs +1 -0
- data/lib/templates/php/scenarios.hbs +13 -0
- data/lib/templates/php/single_scenario.hbs +11 -0
- data/lib/templates/php/single_test.hbs +11 -0
- data/lib/templates/php/step.hbs +1 -0
- data/lib/templates/php/tag.hbs +1 -0
- data/lib/templates/php/template.hbs +1 -0
- data/lib/templates/php/test.hbs +1 -0
- data/lib/templates/php/tests.hbs +13 -0
- data/lib/templates/php/variable.hbs +1 -0
- data/lib/templates/php/while.hbs +5 -0
- data/lib/templates/python/_body.hbs +11 -0
- data/lib/templates/python/_item_as_def.hbs +2 -0
- data/lib/templates/python/_parameters.hbs +1 -0
- data/lib/templates/python/_scenario.hbs +4 -0
- data/lib/templates/python/actionword.hbs +1 -0
- data/lib/templates/python/actionwords.hbs +12 -0
- data/lib/templates/python/argument.hbs +1 -0
- data/lib/templates/python/assign.hbs +1 -0
- data/lib/templates/python/binaryexpression.hbs +1 -0
- data/lib/templates/python/booleanliteral.hbs +1 -0
- data/lib/templates/python/call.hbs +2 -0
- data/lib/templates/python/dataset.hbs +2 -0
- data/lib/templates/python/dict.hbs +1 -0
- data/lib/templates/python/field.hbs +1 -0
- data/lib/templates/python/folder.hbs +12 -0
- data/lib/templates/python/ifthen.hbs +4 -0
- data/lib/templates/python/index.hbs +1 -0
- data/lib/templates/python/libraries.hbs +9 -0
- data/lib/templates/python/library.hbs +17 -0
- data/lib/templates/python/libraryactionword.hbs +1 -0
- data/lib/templates/python/list.hbs +1 -0
- data/lib/templates/python/nullliteral.hbs +1 -0
- data/lib/templates/python/parameter.hbs +1 -0
- data/lib/templates/python/parenthesis.hbs +1 -0
- data/lib/templates/python/project.hbs +2 -0
- data/lib/templates/python/property.hbs +1 -0
- data/lib/templates/python/scenario.hbs +1 -0
- data/lib/templates/python/scenarios.hbs +11 -0
- data/lib/templates/python/single_scenario.hbs +9 -0
- data/lib/templates/python/single_test.hbs +9 -0
- data/lib/templates/python/step.hbs +1 -0
- data/lib/templates/python/tag.hbs +1 -0
- data/lib/templates/python/template.hbs +1 -0
- data/lib/templates/python/test.hbs +1 -0
- data/lib/templates/python/tests.hbs +11 -0
- data/lib/templates/python/unittest/actionwords.hbs +9 -0
- data/lib/templates/python/while.hbs +4 -0
- data/lib/templates/robotframework/_keyword.hbs +1 -0
- data/lib/templates/robotframework/_keyword_body.hbs +4 -0
- data/lib/templates/robotframework/_scenario.hbs +12 -0
- data/lib/templates/robotframework/actionword.hbs +3 -0
- data/lib/templates/robotframework/actionwords.hbs +4 -0
- data/lib/templates/robotframework/argument.hbs +1 -0
- data/lib/templates/robotframework/call.hbs +1 -0
- data/lib/templates/robotframework/dataset.hbs +1 -0
- data/lib/templates/robotframework/datatable.hbs +2 -0
- data/lib/templates/robotframework/folder.hbs +35 -0
- data/lib/templates/robotframework/ifthen.hbs +1 -0
- data/lib/templates/robotframework/parameter.hbs +1 -0
- data/lib/templates/robotframework/property.hbs +1 -0
- data/lib/templates/robotframework/scenarios.hbs +25 -0
- data/lib/templates/robotframework/single_scenario.hbs +10 -0
- data/lib/templates/robotframework/single_test.hbs +10 -0
- data/lib/templates/robotframework/stringliteral.hbs +1 -0
- data/lib/templates/robotframework/template.hbs +1 -0
- data/lib/templates/robotframework/test.hbs +1 -0
- data/lib/templates/robotframework/tests.hbs +7 -0
- data/lib/templates/robotframework/variable.hbs +1 -0
- data/lib/templates/robotframework/while.hbs +1 -0
- data/lib/templates/ruby/_body.hbs +10 -0
- data/lib/templates/ruby/_item_as_def.hbs +3 -0
- data/lib/templates/ruby/_scenario.hbs +5 -0
- data/lib/templates/ruby/actionword.hbs +1 -0
- data/lib/templates/ruby/actionwords.hbs +6 -0
- data/lib/templates/ruby/argument.hbs +1 -0
- data/lib/templates/ruby/assign.hbs +1 -0
- data/lib/templates/ruby/binaryexpression.hbs +1 -0
- data/lib/templates/ruby/call.hbs +2 -0
- data/lib/templates/ruby/dataset.hbs +3 -0
- data/lib/templates/ruby/dict.hbs +1 -0
- data/lib/templates/ruby/field.hbs +1 -0
- data/lib/templates/ruby/folder.hbs +16 -0
- data/lib/templates/ruby/ifthen.hbs +7 -0
- data/lib/templates/ruby/index.hbs +1 -0
- data/lib/templates/ruby/list.hbs +1 -0
- data/lib/templates/ruby/minitest/_item_as_def.hbs +3 -0
- data/lib/templates/ruby/minitest/_scenario.hbs +4 -0
- data/lib/templates/ruby/minitest/dataset.hbs +3 -0
- data/lib/templates/ruby/minitest/folder.hbs +18 -0
- data/lib/templates/ruby/minitest/scenario.hbs +1 -0
- data/lib/templates/ruby/minitest/scenarios.hbs +13 -0
- data/lib/templates/ruby/minitest/single_scenario.hbs +11 -0
- data/lib/templates/ruby/minitest/single_test.hbs +11 -0
- data/lib/templates/ruby/minitest/test.hbs +1 -0
- data/lib/templates/ruby/minitest/tests.hbs +13 -0
- data/lib/templates/ruby/parameter.hbs +1 -0
- data/lib/templates/ruby/parenthesis.hbs +1 -0
- data/lib/templates/ruby/project.hbs +2 -0
- data/lib/templates/ruby/property.hbs +1 -0
- data/lib/templates/ruby/scenario.hbs +1 -0
- data/lib/templates/ruby/scenarios.hbs +12 -0
- data/lib/templates/ruby/single_scenario.hbs +11 -0
- data/lib/templates/ruby/single_test.hbs +11 -0
- data/lib/templates/ruby/step.hbs +1 -0
- data/lib/templates/ruby/symbol.hbs +1 -0
- data/lib/templates/ruby/tag.hbs +1 -0
- data/lib/templates/ruby/template.hbs +1 -0
- data/lib/templates/ruby/test.hbs +1 -0
- data/lib/templates/ruby/tests.hbs +12 -0
- data/lib/templates/ruby/while.hbs +5 -0
- data/lib/templates/seleniumide/argument.hbs +1 -0
- data/lib/templates/seleniumide/call.hbs +6 -0
- data/lib/templates/seleniumide/single_test.hbs +28 -0
- data/lib/templates/seleniumide/step.hbs +0 -0
- data/lib/templates/seleniumide/stringliteral.hbs +1 -0
- data/lib/templates/seleniumide/template.hbs +1 -0
- data/lib/templates/seleniumide/test.hbs +4 -0
- data/lib/templates/seleniumide/tests.hbs +19 -0
- data/lib/templates/specflow/actionword.hbs +6 -0
- data/lib/templates/specflow/actionwords/parameter.hbs +1 -0
- data/lib/templates/specflow/actionwords.hbs +14 -0
- data/lib/templates/specflow/gherkin/tag.hbs +1 -0
- data/lib/templates/specflow/parameter.hbs +1 -0
- data/lib/templates/swift/_body.hbs +11 -0
- data/lib/templates/swift/_item_as_def.hbs +5 -0
- data/lib/templates/swift/_scenario.hbs +7 -0
- data/lib/templates/swift/actionword.hbs +1 -0
- data/lib/templates/swift/actionwords.hbs +6 -0
- data/lib/templates/swift/argument.hbs +1 -0
- data/lib/templates/swift/assign.hbs +1 -0
- data/lib/templates/swift/binaryexpression.hbs +1 -0
- data/lib/templates/swift/call.hbs +2 -0
- data/lib/templates/swift/dataset.hbs +4 -0
- data/lib/templates/swift/dict.hbs +1 -0
- data/lib/templates/swift/field.hbs +1 -0
- data/lib/templates/swift/folder.hbs +23 -0
- data/lib/templates/swift/ifthen.hbs +7 -0
- data/lib/templates/swift/index.hbs +1 -0
- data/lib/templates/swift/list.hbs +1 -0
- data/lib/templates/swift/parameter.hbs +1 -0
- data/lib/templates/swift/parenthesis.hbs +1 -0
- data/lib/templates/swift/project.hbs +2 -0
- data/lib/templates/swift/property.hbs +1 -0
- data/lib/templates/swift/scenario.hbs +1 -0
- data/lib/templates/swift/scenarios.hbs +25 -0
- data/lib/templates/swift/single_scenario.hbs +24 -0
- data/lib/templates/swift/single_test.hbs +23 -0
- data/lib/templates/swift/step.hbs +1 -0
- data/lib/templates/swift/stringliteral.hbs +1 -0
- data/lib/templates/swift/symbol.hbs +1 -0
- data/lib/templates/swift/tag.hbs +1 -0
- data/lib/templates/swift/template.hbs +1 -0
- data/lib/templates/swift/test.hbs +1 -0
- data/lib/templates/swift/tests.hbs +25 -0
- data/lib/templates/swift/while.hbs +5 -0
- data/lib/templates/typescript/_item_as_function.hbs +3 -0
- data/lib/templates/typescript/actionword.hbs +1 -0
- data/lib/templates/typescript/actionwords.hbs +7 -0
- data/lib/templates/typescript/libraries.hbs +9 -0
- data/lib/templates/typescript/library.hbs +18 -0
- data/lib/templates/typescript/libraryactionword.hbs +1 -0
- data/lib/templates/typescript/parameter.hbs +1 -0
- metadata +783 -0
@@ -0,0 +1,270 @@
|
|
1
|
+
require 'i18n'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
require 'hiptest-publisher/utils'
|
5
|
+
|
6
|
+
module Hiptest
|
7
|
+
class CliOptionError < StandardError
|
8
|
+
end
|
9
|
+
|
10
|
+
class CliOptionsChecker
|
11
|
+
attr_reader :reporter, :cli_options
|
12
|
+
def initialize(cli_options, reporter)
|
13
|
+
@cli_options = cli_options
|
14
|
+
@reporter = reporter
|
15
|
+
end
|
16
|
+
|
17
|
+
def check!
|
18
|
+
check_config_file
|
19
|
+
|
20
|
+
if cli_options.only == 'list'
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
check_secret_token
|
25
|
+
check_filters
|
26
|
+
check_status_filter
|
27
|
+
check_meta
|
28
|
+
|
29
|
+
if cli_options.push?
|
30
|
+
check_execution_environment
|
31
|
+
check_push_file
|
32
|
+
check_build_options
|
33
|
+
else
|
34
|
+
check_output_directory
|
35
|
+
check_actionwords_signature_file
|
36
|
+
check_xml_file
|
37
|
+
check_test_run_id
|
38
|
+
check_language_and_only
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def check_config_file
|
43
|
+
begin
|
44
|
+
ParseConfig.new(cli_options.config) if present?(cli_options.config)
|
45
|
+
rescue Errno::EACCES => err
|
46
|
+
raise CliOptionError, I18n.t('errors.cli_options.missing_config_file', config_file: cli_options.config)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def check_filters
|
51
|
+
filters = [
|
52
|
+
cli_options.filter_on_scenario_ids,
|
53
|
+
cli_options.filter_on_folder_ids,
|
54
|
+
cli_options.filter_on_scenario_name,
|
55
|
+
cli_options.filter_on_folder_name,
|
56
|
+
cli_options.filter_on_tags
|
57
|
+
].reject {|opt| absent?(opt) }
|
58
|
+
|
59
|
+
return if filters.empty?
|
60
|
+
|
61
|
+
if filters.size > 1
|
62
|
+
raise CliOptionError, I18n.t('errors.cli_options.multiple_filters')
|
63
|
+
end
|
64
|
+
|
65
|
+
if present?(cli_options.test_run_id) || present?(cli_options.test_run_name)
|
66
|
+
raise CliOptionError, I18n.t('errors.cli_options.filter_with_test_run')
|
67
|
+
end
|
68
|
+
|
69
|
+
check_numeric_list(:filter_on_scenario_ids)
|
70
|
+
check_numeric_list(:filter_on_folder_ids)
|
71
|
+
check_tag_list(:filter_on_tags)
|
72
|
+
end
|
73
|
+
|
74
|
+
def check_status_filter
|
75
|
+
return if absent?(cli_options.filter_on_status)
|
76
|
+
|
77
|
+
if absent?(cli_options.test_run_id) && absent?(cli_options.test_run_name)
|
78
|
+
raise CliOptionError, I18n.t('errors.cli_options.filter_status_without_test_run')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def check_secret_token
|
83
|
+
if absent?(cli_options.xml_file)
|
84
|
+
if absent?(cli_options.token)
|
85
|
+
raise CliOptionError, I18n.t('errors.cli_options.missing_token')
|
86
|
+
end
|
87
|
+
|
88
|
+
unless numeric?(cli_options.token)
|
89
|
+
raise CliOptionError, I18n.t('errors.cli_options.invalid_token', token: cli_options.token)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def check_push_file
|
95
|
+
if cli_options.push && !cli_options.global_failure_on_missing_reports
|
96
|
+
agnostic_path = clean_path(cli_options.push)
|
97
|
+
globbed_files = Dir.glob(agnostic_path)
|
98
|
+
|
99
|
+
if globbed_files.length == 0
|
100
|
+
raise CliOptionError, I18n.t('errors.cli_options.unreadable_report_file', path: cli_options.push)
|
101
|
+
elsif globbed_files.length == 1 && globbed_files == [cli_options.push]
|
102
|
+
if !File.readable?(agnostic_path)
|
103
|
+
raise CliOptionError, I18n.t('errors.cli_options.unreadable_report_file', path: cli_options.push)
|
104
|
+
elsif !File.file?(agnostic_path)
|
105
|
+
raise CliOptionError, I18n.t('errors.cli_options.irregular_report_file', path: cli_options.push)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def check_execution_environment
|
112
|
+
if cli_options.execution_environment
|
113
|
+
if cli_options.execution_environment.length > 255
|
114
|
+
raise CliOptionError, I18n.t('errors.cli_options.invalid_execution_environment')
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def check_output_directory
|
120
|
+
output_directory = clean_path(cli_options.output_directory)
|
121
|
+
|
122
|
+
parent = first_existing_parent(output_directory)
|
123
|
+
if !parent.writable?
|
124
|
+
if parent.realpath === Pathname.new(cli_options.output_directory).cleanpath
|
125
|
+
raise CliOptionError, I18n.t('errors.cli_options.output_directory_not_writable', output_dir: cli_options.output_directory)
|
126
|
+
else
|
127
|
+
raise CliOptionError, I18n.t('errors.cli_options.output_directory_parent_not_writable', realpath: parent.realpath, output_dir: cli_options.output_directory)
|
128
|
+
end
|
129
|
+
elsif !parent.directory?
|
130
|
+
raise CliOptionError, I18n.t('errors.cli_options.output_directory_not_directory', output_dir: cli_options.output_directory)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
def check_actionwords_signature_file
|
136
|
+
if cli_options.actionwords_diff?
|
137
|
+
actionwords_signature_file = Pathname.new(cli_options.output_directory).join("actionwords_signature.yaml")
|
138
|
+
if actionwords_signature_file.directory?
|
139
|
+
raise CliOptionError, I18n.t('errors.cli_options.actionwords_signature_directory', path: actionwords_signature_file.realpath)
|
140
|
+
elsif !actionwords_signature_file.exist?
|
141
|
+
raise CliOptionError, I18n.t('errors.cli_options.missing_actionwords_signature_file', directory_path: File.expand_path(cli_options.output_directory))
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def check_xml_file
|
147
|
+
if cli_options.xml_file
|
148
|
+
xml_path = clean_path(cli_options.xml_file)
|
149
|
+
|
150
|
+
if !File.readable?(xml_path)
|
151
|
+
raise CliOptionError, I18n.t('errors.cli_options.unreadable_xml_file', path: cli_options.xml_file)
|
152
|
+
elsif !File.file?(xml_path)
|
153
|
+
raise CliOptionError, I18n.t('errors.cli_options.irregular_xml_file', path: cli_options.xml_file)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def check_test_run_id
|
159
|
+
if present?(cli_options.test_run_id) && !numeric?(cli_options.test_run_id)
|
160
|
+
raise CliOptionError, I18n.t('errors.cli_options.invalid_test_run_id', test_run_id: cli_options.test_run_id)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def check_numeric_list(option_name)
|
165
|
+
value = cli_options.send(option_name)
|
166
|
+
return if absent?(value)
|
167
|
+
|
168
|
+
value.split(',').each do |val|
|
169
|
+
next if numeric?(val.strip)
|
170
|
+
raise CliOptionError, I18n.t('errors.cli_options.invalid_numeric_value_list', option: option_name, incorrect_value: val.strip.inspect)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def check_tag_list(option_name)
|
175
|
+
value = cli_options.send(option_name)
|
176
|
+
return if absent?(value)
|
177
|
+
|
178
|
+
value.split(',').each do |val|
|
179
|
+
next if tag_compatible?(val.strip)
|
180
|
+
raise CliOptionError, I18n.t('errors.cli_options.invalid_tag_value_list', option: option_name, incorrect_value: val.strip.inspect)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def check_meta
|
185
|
+
value = cli_options.meta
|
186
|
+
return if absent?(value)
|
187
|
+
|
188
|
+
value.split(',').each do |val|
|
189
|
+
next if meta_compatible?(val.strip)
|
190
|
+
raise CliOptionError, I18n.t('errors.cli_options.invalid_meta', incorrect_value: val.strip.inspect)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def check_language_and_only
|
195
|
+
if present?(cli_options.language)
|
196
|
+
begin
|
197
|
+
language_config_parser = LanguageConfigParser.new(cli_options)
|
198
|
+
rescue ArgumentError => err
|
199
|
+
raise CliOptionError, err.message
|
200
|
+
end
|
201
|
+
|
202
|
+
if present?(cli_options.only)
|
203
|
+
if language_config_parser.filtered_group_names != cli_options.groups_to_keep
|
204
|
+
unknown_categories = cli_options.groups_to_keep - language_config_parser.group_names
|
205
|
+
raise CliOptionError, I18n.t(
|
206
|
+
'errors.cli_options.invalid_category',
|
207
|
+
count: unknown_categories.length,
|
208
|
+
invalid_categories: formatted_categories(unknown_categories),
|
209
|
+
available_categories: formatted_categories(language_config_parser.group_names),
|
210
|
+
language: cli_options.language_framework
|
211
|
+
)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
def check_build_options
|
218
|
+
if present?(cli_options.build_id) && present?(cli_options.build_name)
|
219
|
+
raise CliOptionError, I18n.t('errors.cli_options.multiple_build_options')
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
private
|
224
|
+
|
225
|
+
def numeric?(arg)
|
226
|
+
arg =~ /\A\d*\z/
|
227
|
+
end
|
228
|
+
|
229
|
+
def missing?(arg)
|
230
|
+
arg.nil?
|
231
|
+
end
|
232
|
+
|
233
|
+
def empty?(arg)
|
234
|
+
arg.strip.empty?
|
235
|
+
end
|
236
|
+
|
237
|
+
def absent?(arg)
|
238
|
+
missing?(arg) || empty?(arg)
|
239
|
+
end
|
240
|
+
|
241
|
+
def present?(arg)
|
242
|
+
!absent?(arg)
|
243
|
+
end
|
244
|
+
|
245
|
+
def tag_compatible?(value)
|
246
|
+
value =~ /\A[a-zA-Z0-9_-]*(: ?[a-zA-Z0-9_-]*)?\z/
|
247
|
+
end
|
248
|
+
|
249
|
+
def meta_compatible?(value)
|
250
|
+
value =~ /\A[a-zA-Z0-9_-]*: ?.*\z/
|
251
|
+
end
|
252
|
+
|
253
|
+
def formatted_categories(categories)
|
254
|
+
formatted_categories = categories.map(&:inspect)
|
255
|
+
if formatted_categories.length == 1
|
256
|
+
formatted_categories.first
|
257
|
+
else
|
258
|
+
I18n.t(:readable_list, first_items: formatted_categories[0...-1].join(", "), last_item: formatted_categories.last)
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
def first_existing_parent(path)
|
263
|
+
pathname = Pathname.new(path)
|
264
|
+
while !pathname.exist?
|
265
|
+
pathname = pathname.parent
|
266
|
+
end
|
267
|
+
pathname.realpath
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
@@ -0,0 +1,326 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'i18n'
|
3
|
+
require 'json'
|
4
|
+
require 'net/http'
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
require_relative 'export_cache'
|
8
|
+
require_relative 'formatters/reporter'
|
9
|
+
|
10
|
+
module Hiptest
|
11
|
+
|
12
|
+
class ClientError < StandardError
|
13
|
+
end
|
14
|
+
|
15
|
+
class RedirectionError < StandardError
|
16
|
+
attr_reader :redirect
|
17
|
+
|
18
|
+
def initialize(msg, redirect)
|
19
|
+
@redirect = redirect
|
20
|
+
super(msg)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class AsyncExportUnavailable < StandardError
|
25
|
+
end
|
26
|
+
|
27
|
+
class MaximumRedirectionReachedError < StandardError
|
28
|
+
end
|
29
|
+
|
30
|
+
MAX_REDIRECTION = 10
|
31
|
+
|
32
|
+
class Client
|
33
|
+
attr_reader :cli_options
|
34
|
+
attr_writer :async_options
|
35
|
+
|
36
|
+
def initialize(cli_options, reporter = nil)
|
37
|
+
@cli_options = cli_options
|
38
|
+
@reporter = reporter || NullReporter.new
|
39
|
+
@async_options = { max_attempts: 200, sleep_time_between_attemps: 5 }
|
40
|
+
end
|
41
|
+
|
42
|
+
def url
|
43
|
+
if cli_options.push?
|
44
|
+
"#{cli_options.site}/import_test_results/#{cli_options.token}/#{cli_options.push_format}#{push_query_parameters}"
|
45
|
+
elsif test_run_id
|
46
|
+
"#{base_publication_path}/test_run/#{test_run_id}#{test_run_export_filter}"
|
47
|
+
else
|
48
|
+
"#{base_publication_path}/#{cli_options.leafless_export ? 'leafless_tests' : 'project'}#{project_export_filters}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def global_failure_url
|
53
|
+
"#{cli_options.site}/report_global_failure/#{cli_options.token}/#{cli_options.test_run_id}/"
|
54
|
+
end
|
55
|
+
|
56
|
+
def project_export_filters
|
57
|
+
mapping = {
|
58
|
+
filter_on_scenario_ids: 'filter_scenario_ids',
|
59
|
+
filter_on_folder_ids: 'filter_folder_ids',
|
60
|
+
filter_on_scenario_name: 'filter_scenario_name',
|
61
|
+
filter_on_folder_name: 'filter_folder_name',
|
62
|
+
filter_on_tags: 'filter_tags'
|
63
|
+
}
|
64
|
+
|
65
|
+
options = []
|
66
|
+
|
67
|
+
mapping.each do |key, filter_name|
|
68
|
+
value = @cli_options[key]
|
69
|
+
next if value.nil? || value.empty?
|
70
|
+
|
71
|
+
if [:filter_on_scenario_ids, :filter_on_folder_ids, :filter_on_tags].include?(key)
|
72
|
+
value = value.split(',').map(&:strip).map{ |s| ERB::Util.url_encode(s) }.join(',')
|
73
|
+
else
|
74
|
+
value = ERB::Util.url_encode(value)
|
75
|
+
end
|
76
|
+
|
77
|
+
options << "#{filter_name}=#{value}"
|
78
|
+
if [:filter_on_folder_ids, :filter_on_folder_name].include?(key) && @cli_options[:not_recursive]
|
79
|
+
options << "not_recursive=true"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
return options.empty? ? '' : "?#{options.join('&')}"
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_run_export_filter
|
88
|
+
value = @cli_options.filter_on_status
|
89
|
+
return '' if value.nil? || value.empty?
|
90
|
+
|
91
|
+
return "?filter_status=#{value}"
|
92
|
+
end
|
93
|
+
|
94
|
+
def fetch_project
|
95
|
+
cached = export_cache.cache_for(url)
|
96
|
+
|
97
|
+
unless cached.nil?
|
98
|
+
@reporter.with_status_message I18n.t(:using_cached_data) do
|
99
|
+
return cached
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
content = @reporter.with_status_message I18n.t(:fetching_data) do
|
104
|
+
break fetch_project_export if use_synchronous_fetch?
|
105
|
+
|
106
|
+
begin
|
107
|
+
fetch_project_export_asynchronously
|
108
|
+
rescue AsyncExportUnavailable
|
109
|
+
fetch_project_export
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
export_cache.cache(url, content)
|
114
|
+
content
|
115
|
+
end
|
116
|
+
|
117
|
+
def available_test_runs
|
118
|
+
@available_test_runs ||= begin
|
119
|
+
response = send_get_request("#{base_publication_path}/test_runs")
|
120
|
+
if response.code_type == Net::HTTPNotFound
|
121
|
+
:api_not_available
|
122
|
+
else
|
123
|
+
json_response = JSON.parse(response.body)
|
124
|
+
json_response["test_runs"]
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def push_results
|
130
|
+
# Code from: https://github.com/nicksieger/multipart-post
|
131
|
+
uploaded = {}
|
132
|
+
Dir.glob(cli_options.push.gsub('\\', '/')).each do |filename|
|
133
|
+
uploaded["file-#{filename.normalize}"] = filename
|
134
|
+
end
|
135
|
+
|
136
|
+
if cli_options.global_failure_on_missing_reports && uploaded.empty?
|
137
|
+
return send_post_request(global_failure_url)
|
138
|
+
end
|
139
|
+
|
140
|
+
send_multipart_request(url, uploaded)
|
141
|
+
end
|
142
|
+
|
143
|
+
private
|
144
|
+
|
145
|
+
def use_synchronous_fetch?
|
146
|
+
cli_options.push? || cli_options.leafless_export || test_run_id
|
147
|
+
end
|
148
|
+
|
149
|
+
def fetch_project_export
|
150
|
+
response = send_get_request(url)
|
151
|
+
if response.code_type == Net::HTTPNotFound
|
152
|
+
raise ClientError, I18n.t('errors.project_not_found')
|
153
|
+
end
|
154
|
+
|
155
|
+
response.body
|
156
|
+
end
|
157
|
+
|
158
|
+
def fetch_project_export_asynchronously
|
159
|
+
publication_export_id = fetch_asynchronous_publication_export_id
|
160
|
+
url = "#{base_publication_path}/async_project/#{publication_export_id}"
|
161
|
+
response = nil
|
162
|
+
|
163
|
+
# the server should respond with a timeout after 15 minutes
|
164
|
+
# it is about 180 attempts with a sleep time of 5 seconds between each requests
|
165
|
+
sleep_time_between_attemps = @async_options[:sleep_time_between_attemps]
|
166
|
+
max_attempts = @async_options[:max_attempts]
|
167
|
+
|
168
|
+
loop do
|
169
|
+
response = send_get_request(url)
|
170
|
+
|
171
|
+
break unless response.code_type == Net::HTTPAccepted
|
172
|
+
break if 0 >= (max_attempts -= 1)
|
173
|
+
|
174
|
+
sleep(sleep_time_between_attemps)
|
175
|
+
end
|
176
|
+
|
177
|
+
response.body
|
178
|
+
end
|
179
|
+
|
180
|
+
def fetch_asynchronous_publication_export_id
|
181
|
+
url = "#{base_publication_path}/async_project#{project_export_filters}"
|
182
|
+
response = send_post_request(url)
|
183
|
+
|
184
|
+
raise AsyncExportUnavailable if response.code_type == Net::HTTPNotFound
|
185
|
+
|
186
|
+
JSON.parse(response.body)['publication_export_id']
|
187
|
+
end
|
188
|
+
|
189
|
+
def export_cache
|
190
|
+
@export_cache ||= ExportCache.new(
|
191
|
+
@cli_options.cache_dir,
|
192
|
+
@cli_options.cache_duration,
|
193
|
+
reporter: @reporter)
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_run_id
|
197
|
+
return unless cli_options.test_run_id? || cli_options.test_run_name?
|
198
|
+
|
199
|
+
if cli_options.test_run_id?
|
200
|
+
key = "id"
|
201
|
+
searched_value = cli_options.test_run_id
|
202
|
+
elsif cli_options.test_run_name?
|
203
|
+
key = "name"
|
204
|
+
searched_value = cli_options.test_run_name
|
205
|
+
end
|
206
|
+
|
207
|
+
if available_test_runs == :api_not_available
|
208
|
+
if cli_options.test_run_id?
|
209
|
+
cli_options.test_run_id
|
210
|
+
else
|
211
|
+
raise ClientError, I18n.t('errors.test_run_list_unavailable')
|
212
|
+
end
|
213
|
+
else
|
214
|
+
matching_test_run = available_test_runs.find { |test_run| test_run[key] == searched_value }
|
215
|
+
if matching_test_run.nil?
|
216
|
+
raise ClientError, no_matching_test_runs_error_message
|
217
|
+
end
|
218
|
+
matching_test_run["id"]
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def no_matching_test_runs_error_message
|
223
|
+
if available_test_runs.empty?
|
224
|
+
I18n.t('errors.no_test_runs')
|
225
|
+
else
|
226
|
+
I18n.t('errors.no_matching_test_run', test_runs: columnize_test_runs(available_test_runs))
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
def columnize_test_runs(test_runs)
|
231
|
+
lines = []
|
232
|
+
lines << ["ID", "Name"]
|
233
|
+
lines << ["--", "----"]
|
234
|
+
lines += test_runs.map { |tr| [tr["id"], tr["name"]] }
|
235
|
+
first_column_width = lines.map { |line| line[0].length }.max
|
236
|
+
lines.map! { |line| " #{line[0].ljust(first_column_width)} #{line[1]}" }
|
237
|
+
lines.join("\n")
|
238
|
+
end
|
239
|
+
|
240
|
+
def base_publication_path
|
241
|
+
"#{cli_options.site}/publication/#{cli_options.token}"
|
242
|
+
end
|
243
|
+
|
244
|
+
def send_get_request(url, attempt = MAX_REDIRECTION)
|
245
|
+
raise MaximumRedirectionReachedError if attempt < 0
|
246
|
+
|
247
|
+
uri = URI.parse(url)
|
248
|
+
send_request(Net::HTTP::Get.new(uri))
|
249
|
+
rescue RedirectionError => err
|
250
|
+
send_get_request(err.redirect, attempt - 1)
|
251
|
+
end
|
252
|
+
|
253
|
+
def send_post_request(url, attempt = MAX_REDIRECTION)
|
254
|
+
raise MaximumRedirectionReachedError if attempt < 0
|
255
|
+
|
256
|
+
uri = URI.parse(url)
|
257
|
+
send_request(Net::HTTP::Post.new(uri))
|
258
|
+
rescue RedirectionError => err
|
259
|
+
send_post_request(err.redirect, attempt - 1)
|
260
|
+
end
|
261
|
+
|
262
|
+
def send_multipart_request(url, uploaded, attempt = MAX_REDIRECTION)
|
263
|
+
raise MaximumRedirectionReachedError if attempt < 0
|
264
|
+
|
265
|
+
uri = URI.parse(url)
|
266
|
+
files = {}
|
267
|
+
uploaded.each do |fieldname, filename|
|
268
|
+
files[fieldname] = UploadIO.new(File.new(filename), "text", filename)
|
269
|
+
end
|
270
|
+
|
271
|
+
send_request(Net::HTTP::Post::Multipart.new(uri, files))
|
272
|
+
rescue RedirectionError => err
|
273
|
+
send_multipart_request(err.redirect, uploaded, attempt - 1)
|
274
|
+
end
|
275
|
+
|
276
|
+
def send_request(request)
|
277
|
+
request["User-Agent"] = "Ruby/hiptest-publisher"
|
278
|
+
use_ssl = request.uri.scheme == "https"
|
279
|
+
|
280
|
+
proxy_uri = find_proxy_uri(request.uri.hostname, request.uri.port)
|
281
|
+
if proxy_uri
|
282
|
+
proxy_address = proxy_uri.hostname
|
283
|
+
proxy_port = proxy_uri.port
|
284
|
+
proxy_user, proxy_pass = proxy_uri.userinfo.split(':', 2) if proxy_uri.userinfo
|
285
|
+
end
|
286
|
+
|
287
|
+
Net::HTTP.start(
|
288
|
+
request.uri.hostname, request.uri.port,
|
289
|
+
proxy_address, proxy_port, proxy_user, proxy_pass,
|
290
|
+
use_ssl: use_ssl,
|
291
|
+
verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
|
292
|
+
@reporter.show_verbose_message(I18n.t(:request_sent, uri: request.uri))
|
293
|
+
response = http.request(request)
|
294
|
+
|
295
|
+
raise RedirectionError.new("Got redirected", response['location']) if response.is_a?(Net::HTTPRedirection)
|
296
|
+
|
297
|
+
response
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
def find_proxy_uri(address, port)
|
302
|
+
return URI.parse(@cli_options.http_proxy) if @cli_options.http_proxy
|
303
|
+
|
304
|
+
URI::HTTP.new(
|
305
|
+
"http", nil, address, port, nil, nil, nil, nil, nil
|
306
|
+
).find_proxy
|
307
|
+
end
|
308
|
+
|
309
|
+
def push_query_parameters
|
310
|
+
parameters = {}
|
311
|
+
unless cli_options.execution_environment.strip.empty?
|
312
|
+
parameters['execution_environment'] = cli_options.execution_environment
|
313
|
+
end
|
314
|
+
|
315
|
+
unless cli_options.build_id.strip.empty?
|
316
|
+
parameters['build_id'] = cli_options.build_id
|
317
|
+
end
|
318
|
+
|
319
|
+
unless cli_options.build_name.strip.empty?
|
320
|
+
parameters['build_name'] = cli_options.build_name
|
321
|
+
end
|
322
|
+
|
323
|
+
parameters.empty? ? "" : "?#{parameters.map {|key, value| "#{key}=#{ERB::Util.url_encode(value)}"}.join("&")}"
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'i18n'
|
2
|
+
|
3
|
+
require_relative 'formatters/reporter'
|
4
|
+
require_relative 'file_writer'
|
5
|
+
|
6
|
+
|
7
|
+
module Hiptest
|
8
|
+
class ExportCache
|
9
|
+
def initialize(cache_dir, cache_duration, reporter: nil)
|
10
|
+
@cache_dir = cache_dir
|
11
|
+
@cache_duration = cache_duration
|
12
|
+
@reporter = reporter || Reporter.new
|
13
|
+
|
14
|
+
clear_cache
|
15
|
+
end
|
16
|
+
|
17
|
+
def cache(url, content, date: nil)
|
18
|
+
return if @cache_duration <= 0
|
19
|
+
|
20
|
+
date ||= Time.now
|
21
|
+
filename = "#{Digest::MD5.hexdigest(url)}-#{date.to_i}"
|
22
|
+
|
23
|
+
file_writer.write_to_file(File.join(@cache_dir, filename), I18n.t("caching_data")) { content }
|
24
|
+
end
|
25
|
+
|
26
|
+
def cache_for(url)
|
27
|
+
return if @cache_duration <= 0
|
28
|
+
|
29
|
+
hashed_url = Digest::MD5.hexdigest(url)
|
30
|
+
expiry_date = (Time.now - @cache_duration).to_i
|
31
|
+
|
32
|
+
cached_filename = cached_filenames
|
33
|
+
.select do |filename |
|
34
|
+
filename.start_with?("#{hashed_url}-") && !expired?(filename, expiry_date)
|
35
|
+
end
|
36
|
+
.sort do | f1, f2|
|
37
|
+
timestamp_from_filename(f1) <=> timestamp_from_filename(f2)
|
38
|
+
end
|
39
|
+
.last
|
40
|
+
|
41
|
+
return nil if cached_filename.nil?
|
42
|
+
|
43
|
+
full_path = File.join(@cache_dir, cached_filename)
|
44
|
+
@reporter.show_verbose_message(I18n.t(:using_cache, full_path: full_path))
|
45
|
+
File.read(full_path)
|
46
|
+
end
|
47
|
+
|
48
|
+
def clear_cache
|
49
|
+
expired_files.map do |filename|
|
50
|
+
FileUtils.rm(File.join(@cache_dir, filename))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def file_writer
|
57
|
+
FileWriter.new(@reporter)
|
58
|
+
end
|
59
|
+
|
60
|
+
def expired_files
|
61
|
+
expiry_date = (Time.now - @cache_duration).to_i
|
62
|
+
|
63
|
+
cached_filenames.select do |filename |
|
64
|
+
expired?(filename, expiry_date)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def cached_filenames
|
69
|
+
Dir
|
70
|
+
.entries(@cache_dir)
|
71
|
+
.select { |entry| File.file?(File.join(@cache_dir, entry)) }
|
72
|
+
rescue Errno::ENOENT => err
|
73
|
+
[]
|
74
|
+
end
|
75
|
+
|
76
|
+
def expired?(filename, expiry_date)
|
77
|
+
timestamp_from_filename(filename) < expiry_date
|
78
|
+
end
|
79
|
+
|
80
|
+
def timestamp_from_filename(filename)
|
81
|
+
m = filename.match(/\A[a-f0-9]{32}-(\d+)\Z/)
|
82
|
+
m.nil? ? nil : m[1].to_i
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Hiptest
|
4
|
+
class FileWriter
|
5
|
+
def initialize(reporter)
|
6
|
+
@reporter = reporter
|
7
|
+
end
|
8
|
+
|
9
|
+
def write_to_file(path, message)
|
10
|
+
@reporter.with_status_message "#{message}: #{path}" do
|
11
|
+
mkdirs_for(path)
|
12
|
+
content = yield
|
13
|
+
|
14
|
+
File.open(path, 'w') do |file|
|
15
|
+
file.write(content)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
rescue => err
|
19
|
+
@reporter.dump_error(err)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def mkdirs_for(path)
|
25
|
+
unless Dir.exists?(File.dirname(path))
|
26
|
+
FileUtils.mkpath(File.dirname(path))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|