summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cirrus.yml11
-rw-r--r--Makefile95
-rw-r--r--cmd/podman/docker/types.go5
-rw-r--r--contrib/cirrus/README.md4
-rwxr-xr-xhack/tree_status.sh13
-rw-r--r--libpod/container_internal.go4
-rw-r--r--pkg/spec/spec.go34
-rw-r--r--test/README.md17
-rw-r--r--test/e2e/common_test.go20
-rw-r--r--test/e2e/libpod_suite_remoteclient_test.go2
-rw-r--r--test/e2e/libpod_suite_test.go2
-rw-r--r--test/e2e/run_signal_test.go6
-rw-r--r--vendor.conf9
-rw-r--r--vendor/github.com/containers/buildah/imagebuildah/build.go17
-rw-r--r--vendor/github.com/containers/storage/pkg/archive/example_changes.go97
-rw-r--r--vendor/github.com/hpcloud/tail/LICENSE.txt21
-rw-r--r--vendor/github.com/hpcloud/tail/README.md28
-rw-r--r--vendor/github.com/hpcloud/tail/ratelimiter/leakybucket.go97
-rw-r--r--vendor/github.com/hpcloud/tail/ratelimiter/memory.go58
-rw-r--r--vendor/github.com/hpcloud/tail/ratelimiter/storage.go6
-rw-r--r--vendor/github.com/hpcloud/tail/tail.go438
-rw-r--r--vendor/github.com/hpcloud/tail/tail_posix.go11
-rw-r--r--vendor/github.com/hpcloud/tail/tail_windows.go12
-rw-r--r--vendor/github.com/hpcloud/tail/util/util.go48
-rw-r--r--vendor/github.com/hpcloud/tail/watch/filechanges.go36
-rw-r--r--vendor/github.com/hpcloud/tail/watch/inotify.go128
-rw-r--r--vendor/github.com/hpcloud/tail/watch/inotify_tracker.go260
-rw-r--r--vendor/github.com/hpcloud/tail/watch/polling.go118
-rw-r--r--vendor/github.com/hpcloud/tail/watch/watch.go20
-rw-r--r--vendor/github.com/hpcloud/tail/winfile/winfile.go92
-rw-r--r--vendor/github.com/onsi/ginkgo/.gitignore7
-rw-r--r--vendor/github.com/onsi/ginkgo/.travis.yml17
-rw-r--r--vendor/github.com/onsi/ginkgo/CHANGELOG.md207
-rw-r--r--vendor/github.com/onsi/ginkgo/CONTRIBUTING.md33
-rw-r--r--vendor/github.com/onsi/ginkgo/LICENSE20
-rw-r--r--vendor/github.com/onsi/ginkgo/README.md121
-rw-r--r--vendor/github.com/onsi/ginkgo/RELEASING.md14
-rw-r--r--vendor/github.com/onsi/ginkgo/config/config.go200
-rw-r--r--vendor/github.com/onsi/ginkgo/extensions/table/table.go98
-rw-r--r--vendor/github.com/onsi/ginkgo/extensions/table/table_entry.go81
-rw-r--r--vendor/github.com/onsi/ginkgo/extensions/table/table_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/extensions/table/table_test.go64
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/bootstrap_command.go202
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/build_command.go68
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/convert/ginkgo_ast_nodes.go123
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/convert/import.go91
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/convert/package_rewriter.go127
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/convert/test_finder.go56
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/convert/testfile_rewriter.go163
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/convert/testing_t_rewriter.go130
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/convert_command.go45
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/generate_command.go167
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/help_command.go31
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/interrupthandler/interrupt_handler.go52
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/interrupthandler/sigquit_swallower_unix.go14
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/interrupthandler/sigquit_swallower_windows.go7
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/main.go300
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/nodot/nodot.go194
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/nodot/nodot_suite_test.go92
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/nodot/nodot_test.go82
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/nodot_command.go77
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/notifications.go141
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/run_command.go275
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/run_watch_and_build_command_flags.go167
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/suite_runner.go173
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/testrunner/build_args.go7
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/testrunner/build_args_old.go7
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/testrunner/log_writer.go52
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/testrunner/run_result.go27
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/testrunner/test_runner.go556
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/testrunner/test_runner_test.go60
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/testsuite/test_suite.go115
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/testsuite/testsuite_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/testsuite/testsuite_test.go212
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/testsuite/vendor_check_go15.go16
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/testsuite/vendor_check_go15_test.go201
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/testsuite/vendor_check_go16.go15
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/unfocus_command.go61
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/version_command.go24
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/watch/delta.go22
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/watch/delta_tracker.go75
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/watch/dependencies.go91
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/watch/package_hash.go104
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/watch/package_hashes.go85
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/watch/suite.go87
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo/watch_command.go175
-rw-r--r--vendor/github.com/onsi/ginkgo/ginkgo_dsl.go619
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/coverage.go21
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/coverage_fixture_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/coverage_fixture_test.go31
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/external_coverage_fixture/external_coverage.go9
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/second_package/coverage.go21
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/second_package/coverage_fixture_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/second_package/coverage_fixture_test.go29
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/extra_functions_test.go14
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/nested/nested_test.go10
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/nested_without_gofiles/subpackage/nested_subpackage_test.go9
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/outside_package_test.go16
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/xunit_test.go41
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/extra_functions_test.go17
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/fixtures_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/nested_subpackage_test.go11
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/nested_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/nested_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/outside_package_test.go19
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/xunit_test.go44
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/coverage.go25
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/coverage_fixture_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/coverage_fixture_test.go31
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/external_coverage_fixture/external_coverage.go9
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/debug_parallel_fixture/debug_parallel_fixture_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/debug_parallel_fixture/debug_parallel_fixture_test.go18
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/does_not_compile/does_not_compile_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/does_not_compile/does_not_compile_test.go11
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/eventually_failing/eventually_failing_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/eventually_failing/eventually_failing_test.go29
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/exiting_synchronized_setup_tests/exiting_synchronized_setup_tests_suite_test.go35
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/fail_fixture/fail_fixture_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/fail_fixture/fail_fixture_test.go103
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_after_suite/failing_after_suite_suite_test.go22
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_after_suite/failing_after_suite_test.go15
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_before_suite/failing_before_suite_suite_test.go22
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_before_suite/failing_before_suite_test.go15
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_ginkgo_tests/failing_ginkgo_tests.go5
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_ginkgo_tests/failing_ginkgo_tests_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_ginkgo_tests/failing_ginkgo_tests_test.go17
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/flags_tests/flags.go9
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/flags_tests/flags_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/flags_tests/flags_test.go97
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture/README.md1
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture/focused_fixture_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture/focused_fixture_test.go73
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture_with_vendor/focused_fixture_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture_with_vendor/focused_fixture_test.go73
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/hanging_suite/hanging_suite_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/hanging_suite/hanging_suite_test.go30
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/more_ginkgo_tests/more_ginkgo_tests.go5
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/more_ginkgo_tests/more_ginkgo_tests_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/more_ginkgo_tests/more_ginkgo_tests_test.go17
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/no_test_fn/no_test_fn.go5
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/no_test_fn/no_test_fn_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/no_tests/no_tests.go4
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_ginkgo_tests/passing_ginkgo_tests.go9
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_ginkgo_tests/passing_ginkgo_tests_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_ginkgo_tests/passing_ginkgo_tests_test.go30
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_suite_setup/passing_suite_setup_suite_test.go26
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_suite_setup/passing_suite_test.go28
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/progress_fixture/progress_fixture_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/progress_fixture/progress_fixture_test.go49
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/skip_fixture/skip_fixture_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/skip_fixture/skip_fixture_test.go71
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/suite_command_tests/suite_command.go9
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/suite_command_tests/suite_command_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/suite_command_tests/suite_command_test.go18
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/synchronized_setup_tests/synchronized_setup_tests_suite_test.go43
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/tags_tests/ignored_test.go17
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/tags_tests/tags_tests_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/tags_tests/tags_tests_test.go11
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/test_description/test_description_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/test_description/test_description_test.go23
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A/A.go7
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A/A_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A/A_test.go14
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B/B.go7
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B/B_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B/B_test.go14
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C.go5
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C.json3
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C_test.go14
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/D/D.go7
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/D/D_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/D/D_test.go14
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/xunit_tests/xunit_tests.go5
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/_fixtures/xunit_tests/xunit_tests_test.go11
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/convert_test.go121
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/coverage_test.go147
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/fail_test.go55
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/flags_test.go237
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/integration.go1
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/integration_suite_test.go129
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/interrupt_test.go51
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/precompiled_test.go53
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/progress_test.go94
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/run_test.go483
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/skip_test.go43
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/subcommand_test.go419
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/suite_command_test.go63
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/suite_setup_test.go178
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/tags_test.go27
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/test_description_test.go25
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/verbose_and_succinct_test.go90
-rw-r--r--vendor/github.com/onsi/ginkgo/integration/watch_test.go275
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/codelocation/code_location.go32
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_test.go80
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/containernode/container_node.go151
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/containernode/container_node_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/containernode/container_node_test.go213
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/failer/failer.go92
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/failer/failer_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/failer/failer_test.go141
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/benchmarker.go103
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/interfaces.go19
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/it_node.go47
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/it_node_test.go22
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/leaf_node_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/measure_node.go62
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/measure_node_test.go155
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go117
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/setup_nodes.go48
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/setup_nodes_test.go48
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/shared_runner_test.go353
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes.go55
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes_test.go230
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_after_suite_node.go90
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_after_suite_node_test.go199
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_before_suite_node.go181
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_before_suite_node_test.go446
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/remote/aggregator.go249
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/remote/aggregator_test.go315
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/remote/fake_output_interceptor_test.go22
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/remote/fake_poster_test.go33
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/remote/forwarding_reporter.go147
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/remote/forwarding_reporter_test.go181
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/remote/output_interceptor.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/remote/output_interceptor_unix.go83
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/remote/output_interceptor_win.go36
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/remote/remote_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/remote/server.go224
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/remote/server_test.go269
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_linux_arm64.go11
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_solaris.go9
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_unix.go11
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/spec/spec.go247
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/spec/spec_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/spec/spec_test.go739
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/spec/specs.go123
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/spec/specs_test.go287
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/spec_iterator/index_computer.go55
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/spec_iterator/index_computer_test.go149
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/spec_iterator/parallel_spec_iterator.go59
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/spec_iterator/parallel_spec_iterator_test.go112
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/spec_iterator/serial_spec_iterator.go45
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/spec_iterator/serial_spec_iterator_test.go64
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/spec_iterator/sharded_parallel_spec_iterator.go47
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/spec_iterator/sharded_parallel_spec_iterator_test.go62
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/spec_iterator/spec_iterator.go20
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/spec_iterator/spec_iterator_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/specrunner/random_id.go15
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner.go411
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner_test.go785
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/suite/suite.go190
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/suite/suite_suite_test.go35
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/suite/suite_test.go385
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/testingtproxy/testing_t_proxy.go76
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/writer/fake_writer.go36
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/writer/writer.go89
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/writer/writer_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/internal/writer/writer_test.go75
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/default_reporter.go84
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/default_reporter_test.go433
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/fake_reporter.go59
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/junit_reporter.go152
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/junit_reporter_test.go258
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/reporter.go15
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/reporters_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/console_logging.go64
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/fake_stenographer.go142
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/stenographer.go572
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/support/README.md6
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/LICENSE21
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/README.md43
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/colorable_others.go24
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/colorable_windows.go783
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/noncolorable.go57
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/LICENSE9
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/README.md37
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/doc.go2
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_appengine.go9
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_bsd.go18
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_linux.go18
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_solaris.go16
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_windows.go19
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/teamcity_reporter.go93
-rw-r--r--vendor/github.com/onsi/ginkgo/reporters/teamcity_reporter_test.go214
-rw-r--r--vendor/github.com/onsi/ginkgo/types/code_location.go15
-rw-r--r--vendor/github.com/onsi/ginkgo/types/synchronization.go30
-rw-r--r--vendor/github.com/onsi/ginkgo/types/types.go174
-rw-r--r--vendor/github.com/onsi/ginkgo/types/types_suite_test.go13
-rw-r--r--vendor/github.com/onsi/ginkgo/types/types_test.go99
-rw-r--r--vendor/github.com/onsi/gomega/.gitignore5
-rw-r--r--vendor/github.com/onsi/gomega/.travis.yml23
-rw-r--r--vendor/github.com/onsi/gomega/CHANGELOG.md125
-rw-r--r--vendor/github.com/onsi/gomega/CONTRIBUTING.md14
-rw-r--r--vendor/github.com/onsi/gomega/LICENSE20
-rw-r--r--vendor/github.com/onsi/gomega/README.md21
-rw-r--r--vendor/github.com/onsi/gomega/RELEASING.md12
-rw-r--r--vendor/github.com/onsi/gomega/format/format.go382
-rw-r--r--vendor/github.com/onsi/gomega/format/format_suite_test.go13
-rw-r--r--vendor/github.com/onsi/gomega/format/format_test.go627
-rw-r--r--vendor/github.com/onsi/gomega/gbytes/buffer.go245
-rw-r--r--vendor/github.com/onsi/gomega/gbytes/buffer_test.go205
-rw-r--r--vendor/github.com/onsi/gomega/gbytes/gbuffer_suite_test.go13
-rw-r--r--vendor/github.com/onsi/gomega/gbytes/io_wrappers.go85
-rw-r--r--vendor/github.com/onsi/gomega/gbytes/io_wrappers_test.go188
-rw-r--r--vendor/github.com/onsi/gomega/gbytes/say_matcher.go104
-rw-r--r--vendor/github.com/onsi/gomega/gbytes/say_matcher_test.go169
-rw-r--r--vendor/github.com/onsi/gomega/gexec/_fixture/firefly/main.go36
-rw-r--r--vendor/github.com/onsi/gomega/gexec/build.go112
-rw-r--r--vendor/github.com/onsi/gomega/gexec/build_test.go112
-rw-r--r--vendor/github.com/onsi/gomega/gexec/exit_matcher.go86
-rw-r--r--vendor/github.com/onsi/gomega/gexec/exit_matcher_test.go114
-rw-r--r--vendor/github.com/onsi/gomega/gexec/gexec_suite_test.go26
-rw-r--r--vendor/github.com/onsi/gomega/gexec/prefixed_writer.go53
-rw-r--r--vendor/github.com/onsi/gomega/gexec/prefixed_writer_test.go43
-rw-r--r--vendor/github.com/onsi/gomega/gexec/session.go303
-rw-r--r--vendor/github.com/onsi/gomega/gexec/session_test.go336
-rw-r--r--vendor/github.com/onsi/gomega/ghttp/handlers.go322
-rw-r--r--vendor/github.com/onsi/gomega/ghttp/protobuf/protobuf.go3
-rw-r--r--vendor/github.com/onsi/gomega/ghttp/protobuf/simple_message.pb.go55
-rw-r--r--vendor/github.com/onsi/gomega/ghttp/protobuf/simple_message.proto9
-rw-r--r--vendor/github.com/onsi/gomega/ghttp/test_server.go422
-rw-r--r--vendor/github.com/onsi/gomega/ghttp/test_server_suite_test.go13
-rw-r--r--vendor/github.com/onsi/gomega/ghttp/test_server_test.go1129
-rw-r--r--vendor/github.com/onsi/gomega/go.mod15
-rw-r--r--vendor/github.com/onsi/gomega/go.sum24
-rw-r--r--vendor/github.com/onsi/gomega/gomega_dsl.go421
-rw-r--r--vendor/github.com/onsi/gomega/gstruct/elements.go159
-rw-r--r--vendor/github.com/onsi/gomega/gstruct/elements_test.go144
-rw-r--r--vendor/github.com/onsi/gomega/gstruct/errors/nested_types.go72
-rw-r--r--vendor/github.com/onsi/gomega/gstruct/fields.go168
-rw-r--r--vendor/github.com/onsi/gomega/gstruct/fields_test.go76
-rw-r--r--vendor/github.com/onsi/gomega/gstruct/gstruct_tests_suite_test.go13
-rw-r--r--vendor/github.com/onsi/gomega/gstruct/ignore.go37
-rw-r--r--vendor/github.com/onsi/gomega/gstruct/ignore_test.go23
-rw-r--r--vendor/github.com/onsi/gomega/gstruct/pointer.go56
-rw-r--r--vendor/github.com/onsi/gomega/gstruct/pointer_test.go33
-rw-r--r--vendor/github.com/onsi/gomega/gstruct/types.go15
-rw-r--r--vendor/github.com/onsi/gomega/internal/assertion/assertion.go105
-rw-r--r--vendor/github.com/onsi/gomega/internal/assertion/assertion_suite_test.go13
-rw-r--r--vendor/github.com/onsi/gomega/internal/assertion/assertion_test.go258
-rw-r--r--vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion.go194
-rw-r--r--vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_suite_test.go13
-rw-r--r--vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_test.go351
-rw-r--r--vendor/github.com/onsi/gomega/internal/fakematcher/fake_matcher.go23
-rw-r--r--vendor/github.com/onsi/gomega/internal/oraclematcher/oracle_matcher.go25
-rw-r--r--vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support.go60
-rw-r--r--vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support_test.go92
-rw-r--r--vendor/github.com/onsi/gomega/matchers.go427
-rw-r--r--vendor/github.com/onsi/gomega/matchers/and.go63
-rw-r--r--vendor/github.com/onsi/gomega/matchers/and_test.go103
-rw-r--r--vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher.go35
-rw-r--r--vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher_test.go46
-rw-r--r--vendor/github.com/onsi/gomega/matchers/attributes_slice.go14
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_a_directory.go54
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_a_directory_test.go40
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_a_regular_file.go54
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_a_regular_file_test.go40
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_an_existing_file.go38
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_an_existing_file_test.go40
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_closed_matcher.go46
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_closed_matcher_test.go70
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_empty_matcher.go27
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_empty_matcher_test.go52
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher.go34
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher_test.go50
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_false_matcher.go26
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_false_matcher_test.go20
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_identical_to.go37
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_identical_to_test.go61
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_nil_matcher.go18
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_nil_matcher_test.go28
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go132
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_numerically_matcher_test.go172
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_sent_matcher.go71
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_sent_matcher_test.go107
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_temporally_matcher.go66
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_temporally_matcher_test.go99
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_true_matcher.go26
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_true_matcher_test.go20
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_zero_matcher.go28
-rw-r--r--vendor/github.com/onsi/gomega/matchers/be_zero_matcher_test.go40
-rw-r--r--vendor/github.com/onsi/gomega/matchers/consist_of.go80
-rw-r--r--vendor/github.com/onsi/gomega/matchers/consist_of_test.go75
-rw-r--r--vendor/github.com/onsi/gomega/matchers/contain_element_matcher.go56
-rw-r--r--vendor/github.com/onsi/gomega/matchers/contain_element_matcher_test.go76
-rw-r--r--vendor/github.com/onsi/gomega/matchers/contain_substring_matcher.go38
-rw-r--r--vendor/github.com/onsi/gomega/matchers/contain_substring_matcher_test.go36
-rw-r--r--vendor/github.com/onsi/gomega/matchers/equal_matcher.go42
-rw-r--r--vendor/github.com/onsi/gomega/matchers/equal_matcher_test.go80
-rw-r--r--vendor/github.com/onsi/gomega/matchers/have_cap_matcher.go28
-rw-r--r--vendor/github.com/onsi/gomega/matchers/have_cap_matcher_test.go50
-rw-r--r--vendor/github.com/onsi/gomega/matchers/have_key_matcher.go54
-rw-r--r--vendor/github.com/onsi/gomega/matchers/have_key_matcher_test.go73
-rw-r--r--vendor/github.com/onsi/gomega/matchers/have_key_with_value_matcher.go74
-rw-r--r--vendor/github.com/onsi/gomega/matchers/have_key_with_value_matcher_test.go82
-rw-r--r--vendor/github.com/onsi/gomega/matchers/have_len_matcher.go28
-rw-r--r--vendor/github.com/onsi/gomega/matchers/have_len_matcher_test.go53
-rw-r--r--vendor/github.com/onsi/gomega/matchers/have_occurred_matcher.go33
-rw-r--r--vendor/github.com/onsi/gomega/matchers/have_occurred_matcher_test.go59
-rw-r--r--vendor/github.com/onsi/gomega/matchers/have_prefix_matcher.go36
-rw-r--r--vendor/github.com/onsi/gomega/matchers/have_prefix_matcher_test.go36
-rw-r--r--vendor/github.com/onsi/gomega/matchers/have_suffix_matcher.go36
-rw-r--r--vendor/github.com/onsi/gomega/matchers/have_suffix_matcher_test.go36
-rw-r--r--vendor/github.com/onsi/gomega/matchers/match_error_matcher.go51
-rw-r--r--vendor/github.com/onsi/gomega/matchers/match_error_matcher_test.go107
-rw-r--r--vendor/github.com/onsi/gomega/matchers/match_json_matcher.go65
-rw-r--r--vendor/github.com/onsi/gomega/matchers/match_json_matcher_test.go103
-rw-r--r--vendor/github.com/onsi/gomega/matchers/match_regexp_matcher.go43
-rw-r--r--vendor/github.com/onsi/gomega/matchers/match_regexp_matcher_test.go44
-rw-r--r--vendor/github.com/onsi/gomega/matchers/match_xml_matcher.go134
-rw-r--r--vendor/github.com/onsi/gomega/matchers/match_xml_matcher_test.go97
-rw-r--r--vendor/github.com/onsi/gomega/matchers/match_yaml_matcher.go76
-rw-r--r--vendor/github.com/onsi/gomega/matchers/match_yaml_matcher_test.go101
-rw-r--r--vendor/github.com/onsi/gomega/matchers/matcher_tests_suite_test.go50
-rw-r--r--vendor/github.com/onsi/gomega/matchers/not.go30
-rw-r--r--vendor/github.com/onsi/gomega/matchers/not_test.go64
-rw-r--r--vendor/github.com/onsi/gomega/matchers/or.go67
-rw-r--r--vendor/github.com/onsi/gomega/matchers/or_test.go92
-rw-r--r--vendor/github.com/onsi/gomega/matchers/panic_matcher.go46
-rw-r--r--vendor/github.com/onsi/gomega/matchers/panic_matcher_test.go52
-rw-r--r--vendor/github.com/onsi/gomega/matchers/receive_matcher.go128
-rw-r--r--vendor/github.com/onsi/gomega/matchers/receive_matcher_test.go304
-rw-r--r--vendor/github.com/onsi/gomega/matchers/semi_structured_data_support.go92
-rw-r--r--vendor/github.com/onsi/gomega/matchers/succeed_matcher.go33
-rw-r--r--vendor/github.com/onsi/gomega/matchers/succeed_matcher_test.go72
-rw-r--r--vendor/github.com/onsi/gomega/matchers/support/goraph/MIT.LICENSE20
-rw-r--r--vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraph.go41
-rw-r--r--vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraphmatching.go159
-rw-r--r--vendor/github.com/onsi/gomega/matchers/support/goraph/edge/edge.go61
-rw-r--r--vendor/github.com/onsi/gomega/matchers/support/goraph/node/node.go7
-rw-r--r--vendor/github.com/onsi/gomega/matchers/support/goraph/util/util.go7
-rw-r--r--vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_01.xml6
-rw-r--r--vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_02.xml9
-rw-r--r--vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_03.xml1
-rw-r--r--vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_04.xml6
-rw-r--r--vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_05.xml211
-rw-r--r--vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_06.xml13
-rw-r--r--vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_07.xml13
-rw-r--r--vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_08.xml13
-rw-r--r--vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_09.xml4
-rw-r--r--vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_10.xml4
-rw-r--r--vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_11.xml7
-rw-r--r--vendor/github.com/onsi/gomega/matchers/type_support.go179
-rw-r--r--vendor/github.com/onsi/gomega/matchers/with_transform.go72
-rw-r--r--vendor/github.com/onsi/gomega/matchers/with_transform_test.go102
-rw-r--r--vendor/github.com/onsi/gomega/types/types.go26
-rw-r--r--vendor/github.com/urfave/cli/help.go2
-rw-r--r--vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go45
-rw-r--r--vendor/github.com/varlink/go/cmd/varlink/main.go28
-rw-r--r--vendor/github.com/varlink/go/varlink/varlink_test.go52
-rw-r--r--vendor/gopkg.in/fsnotify.v1/LICENSE28
-rw-r--r--vendor/gopkg.in/fsnotify.v1/README.md50
-rw-r--r--vendor/gopkg.in/fsnotify.v1/fen.go37
-rw-r--r--vendor/gopkg.in/fsnotify.v1/fsnotify.go62
-rw-r--r--vendor/gopkg.in/fsnotify.v1/inotify.go325
-rw-r--r--vendor/gopkg.in/fsnotify.v1/inotify_poller.go187
-rw-r--r--vendor/gopkg.in/fsnotify.v1/kqueue.go503
-rw-r--r--vendor/gopkg.in/fsnotify.v1/open_mode_bsd.go11
-rw-r--r--vendor/gopkg.in/fsnotify.v1/open_mode_darwin.go12
-rw-r--r--vendor/gopkg.in/fsnotify.v1/windows.go561
-rw-r--r--vendor/gopkg.in/tomb.v1/LICENSE29
-rw-r--r--vendor/gopkg.in/tomb.v1/README.md4
-rw-r--r--vendor/gopkg.in/tomb.v1/tomb.go176
467 files changed, 40294 insertions, 230 deletions
diff --git a/.cirrus.yml b/.cirrus.yml
index dbd0e8b3e..cb1279331 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -109,6 +109,16 @@ gating_task:
- '/usr/local/bin/entrypoint.sh validate'
- '/usr/local/bin/entrypoint.sh lint'
+ # This task runs `make vendor` followed by ./hack/tree_status.sh to check
+ # whether the git tree is clean. The reasoning for that is to make sure
+ # that the vendor.conf, the code and the vendored packages in ./vendor are
+ # in sync at all times.
+ vendor_script:
+ - '/usr/local/bin/entrypoint.sh .install.vndr'
+ - '/usr/local/bin/entrypoint.sh vendor'
+ - 'cd /go/src/github.com/containers/libpod && ./hack/tree_status.sh'
+
+
build_each_commit_task:
depends_on:
@@ -252,6 +262,7 @@ success_task:
depends_on: # ignores any dependent task conditions
- "gating"
+ - "vendor_check"
- "testing"
- "optional_testing"
- "cache_images"
diff --git a/Makefile b/Makefile
index 334ee980d..df8549541 100644
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,7 @@ ifneq (,$(findstring varlink,$(BUILDTAGS)))
PODMAN_VARLINK_DEPENDENCIES = cmd/podman/varlink/iopodman.go
endif
CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null || echo docker)
+OCI_RUNTIME ?= ""
BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions
OCIUMOUNTINSTALLDIR=$(PREFIX)/share/oci-umount/oci-umount.d
@@ -41,6 +42,10 @@ ISODATE ?= $(shell date --iso-8601)
#Update to LIBSECCOMP_COMMIT should reflect in Dockerfile too.
LIBSECCOMP_COMMIT := release-2.3
+# Rarely if ever should integration tests take more than 50min,
+# caller may override in special circumstances if needed.
+GINKGOTIMEOUT ?= -timeout=50m
+
# If GOPATH not specified, use one in the local directory
ifeq ($(GOPATH),)
export GOPATH := $(CURDIR)/_output
@@ -67,28 +72,36 @@ all: binaries docs
default: help
+define PRINT_HELP_PYSCRIPT
+import re, sys
+
+print("Usage: make <target>")
+cmds = {}
+for line in sys.stdin:
+ match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
+ if match:
+ target, help = match.groups()
+ cmds.update({target: help})
+for cmd in sorted(cmds):
+ print(" * '%s' - %s" % (cmd, cmds[cmd]))
+endef
+export PRINT_HELP_PYSCRIPT
+
help:
- @echo "Usage: make <target>"
- @echo
- @echo " * 'install' - Install binaries to system locations"
- @echo " * 'binaries' - Build podman"
- @echo " * 'integration' - Execute integration tests"
- @echo " * 'clean' - Clean artifacts"
- @echo " * 'lint' - Execute the source code linter"
- @echo " * 'gofmt' - Verify the source code gofmt"
+ @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
.gopathok:
ifeq ("$(wildcard $(GOPKGDIR))","")
mkdir -p "$(GOPKGBASEDIR)"
- ln -s "$(CURDIR)" "$(GOPKGBASEDIR)"
+ ln -sf "$(CURDIR)" "$(GOPKGBASEDIR)"
endif
touch $@
-lint: .gopathok varlink_generate
+lint: .gopathok varlink_generate ## Execute the source code linter
@echo "checking lint"
@./.tool/lint
-gofmt:
+gofmt: ## Verify the source code gofmt
find . -name '*.go' ! -path './vendor/*' -exec gofmt -s -w {} \+
git diff --exit-code
@@ -104,16 +117,16 @@ test/checkseccomp/checkseccomp: .gopathok $(wildcard test/checkseccomp/*.go)
test/goecho/goecho: .gopathok $(wildcard test/goecho/*.go)
$(GO) build -ldflags '$(LDFLAGS)' -o $@ $(PROJECT)/test/goecho
-podman: .gopathok $(PODMAN_VARLINK_DEPENDENCIES)
+podman: .gopathok $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman
$(GO) build -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS)" -o bin/$@ $(PROJECT)/cmd/podman
-podman-remote: .gopathok $(PODMAN_VARLINK_DEPENDENCIES)
+podman-remote: .gopathok $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman on remote environment
$(GO) build -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS) remoteclient" -o bin/$@ $(PROJECT)/cmd/podman
-podman-remote-darwin: .gopathok $(PODMAN_VARLINK_DEPENDENCIES)
+podman-remote-darwin: .gopathok $(PODMAN_VARLINK_DEPENDENCIES) ## Build with podman on remote OSX environment
GOOS=darwin $(GO) build -ldflags '$(LDFLAGS_PODMAN)' -tags "remoteclient containers_image_openpgp exclude_graphdriver_devicemapper" -o bin/$@ $(PROJECT)/cmd/podman
-local-cross: $(CROSS_BUILD_TARGETS)
+local-cross: $(CROSS_BUILD_TARGETS) ## Cross local compilation
bin/podman.cross.%: .gopathok
TARGET="$*"; \
@@ -121,7 +134,7 @@ bin/podman.cross.%: .gopathok
GOARCH="$${TARGET##*.}" \
$(GO) build -ldflags '$(LDFLAGS_PODMAN)' -tags '$(BUILDTAGS_CROSS)' -o "$@" $(PROJECT)/cmd/podman
-clean:
+clean: ## Clean artifacts
rm -rf \
.gopathok \
_output \
@@ -141,17 +154,17 @@ clean:
find . -name \*~ -delete
find . -name \#\* -delete
-libpodimage:
+libpodimage: ## Build the libpod image
${CONTAINER_RUNTIME} build -t ${LIBPOD_IMAGE} .
dbuild: libpodimage
${CONTAINER_RUNTIME} run --name=${LIBPOD_INSTANCE} --privileged -v ${PWD}:/go/src/${PROJECT} --rm ${LIBPOD_IMAGE} make all
-test: libpodimage
- ${CONTAINER_RUNTIME} run -e STORAGE_OPTIONS="--storage-driver=vfs" -e TESTFLAGS -e CGROUP_MANAGER=cgroupfs -e TRAVIS -t --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${LIBPOD_IMAGE} make clean all localunit install.catatonit localintegration
+test: libpodimage ## Run tests on built image
+ ${CONTAINER_RUNTIME} run -e STORAGE_OPTIONS="--storage-driver=vfs" -e TESTFLAGS -e OCI_RUNTIME -e CGROUP_MANAGER=cgroupfs -e TRAVIS -t --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${LIBPOD_IMAGE} make clean all localunit install.catatonit localintegration
-integration: libpodimage
- ${CONTAINER_RUNTIME} run -e STORAGE_OPTIONS="--storage-driver=vfs" -e TESTFLAGS -e CGROUP_MANAGER=cgroupfs -e TRAVIS -t --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${LIBPOD_IMAGE} make clean all install.catatonit localintegration
+integration: libpodimage ## Execute integration tests
+ ${CONTAINER_RUNTIME} run -e STORAGE_OPTIONS="--storage-driver=vfs" -e TESTFLAGS -e OCI_RUNTIME -e CGROUP_MANAGER=cgroupfs -e TRAVIS -t --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${LIBPOD_IMAGE} make clean all install.catatonit localintegration
integration.fedora:
DIST=Fedora sh .papr_prepare.sh
@@ -159,40 +172,40 @@ integration.fedora:
integration.centos:
DIST=CentOS sh .papr_prepare.sh
-shell: libpodimage
- ${CONTAINER_RUNTIME} run -e STORAGE_OPTIONS="--storage-driver=vfs" -e CGROUP_MANAGER=cgroupfs -e TESTFLAGS -e TRAVIS -it --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${LIBPOD_IMAGE} sh
+shell: libpodimage ## Run the built image and attach a shell
+ ${CONTAINER_RUNTIME} run -e STORAGE_OPTIONS="--storage-driver=vfs" -e CGROUP_MANAGER=cgroupfs -e TESTFLAGS -e OCI_RUNTIME -e TRAVIS -it --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${LIBPOD_IMAGE} sh
-testunit: libpodimage
- ${CONTAINER_RUNTIME} run -e STORAGE_OPTIONS="--storage-driver=vfs" -e TESTFLAGS -e CGROUP_MANAGER=cgroupfs -e TRAVIS -t --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${LIBPOD_IMAGE} make localunit
+testunit: libpodimage ## Run unittest on the built image
+ ${CONTAINER_RUNTIME} run -e STORAGE_OPTIONS="--storage-driver=vfs" -e TESTFLAGS -e CGROUP_MANAGER=cgroupfs -e OCI_RUNTIME -e TRAVIS -t --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${LIBPOD_IMAGE} make localunit
localunit: test/goecho/goecho varlink_generate
$(GO) test -tags "$(BUILDTAGS)" -cover $(PACKAGES)
$(MAKE) -C contrib/cirrus/packer test
ginkgo:
- ginkgo -v -tags "$(BUILDTAGS)" -cover -flakeAttempts 3 -progress -trace -noColor test/e2e/.
+ ginkgo -v -tags "$(BUILDTAGS)" $(GINKGOTIMEOUT) -cover -flakeAttempts 3 -progress -trace -noColor test/e2e/.
ginkgo-remote:
- ginkgo -v -tags "$(BUILDTAGS) remoteclient" -cover -flakeAttempts 3 -progress -trace -noColor test/e2e/.
+ ginkgo -v -tags "$(BUILDTAGS) remoteclient" $(GINKGOTIMEOUT) -cover -flakeAttempts 3 -progress -trace -noColor test/e2e/.
localintegration: varlink_generate test-binaries ginkgo ginkgo-remote
-localsystem: .install.ginkgo .install.gomega
+localsystem: .install.ginkgo
ginkgo -v -noColor test/system/
-system.test-binary: .install.ginkgo .install.gomega
+system.test-binary: .install.ginkgo
$(GO) test -c ./test/system
-perftest:
+perftest: ## Build perf tests
$ cd contrib/perftest;go build
-run-perftest: perftest
+run-perftest: perftest ## Build and run perf tests
$ contrib/perftest/perftest
vagrant-check:
BOX=$(BOX) sh ./vagrant.sh
-binaries: varlink_generate podman podman-remote
+binaries: varlink_generate podman podman-remote ## Build podman
install.catatonit:
./hack/install_catatonit.sh
@@ -205,12 +218,12 @@ MANPAGES ?= $(MANPAGES_MD:%.md=%)
$(MANPAGES): %: %.md .gopathok
@sed -e 's/\((podman.*\.md)\)//' -e 's/\[\(podman.*\)\]/\1/' $< | $(GOMD2MAN) -in /dev/stdin -out $@
-docs: $(MANPAGES)
+docs: $(MANPAGES) ## Generate documentation
docker-docs: docs
(cd docs; ./dckrman.sh *.1)
-changelog:
+changelog: ## Generate changelog
@echo "Creating changelog from $(CHANGELOG_BASE) to $(CHANGELOG_TARGET)"
$(eval TMPFILE := $(shell mktemp))
$(shell cat changelog.txt > $(TMPFILE))
@@ -220,7 +233,7 @@ changelog:
$(shell cat $(TMPFILE) >> changelog.txt)
$(shell rm $(TMPFILE))
-install: .gopathok install.bin install.man install.cni install.systemd
+install: .gopathok install.bin install.man install.cni install.systemd ## Install binaries to system locations
install.bin:
install ${SELINUXOPT} -d -m 755 $(BINDIR)
@@ -273,14 +286,14 @@ uninstall:
.PHONY: install.tools
-install.tools: .install.gitvalidation .install.gometalinter .install.md2man .install.ginkgo .install.gomega
+install.tools: .install.gitvalidation .install.gometalinter .install.md2man .install.ginkgo ## Install needed tools
-.install.gomega: .gopathok
- $(GO) get github.com/onsi/gomega/...
+.install.vndr: .gopathok
+ $(GO) get github.com/LK4D4/vndr
.install.ginkgo: .gopathok
if [ ! -x "$(GOBIN)/ginkgo" ]; then \
- $(GO) get -u github.com/onsi/ginkgo/ginkgo; \
+ $(GO) build -o ${GOPATH}/bin/ginkgo ./vendor/github.com/onsi/ginkgo/ginkgo ; \
fi
.install.gitvalidation: .gopathok
@@ -336,7 +349,9 @@ build-all-new-commits:
git rebase $(GIT_BASE_BRANCH) -x make
vendor:
- vndr -whitelist "github.com/varlink/go"
+ vndr -whitelist "github.com/varlink/go" \
+ -whitelist "github.com/onsi/ginkgo" \
+ -whitelist "github.com/onsi/gomega"
.PHONY: \
.gopathok \
diff --git a/cmd/podman/docker/types.go b/cmd/podman/docker/types.go
index 90349a31c..eda618e40 100644
--- a/cmd/podman/docker/types.go
+++ b/cmd/podman/docker/types.go
@@ -69,8 +69,9 @@ type HealthConfig struct {
Test []string `json:",omitempty"`
// Zero means to inherit. Durations are expressed as integer nanoseconds.
- Interval time.Duration `json:",omitempty"` // Interval is the time to wait between checks.
- Timeout time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung.
+ Interval time.Duration `json:",omitempty"` // Interval is the time to wait between checks.
+ Timeout time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung.
+ StartPeriod time.Duration `json:",omitempty"` // Time to wait after the container starts before running the first check.
// Retries is the number of consecutive failures needed to consider a container as unhealthy.
// Zero means inherit.
diff --git a/contrib/cirrus/README.md b/contrib/cirrus/README.md
index e175479f1..0d91301c6 100644
--- a/contrib/cirrus/README.md
+++ b/contrib/cirrus/README.md
@@ -28,6 +28,10 @@ task (pass or fail) is set based on the exit status of the last script to execut
4. ``lint``: Execute regular `make lint` to check for any code cruft.
Should also run for less than a few minutes.
+5. ``vendor``: runs `make vendor` followed by `./hack/tree_status.sh` to check
+ whether the git tree is clean. The reasoning for that is to make sure that
+ the vendor.conf, the code and the vendored packages in ./vendor are in sync
+ at all times.
### ``testing`` Task
diff --git a/hack/tree_status.sh b/hack/tree_status.sh
new file mode 100755
index 000000000..12c1d1ee5
--- /dev/null
+++ b/hack/tree_status.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+set -e
+
+STATUS=$(git status --porcelain)
+if [[ -z $STATUS ]]
+then
+ echo "tree is clean"
+else
+ echo "tree is dirty, please commit all changes and sync the vendor.conf"
+ echo ""
+ echo $STATUS
+ exit 1
+fi
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 39c1501da..b0dcc853e 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -392,7 +392,9 @@ func resetState(state *ContainerState) error {
state.PID = 0
state.Mountpoint = ""
state.Mounted = false
- state.State = ContainerStateConfigured
+ if state.State != ContainerStateExited {
+ state.State = ContainerStateConfigured
+ }
state.ExecSessions = make(map[string]*ExecSession)
state.NetworkStatus = nil
state.BindMounts = make(map[string]string)
diff --git a/pkg/spec/spec.go b/pkg/spec/spec.go
index 46105af4a..76b8963ff 100644
--- a/pkg/spec/spec.go
+++ b/pkg/spec/spec.go
@@ -9,6 +9,7 @@ import (
"github.com/containers/storage/pkg/mount"
"github.com/docker/docker/daemon/caps"
"github.com/docker/go-units"
+ "github.com/opencontainers/runc/libcontainer/user"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
"github.com/pkg/errors"
@@ -45,6 +46,18 @@ func supercedeUserMounts(mounts []spec.Mount, configMount []spec.Mount) []spec.M
return configMount
}
+func getAvailableGids() (int64, error) {
+ idMap, err := user.ParseIDMapFile("/proc/self/gid_map")
+ if err != nil {
+ return 0, err
+ }
+ count := int64(0)
+ for _, r := range idMap {
+ count += r.Count
+ }
+ return count, nil
+}
+
// CreateConfigToOCISpec parses information needed to create a container into an OCI runtime spec
func CreateConfigToOCISpec(config *CreateConfig) (*spec.Spec, error) { //nolint
cgroupPerm := "ro"
@@ -91,14 +104,21 @@ func CreateConfigToOCISpec(config *CreateConfig) (*spec.Spec, error) { //nolint
g.AddMount(sysMnt)
}
if isRootless {
- g.RemoveMount("/dev/pts")
- devPts := spec.Mount{
- Destination: "/dev/pts",
- Type: "devpts",
- Source: "devpts",
- Options: []string{"rprivate", "nosuid", "noexec", "newinstance", "ptmxmode=0666", "mode=0620"},
+ nGids, err := getAvailableGids()
+ if err != nil {
+ return nil, err
+ }
+ if nGids < 5 {
+ // If we have no GID mappings, the gid=5 default option would fail, so drop it.
+ g.RemoveMount("/dev/pts")
+ devPts := spec.Mount{
+ Destination: "/dev/pts",
+ Type: "devpts",
+ Source: "devpts",
+ Options: []string{"rprivate", "nosuid", "noexec", "newinstance", "ptmxmode=0666", "mode=0620"},
+ }
+ g.AddMount(devPts)
}
- g.AddMount(devPts)
}
if inUserNS && config.IpcMode.IsHost() {
g.RemoveMount("/dev/mqueue")
diff --git a/test/README.md b/test/README.md
index fd72ecd00..90dcdfe3d 100644
--- a/test/README.md
+++ b/test/README.md
@@ -34,27 +34,14 @@ between Ginkgo and the Go test framework.
## Installing dependencies
The dependencies for integration really consists of three things:
* ginkgo binary
-* ginkgo sources
-* gomega sources
The following instructions assume your GOPATH is ~/go. Adjust as needed for your
environment.
### Installing ginkgo
-Fetch and build ginkgo with the following command:
+Build ginkgo and install it under $GOPATH/bin with the following command:
```
-GOPATH=~/go go get -u github.com/onsi/ginkgo/ginkgo
-```
-Now install the ginkgo binary into your path:
-```
-install -D -m 755 "$GOPATH"/bin/ginkgo /usr/bin/
-```
-You now have a ginkgo binary and its sources in your GOPATH.
-
-### Install gomega sources
-The gomega sources can be simply installed with the command:
-```
-GOPATH=~/go go get github.com/onsi/gomega/...
+GOPATH=~/go make .install.ginkgo
```
# Integration Tests
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go
index 308a6bf29..b22ead3fa 100644
--- a/test/e2e/common_test.go
+++ b/test/e2e/common_test.go
@@ -34,7 +34,7 @@ type PodmanTestIntegration struct {
ConmonBinary string
CrioRoot string
CNIConfigDir string
- RunCBinary string
+ OCIRuntime string
RunRoot string
StorageOptions string
SignaturePolicyPath string
@@ -136,12 +136,16 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
cgroupManager = "cgroupfs"
}
- runCBinary, err := exec.LookPath("runc")
- // If we cannot find the runc binary, setting to something static as we have no way
- // to return an error. The tests will fail and point out that the runc binary could
- // not be found nicely.
- if err != nil {
- runCBinary = "/usr/bin/runc"
+ ociRuntime := os.Getenv("OCI_RUNTIME")
+ if ociRuntime == "" {
+ var err error
+ ociRuntime, err = exec.LookPath("runc")
+ // If we cannot find the runc binary, setting to something static as we have no way
+ // to return an error. The tests will fail and point out that the runc binary could
+ // not be found nicely.
+ if err != nil {
+ ociRuntime = "/usr/bin/runc"
+ }
}
CNIConfigDir := "/etc/cni/net.d"
@@ -156,7 +160,7 @@ func PodmanTestCreateUtil(tempDir string, remote bool) *PodmanTestIntegration {
ConmonBinary: conmonBinary,
CrioRoot: filepath.Join(tempDir, "crio"),
CNIConfigDir: CNIConfigDir,
- RunCBinary: runCBinary,
+ OCIRuntime: ociRuntime,
RunRoot: filepath.Join(tempDir, "crio-run"),
StorageOptions: storageOptions,
SignaturePolicyPath: filepath.Join(INTEGRATION_ROOT, "test/policy.json"),
diff --git a/test/e2e/libpod_suite_remoteclient_test.go b/test/e2e/libpod_suite_remoteclient_test.go
index 4b769a574..e6bc00397 100644
--- a/test/e2e/libpod_suite_remoteclient_test.go
+++ b/test/e2e/libpod_suite_remoteclient_test.go
@@ -164,7 +164,7 @@ func (p *PodmanTestIntegration) makeOptions(args []string) []string {
//MakeOptions assembles all the podman main options
func getVarlinkOptions(p *PodmanTestIntegration, args []string) []string {
podmanOptions := strings.Split(fmt.Sprintf("--root %s --runroot %s --runtime %s --conmon %s --cni-config-dir %s --cgroup-manager %s",
- p.CrioRoot, p.RunRoot, p.RunCBinary, p.ConmonBinary, p.CNIConfigDir, p.CgroupManager), " ")
+ p.CrioRoot, p.RunRoot, p.OCIRuntime, p.ConmonBinary, p.CNIConfigDir, p.CgroupManager), " ")
if os.Getenv("HOOK_OPTION") != "" {
podmanOptions = append(podmanOptions, os.Getenv("HOOK_OPTION"))
}
diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go
index 1f218cbdf..4b4baa93c 100644
--- a/test/e2e/libpod_suite_test.go
+++ b/test/e2e/libpod_suite_test.go
@@ -207,7 +207,7 @@ func PodmanTestCreate(tempDir string) *PodmanTestIntegration {
//MakeOptions assembles all the podman main options
func (p *PodmanTestIntegration) makeOptions(args []string) []string {
podmanOptions := strings.Split(fmt.Sprintf("--root %s --runroot %s --runtime %s --conmon %s --cni-config-dir %s --cgroup-manager %s",
- p.CrioRoot, p.RunRoot, p.RunCBinary, p.ConmonBinary, p.CNIConfigDir, p.CgroupManager), " ")
+ p.CrioRoot, p.RunRoot, p.OCIRuntime, p.ConmonBinary, p.CNIConfigDir, p.CgroupManager), " ")
if os.Getenv("HOOK_OPTION") != "" {
podmanOptions = append(podmanOptions, os.Getenv("HOOK_OPTION"))
}
diff --git a/test/e2e/run_signal_test.go b/test/e2e/run_signal_test.go
index 9be8e7810..51c14602e 100644
--- a/test/e2e/run_signal_test.go
+++ b/test/e2e/run_signal_test.go
@@ -55,7 +55,7 @@ var _ = Describe("Podman run with --sig-proxy", func() {
_, pid := podmanTest.PodmanPID([]string{"run", "-it", "-v", fmt.Sprintf("%s:/h:Z", udsDir), fedoraMinimal, "bash", "-c", sigCatch})
- uds, _ := os.OpenFile(udsPath, os.O_RDONLY, 0600)
+ uds, _ := os.OpenFile(udsPath, os.O_RDONLY|syscall.O_NONBLOCK, 0600)
defer uds.Close()
// Wait for the script in the container to alert us that it is READY
@@ -73,7 +73,7 @@ var _ = Describe("Podman run with --sig-proxy", func() {
}
time.Sleep(1 * time.Second)
if counter == 15 {
- os.Exit(1)
+ Fail("Timed out waiting for READY from container")
}
counter++
}
@@ -99,7 +99,7 @@ var _ = Describe("Podman run with --sig-proxy", func() {
}
time.Sleep(1 * time.Second)
if counter == 15 {
- os.Exit(1)
+ Fail("timed out waiting for FOO from container")
}
counter++
}
diff --git a/vendor.conf b/vendor.conf
index ce3ca9d44..cd018e3c2 100644
--- a/vendor.conf
+++ b/vendor.conf
@@ -90,8 +90,8 @@ k8s.io/api kubernetes-1.10.13-beta.0 https://github.com/kubernetes/api
k8s.io/apimachinery kubernetes-1.10.13-beta.0 https://github.com/kubernetes/apimachinery
k8s.io/client-go kubernetes-1.10.13-beta.0 https://github.com/kubernetes/client-go
github.com/mrunalp/fileutils 7d4729fb36185a7c1719923406c9d40e54fb93c7
-github.com/varlink/go 92687ab4eb68d99e43b1f5b93477ad76bb54f811
-github.com/containers/buildah 2406e4acaa00938b8324a0ef3caadbe5668ec896
+github.com/varlink/go 3ac79db6fd6aec70924193b090962f92985fe199
+github.com/containers/buildah e7ca330f923701dba8859f5c014d0a9a3f7f0a49
# TODO: Gotty has not been updated since 2012. Can we find replacement?
github.com/Nvveen/Gotty cd527374f1e5bff4938207604a14f2e38a9cf512
# do not go beyond the below commit as the next one requires a more recent
@@ -105,3 +105,8 @@ github.com/pkg/profile v1.2.1
github.com/klauspost/pgzip v1.2.1
github.com/klauspost/compress v1.4.1
github.com/klauspost/cpuid v1.2.0
+github.com/onsi/ginkgo v1.7.0
+github.com/onsi/gomega v1.4.3
+github.com/hpcloud/tail v1.0.0
+gopkg.in/fsnotify.v1 v1.4.2
+gopkg.in/tomb.v1 v1
diff --git a/vendor/github.com/containers/buildah/imagebuildah/build.go b/vendor/github.com/containers/buildah/imagebuildah/build.go
index 56ab7aa57..217bcfc79 100644
--- a/vendor/github.com/containers/buildah/imagebuildah/build.go
+++ b/vendor/github.com/containers/buildah/imagebuildah/build.go
@@ -1311,17 +1311,13 @@ func (b *Executor) Build(ctx context.Context, stages imagebuilder.Stages) (strin
// Check if we have a one line Dockerfile making layers irrelevant
// or the user told us to ignore layers.
- singleLineDockerfile := (len(stages) < 2 && len(stages[0].Node.Children) < 1)
- ignoreLayers := singleLineDockerfile || !b.layers && !b.noCache
+ ignoreLayers := (len(stages) < 2 && len(stages[0].Node.Children) < 2) || (!b.layers && !b.noCache)
if ignoreLayers {
imgID, ref, err := stageExecutor.Commit(ctx, stages[len(stages)-1].Builder, "")
if err != nil {
return "", nil, err
}
- if singleLineDockerfile {
- b.log("COMMIT %s", ref)
- }
imageID = imgID
imageRef = ref
}
@@ -1531,17 +1527,6 @@ func (b *Executor) deleteSuccessfulIntermediateCtrs() error {
return lastErr
}
-func (b *Executor) EnsureContainerPath(path string) error {
- _, err := os.Stat(filepath.Join(b.mountPoint, path))
- if err != nil && os.IsNotExist(err) {
- err = os.MkdirAll(filepath.Join(b.mountPoint, path), 0755)
- }
- if err != nil {
- return errors.Wrapf(err, "error ensuring container path %q", path)
- }
- return nil
-}
-
// preprocessDockerfileContents runs CPP(1) in preprocess-only mode on the input
// dockerfile content and will use ctxDir as the base include path.
//
diff --git a/vendor/github.com/containers/storage/pkg/archive/example_changes.go b/vendor/github.com/containers/storage/pkg/archive/example_changes.go
deleted file mode 100644
index 70f9c5564..000000000
--- a/vendor/github.com/containers/storage/pkg/archive/example_changes.go
+++ /dev/null
@@ -1,97 +0,0 @@
-// +build ignore
-
-// Simple tool to create an archive stream from an old and new directory
-//
-// By default it will stream the comparison of two temporary directories with junk files
-package main
-
-import (
- "flag"
- "fmt"
- "io"
- "io/ioutil"
- "os"
- "path"
-
- "github.com/containers/storage/pkg/archive"
- "github.com/sirupsen/logrus"
-)
-
-var (
- flDebug = flag.Bool("D", false, "debugging output")
- flNewDir = flag.String("newdir", "", "")
- flOldDir = flag.String("olddir", "", "")
- log = logrus.New()
-)
-
-func main() {
- flag.Usage = func() {
- fmt.Println("Produce a tar from comparing two directory paths. By default a demo tar is created of around 200 files (including hardlinks)")
- fmt.Printf("%s [OPTIONS]\n", os.Args[0])
- flag.PrintDefaults()
- }
- flag.Parse()
- log.Out = os.Stderr
- if (len(os.Getenv("DEBUG")) > 0) || *flDebug {
- logrus.SetLevel(logrus.DebugLevel)
- }
- var newDir, oldDir string
-
- if len(*flNewDir) == 0 {
- var err error
- newDir, err = ioutil.TempDir("", "storage-test-newDir")
- if err != nil {
- log.Fatal(err)
- }
- defer os.RemoveAll(newDir)
- if _, err := prepareUntarSourceDirectory(100, newDir, true); err != nil {
- log.Fatal(err)
- }
- } else {
- newDir = *flNewDir
- }
-
- if len(*flOldDir) == 0 {
- oldDir, err := ioutil.TempDir("", "storage-test-oldDir")
- if err != nil {
- log.Fatal(err)
- }
- defer os.RemoveAll(oldDir)
- } else {
- oldDir = *flOldDir
- }
-
- changes, err := archive.ChangesDirs(newDir, oldDir)
- if err != nil {
- log.Fatal(err)
- }
-
- a, err := archive.ExportChanges(newDir, changes)
- if err != nil {
- log.Fatal(err)
- }
- defer a.Close()
-
- i, err := io.Copy(os.Stdout, a)
- if err != nil && err != io.EOF {
- log.Fatal(err)
- }
- fmt.Fprintf(os.Stderr, "wrote archive of %d bytes", i)
-}
-
-func prepareUntarSourceDirectory(numberOfFiles int, targetPath string, makeLinks bool) (int, error) {
- fileData := []byte("fooo")
- for n := 0; n < numberOfFiles; n++ {
- fileName := fmt.Sprintf("file-%d", n)
- if err := ioutil.WriteFile(path.Join(targetPath, fileName), fileData, 0700); err != nil {
- return 0, err
- }
- if makeLinks {
- if err := os.Link(path.Join(targetPath, fileName), path.Join(targetPath, fileName+"-link")); err != nil {
- return 0, err
- }
- }
- }
- totalSize := numberOfFiles * len(fileData)
- return totalSize, nil
-}
diff --git a/vendor/github.com/hpcloud/tail/LICENSE.txt b/vendor/github.com/hpcloud/tail/LICENSE.txt
new file mode 100644
index 000000000..818d802a5
--- /dev/null
+++ b/vendor/github.com/hpcloud/tail/LICENSE.txt
@@ -0,0 +1,21 @@
+# The MIT License (MIT)
+
+# © Copyright 2015 Hewlett Packard Enterprise Development LP
+Copyright (c) 2014 ActiveState
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/hpcloud/tail/README.md b/vendor/github.com/hpcloud/tail/README.md
new file mode 100644
index 000000000..fb7fbc26c
--- /dev/null
+++ b/vendor/github.com/hpcloud/tail/README.md
@@ -0,0 +1,28 @@
+[![Build Status](https://travis-ci.org/hpcloud/tail.svg)](https://travis-ci.org/hpcloud/tail)
+[![Build status](https://ci.appveyor.com/api/projects/status/kohpsf3rvhjhrox6?svg=true)](https://ci.appveyor.com/project/HelionCloudFoundry/tail)
+
+# Go package for tail-ing files
+
+A Go package striving to emulate the features of the BSD `tail` program.
+
+```Go
+t, err := tail.TailFile("/var/log/nginx.log", tail.Config{Follow: true})
+for line := range t.Lines {
+ fmt.Println(line.Text)
+}
+```
+
+See [API documentation](http://godoc.org/github.com/hpcloud/tail).
+
+## Log rotation
+
+Tail comes with full support for truncation/move detection as it is
+designed to work with log rotation tools.
+
+## Installing
+
+ go get github.com/hpcloud/tail/...
+
+## Windows support
+
+This package [needs assistance](https://github.com/hpcloud/tail/labels/Windows) for full Windows support.
diff --git a/vendor/github.com/hpcloud/tail/ratelimiter/leakybucket.go b/vendor/github.com/hpcloud/tail/ratelimiter/leakybucket.go
new file mode 100644
index 000000000..358b69e7f
--- /dev/null
+++ b/vendor/github.com/hpcloud/tail/ratelimiter/leakybucket.go
@@ -0,0 +1,97 @@
+// Package ratelimiter implements the Leaky Bucket ratelimiting algorithm with memcached and in-memory backends.
+package ratelimiter
+
+import (
+ "time"
+)
+
+type LeakyBucket struct {
+ Size uint16
+ Fill float64
+ LeakInterval time.Duration // time.Duration for 1 unit of size to leak
+ Lastupdate time.Time
+ Now func() time.Time
+}
+
+func NewLeakyBucket(size uint16, leakInterval time.Duration) *LeakyBucket {
+ bucket := LeakyBucket{
+ Size: size,
+ Fill: 0,
+ LeakInterval: leakInterval,
+ Now: time.Now,
+ Lastupdate: time.Now(),
+ }
+
+ return &bucket
+}
+
+func (b *LeakyBucket) updateFill() {
+ now := b.Now()
+ if b.Fill > 0 {
+ elapsed := now.Sub(b.Lastupdate)
+
+ b.Fill -= float64(elapsed) / float64(b.LeakInterval)
+ if b.Fill < 0 {
+ b.Fill = 0
+ }
+ }
+ b.Lastupdate = now
+}
+
+func (b *LeakyBucket) Pour(amount uint16) bool {
+ b.updateFill()
+
+ var newfill float64 = b.Fill + float64(amount)
+
+ if newfill > float64(b.Size) {
+ return false
+ }
+
+ b.Fill = newfill
+
+ return true
+}
+
+// The time at which this bucket will be completely drained
+func (b *LeakyBucket) DrainedAt() time.Time {
+ return b.Lastupdate.Add(time.Duration(b.Fill * float64(b.LeakInterval)))
+}
+
+// The duration until this bucket is completely drained
+func (b *LeakyBucket) TimeToDrain() time.Duration {
+ return b.DrainedAt().Sub(b.Now())
+}
+
+func (b *LeakyBucket) TimeSinceLastUpdate() time.Duration {
+ return b.Now().Sub(b.Lastupdate)
+}
+
+type LeakyBucketSer struct {
+ Size uint16
+ Fill float64
+ LeakInterval time.Duration // time.Duration for 1 unit of size to leak
+ Lastupdate time.Time
+}
+
+func (b *LeakyBucket) Serialise() *LeakyBucketSer {
+ bucket := LeakyBucketSer{
+ Size: b.Size,
+ Fill: b.Fill,
+ LeakInterval: b.LeakInterval,
+ Lastupdate: b.Lastupdate,
+ }
+
+ return &bucket
+}
+
+func (b *LeakyBucketSer) DeSerialise() *LeakyBucket {
+ bucket := LeakyBucket{
+ Size: b.Size,
+ Fill: b.Fill,
+ LeakInterval: b.LeakInterval,
+ Lastupdate: b.Lastupdate,
+ Now: time.Now,
+ }
+
+ return &bucket
+}
diff --git a/vendor/github.com/hpcloud/tail/ratelimiter/memory.go b/vendor/github.com/hpcloud/tail/ratelimiter/memory.go
new file mode 100644
index 000000000..8f6a5784a
--- /dev/null
+++ b/vendor/github.com/hpcloud/tail/ratelimiter/memory.go
@@ -0,0 +1,58 @@
+package ratelimiter
+
+import (
+ "errors"
+ "time"
+)
+
+const GC_SIZE int = 100
+
+type Memory struct {
+ store map[string]LeakyBucket
+ lastGCCollected time.Time
+}
+
+func NewMemory() *Memory {
+ m := new(Memory)
+ m.store = make(map[string]LeakyBucket)
+ m.lastGCCollected = time.Now()
+ return m
+}
+
+func (m *Memory) GetBucketFor(key string) (*LeakyBucket, error) {
+
+ bucket, ok := m.store[key]
+ if !ok {
+ return nil, errors.New("miss")
+ }
+
+ return &bucket, nil
+}
+
+func (m *Memory) SetBucketFor(key string, bucket LeakyBucket) error {
+
+ if len(m.store) > GC_SIZE {
+ m.GarbageCollect()
+ }
+
+ m.store[key] = bucket
+
+ return nil
+}
+
+func (m *Memory) GarbageCollect() {
+ now := time.Now()
+
+ // rate limit GC to once per minute
+ if now.Add(60*time.Second).Unix() > m.lastGCCollected.Unix() {
+
+ for key, bucket := range m.store {
+ // if the bucket is drained, then GC
+ if bucket.DrainedAt().Unix() > now.Unix() {
+ delete(m.store, key)
+ }
+ }
+
+ m.lastGCCollected = now
+ }
+}
diff --git a/vendor/github.com/hpcloud/tail/ratelimiter/storage.go b/vendor/github.com/hpcloud/tail/ratelimiter/storage.go
new file mode 100644
index 000000000..89b2fe882
--- /dev/null
+++ b/vendor/github.com/hpcloud/tail/ratelimiter/storage.go
@@ -0,0 +1,6 @@
+package ratelimiter
+
+type Storage interface {
+ GetBucketFor(string) (*LeakyBucket, error)
+ SetBucketFor(string, LeakyBucket) error
+}
diff --git a/vendor/github.com/hpcloud/tail/tail.go b/vendor/github.com/hpcloud/tail/tail.go
new file mode 100644
index 000000000..2d252d605
--- /dev/null
+++ b/vendor/github.com/hpcloud/tail/tail.go
@@ -0,0 +1,438 @@
+// Copyright (c) 2015 HPE Software Inc. All rights reserved.
+// Copyright (c) 2013 ActiveState Software Inc. All rights reserved.
+
+package tail
+
+import (
+ "bufio"
+ "errors"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "log"
+ "os"
+ "strings"
+ "sync"
+ "time"
+
+ "github.com/hpcloud/tail/ratelimiter"
+ "github.com/hpcloud/tail/util"
+ "github.com/hpcloud/tail/watch"
+ "gopkg.in/tomb.v1"
+)
+
+var (
+ ErrStop = fmt.Errorf("tail should now stop")
+)
+
+type Line struct {
+ Text string
+ Time time.Time
+ Err error // Error from tail
+}
+
+// NewLine returns a Line with present time.
+func NewLine(text string) *Line {
+ return &Line{text, time.Now(), nil}
+}
+
+// SeekInfo represents arguments to `os.Seek`
+type SeekInfo struct {
+ Offset int64
+ Whence int // os.SEEK_*
+}
+
+type logger interface {
+ Fatal(v ...interface{})
+ Fatalf(format string, v ...interface{})
+ Fatalln(v ...interface{})
+ Panic(v ...interface{})
+ Panicf(format string, v ...interface{})
+ Panicln(v ...interface{})
+ Print(v ...interface{})
+ Printf(format string, v ...interface{})
+ Println(v ...interface{})
+}
+
+// Config is used to specify how a file must be tailed.
+type Config struct {
+ // File-specifc
+ Location *SeekInfo // Seek to this location before tailing
+ ReOpen bool // Reopen recreated files (tail -F)
+ MustExist bool // Fail early if the file does not exist
+ Poll bool // Poll for file changes instead of using inotify
+ Pipe bool // Is a named pipe (mkfifo)
+ RateLimiter *ratelimiter.LeakyBucket
+
+ // Generic IO
+ Follow bool // Continue looking for new lines (tail -f)
+ MaxLineSize int // If non-zero, split longer lines into multiple lines
+
+ // Logger, when nil, is set to tail.DefaultLogger
+ // To disable logging: set field to tail.DiscardingLogger
+ Logger logger
+}
+
+type Tail struct {
+ Filename string
+ Lines chan *Line
+ Config
+
+ file *os.File
+ reader *bufio.Reader
+
+ watcher watch.FileWatcher
+ changes *watch.FileChanges
+
+ tomb.Tomb // provides: Done, Kill, Dying
+
+ lk sync.Mutex
+}
+
+var (
+ // DefaultLogger is used when Config.Logger == nil
+ DefaultLogger = log.New(os.Stderr, "", log.LstdFlags)
+ // DiscardingLogger can be used to disable logging output
+ DiscardingLogger = log.New(ioutil.Discard, "", 0)
+)
+
+// TailFile begins tailing the file. Output stream is made available
+// via the `Tail.Lines` channel. To handle errors during tailing,
+// invoke the `Wait` or `Err` method after finishing reading from the
+// `Lines` channel.
+func TailFile(filename string, config Config) (*Tail, error) {
+ if config.ReOpen && !config.Follow {
+ util.Fatal("cannot set ReOpen without Follow.")
+ }
+
+ t := &Tail{
+ Filename: filename,
+ Lines: make(chan *Line),
+ Config: config,
+ }
+
+ // when Logger was not specified in config, use default logger
+ if t.Logger == nil {
+ t.Logger = log.New(os.Stderr, "", log.LstdFlags)
+ }
+
+ if t.Poll {
+ t.watcher = watch.NewPollingFileWatcher(filename)
+ } else {
+ t.watcher = watch.NewInotifyFileWatcher(filename)
+ }
+
+ if t.MustExist {
+ var err error
+ t.file, err = OpenFile(t.Filename)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ go t.tailFileSync()
+
+ return t, nil
+}
+
+// Return the file's current position, like stdio's ftell().
+// But this value is not very accurate.
+// it may readed one line in the chan(tail.Lines),
+// so it may lost one line.
+func (tail *Tail) Tell() (offset int64, err error) {
+ if tail.file == nil {
+ return
+ }
+ offset, err = tail.file.Seek(0, os.SEEK_CUR)
+ if err != nil {
+ return
+ }
+
+ tail.lk.Lock()
+ defer tail.lk.Unlock()
+ if tail.reader == nil {
+ return
+ }
+
+ offset -= int64(tail.reader.Buffered())
+ return
+}
+
+// Stop stops the tailing activity.
+func (tail *Tail) Stop() error {
+ tail.Kill(nil)
+ return tail.Wait()
+}
+
+// StopAtEOF stops tailing as soon as the end of the file is reached.
+func (tail *Tail) StopAtEOF() error {
+ tail.Kill(errStopAtEOF)
+ return tail.Wait()
+}
+
+var errStopAtEOF = errors.New("tail: stop at eof")
+
+func (tail *Tail) close() {
+ close(tail.Lines)
+ tail.closeFile()
+}
+
+func (tail *Tail) closeFile() {
+ if tail.file != nil {
+ tail.file.Close()
+ tail.file = nil
+ }
+}
+
+func (tail *Tail) reopen() error {
+ tail.closeFile()
+ for {
+ var err error
+ tail.file, err = OpenFile(tail.Filename)
+ if err != nil {
+ if os.IsNotExist(err) {
+ tail.Logger.Printf("Waiting for %s to appear...", tail.Filename)
+ if err := tail.watcher.BlockUntilExists(&tail.Tomb); err != nil {
+ if err == tomb.ErrDying {
+ return err
+ }
+ return fmt.Errorf("Failed to detect creation of %s: %s", tail.Filename, err)
+ }
+ continue
+ }
+ return fmt.Errorf("Unable to open file %s: %s", tail.Filename, err)
+ }
+ break
+ }
+ return nil
+}
+
+func (tail *Tail) readLine() (string, error) {
+ tail.lk.Lock()
+ line, err := tail.reader.ReadString('\n')
+ tail.lk.Unlock()
+ if err != nil {
+ // Note ReadString "returns the data read before the error" in
+ // case of an error, including EOF, so we return it as is. The
+ // caller is expected to process it if err is EOF.
+ return line, err
+ }
+
+ line = strings.TrimRight(line, "\n")
+
+ return line, err
+}
+
+func (tail *Tail) tailFileSync() {
+ defer tail.Done()
+ defer tail.close()
+
+ if !tail.MustExist {
+ // deferred first open.
+ err := tail.reopen()
+ if err != nil {
+ if err != tomb.ErrDying {
+ tail.Kill(err)
+ }
+ return
+ }
+ }
+
+ // Seek to requested location on first open of the file.
+ if tail.Location != nil {
+ _, err := tail.file.Seek(tail.Location.Offset, tail.Location.Whence)
+ tail.Logger.Printf("Seeked %s - %+v\n", tail.Filename, tail.Location)
+ if err != nil {
+ tail.Killf("Seek error on %s: %s", tail.Filename, err)
+ return
+ }
+ }
+
+ tail.openReader()
+
+ var offset int64 = 0
+ var err error
+
+ // Read line by line.
+ for {
+ // do not seek in named pipes
+ if !tail.Pipe {
+ // grab the position in case we need to back up in the event of a half-line
+ offset, err = tail.Tell()
+ if err != nil {
+ tail.Kill(err)
+ return
+ }
+ }
+
+ line, err := tail.readLine()
+
+ // Process `line` even if err is EOF.
+ if err == nil {
+ cooloff := !tail.sendLine(line)
+ if cooloff {
+ // Wait a second before seeking till the end of
+ // file when rate limit is reached.
+ msg := fmt.Sprintf(
+ "Too much log activity; waiting a second " +
+ "before resuming tailing")
+ tail.Lines <- &Line{msg, time.Now(), fmt.Errorf(msg)}
+ select {
+ case <-time.After(time.Second):
+ case <-tail.Dying():
+ return
+ }
+ if err := tail.seekEnd(); err != nil {
+ tail.Kill(err)
+ return
+ }
+ }
+ } else if err == io.EOF {
+ if !tail.Follow {
+ if line != "" {
+ tail.sendLine(line)
+ }
+ return
+ }
+
+ if tail.Follow && line != "" {
+ // this has the potential to never return the last line if
+ // it's not followed by a newline; seems a fair trade here
+ err := tail.seekTo(SeekInfo{Offset: offset, Whence: 0})
+ if err != nil {
+ tail.Kill(err)
+ return
+ }
+ }
+
+ // When EOF is reached, wait for more data to become
+ // available. Wait strategy is based on the `tail.watcher`
+ // implementation (inotify or polling).
+ err := tail.waitForChanges()
+ if err != nil {
+ if err != ErrStop {
+ tail.Kill(err)
+ }
+ return
+ }
+ } else {
+ // non-EOF error
+ tail.Killf("Error reading %s: %s", tail.Filename, err)
+ return
+ }
+
+ select {
+ case <-tail.Dying():
+ if tail.Err() == errStopAtEOF {
+ continue
+ }
+ return
+ default:
+ }
+ }
+}
+
+// waitForChanges waits until the file has been appended, deleted,
+// moved or truncated. When moved or deleted - the file will be
+// reopened if ReOpen is true. Truncated files are always reopened.
+func (tail *Tail) waitForChanges() error {
+ if tail.changes == nil {
+ pos, err := tail.file.Seek(0, os.SEEK_CUR)
+ if err != nil {
+ return err
+ }
+ tail.changes, err = tail.watcher.ChangeEvents(&tail.Tomb, pos)
+ if err != nil {
+ return err
+ }
+ }
+
+ select {
+ case <-tail.changes.Modified:
+ return nil
+ case <-tail.changes.Deleted:
+ tail.changes = nil
+ if tail.ReOpen {
+ // XXX: we must not log from a library.
+ tail.Logger.Printf("Re-opening moved/deleted file %s ...", tail.Filename)
+ if err := tail.reopen(); err != nil {
+ return err
+ }
+ tail.Logger.Printf("Successfully reopened %s", tail.Filename)
+ tail.openReader()
+ return nil
+ } else {
+ tail.Logger.Printf("Stopping tail as file no longer exists: %s", tail.Filename)
+ return ErrStop
+ }
+ case <-tail.changes.Truncated:
+ // Always reopen truncated files (Follow is true)
+ tail.Logger.Printf("Re-opening truncated file %s ...", tail.Filename)
+ if err := tail.reopen(); err != nil {
+ return err
+ }
+ tail.Logger.Printf("Successfully reopened truncated %s", tail.Filename)
+ tail.openReader()
+ return nil
+ case <-tail.Dying():
+ return ErrStop
+ }
+ panic("unreachable")
+}
+
+func (tail *Tail) openReader() {
+ if tail.MaxLineSize > 0 {
+ // add 2 to account for newline characters
+ tail.reader = bufio.NewReaderSize(tail.file, tail.MaxLineSize+2)
+ } else {
+ tail.reader = bufio.NewReader(tail.file)
+ }
+}
+
+func (tail *Tail) seekEnd() error {
+ return tail.seekTo(SeekInfo{Offset: 0, Whence: os.SEEK_END})
+}
+
+func (tail *Tail) seekTo(pos SeekInfo) error {
+ _, err := tail.file.Seek(pos.Offset, pos.Whence)
+ if err != nil {
+ return fmt.Errorf("Seek error on %s: %s", tail.Filename, err)
+ }
+ // Reset the read buffer whenever the file is re-seek'ed
+ tail.reader.Reset(tail.file)
+ return nil
+}
+
+// sendLine sends the line(s) to Lines channel, splitting longer lines
+// if necessary. Return false if rate limit is reached.
+func (tail *Tail) sendLine(line string) bool {
+ now := time.Now()
+ lines := []string{line}
+
+ // Split longer lines
+ if tail.MaxLineSize > 0 && len(line) > tail.MaxLineSize {
+ lines = util.PartitionString(line, tail.MaxLineSize)
+ }
+
+ for _, line := range lines {
+ tail.Lines <- &Line{line, now, nil}
+ }
+
+ if tail.Config.RateLimiter != nil {
+ ok := tail.Config.RateLimiter.Pour(uint16(len(lines)))
+ if !ok {
+ tail.Logger.Printf("Leaky bucket full (%v); entering 1s cooloff period.\n",
+ tail.Filename)
+ return false
+ }
+ }
+
+ return true
+}
+
+// Cleanup removes inotify watches added by the tail package. This function is
+// meant to be invoked from a process's exit handler. Linux kernel may not
+// automatically remove inotify watches after the process exits.
+func (tail *Tail) Cleanup() {
+ watch.Cleanup(tail.Filename)
+}
diff --git a/vendor/github.com/hpcloud/tail/tail_posix.go b/vendor/github.com/hpcloud/tail/tail_posix.go
new file mode 100644
index 000000000..bc4dc3357
--- /dev/null
+++ b/vendor/github.com/hpcloud/tail/tail_posix.go
@@ -0,0 +1,11 @@
+// +build linux darwin freebsd netbsd openbsd
+
+package tail
+
+import (
+ "os"
+)
+
+func OpenFile(name string) (file *os.File, err error) {
+ return os.Open(name)
+}
diff --git a/vendor/github.com/hpcloud/tail/tail_windows.go b/vendor/github.com/hpcloud/tail/tail_windows.go
new file mode 100644
index 000000000..ef2cfca1b
--- /dev/null
+++ b/vendor/github.com/hpcloud/tail/tail_windows.go
@@ -0,0 +1,12 @@
+// +build windows
+
+package tail
+
+import (
+ "github.com/hpcloud/tail/winfile"
+ "os"
+)
+
+func OpenFile(name string) (file *os.File, err error) {
+ return winfile.OpenFile(name, os.O_RDONLY, 0)
+}
diff --git a/vendor/github.com/hpcloud/tail/util/util.go b/vendor/github.com/hpcloud/tail/util/util.go
new file mode 100644
index 000000000..54151fe39
--- /dev/null
+++ b/vendor/github.com/hpcloud/tail/util/util.go
@@ -0,0 +1,48 @@
+// Copyright (c) 2015 HPE Software Inc. All rights reserved.
+// Copyright (c) 2013 ActiveState Software Inc. All rights reserved.
+
+package util
+
+import (
+ "fmt"
+ "log"
+ "os"
+ "runtime/debug"
+)
+
+type Logger struct {
+ *log.Logger
+}
+
+var LOGGER = &Logger{log.New(os.Stderr, "", log.LstdFlags)}
+
+// fatal is like panic except it displays only the current goroutine's stack.
+func Fatal(format string, v ...interface{}) {
+ // https://github.com/hpcloud/log/blob/master/log.go#L45
+ LOGGER.Output(2, fmt.Sprintf("FATAL -- "+format, v...)+"\n"+string(debug.Stack()))
+ os.Exit(1)
+}
+
+// partitionString partitions the string into chunks of given size,
+// with the last chunk of variable size.
+func PartitionString(s string, chunkSize int) []string {
+ if chunkSize <= 0 {
+ panic("invalid chunkSize")
+ }
+ length := len(s)
+ chunks := 1 + length/chunkSize
+ start := 0
+ end := chunkSize
+ parts := make([]string, 0, chunks)
+ for {
+ if end > length {
+ end = length
+ }
+ parts = append(parts, s[start:end])
+ if end == length {
+ break
+ }
+ start, end = end, end+chunkSize
+ }
+ return parts
+}
diff --git a/vendor/github.com/hpcloud/tail/watch/filechanges.go b/vendor/github.com/hpcloud/tail/watch/filechanges.go
new file mode 100644
index 000000000..3ce5dcecb
--- /dev/null
+++ b/vendor/github.com/hpcloud/tail/watch/filechanges.go
@@ -0,0 +1,36 @@
+package watch
+
+type FileChanges struct {
+ Modified chan bool // Channel to get notified of modifications
+ Truncated chan bool // Channel to get notified of truncations
+ Deleted chan bool // Channel to get notified of deletions/renames
+}
+
+func NewFileChanges() *FileChanges {
+ return &FileChanges{
+ make(chan bool), make(chan bool), make(chan bool)}
+}
+
+func (fc *FileChanges) NotifyModified() {
+ sendOnlyIfEmpty(fc.Modified)
+}
+
+func (fc *FileChanges) NotifyTruncated() {
+ sendOnlyIfEmpty(fc.Truncated)
+}
+
+func (fc *FileChanges) NotifyDeleted() {
+ sendOnlyIfEmpty(fc.Deleted)
+}
+
+// sendOnlyIfEmpty sends on a bool channel only if the channel has no
+// backlog to be read by other goroutines. This concurrency pattern
+// can be used to notify other goroutines if and only if they are
+// looking for it (i.e., subsequent notifications can be compressed
+// into one).
+func sendOnlyIfEmpty(ch chan bool) {
+ select {
+ case ch <- true:
+ default:
+ }
+}
diff --git a/vendor/github.com/hpcloud/tail/watch/inotify.go b/vendor/github.com/hpcloud/tail/watch/inotify.go
new file mode 100644
index 000000000..4478f1e1a
--- /dev/null
+++ b/vendor/github.com/hpcloud/tail/watch/inotify.go
@@ -0,0 +1,128 @@
+// Copyright (c) 2015 HPE Software Inc. All rights reserved.
+// Copyright (c) 2013 ActiveState Software Inc. All rights reserved.
+
+package watch
+
+import (
+ "fmt"
+ "os"
+ "path/filepath"
+
+ "github.com/hpcloud/tail/util"
+
+ "gopkg.in/fsnotify.v1"
+ "gopkg.in/tomb.v1"
+)
+
+// InotifyFileWatcher uses inotify to monitor file changes.
+type InotifyFileWatcher struct {
+ Filename string
+ Size int64
+}
+
+func NewInotifyFileWatcher(filename string) *InotifyFileWatcher {
+ fw := &InotifyFileWatcher{filepath.Clean(filename), 0}
+ return fw
+}
+
+func (fw *InotifyFileWatcher) BlockUntilExists(t *tomb.Tomb) error {
+ err := WatchCreate(fw.Filename)
+ if err != nil {
+ return err
+ }
+ defer RemoveWatchCreate(fw.Filename)
+
+ // Do a real check now as the file might have been created before
+ // calling `WatchFlags` above.
+ if _, err = os.Stat(fw.Filename); !os.IsNotExist(err) {
+ // file exists, or stat returned an error.
+ return err
+ }
+
+ events := Events(fw.Filename)
+
+ for {
+ select {
+ case evt, ok := <-events:
+ if !ok {
+ return fmt.Errorf("inotify watcher has been closed")
+ }
+ evtName, err := filepath.Abs(evt.Name)
+ if err != nil {
+ return err
+ }
+ fwFilename, err := filepath.Abs(fw.Filename)
+ if err != nil {
+ return err
+ }
+ if evtName == fwFilename {
+ return nil
+ }
+ case <-t.Dying():
+ return tomb.ErrDying
+ }
+ }
+ panic("unreachable")
+}
+
+func (fw *InotifyFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChanges, error) {
+ err := Watch(fw.Filename)
+ if err != nil {
+ return nil, err
+ }
+
+ changes := NewFileChanges()
+ fw.Size = pos
+
+ go func() {
+ defer RemoveWatch(fw.Filename)
+
+ events := Events(fw.Filename)
+
+ for {
+ prevSize := fw.Size
+
+ var evt fsnotify.Event
+ var ok bool
+
+ select {
+ case evt, ok = <-events:
+ if !ok {
+ return
+ }
+ case <-t.Dying():
+ return
+ }
+
+ switch {
+ case evt.Op&fsnotify.Remove == fsnotify.Remove:
+ fallthrough
+
+ case evt.Op&fsnotify.Rename == fsnotify.Rename:
+ changes.NotifyDeleted()
+ return
+
+ case evt.Op&fsnotify.Write == fsnotify.Write:
+ fi, err := os.Stat(fw.Filename)
+ if err != nil {
+ if os.IsNotExist(err) {
+ changes.NotifyDeleted()
+ return
+ }
+ // XXX: report this error back to the user
+ util.Fatal("Failed to stat file %v: %v", fw.Filename, err)
+ }
+ fw.Size = fi.Size()
+
+ if prevSize > 0 && prevSize > fw.Size {
+ changes.NotifyTruncated()
+ } else {
+ changes.NotifyModified()
+ }
+ prevSize = fw.Size
+ }
+ }
+ }()
+
+ return changes, nil
+}
diff --git a/vendor/github.com/hpcloud/tail/watch/inotify_tracker.go b/vendor/github.com/hpcloud/tail/watch/inotify_tracker.go
new file mode 100644
index 000000000..03be4275c
--- /dev/null
+++ b/vendor/github.com/hpcloud/tail/watch/inotify_tracker.go
@@ -0,0 +1,260 @@
+// Copyright (c) 2015 HPE Software Inc. All rights reserved.
+// Copyright (c) 2013 ActiveState Software Inc. All rights reserved.
+
+package watch
+
+import (
+ "log"
+ "os"
+ "path/filepath"
+ "sync"
+ "syscall"
+
+ "github.com/hpcloud/tail/util"
+
+ "gopkg.in/fsnotify.v1"
+)
+
+type InotifyTracker struct {
+ mux sync.Mutex
+ watcher *fsnotify.Watcher
+ chans map[string]chan fsnotify.Event
+ done map[string]chan bool
+ watchNums map[string]int
+ watch chan *watchInfo
+ remove chan *watchInfo
+ error chan error
+}
+
+type watchInfo struct {
+ op fsnotify.Op
+ fname string
+}
+
+func (this *watchInfo) isCreate() bool {
+ return this.op == fsnotify.Create
+}
+
+var (
+ // globally shared InotifyTracker; ensures only one fsnotify.Watcher is used
+ shared *InotifyTracker
+
+ // these are used to ensure the shared InotifyTracker is run exactly once
+ once = sync.Once{}
+ goRun = func() {
+ shared = &InotifyTracker{
+ mux: sync.Mutex{},
+ chans: make(map[string]chan fsnotify.Event),
+ done: make(map[string]chan bool),
+ watchNums: make(map[string]int),
+ watch: make(chan *watchInfo),
+ remove: make(chan *watchInfo),
+ error: make(chan error),
+ }
+ go shared.run()
+ }
+
+ logger = log.New(os.Stderr, "", log.LstdFlags)
+)
+
+// Watch signals the run goroutine to begin watching the input filename
+func Watch(fname string) error {
+ return watch(&watchInfo{
+ fname: fname,
+ })
+}
+
+// Watch create signals the run goroutine to begin watching the input filename
+// if call the WatchCreate function, don't call the Cleanup, call the RemoveWatchCreate
+func WatchCreate(fname string) error {
+ return watch(&watchInfo{
+ op: fsnotify.Create,
+ fname: fname,
+ })
+}
+
+func watch(winfo *watchInfo) error {
+ // start running the shared InotifyTracker if not already running
+ once.Do(goRun)
+
+ winfo.fname = filepath.Clean(winfo.fname)
+ shared.watch <- winfo
+ return <-shared.error
+}
+
+// RemoveWatch signals the run goroutine to remove the watch for the input filename
+func RemoveWatch(fname string) {
+ remove(&watchInfo{
+ fname: fname,
+ })
+}
+
+// RemoveWatch create signals the run goroutine to remove the watch for the input filename
+func RemoveWatchCreate(fname string) {
+ remove(&watchInfo{
+ op: fsnotify.Create,
+ fname: fname,
+ })
+}
+
+func remove(winfo *watchInfo) {
+ // start running the shared InotifyTracker if not already running
+ once.Do(goRun)
+
+ winfo.fname = filepath.Clean(winfo.fname)
+ shared.mux.Lock()
+ done := shared.done[winfo.fname]
+ if done != nil {
+ delete(shared.done, winfo.fname)
+ close(done)
+ }
+
+ fname := winfo.fname
+ if winfo.isCreate() {
+ // Watch for new files to be created in the parent directory.
+ fname = filepath.Dir(fname)
+ }
+ shared.watchNums[fname]--
+ watchNum := shared.watchNums[fname]
+ if watchNum == 0 {
+ delete(shared.watchNums, fname)
+ }
+ shared.mux.Unlock()
+
+ // If we were the last ones to watch this file, unsubscribe from inotify.
+ // This needs to happen after releasing the lock because fsnotify waits
+ // synchronously for the kernel to acknowledge the removal of the watch
+ // for this file, which causes us to deadlock if we still held the lock.
+ if watchNum == 0 {
+ shared.watcher.Remove(fname)
+ }
+ shared.remove <- winfo
+}
+
+// Events returns a channel to which FileEvents corresponding to the input filename
+// will be sent. This channel will be closed when removeWatch is called on this
+// filename.
+func Events(fname string) <-chan fsnotify.Event {
+ shared.mux.Lock()
+ defer shared.mux.Unlock()
+
+ return shared.chans[fname]
+}
+
+// Cleanup removes the watch for the input filename if necessary.
+func Cleanup(fname string) {
+ RemoveWatch(fname)
+}
+
+// watchFlags calls fsnotify.WatchFlags for the input filename and flags, creating
+// a new Watcher if the previous Watcher was closed.
+func (shared *InotifyTracker) addWatch(winfo *watchInfo) error {
+ shared.mux.Lock()
+ defer shared.mux.Unlock()
+
+ if shared.chans[winfo.fname] == nil {
+ shared.chans[winfo.fname] = make(chan fsnotify.Event)
+ shared.done[winfo.fname] = make(chan bool)
+ }
+
+ fname := winfo.fname
+ if winfo.isCreate() {
+ // Watch for new files to be created in the parent directory.
+ fname = filepath.Dir(fname)
+ }
+
+ // already in inotify watch
+ if shared.watchNums[fname] > 0 {
+ shared.watchNums[fname]++
+ if winfo.isCreate() {
+ shared.watchNums[winfo.fname]++
+ }
+ return nil
+ }
+
+ err := shared.watcher.Add(fname)
+ if err == nil {
+ shared.watchNums[fname]++
+ if winfo.isCreate() {
+ shared.watchNums[winfo.fname]++
+ }
+ }
+ return err
+}
+
+// removeWatch calls fsnotify.RemoveWatch for the input filename and closes the
+// corresponding events channel.
+func (shared *InotifyTracker) removeWatch(winfo *watchInfo) {
+ shared.mux.Lock()
+ defer shared.mux.Unlock()
+
+ ch := shared.chans[winfo.fname]
+ if ch == nil {
+ return
+ }
+
+ delete(shared.chans, winfo.fname)
+ close(ch)
+
+ if !winfo.isCreate() {
+ return
+ }
+
+ shared.watchNums[winfo.fname]--
+ if shared.watchNums[winfo.fname] == 0 {
+ delete(shared.watchNums, winfo.fname)
+ }
+}
+
+// sendEvent sends the input event to the appropriate Tail.
+func (shared *InotifyTracker) sendEvent(event fsnotify.Event) {
+ name := filepath.Clean(event.Name)
+
+ shared.mux.Lock()
+ ch := shared.chans[name]
+ done := shared.done[name]
+ shared.mux.Unlock()
+
+ if ch != nil && done != nil {
+ select {
+ case ch <- event:
+ case <-done:
+ }
+ }
+}
+
+// run starts the goroutine in which the shared struct reads events from its
+// Watcher's Event channel and sends the events to the appropriate Tail.
+func (shared *InotifyTracker) run() {
+ watcher, err := fsnotify.NewWatcher()
+ if err != nil {
+ util.Fatal("failed to create Watcher")
+ }
+ shared.watcher = watcher
+
+ for {
+ select {
+ case winfo := <-shared.watch:
+ shared.error <- shared.addWatch(winfo)
+
+ case winfo := <-shared.remove:
+ shared.removeWatch(winfo)
+
+ case event, open := <-shared.watcher.Events:
+ if !open {
+ return
+ }
+ shared.sendEvent(event)
+
+ case err, open := <-shared.watcher.Errors:
+ if !open {
+ return
+ } else if err != nil {
+ sysErr, ok := err.(*os.SyscallError)
+ if !ok || sysErr.Err != syscall.EINTR {
+ logger.Printf("Error in Watcher Error channel: %s", err)
+ }
+ }
+ }
+ }
+}
diff --git a/vendor/github.com/hpcloud/tail/watch/polling.go b/vendor/github.com/hpcloud/tail/watch/polling.go
new file mode 100644
index 000000000..49491f21d
--- /dev/null
+++ b/vendor/github.com/hpcloud/tail/watch/polling.go
@@ -0,0 +1,118 @@
+// Copyright (c) 2015 HPE Software Inc. All rights reserved.
+// Copyright (c) 2013 ActiveState Software Inc. All rights reserved.
+
+package watch
+
+import (
+ "os"
+ "runtime"
+ "time"
+
+ "github.com/hpcloud/tail/util"
+ "gopkg.in/tomb.v1"
+)
+
+// PollingFileWatcher polls the file for changes.
+type PollingFileWatcher struct {
+ Filename string
+ Size int64
+}
+
+func NewPollingFileWatcher(filename string) *PollingFileWatcher {
+ fw := &PollingFileWatcher{filename, 0}
+ return fw
+}
+
+var POLL_DURATION time.Duration
+
+func (fw *PollingFileWatcher) BlockUntilExists(t *tomb.Tomb) error {
+ for {
+ if _, err := os.Stat(fw.Filename); err == nil {
+ return nil
+ } else if !os.IsNotExist(err) {
+ return err
+ }
+ select {
+ case <-time.After(POLL_DURATION):
+ continue
+ case <-t.Dying():
+ return tomb.ErrDying
+ }
+ }
+ panic("unreachable")
+}
+
+func (fw *PollingFileWatcher) ChangeEvents(t *tomb.Tomb, pos int64) (*FileChanges, error) {
+ origFi, err := os.Stat(fw.Filename)
+ if err != nil {
+ return nil, err
+ }
+
+ changes := NewFileChanges()
+ var prevModTime time.Time
+
+ // XXX: use tomb.Tomb to cleanly manage these goroutines. replace
+ // the fatal (below) with tomb's Kill.
+
+ fw.Size = pos
+
+ go func() {
+ prevSize := fw.Size
+ for {
+ select {
+ case <-t.Dying():
+ return
+ default:
+ }
+
+ time.Sleep(POLL_DURATION)
+ fi, err := os.Stat(fw.Filename)
+ if err != nil {
+ // Windows cannot delete a file if a handle is still open (tail keeps one open)
+ // so it gives access denied to anything trying to read it until all handles are released.
+ if os.IsNotExist(err) || (runtime.GOOS == "windows" && os.IsPermission(err)) {
+ // File does not exist (has been deleted).
+ changes.NotifyDeleted()
+ return
+ }
+
+ // XXX: report this error back to the user
+ util.Fatal("Failed to stat file %v: %v", fw.Filename, err)
+ }
+
+ // File got moved/renamed?
+ if !os.SameFile(origFi, fi) {
+ changes.NotifyDeleted()
+ return
+ }
+
+ // File got truncated?
+ fw.Size = fi.Size()
+ if prevSize > 0 && prevSize > fw.Size {
+ changes.NotifyTruncated()
+ prevSize = fw.Size
+ continue
+ }
+ // File got bigger?
+ if prevSize > 0 && prevSize < fw.Size {
+ changes.NotifyModified()
+ prevSize = fw.Size
+ continue
+ }
+ prevSize = fw.Size
+
+ // File was appended to (changed)?
+ modTime := fi.ModTime()
+ if modTime != prevModTime {
+ prevModTime = modTime
+ changes.NotifyModified()
+ }
+ }
+ }()
+
+ return changes, nil
+}
+
+func init() {
+ POLL_DURATION = 250 * time.Millisecond
+}
diff --git a/vendor/github.com/hpcloud/tail/watch/watch.go b/vendor/github.com/hpcloud/tail/watch/watch.go
new file mode 100644
index 000000000..2e1783ef0
--- /dev/null
+++ b/vendor/github.com/hpcloud/tail/watch/watch.go
@@ -0,0 +1,20 @@
+// Copyright (c) 2015 HPE Software Inc. All rights reserved.
+// Copyright (c) 2013 ActiveState Software Inc. All rights reserved.
+
+package watch
+
+import "gopkg.in/tomb.v1"
+
+// FileWatcher monitors file-level events.
+type FileWatcher interface {
+ // BlockUntilExists blocks until the file comes into existence.
+ BlockUntilExists(*tomb.Tomb) error
+
+ // ChangeEvents reports on changes to a file, be it modification,
+ // deletion, renames or truncations. Returned FileChanges group of
+ // channels will be closed, thus become unusable, after a deletion
+ // or truncation event.
+ // In order to properly report truncations, ChangeEvents requires
+ // the caller to pass their current offset in the file.
+ ChangeEvents(*tomb.Tomb, int64) (*FileChanges, error)
+}
diff --git a/vendor/github.com/hpcloud/tail/winfile/winfile.go b/vendor/github.com/hpcloud/tail/winfile/winfile.go
new file mode 100644
index 000000000..aa7e7bc5d
--- /dev/null
+++ b/vendor/github.com/hpcloud/tail/winfile/winfile.go
@@ -0,0 +1,92 @@
+// +build windows
+
+package winfile
+
+import (
+ "os"
+ "syscall"
+ "unsafe"
+)
+
+// issue also described here
+//https://codereview.appspot.com/8203043/
+
+// https://github.com/jnwhiteh/golang/blob/master/src/pkg/syscall/syscall_windows.go#L218
+func Open(path string, mode int, perm uint32) (fd syscall.Handle, err error) {
+ if len(path) == 0 {
+ return syscall.InvalidHandle, syscall.ERROR_FILE_NOT_FOUND
+ }
+ pathp, err := syscall.UTF16PtrFromString(path)
+ if err != nil {
+ return syscall.InvalidHandle, err
+ }
+ var access uint32
+ switch mode & (syscall.O_RDONLY | syscall.O_WRONLY | syscall.O_RDWR) {
+ case syscall.O_RDONLY:
+ access = syscall.GENERIC_READ
+ case syscall.O_WRONLY:
+ access = syscall.GENERIC_WRITE
+ case syscall.O_RDWR:
+ access = syscall.GENERIC_READ | syscall.GENERIC_WRITE
+ }
+ if mode&syscall.O_CREAT != 0 {
+ access |= syscall.GENERIC_WRITE
+ }
+ if mode&syscall.O_APPEND != 0 {
+ access &^= syscall.GENERIC_WRITE
+ access |= syscall.FILE_APPEND_DATA
+ }
+ sharemode := uint32(syscall.FILE_SHARE_READ | syscall.FILE_SHARE_WRITE | syscall.FILE_SHARE_DELETE)
+ var sa *syscall.SecurityAttributes
+ if mode&syscall.O_CLOEXEC == 0 {
+ sa = makeInheritSa()
+ }
+ var createmode uint32
+ switch {
+ case mode&(syscall.O_CREAT|syscall.O_EXCL) == (syscall.O_CREAT | syscall.O_EXCL):
+ createmode = syscall.CREATE_NEW
+ case mode&(syscall.O_CREAT|syscall.O_TRUNC) == (syscall.O_CREAT | syscall.O_TRUNC):
+ createmode = syscall.CREATE_ALWAYS
+ case mode&syscall.O_CREAT == syscall.O_CREAT:
+ createmode = syscall.OPEN_ALWAYS
+ case mode&syscall.O_TRUNC == syscall.O_TRUNC:
+ createmode = syscall.TRUNCATE_EXISTING
+ default:
+ createmode = syscall.OPEN_EXISTING
+ }
+ h, e := syscall.CreateFile(pathp, access, sharemode, sa, createmode, syscall.FILE_ATTRIBUTE_NORMAL, 0)
+ return h, e
+}
+
+// https://github.com/jnwhiteh/golang/blob/master/src/pkg/syscall/syscall_windows.go#L211
+func makeInheritSa() *syscall.SecurityAttributes {
+ var sa syscall.SecurityAttributes
+ sa.Length = uint32(unsafe.Sizeof(sa))
+ sa.InheritHandle = 1
+ return &sa
+}
+
+// https://github.com/jnwhiteh/golang/blob/master/src/pkg/os/file_windows.go#L133
+func OpenFile(name string, flag int, perm os.FileMode) (file *os.File, err error) {
+ r, e := Open(name, flag|syscall.O_CLOEXEC, syscallMode(perm))
+ if e != nil {
+ return nil, e
+ }
+ return os.NewFile(uintptr(r), name), nil
+}
+
+// https://github.com/jnwhiteh/golang/blob/master/src/pkg/os/file_posix.go#L61
+func syscallMode(i os.FileMode) (o uint32) {
+ o |= uint32(i.Perm())
+ if i&os.ModeSetuid != 0 {
+ o |= syscall.S_ISUID
+ }
+ if i&os.ModeSetgid != 0 {
+ o |= syscall.S_ISGID
+ }
+ if i&os.ModeSticky != 0 {
+ o |= syscall.S_ISVTX
+ }
+ // No mapping for Go's ModeTemporary (plan9 only).
+ return
+}
diff --git a/vendor/github.com/onsi/ginkgo/.gitignore b/vendor/github.com/onsi/ginkgo/.gitignore
new file mode 100644
index 000000000..b9f9659d2
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/.gitignore
@@ -0,0 +1,7 @@
+.DS_Store
+TODO
+tmp/**/*
+*.coverprofile
+.vscode
+.idea/
+*.log
diff --git a/vendor/github.com/onsi/ginkgo/.travis.yml b/vendor/github.com/onsi/ginkgo/.travis.yml
new file mode 100644
index 000000000..3900878bd
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/.travis.yml
@@ -0,0 +1,17 @@
+language: go
+go:
+ - 1.6.x
+ - 1.7.x
+ - 1.8.x
+ - 1.9.x
+ - 1.10.x
+ - 1.11.x
+
+install:
+ - go get -v -t ./...
+ - go get golang.org/x/tools/cmd/cover
+ - go get github.com/onsi/gomega
+ - go install github.com/onsi/ginkgo/ginkgo
+ - export PATH=$PATH:$HOME/gopath/bin
+
+script: $HOME/gopath/bin/ginkgo -r --randomizeAllSpecs --randomizeSuites --race --trace && go vet
diff --git a/vendor/github.com/onsi/ginkgo/CHANGELOG.md b/vendor/github.com/onsi/ginkgo/CHANGELOG.md
new file mode 100644
index 000000000..d7d797017
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/CHANGELOG.md
@@ -0,0 +1,207 @@
+## 1.7.0
+
+### New Features
+- Add JustAfterEach (#484) [0d4f080]
+
+### Fixes
+- Correctly round suite time in junit reporter [2445fc1]
+- Avoid using -i argument to go test for Golang 1.10+ [46bbc26]
+
+## 1.6.0
+
+### New Features
+- add --debug flag to emit node output to files (#499) [39febac]
+
+### Fixes
+- fix: for `go vet` to pass [69338ec]
+- docs: fix for contributing instructions [7004cb1]
+- consolidate and streamline contribution docs (#494) [d848015]
+- Make generated Junit file compatable with "Maven Surefire" (#488) [e51bee6]
+- all: gofmt [000d317]
+- Increase eventually timeout to 30s [c73579c]
+- Clarify asynchronous test behaviour [294d8f4]
+- Travis badge should only show master [26d2143]
+
+## 1.5.0 5/10/2018
+
+### New Features
+- Supports go v1.10 (#443, #446, #451) [e873237, 468e89e, e37dbfe, a37f4c0, c0b857d, bca5260, 4177ca8]
+- Add a When() synonym for Context() (#386) [747514b, 7484dad, 7354a07, dd826c8]
+- Re-add noisySkippings flag [652e15c]
+- Allow coverage to be displayed for focused specs (#367) [11459a8]
+- Handle -outputdir flag (#364) [228e3a8]
+- Handle -coverprofile flag (#355) [43392d5]
+
+### Fixes
+- When using custom reporters register the custom reporters *before* the default reporter. This allows users to see the output of any print statements in their customer reporters. (#365) [8382b23]
+- When running a test and calculating the coverage using the `-coverprofile` and `-outputdir` flags, Ginkgo fails with an error if the directory does not exist. This is due to an [issue in go 1.10](https://github.com/golang/go/issues/24588) (#446) [b36a6e0]
+- `unfocus` command ignores vendor folder (#459) [e5e551c, c556e43, a3b6351, 9a820dd]
+- Ignore packages whose tests are all ignored by go (#456) [7430ca7, 6d8be98]
+- Increase the threshold when checking time measuments (#455) [2f714bf, 68f622c]
+- Fix race condition in coverage tests (#423) [a5a8ff7, ab9c08b]
+- Add an extra new line after reporting spec run completion for test2json [874520d]
+- added name name field to junit reported testsuite [ae61c63]
+- Do not set the run time of a spec when the dryRun flag is used (#438) [457e2d9, ba8e856]
+- Process FWhen and FSpecify when unfocusing (#434) [9008c7b, ee65bd, df87dfe]
+- Synchronise the access to the state of specs to avoid race conditions (#430) [7d481bc, ae6829d]
+- Added Duration on GinkgoTestDescription (#383) [5f49dad, 528417e, 0747408, 329d7ed]
+- Fix Ginkgo stack trace on failure for Specify (#415) [b977ede, 65ca40e, 6c46eb8]
+- Update README with Go 1.6+, Golang -> Go (#409) [17f6b97, bc14b66, 20d1598]
+- Use fmt.Errorf instead of errors.New(fmt.Sprintf (#401) [a299f56, 44e2eaa]
+- Imports in generated code should follow conventions (#398) [0bec0b0, e8536d8]
+- Prevent data race error when Recording a benchmark value from multiple go routines (#390) [c0c4881, 7a241e9]
+- Replace GOPATH in Environment [4b883f0]
+
+
+## 1.4.0 7/16/2017
+
+- `ginkgo` now provides a hint if you accidentally forget to run `ginkgo bootstrap` to generate a `*_suite_test.go` file that actually invokes the Ginkgo test runner. [#345](https://github.com/onsi/ginkgo/pull/345)
+- thanks to improvements in `go test -c` `ginkgo` no longer needs to fix Go's compilation output to ensure compilation errors are expressed relative to the CWD. [#357]
+- `ginkgo watch -watchRegExp=...` allows you to specify a custom regular expression to watch. Only files matching the regular expression are watched for changes (the default is `\.go$`) [#356]
+- `ginkgo` now always emits compilation output. Previously, only failed compilation output was printed out. [#277]
+- `ginkgo -requireSuite` now fails the test run if there are `*_test.go` files but `go test` fails to detect any tests. Typically this means you forgot to run `ginkgo bootstrap` to generate a suite file. [#344]
+- `ginkgo -timeout=DURATION` allows you to adjust the timeout for the entire test suite (default is 24 hours) [#248]
+
+## 1.3.0 3/28/2017
+
+Improvements:
+
+- Significantly improved parallel test distribution. Now instead of pre-sharding test cases across workers (which can result in idle workers and poor test performance) Ginkgo uses a shared queue to keep all workers busy until all tests are complete. This improves test-time performance and consistency.
+- `Skip(message)` can be used to skip the current test.
+- Added `extensions/table` - a Ginkgo DSL for [Table Driven Tests](http://onsi.github.io/ginkgo/#table-driven-tests)
+- Add `GinkgoRandomSeed()` - shorthand for `config.GinkgoConfig.RandomSeed`
+- Support for retrying flaky tests with `--flakeAttempts`
+- `ginkgo ./...` now recurses as you'd expect
+- Added `Specify` a synonym for `It`
+- Support colorise on Windows
+- Broader support for various go compilation flags in the `ginkgo` CLI
+
+Bug Fixes:
+
+- Ginkgo tests now fail when you `panic(nil)` (#167)
+
+## 1.2.0 5/31/2015
+
+Improvements
+
+- `ginkgo -coverpkg` calls down to `go test -coverpkg` (#160)
+- `ginkgo -afterSuiteHook COMMAND` invokes the passed-in `COMMAND` after a test suite completes (#152)
+- Relaxed requirement for Go 1.4+. `ginkgo` now works with Go v1.3+ (#166)
+
+## 1.2.0-beta
+
+Ginkgo now requires Go 1.4+
+
+Improvements:
+
+- Call reporters in reverse order when announcing spec completion -- allows custom reporters to emit output before the default reporter does.
+- Improved focus behavior. Now, this:
+
+ ```golang
+ FDescribe("Some describe", func() {
+ It("A", func() {})
+
+ FIt("B", func() {})
+ })
+ ```
+
+ will run `B` but *not* `A`. This tends to be a common usage pattern when in the thick of writing and debugging tests.
+- When `SIGINT` is received, Ginkgo will emit the contents of the `GinkgoWriter` before running the `AfterSuite`. Useful for debugging stuck tests.
+- When `--progress` is set, Ginkgo will write test progress (in particular, Ginkgo will say when it is about to run a BeforeEach, AfterEach, It, etc...) to the `GinkgoWriter`. This is useful for debugging stuck tests and tests that generate many logs.
+- Improved output when an error occurs in a setup or teardown block.
+- When `--dryRun` is set, Ginkgo will walk the spec tree and emit to its reporter *without* actually running anything. Best paired with `-v` to understand which specs will run in which order.
+- Add `By` to help document long `It`s. `By` simply writes to the `GinkgoWriter`.
+- Add support for precompiled tests:
+ - `ginkgo build <path-to-package>` will now compile the package, producing a file named `package.test`
+ - The compiled `package.test` file can be run directly. This runs the tests in series.
+ - To run precompiled tests in parallel, you can run: `ginkgo -p package.test`
+- Support `bootstrap`ping and `generate`ing [Agouti](http://agouti.org) specs.
+- `ginkgo generate` and `ginkgo bootstrap` now honor the package name already defined in a given directory
+- The `ginkgo` CLI ignores `SIGQUIT`. Prevents its stack dump from interlacing with the underlying test suite's stack dump.
+- The `ginkgo` CLI now compiles tests into a temporary directory instead of the package directory. This necessitates upgrading to Go v1.4+.
+- `ginkgo -notify` now works on Linux
+
+Bug Fixes:
+
+- If --skipPackages is used and all packages are skipped, Ginkgo should exit 0.
+- Fix tempfile leak when running in parallel
+- Fix incorrect failure message when a panic occurs during a parallel test run
+- Fixed an issue where a pending test within a focused context (or a focused test within a pending context) would skip all other tests.
+- Be more consistent about handling SIGTERM as well as SIGINT
+- When interupted while concurrently compiling test suites in the background, Ginkgo now cleans up the compiled artifacts.
+- Fixed a long standing bug where `ginkgo -p` would hang if a process spawned by one of the Ginkgo parallel nodes does not exit. (Hooray!)
+
+## 1.1.0 (8/2/2014)
+
+No changes, just dropping the beta.
+
+## 1.1.0-beta (7/22/2014)
+New Features:
+
+- `ginkgo watch` now monitors packages *and their dependencies* for changes. The depth of the dependency tree can be modified with the `-depth` flag.
+- Test suites with a programmatic focus (`FIt`, `FDescribe`, etc...) exit with non-zero status code, even when they pass. This allows CI systems to detect accidental commits of focused test suites.
+- `ginkgo -p` runs the testsuite in parallel with an auto-detected number of nodes.
+- `ginkgo -tags=TAG_LIST` passes a list of tags down to the `go build` command.
+- `ginkgo --failFast` aborts the test suite after the first failure.
+- `ginkgo generate file_1 file_2` can take multiple file arguments.
+- Ginkgo now summarizes any spec failures that occured at the end of the test run.
+- `ginkgo --randomizeSuites` will run tests *suites* in random order using the generated/passed-in seed.
+
+Improvements:
+
+- `ginkgo -skipPackage` now takes a comma-separated list of strings. If the *relative path* to a package matches one of the entries in the comma-separated list, that package is skipped.
+- `ginkgo --untilItFails` no longer recompiles between attempts.
+- Ginkgo now panics when a runnable node (`It`, `BeforeEach`, `JustBeforeEach`, `AfterEach`, `Measure`) is nested within another runnable node. This is always a mistake. Any test suites that panic because of this change should be fixed.
+
+Bug Fixes:
+
+- `ginkgo boostrap` and `ginkgo generate` no longer fail when dealing with `hyphen-separated-packages`.
+- parallel specs are now better distributed across nodes - fixed a crashing bug where (for example) distributing 11 tests across 7 nodes would panic
+
+## 1.0.0 (5/24/2014)
+New Features:
+
+- Add `GinkgoParallelNode()` - shorthand for `config.GinkgoConfig.ParallelNode`
+
+Improvements:
+
+- When compilation fails, the compilation output is rewritten to present a correct *relative* path. Allows ⌘-clicking in iTerm open the file in your text editor.
+- `--untilItFails` and `ginkgo watch` now generate new random seeds between test runs, unless a particular random seed is specified.
+
+Bug Fixes:
+
+- `-cover` now generates a correctly combined coverprofile when running with in parallel with multiple `-node`s.
+- Print out the contents of the `GinkgoWriter` when `BeforeSuite` or `AfterSuite` fail.
+- Fix all remaining race conditions in Ginkgo's test suite.
+
+## 1.0.0-beta (4/14/2014)
+Breaking changes:
+
+- `thirdparty/gomocktestreporter` is gone. Use `GinkgoT()` instead
+- Modified the Reporter interface
+- `watch` is now a subcommand, not a flag.
+
+DSL changes:
+
+- `BeforeSuite` and `AfterSuite` for setting up and tearing down test suites.
+- `AfterSuite` is triggered on interrupt (`^C`) as well as exit.
+- `SynchronizedBeforeSuite` and `SynchronizedAfterSuite` for setting up and tearing down singleton resources across parallel nodes.
+
+CLI changes:
+
+- `watch` is now a subcommand, not a flag
+- `--nodot` flag can be passed to `ginkgo generate` and `ginkgo bootstrap` to avoid dot imports. This explicitly imports all exported identifiers in Ginkgo and Gomega. Refreshing this list can be done by running `ginkgo nodot`
+- Additional arguments can be passed to specs. Pass them after the `--` separator
+- `--skipPackage` flag takes a regexp and ignores any packages with package names passing said regexp.
+- `--trace` flag prints out full stack traces when errors occur, not just the line at which the error occurs.
+
+Misc:
+
+- Start using semantic versioning
+- Start maintaining changelog
+
+Major refactor:
+
+- Pull out Ginkgo's internal to `internal`
+- Rename `example` everywhere to `spec`
+- Much more!
diff --git a/vendor/github.com/onsi/ginkgo/CONTRIBUTING.md b/vendor/github.com/onsi/ginkgo/CONTRIBUTING.md
new file mode 100644
index 000000000..908b95c2c
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/CONTRIBUTING.md
@@ -0,0 +1,33 @@
+# Contributing to Ginkgo
+
+Your contributions to Ginkgo are essential for its long-term maintenance and improvement.
+
+- Please **open an issue first** - describe what problem you are trying to solve and give the community a forum for input and feedback ahead of investing time in writing code!
+- Ensure adequate test coverage:
+ - When adding to the Ginkgo library, add unit and/or integration tests (under the `integration` folder).
+ - When adding to the Ginkgo CLI, note that there are very few unit tests. Please add an integration test.
+- Update the documentation. Ginko uses `godoc` comments and documentation on the `gh-pages` branch.
+ If relevant, please submit a docs PR to that branch alongside your code PR.
+
+Thanks for supporting Ginkgo!
+
+## Setup
+
+Fork the repo, then:
+
+```
+go get github.com/onsi/ginkgo
+go get github.com/onsi/gomega/...
+cd $GOPATH/src/github.com/onsi/ginkgo
+git remote add fork git@github.com:<NAME>/ginkgo.git
+
+ginkgo -r -p # ensure tests are green
+go vet ./... # ensure linter is happy
+```
+
+## Making the PR
+ - go to a new branch `git checkout -b my-feature`
+ - make your changes
+ - run tests and linter again (see above)
+ - `git push fork`
+ - open PR 🎉
diff --git a/vendor/github.com/onsi/ginkgo/LICENSE b/vendor/github.com/onsi/ginkgo/LICENSE
new file mode 100644
index 000000000..9415ee72c
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2013-2014 Onsi Fakhouri
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/onsi/ginkgo/README.md b/vendor/github.com/onsi/ginkgo/README.md
new file mode 100644
index 000000000..cdf8d054a
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/README.md
@@ -0,0 +1,121 @@
+![Ginkgo: A Go BDD Testing Framework](http://onsi.github.io/ginkgo/images/ginkgo.png)
+
+[![Build Status](https://travis-ci.org/onsi/ginkgo.svg?branch=master)](https://travis-ci.org/onsi/ginkgo)
+
+Jump to the [docs](http://onsi.github.io/ginkgo/) to learn more. To start rolling your Ginkgo tests *now* [keep reading](#set-me-up)!
+
+If you have a question, comment, bug report, feature request, etc. please open a GitHub issue.
+
+## Feature List
+
+- Ginkgo uses Go's `testing` package and can live alongside your existing `testing` tests. It's easy to [bootstrap](http://onsi.github.io/ginkgo/#bootstrapping-a-suite) and start writing your [first tests](http://onsi.github.io/ginkgo/#adding-specs-to-a-suite)
+
+- Structure your BDD-style tests expressively:
+ - Nestable [`Describe`, `Context` and `When` container blocks](http://onsi.github.io/ginkgo/#organizing-specs-with-containers-describe-and-context)
+ - [`BeforeEach` and `AfterEach` blocks](http://onsi.github.io/ginkgo/#extracting-common-setup-beforeeach) for setup and teardown
+ - [`It` and `Specify` blocks](http://onsi.github.io/ginkgo/#individual-specs-) that hold your assertions
+ - [`JustBeforeEach` blocks](http://onsi.github.io/ginkgo/#separating-creation-and-configuration-justbeforeeach) that separate creation from configuration (also known as the subject action pattern).
+ - [`BeforeSuite` and `AfterSuite` blocks](http://onsi.github.io/ginkgo/#global-setup-and-teardown-beforesuite-and-aftersuite) to prep for and cleanup after a suite.
+
+- A comprehensive test runner that lets you:
+ - Mark specs as [pending](http://onsi.github.io/ginkgo/#pending-specs)
+ - [Focus](http://onsi.github.io/ginkgo/#focused-specs) individual specs, and groups of specs, either programmatically or on the command line
+ - Run your tests in [random order](http://onsi.github.io/ginkgo/#spec-permutation), and then reuse random seeds to replicate the same order.
+ - Break up your test suite into parallel processes for straightforward [test parallelization](http://onsi.github.io/ginkgo/#parallel-specs)
+
+- `ginkgo`: a command line interface with plenty of handy command line arguments for [running your tests](http://onsi.github.io/ginkgo/#running-tests) and [generating](http://onsi.github.io/ginkgo/#generators) test files. Here are a few choice examples:
+ - `ginkgo -nodes=N` runs your tests in `N` parallel processes and print out coherent output in realtime
+ - `ginkgo -cover` runs your tests using Go's code coverage tool
+ - `ginkgo convert` converts an XUnit-style `testing` package to a Ginkgo-style package
+ - `ginkgo -focus="REGEXP"` and `ginkgo -skip="REGEXP"` allow you to specify a subset of tests to run via regular expression
+ - `ginkgo -r` runs all tests suites under the current directory
+ - `ginkgo -v` prints out identifying information for each tests just before it runs
+
+ And much more: run `ginkgo help` for details!
+
+ The `ginkgo` CLI is convenient, but purely optional -- Ginkgo works just fine with `go test`
+
+- `ginkgo watch` [watches](https://onsi.github.io/ginkgo/#watching-for-changes) packages *and their dependencies* for changes, then reruns tests. Run tests immediately as you develop!
+
+- Built-in support for testing [asynchronicity](http://onsi.github.io/ginkgo/#asynchronous-tests)
+
+- Built-in support for [benchmarking](http://onsi.github.io/ginkgo/#benchmark-tests) your code. Control the number of benchmark samples as you gather runtimes and other, arbitrary, bits of numerical information about your code.
+
+- [Completions for Sublime Text](https://github.com/onsi/ginkgo-sublime-completions): just use [Package Control](https://sublime.wbond.net/) to install `Ginkgo Completions`.
+
+- [Completions for VSCode](https://github.com/onsi/vscode-ginkgo): just use VSCode's extension installer to install `vscode-ginkgo`.
+
+- Straightforward support for third-party testing libraries such as [Gomock](https://code.google.com/p/gomock/) and [Testify](https://github.com/stretchr/testify). Check out the [docs](http://onsi.github.io/ginkgo/#third-party-integrations) for details.
+
+- A modular architecture that lets you easily:
+ - Write [custom reporters](http://onsi.github.io/ginkgo/#writing-custom-reporters) (for example, Ginkgo comes with a [JUnit XML reporter](http://onsi.github.io/ginkgo/#generating-junit-xml-output) and a TeamCity reporter).
+ - [Adapt an existing matcher library (or write your own!)](http://onsi.github.io/ginkgo/#using-other-matcher-libraries) to work with Ginkgo
+
+## [Gomega](http://github.com/onsi/gomega): Ginkgo's Preferred Matcher Library
+
+Ginkgo is best paired with Gomega. Learn more about Gomega [here](http://onsi.github.io/gomega/)
+
+## [Agouti](http://github.com/sclevine/agouti): A Go Acceptance Testing Framework
+
+Agouti allows you run WebDriver integration tests. Learn more about Agouti [here](http://agouti.org)
+
+## Set Me Up!
+
+You'll need the Go command-line tools. Ginkgo is tested with Go 1.6+, but preferably you should get the latest. Follow the [installation instructions](https://golang.org/doc/install) if you don't have it installed.
+
+```bash
+
+go get -u github.com/onsi/ginkgo/ginkgo # installs the ginkgo CLI
+go get -u github.com/onsi/gomega/... # fetches the matcher library
+
+cd path/to/package/you/want/to/test
+
+ginkgo bootstrap # set up a new ginkgo suite
+ginkgo generate # will create a sample test file. edit this file and add your tests then...
+
+go test # to run your tests
+
+ginkgo # also runs your tests
+
+```
+
+## I'm new to Go: What are my testing options?
+
+Of course, I heartily recommend [Ginkgo](https://github.com/onsi/ginkgo) and [Gomega](https://github.com/onsi/gomega). Both packages are seeing heavy, daily, production use on a number of projects and boast a mature and comprehensive feature-set.
+
+With that said, it's great to know what your options are :)
+
+### What Go gives you out of the box
+
+Testing is a first class citizen in Go, however Go's built-in testing primitives are somewhat limited: The [testing](http://golang.org/pkg/testing) package provides basic XUnit style tests and no assertion library.
+
+### Matcher libraries for Go's XUnit style tests
+
+A number of matcher libraries have been written to augment Go's built-in XUnit style tests. Here are two that have gained traction:
+
+- [testify](https://github.com/stretchr/testify)
+- [gocheck](http://labix.org/gocheck)
+
+You can also use Ginkgo's matcher library [Gomega](https://github.com/onsi/gomega) in [XUnit style tests](http://onsi.github.io/gomega/#using-gomega-with-golangs-xunitstyle-tests)
+
+### BDD style testing frameworks
+
+There are a handful of BDD-style testing frameworks written for Go. Here are a few:
+
+- [Ginkgo](https://github.com/onsi/ginkgo) ;)
+- [GoConvey](https://github.com/smartystreets/goconvey)
+- [Goblin](https://github.com/franela/goblin)
+- [Mao](https://github.com/azer/mao)
+- [Zen](https://github.com/pranavraja/zen)
+
+Finally, @shageman has [put together](https://github.com/shageman/gotestit) a comprehensive comparison of Go testing libraries.
+
+Go explore!
+
+## License
+
+Ginkgo is MIT-Licensed
+
+## Contributing
+
+See [CONTRIBUTING.md](CONTRIBUTING.md)
diff --git a/vendor/github.com/onsi/ginkgo/RELEASING.md b/vendor/github.com/onsi/ginkgo/RELEASING.md
new file mode 100644
index 000000000..1e298c2da
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/RELEASING.md
@@ -0,0 +1,14 @@
+A Ginkgo release is a tagged git sha and a GitHub release. To cut a release:
+
+1. Ensure CHANGELOG.md is up to date.
+ - Use `git log --pretty=format:'- %s [%h]' HEAD...vX.X.X` to list all the commits since the last release
+ - Categorize the changes into
+ - Breaking Changes (requires a major version)
+ - New Features (minor version)
+ - Fixes (fix version)
+ - Maintenance (which in general should not be mentioned in `CHANGELOG.md` as they have no user impact)
+1. Update `VERSION` in `config/config.go`
+1. Create a commit with the version number as the commit message (e.g. `v1.3.0`)
+1. Tag the commit with the version number as the tag name (e.g. `v1.3.0`)
+1. Push the commit and tag to GitHub
+1. Create a new [GitHub release](https://help.github.com/articles/creating-releases/) with the version number as the tag (e.g. `v1.3.0`). List the key changes in the release notes.
diff --git a/vendor/github.com/onsi/ginkgo/config/config.go b/vendor/github.com/onsi/ginkgo/config/config.go
new file mode 100644
index 000000000..5e509313c
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/config/config.go
@@ -0,0 +1,200 @@
+/*
+Ginkgo accepts a number of configuration options.
+
+These are documented [here](http://onsi.github.io/ginkgo/#the_ginkgo_cli)
+
+You can also learn more via
+
+ ginkgo help
+
+or (I kid you not):
+
+ go test -asdf
+*/
+package config
+
+import (
+ "flag"
+ "time"
+
+ "fmt"
+)
+
+const VERSION = "1.7.0"
+
+type GinkgoConfigType struct {
+ RandomSeed int64
+ RandomizeAllSpecs bool
+ RegexScansFilePath bool
+ FocusString string
+ SkipString string
+ SkipMeasurements bool
+ FailOnPending bool
+ FailFast bool
+ FlakeAttempts int
+ EmitSpecProgress bool
+ DryRun bool
+ DebugParallel bool
+
+ ParallelNode int
+ ParallelTotal int
+ SyncHost string
+ StreamHost string
+}
+
+var GinkgoConfig = GinkgoConfigType{}
+
+type DefaultReporterConfigType struct {
+ NoColor bool
+ SlowSpecThreshold float64
+ NoisyPendings bool
+ NoisySkippings bool
+ Succinct bool
+ Verbose bool
+ FullTrace bool
+}
+
+var DefaultReporterConfig = DefaultReporterConfigType{}
+
+func processPrefix(prefix string) string {
+ if prefix != "" {
+ prefix = prefix + "."
+ }
+ return prefix
+}
+
+func Flags(flagSet *flag.FlagSet, prefix string, includeParallelFlags bool) {
+ prefix = processPrefix(prefix)
+ flagSet.Int64Var(&(GinkgoConfig.RandomSeed), prefix+"seed", time.Now().Unix(), "The seed used to randomize the spec suite.")
+ flagSet.BoolVar(&(GinkgoConfig.RandomizeAllSpecs), prefix+"randomizeAllSpecs", false, "If set, ginkgo will randomize all specs together. By default, ginkgo only randomizes the top level Describe, Context and When groups.")
+ flagSet.BoolVar(&(GinkgoConfig.SkipMeasurements), prefix+"skipMeasurements", false, "If set, ginkgo will skip any measurement specs.")
+ flagSet.BoolVar(&(GinkgoConfig.FailOnPending), prefix+"failOnPending", false, "If set, ginkgo will mark the test suite as failed if any specs are pending.")
+ flagSet.BoolVar(&(GinkgoConfig.FailFast), prefix+"failFast", false, "If set, ginkgo will stop running a test suite after a failure occurs.")
+
+ flagSet.BoolVar(&(GinkgoConfig.DryRun), prefix+"dryRun", false, "If set, ginkgo will walk the test hierarchy without actually running anything. Best paired with -v.")
+
+ flagSet.StringVar(&(GinkgoConfig.FocusString), prefix+"focus", "", "If set, ginkgo will only run specs that match this regular expression.")
+ flagSet.StringVar(&(GinkgoConfig.SkipString), prefix+"skip", "", "If set, ginkgo will only run specs that do not match this regular expression.")
+
+ flagSet.BoolVar(&(GinkgoConfig.RegexScansFilePath), prefix+"regexScansFilePath", false, "If set, ginkgo regex matching also will look at the file path (code location).")
+
+ flagSet.IntVar(&(GinkgoConfig.FlakeAttempts), prefix+"flakeAttempts", 1, "Make up to this many attempts to run each spec. Please note that if any of the attempts succeed, the suite will not be failed. But any failures will still be recorded.")
+
+ flagSet.BoolVar(&(GinkgoConfig.EmitSpecProgress), prefix+"progress", false, "If set, ginkgo will emit progress information as each spec runs to the GinkgoWriter.")
+
+ flagSet.BoolVar(&(GinkgoConfig.DebugParallel), prefix+"debug", false, "If set, ginkgo will emit node output to files when running in parallel.")
+
+ if includeParallelFlags {
+ flagSet.IntVar(&(GinkgoConfig.ParallelNode), prefix+"parallel.node", 1, "This worker node's (one-indexed) node number. For running specs in parallel.")
+ flagSet.IntVar(&(GinkgoConfig.ParallelTotal), prefix+"parallel.total", 1, "The total number of worker nodes. For running specs in parallel.")
+ flagSet.StringVar(&(GinkgoConfig.SyncHost), prefix+"parallel.synchost", "", "The address for the server that will synchronize the running nodes.")
+ flagSet.StringVar(&(GinkgoConfig.StreamHost), prefix+"parallel.streamhost", "", "The address for the server that the running nodes should stream data to.")
+ }
+
+ flagSet.BoolVar(&(DefaultReporterConfig.NoColor), prefix+"noColor", false, "If set, suppress color output in default reporter.")
+ flagSet.Float64Var(&(DefaultReporterConfig.SlowSpecThreshold), prefix+"slowSpecThreshold", 5.0, "(in seconds) Specs that take longer to run than this threshold are flagged as slow by the default reporter.")
+ flagSet.BoolVar(&(DefaultReporterConfig.NoisyPendings), prefix+"noisyPendings", true, "If set, default reporter will shout about pending tests.")
+ flagSet.BoolVar(&(DefaultReporterConfig.NoisySkippings), prefix+"noisySkippings", true, "If set, default reporter will shout about skipping tests.")
+ flagSet.BoolVar(&(DefaultReporterConfig.Verbose), prefix+"v", false, "If set, default reporter print out all specs as they begin.")
+ flagSet.BoolVar(&(DefaultReporterConfig.Succinct), prefix+"succinct", false, "If set, default reporter prints out a very succinct report")
+ flagSet.BoolVar(&(DefaultReporterConfig.FullTrace), prefix+"trace", false, "If set, default reporter prints out the full stack trace when a failure occurs")
+}
+
+func BuildFlagArgs(prefix string, ginkgo GinkgoConfigType, reporter DefaultReporterConfigType) []string {
+ prefix = processPrefix(prefix)
+ result := make([]string, 0)
+
+ if ginkgo.RandomSeed > 0 {
+ result = append(result, fmt.Sprintf("--%sseed=%d", prefix, ginkgo.RandomSeed))
+ }
+
+ if ginkgo.RandomizeAllSpecs {
+ result = append(result, fmt.Sprintf("--%srandomizeAllSpecs", prefix))
+ }
+
+ if ginkgo.SkipMeasurements {
+ result = append(result, fmt.Sprintf("--%sskipMeasurements", prefix))
+ }
+
+ if ginkgo.FailOnPending {
+ result = append(result, fmt.Sprintf("--%sfailOnPending", prefix))
+ }
+
+ if ginkgo.FailFast {
+ result = append(result, fmt.Sprintf("--%sfailFast", prefix))
+ }
+
+ if ginkgo.DryRun {
+ result = append(result, fmt.Sprintf("--%sdryRun", prefix))
+ }
+
+ if ginkgo.FocusString != "" {
+ result = append(result, fmt.Sprintf("--%sfocus=%s", prefix, ginkgo.FocusString))
+ }
+
+ if ginkgo.SkipString != "" {
+ result = append(result, fmt.Sprintf("--%sskip=%s", prefix, ginkgo.SkipString))
+ }
+
+ if ginkgo.FlakeAttempts > 1 {
+ result = append(result, fmt.Sprintf("--%sflakeAttempts=%d", prefix, ginkgo.FlakeAttempts))
+ }
+
+ if ginkgo.EmitSpecProgress {
+ result = append(result, fmt.Sprintf("--%sprogress", prefix))
+ }
+
+ if ginkgo.DebugParallel {
+ result = append(result, fmt.Sprintf("--%sdebug", prefix))
+ }
+
+ if ginkgo.ParallelNode != 0 {
+ result = append(result, fmt.Sprintf("--%sparallel.node=%d", prefix, ginkgo.ParallelNode))
+ }
+
+ if ginkgo.ParallelTotal != 0 {
+ result = append(result, fmt.Sprintf("--%sparallel.total=%d", prefix, ginkgo.ParallelTotal))
+ }
+
+ if ginkgo.StreamHost != "" {
+ result = append(result, fmt.Sprintf("--%sparallel.streamhost=%s", prefix, ginkgo.StreamHost))
+ }
+
+ if ginkgo.SyncHost != "" {
+ result = append(result, fmt.Sprintf("--%sparallel.synchost=%s", prefix, ginkgo.SyncHost))
+ }
+
+ if ginkgo.RegexScansFilePath {
+ result = append(result, fmt.Sprintf("--%sregexScansFilePath", prefix))
+ }
+
+ if reporter.NoColor {
+ result = append(result, fmt.Sprintf("--%snoColor", prefix))
+ }
+
+ if reporter.SlowSpecThreshold > 0 {
+ result = append(result, fmt.Sprintf("--%sslowSpecThreshold=%.5f", prefix, reporter.SlowSpecThreshold))
+ }
+
+ if !reporter.NoisyPendings {
+ result = append(result, fmt.Sprintf("--%snoisyPendings=false", prefix))
+ }
+
+ if !reporter.NoisySkippings {
+ result = append(result, fmt.Sprintf("--%snoisySkippings=false", prefix))
+ }
+
+ if reporter.Verbose {
+ result = append(result, fmt.Sprintf("--%sv", prefix))
+ }
+
+ if reporter.Succinct {
+ result = append(result, fmt.Sprintf("--%ssuccinct", prefix))
+ }
+
+ if reporter.FullTrace {
+ result = append(result, fmt.Sprintf("--%strace", prefix))
+ }
+
+ return result
+}
diff --git a/vendor/github.com/onsi/ginkgo/extensions/table/table.go b/vendor/github.com/onsi/ginkgo/extensions/table/table.go
new file mode 100644
index 000000000..ae8ab7d24
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/extensions/table/table.go
@@ -0,0 +1,98 @@
+/*
+
+Table provides a simple DSL for Ginkgo-native Table-Driven Tests
+
+The godoc documentation describes Table's API. More comprehensive documentation (with examples!) is available at http://onsi.github.io/ginkgo#table-driven-tests
+
+*/
+
+package table
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/ginkgo"
+)
+
+/*
+DescribeTable describes a table-driven test.
+
+For example:
+
+ DescribeTable("a simple table",
+ func(x int, y int, expected bool) {
+ Ω(x > y).Should(Equal(expected))
+ },
+ Entry("x > y", 1, 0, true),
+ Entry("x == y", 0, 0, false),
+ Entry("x < y", 0, 1, false),
+ )
+
+The first argument to `DescribeTable` is a string description.
+The second argument is a function that will be run for each table entry. Your assertions go here - the function is equivalent to a Ginkgo It.
+The subsequent arguments must be of type `TableEntry`. We recommend using the `Entry` convenience constructors.
+
+The `Entry` constructor takes a string description followed by an arbitrary set of parameters. These parameters are passed into your function.
+
+Under the hood, `DescribeTable` simply generates a new Ginkgo `Describe`. Each `Entry` is turned into an `It` within the `Describe`.
+
+It's important to understand that the `Describe`s and `It`s are generated at evaluation time (i.e. when Ginkgo constructs the tree of tests and before the tests run).
+
+Individual Entries can be focused (with FEntry) or marked pending (with PEntry or XEntry). In addition, the entire table can be focused or marked pending with FDescribeTable and PDescribeTable/XDescribeTable.
+*/
+func DescribeTable(description string, itBody interface{}, entries ...TableEntry) bool {
+ describeTable(description, itBody, entries, false, false)
+ return true
+}
+
+/*
+You can focus a table with `FDescribeTable`. This is equivalent to `FDescribe`.
+*/
+func FDescribeTable(description string, itBody interface{}, entries ...TableEntry) bool {
+ describeTable(description, itBody, entries, false, true)
+ return true
+}
+
+/*
+You can mark a table as pending with `PDescribeTable`. This is equivalent to `PDescribe`.
+*/
+func PDescribeTable(description string, itBody interface{}, entries ...TableEntry) bool {
+ describeTable(description, itBody, entries, true, false)
+ return true
+}
+
+/*
+You can mark a table as pending with `XDescribeTable`. This is equivalent to `XDescribe`.
+*/
+func XDescribeTable(description string, itBody interface{}, entries ...TableEntry) bool {
+ describeTable(description, itBody, entries, true, false)
+ return true
+}
+
+func describeTable(description string, itBody interface{}, entries []TableEntry, pending bool, focused bool) {
+ itBodyValue := reflect.ValueOf(itBody)
+ if itBodyValue.Kind() != reflect.Func {
+ panic(fmt.Sprintf("DescribeTable expects a function, got %#v", itBody))
+ }
+
+ if pending {
+ ginkgo.PDescribe(description, func() {
+ for _, entry := range entries {
+ entry.generateIt(itBodyValue)
+ }
+ })
+ } else if focused {
+ ginkgo.FDescribe(description, func() {
+ for _, entry := range entries {
+ entry.generateIt(itBodyValue)
+ }
+ })
+ } else {
+ ginkgo.Describe(description, func() {
+ for _, entry := range entries {
+ entry.generateIt(itBodyValue)
+ }
+ })
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/extensions/table/table_entry.go b/vendor/github.com/onsi/ginkgo/extensions/table/table_entry.go
new file mode 100644
index 000000000..5fa645bce
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/extensions/table/table_entry.go
@@ -0,0 +1,81 @@
+package table
+
+import (
+ "reflect"
+
+ "github.com/onsi/ginkgo"
+)
+
+/*
+TableEntry represents an entry in a table test. You generally use the `Entry` constructor.
+*/
+type TableEntry struct {
+ Description string
+ Parameters []interface{}
+ Pending bool
+ Focused bool
+}
+
+func (t TableEntry) generateIt(itBody reflect.Value) {
+ if t.Pending {
+ ginkgo.PIt(t.Description)
+ return
+ }
+
+ values := []reflect.Value{}
+ for i, param := range t.Parameters {
+ var value reflect.Value
+
+ if param == nil {
+ inType := itBody.Type().In(i)
+ value = reflect.Zero(inType)
+ } else {
+ value = reflect.ValueOf(param)
+ }
+
+ values = append(values, value)
+ }
+
+ body := func() {
+ itBody.Call(values)
+ }
+
+ if t.Focused {
+ ginkgo.FIt(t.Description, body)
+ } else {
+ ginkgo.It(t.Description, body)
+ }
+}
+
+/*
+Entry constructs a TableEntry.
+
+The first argument is a required description (this becomes the content of the generated Ginkgo `It`).
+Subsequent parameters are saved off and sent to the callback passed in to `DescribeTable`.
+
+Each Entry ends up generating an individual Ginkgo It.
+*/
+func Entry(description string, parameters ...interface{}) TableEntry {
+ return TableEntry{description, parameters, false, false}
+}
+
+/*
+You can focus a particular entry with FEntry. This is equivalent to FIt.
+*/
+func FEntry(description string, parameters ...interface{}) TableEntry {
+ return TableEntry{description, parameters, false, true}
+}
+
+/*
+You can mark a particular entry as pending with PEntry. This is equivalent to PIt.
+*/
+func PEntry(description string, parameters ...interface{}) TableEntry {
+ return TableEntry{description, parameters, true, false}
+}
+
+/*
+You can mark a particular entry as pending with XEntry. This is equivalent to XIt.
+*/
+func XEntry(description string, parameters ...interface{}) TableEntry {
+ return TableEntry{description, parameters, true, false}
+}
diff --git a/vendor/github.com/onsi/ginkgo/extensions/table/table_suite_test.go b/vendor/github.com/onsi/ginkgo/extensions/table/table_suite_test.go
new file mode 100644
index 000000000..f482ec3dc
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/extensions/table/table_suite_test.go
@@ -0,0 +1,13 @@
+package table_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestTable(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Table Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/extensions/table/table_test.go b/vendor/github.com/onsi/ginkgo/extensions/table/table_test.go
new file mode 100644
index 000000000..b008e432b
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/extensions/table/table_test.go
@@ -0,0 +1,64 @@
+package table_test
+
+import (
+ "strings"
+
+ . "github.com/onsi/ginkgo/extensions/table"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Table", func() {
+ DescribeTable("a simple table",
+ func(x int, y int, expected bool) {
+ Ω(x > y).Should(Equal(expected))
+ },
+ Entry("x > y", 1, 0, true),
+ Entry("x == y", 0, 0, false),
+ Entry("x < y", 0, 1, false),
+ )
+
+ type ComplicatedThings struct {
+ Superstructure string
+ Substructure string
+ Count int
+ }
+
+ DescribeTable("a more complicated table",
+ func(c ComplicatedThings) {
+ Ω(strings.Count(c.Superstructure, c.Substructure)).Should(BeNumerically("==", c.Count))
+ },
+ Entry("with no matching substructures", ComplicatedThings{
+ Superstructure: "the sixth sheikh's sixth sheep's sick",
+ Substructure: "emir",
+ Count: 0,
+ }),
+ Entry("with one matching substructure", ComplicatedThings{
+ Superstructure: "the sixth sheikh's sixth sheep's sick",
+ Substructure: "sheep",
+ Count: 1,
+ }),
+ Entry("with many matching substructures", ComplicatedThings{
+ Superstructure: "the sixth sheikh's sixth sheep's sick",
+ Substructure: "si",
+ Count: 3,
+ }),
+ )
+
+ PDescribeTable("a failure",
+ func(value bool) {
+ Ω(value).Should(BeFalse())
+ },
+ Entry("when true", true),
+ Entry("when false", false),
+ Entry("when malformed", 2),
+ )
+
+ DescribeTable("an untyped nil as an entry",
+ func(x interface{}) {
+ Expect(x).To(BeNil())
+ },
+ Entry("nil", nil),
+ )
+})
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/bootstrap_command.go b/vendor/github.com/onsi/ginkgo/ginkgo/bootstrap_command.go
new file mode 100644
index 000000000..fea4d4d4e
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/bootstrap_command.go
@@ -0,0 +1,202 @@
+package main
+
+import (
+ "bytes"
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "strings"
+ "text/template"
+
+ "go/build"
+
+ "github.com/onsi/ginkgo/ginkgo/nodot"
+)
+
+func BuildBootstrapCommand() *Command {
+ var (
+ agouti, noDot, internal bool
+ customBootstrapFile string
+ )
+ flagSet := flag.NewFlagSet("bootstrap", flag.ExitOnError)
+ flagSet.BoolVar(&agouti, "agouti", false, "If set, bootstrap will generate a bootstrap file for writing Agouti tests")
+ flagSet.BoolVar(&noDot, "nodot", false, "If set, bootstrap will generate a bootstrap file that does not . import ginkgo and gomega")
+ flagSet.BoolVar(&internal, "internal", false, "If set, generate will generate a test file that uses the regular package name")
+ flagSet.StringVar(&customBootstrapFile, "template", "", "If specified, generate will use the contents of the file passed as the bootstrap template")
+
+ return &Command{
+ Name: "bootstrap",
+ FlagSet: flagSet,
+ UsageCommand: "ginkgo bootstrap <FLAGS>",
+ Usage: []string{
+ "Bootstrap a test suite for the current package",
+ "Accepts the following flags:",
+ },
+ Command: func(args []string, additionalArgs []string) {
+ generateBootstrap(agouti, noDot, internal, customBootstrapFile)
+ },
+ }
+}
+
+var bootstrapText = `package {{.Package}}
+
+import (
+ "testing"
+
+ {{.GinkgoImport}}
+ {{.GomegaImport}}
+)
+
+func Test{{.FormattedName}}(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "{{.FormattedName}} Suite")
+}
+`
+
+var agoutiBootstrapText = `package {{.Package}}
+
+import (
+ "testing"
+
+ {{.GinkgoImport}}
+ {{.GomegaImport}}
+ "github.com/sclevine/agouti"
+)
+
+func Test{{.FormattedName}}(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "{{.FormattedName}} Suite")
+}
+
+var agoutiDriver *agouti.WebDriver
+
+var _ = BeforeSuite(func() {
+ // Choose a WebDriver:
+
+ agoutiDriver = agouti.PhantomJS()
+ // agoutiDriver = agouti.Selenium()
+ // agoutiDriver = agouti.ChromeDriver()
+
+ Expect(agoutiDriver.Start()).To(Succeed())
+})
+
+var _ = AfterSuite(func() {
+ Expect(agoutiDriver.Stop()).To(Succeed())
+})
+`
+
+type bootstrapData struct {
+ Package string
+ FormattedName string
+ GinkgoImport string
+ GomegaImport string
+}
+
+func getPackageAndFormattedName() (string, string, string) {
+ path, err := os.Getwd()
+ if err != nil {
+ complainAndQuit("Could not get current working directory: \n" + err.Error())
+ }
+
+ dirName := strings.Replace(filepath.Base(path), "-", "_", -1)
+ dirName = strings.Replace(dirName, " ", "_", -1)
+
+ pkg, err := build.ImportDir(path, 0)
+ packageName := pkg.Name
+ if err != nil {
+ packageName = dirName
+ }
+
+ formattedName := prettifyPackageName(filepath.Base(path))
+ return packageName, dirName, formattedName
+}
+
+func prettifyPackageName(name string) string {
+ name = strings.Replace(name, "-", " ", -1)
+ name = strings.Replace(name, "_", " ", -1)
+ name = strings.Title(name)
+ name = strings.Replace(name, " ", "", -1)
+ return name
+}
+
+func determinePackageName(name string, internal bool) string {
+ if internal {
+ return name
+ }
+
+ return name + "_test"
+}
+
+func fileExists(path string) bool {
+ _, err := os.Stat(path)
+ if err == nil {
+ return true
+ }
+ return false
+}
+
+func generateBootstrap(agouti, noDot, internal bool, customBootstrapFile string) {
+ packageName, bootstrapFilePrefix, formattedName := getPackageAndFormattedName()
+ data := bootstrapData{
+ Package: determinePackageName(packageName, internal),
+ FormattedName: formattedName,
+ GinkgoImport: `. "github.com/onsi/ginkgo"`,
+ GomegaImport: `. "github.com/onsi/gomega"`,
+ }
+
+ if noDot {
+ data.GinkgoImport = `"github.com/onsi/ginkgo"`
+ data.GomegaImport = `"github.com/onsi/gomega"`
+ }
+
+ targetFile := fmt.Sprintf("%s_suite_test.go", bootstrapFilePrefix)
+ if fileExists(targetFile) {
+ fmt.Printf("%s already exists.\n\n", targetFile)
+ os.Exit(1)
+ } else {
+ fmt.Printf("Generating ginkgo test suite bootstrap for %s in:\n\t%s\n", packageName, targetFile)
+ }
+
+ f, err := os.Create(targetFile)
+ if err != nil {
+ complainAndQuit("Could not create file: " + err.Error())
+ panic(err.Error())
+ }
+ defer f.Close()
+
+ var templateText string
+ if customBootstrapFile != "" {
+ tpl, err := ioutil.ReadFile(customBootstrapFile)
+ if err != nil {
+ panic(err.Error())
+ }
+ templateText = string(tpl)
+ } else if agouti {
+ templateText = agoutiBootstrapText
+ } else {
+ templateText = bootstrapText
+ }
+
+ bootstrapTemplate, err := template.New("bootstrap").Parse(templateText)
+ if err != nil {
+ panic(err.Error())
+ }
+
+ buf := &bytes.Buffer{}
+ bootstrapTemplate.Execute(buf, data)
+
+ if noDot {
+ contents, err := nodot.ApplyNoDot(buf.Bytes())
+ if err != nil {
+ complainAndQuit("Failed to import nodot declarations: " + err.Error())
+ }
+ fmt.Println("To update the nodot declarations in the future, switch to this directory and run:\n\tginkgo nodot")
+ buf = bytes.NewBuffer(contents)
+ }
+
+ buf.WriteTo(f)
+
+ goFmt(targetFile)
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/build_command.go b/vendor/github.com/onsi/ginkgo/ginkgo/build_command.go
new file mode 100644
index 000000000..f0eb375c3
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/build_command.go
@@ -0,0 +1,68 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "os"
+ "path/filepath"
+
+ "github.com/onsi/ginkgo/ginkgo/interrupthandler"
+ "github.com/onsi/ginkgo/ginkgo/testrunner"
+)
+
+func BuildBuildCommand() *Command {
+ commandFlags := NewBuildCommandFlags(flag.NewFlagSet("build", flag.ExitOnError))
+ interruptHandler := interrupthandler.NewInterruptHandler()
+ builder := &SpecBuilder{
+ commandFlags: commandFlags,
+ interruptHandler: interruptHandler,
+ }
+
+ return &Command{
+ Name: "build",
+ FlagSet: commandFlags.FlagSet,
+ UsageCommand: "ginkgo build <FLAGS> <PACKAGES>",
+ Usage: []string{
+ "Build the passed in <PACKAGES> (or the package in the current directory if left blank).",
+ "Accepts the following flags:",
+ },
+ Command: builder.BuildSpecs,
+ }
+}
+
+type SpecBuilder struct {
+ commandFlags *RunWatchAndBuildCommandFlags
+ interruptHandler *interrupthandler.InterruptHandler
+}
+
+func (r *SpecBuilder) BuildSpecs(args []string, additionalArgs []string) {
+ r.commandFlags.computeNodes()
+
+ suites, _ := findSuites(args, r.commandFlags.Recurse, r.commandFlags.SkipPackage, false)
+
+ if len(suites) == 0 {
+ complainAndQuit("Found no test suites")
+ }
+
+ passed := true
+ for _, suite := range suites {
+ runner := testrunner.New(suite, 1, false, 0, r.commandFlags.GoOpts, nil)
+ fmt.Printf("Compiling %s...\n", suite.PackageName)
+
+ path, _ := filepath.Abs(filepath.Join(suite.Path, fmt.Sprintf("%s.test", suite.PackageName)))
+ err := runner.CompileTo(path)
+ if err != nil {
+ fmt.Println(err.Error())
+ passed = false
+ } else {
+ fmt.Printf(" compiled %s.test\n", suite.PackageName)
+ }
+
+ runner.CleanUp()
+ }
+
+ if passed {
+ os.Exit(0)
+ }
+ os.Exit(1)
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/convert/ginkgo_ast_nodes.go b/vendor/github.com/onsi/ginkgo/ginkgo/convert/ginkgo_ast_nodes.go
new file mode 100644
index 000000000..02e2b3b32
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/convert/ginkgo_ast_nodes.go
@@ -0,0 +1,123 @@
+package convert
+
+import (
+ "fmt"
+ "go/ast"
+ "strings"
+ "unicode"
+)
+
+/*
+ * Creates a func init() node
+ */
+func createVarUnderscoreBlock() *ast.ValueSpec {
+ valueSpec := &ast.ValueSpec{}
+ object := &ast.Object{Kind: 4, Name: "_", Decl: valueSpec, Data: 0}
+ ident := &ast.Ident{Name: "_", Obj: object}
+ valueSpec.Names = append(valueSpec.Names, ident)
+ return valueSpec
+}
+
+/*
+ * Creates a Describe("Testing with ginkgo", func() { }) node
+ */
+func createDescribeBlock() *ast.CallExpr {
+ blockStatement := &ast.BlockStmt{List: []ast.Stmt{}}
+
+ fieldList := &ast.FieldList{}
+ funcType := &ast.FuncType{Params: fieldList}
+ funcLit := &ast.FuncLit{Type: funcType, Body: blockStatement}
+ basicLit := &ast.BasicLit{Kind: 9, Value: "\"Testing with Ginkgo\""}
+ describeIdent := &ast.Ident{Name: "Describe"}
+ return &ast.CallExpr{Fun: describeIdent, Args: []ast.Expr{basicLit, funcLit}}
+}
+
+/*
+ * Convenience function to return the name of the *testing.T param
+ * for a Test function that will be rewritten. This is useful because
+ * we will want to replace the usage of this named *testing.T inside the
+ * body of the function with a GinktoT.
+ */
+func namedTestingTArg(node *ast.FuncDecl) string {
+ return node.Type.Params.List[0].Names[0].Name // *exhale*
+}
+
+/*
+ * Convenience function to return the block statement node for a Describe statement
+ */
+func blockStatementFromDescribe(desc *ast.CallExpr) *ast.BlockStmt {
+ var funcLit *ast.FuncLit
+ var found = false
+
+ for _, node := range desc.Args {
+ switch node := node.(type) {
+ case *ast.FuncLit:
+ found = true
+ funcLit = node
+ break
+ }
+ }
+
+ if !found {
+ panic("Error finding ast.FuncLit inside describe statement. Somebody done goofed.")
+ }
+
+ return funcLit.Body
+}
+
+/* convenience function for creating an It("TestNameHere")
+ * with all the body of the test function inside the anonymous
+ * func passed to It()
+ */
+func createItStatementForTestFunc(testFunc *ast.FuncDecl) *ast.ExprStmt {
+ blockStatement := &ast.BlockStmt{List: testFunc.Body.List}
+ fieldList := &ast.FieldList{}
+ funcType := &ast.FuncType{Params: fieldList}
+ funcLit := &ast.FuncLit{Type: funcType, Body: blockStatement}
+
+ testName := rewriteTestName(testFunc.Name.Name)
+ basicLit := &ast.BasicLit{Kind: 9, Value: fmt.Sprintf("\"%s\"", testName)}
+ itBlockIdent := &ast.Ident{Name: "It"}
+ callExpr := &ast.CallExpr{Fun: itBlockIdent, Args: []ast.Expr{basicLit, funcLit}}
+ return &ast.ExprStmt{X: callExpr}
+}
+
+/*
+* rewrite test names to be human readable
+* eg: rewrites "TestSomethingAmazing" as "something amazing"
+ */
+func rewriteTestName(testName string) string {
+ nameComponents := []string{}
+ currentString := ""
+ indexOfTest := strings.Index(testName, "Test")
+ if indexOfTest != 0 {
+ return testName
+ }
+
+ testName = strings.Replace(testName, "Test", "", 1)
+ first, rest := testName[0], testName[1:]
+ testName = string(unicode.ToLower(rune(first))) + rest
+
+ for _, rune := range testName {
+ if unicode.IsUpper(rune) {
+ nameComponents = append(nameComponents, currentString)
+ currentString = string(unicode.ToLower(rune))
+ } else {
+ currentString += string(rune)
+ }
+ }
+
+ return strings.Join(append(nameComponents, currentString), " ")
+}
+
+func newGinkgoTFromIdent(ident *ast.Ident) *ast.CallExpr {
+ return &ast.CallExpr{
+ Lparen: ident.NamePos + 1,
+ Rparen: ident.NamePos + 2,
+ Fun: &ast.Ident{Name: "GinkgoT"},
+ }
+}
+
+func newGinkgoTInterface() *ast.Ident {
+ return &ast.Ident{Name: "GinkgoTInterface"}
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/convert/import.go b/vendor/github.com/onsi/ginkgo/ginkgo/convert/import.go
new file mode 100644
index 000000000..e226196f7
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/convert/import.go
@@ -0,0 +1,91 @@
+package convert
+
+import (
+ "errors"
+ "fmt"
+ "go/ast"
+)
+
+/*
+ * Given the root node of an AST, returns the node containing the
+ * import statements for the file.
+ */
+func importsForRootNode(rootNode *ast.File) (imports *ast.GenDecl, err error) {
+ for _, declaration := range rootNode.Decls {
+ decl, ok := declaration.(*ast.GenDecl)
+ if !ok || len(decl.Specs) == 0 {
+ continue
+ }
+
+ _, ok = decl.Specs[0].(*ast.ImportSpec)
+ if ok {
+ imports = decl
+ return
+ }
+ }
+
+ err = errors.New(fmt.Sprintf("Could not find imports for root node:\n\t%#v\n", rootNode))
+ return
+}
+
+/*
+ * Removes "testing" import, if present
+ */
+func removeTestingImport(rootNode *ast.File) {
+ importDecl, err := importsForRootNode(rootNode)
+ if err != nil {
+ panic(err.Error())
+ }
+
+ var index int
+ for i, importSpec := range importDecl.Specs {
+ importSpec := importSpec.(*ast.ImportSpec)
+ if importSpec.Path.Value == "\"testing\"" {
+ index = i
+ break
+ }
+ }
+
+ importDecl.Specs = append(importDecl.Specs[:index], importDecl.Specs[index+1:]...)
+}
+
+/*
+ * Adds import statements for onsi/ginkgo, if missing
+ */
+func addGinkgoImports(rootNode *ast.File) {
+ importDecl, err := importsForRootNode(rootNode)
+ if err != nil {
+ panic(err.Error())
+ }
+
+ if len(importDecl.Specs) == 0 {
+ // TODO: might need to create a import decl here
+ panic("unimplemented : expected to find an imports block")
+ }
+
+ needsGinkgo := true
+ for _, importSpec := range importDecl.Specs {
+ importSpec, ok := importSpec.(*ast.ImportSpec)
+ if !ok {
+ continue
+ }
+
+ if importSpec.Path.Value == "\"github.com/onsi/ginkgo\"" {
+ needsGinkgo = false
+ }
+ }
+
+ if needsGinkgo {
+ importDecl.Specs = append(importDecl.Specs, createImport(".", "\"github.com/onsi/ginkgo\""))
+ }
+}
+
+/*
+ * convenience function to create an import statement
+ */
+func createImport(name, path string) *ast.ImportSpec {
+ return &ast.ImportSpec{
+ Name: &ast.Ident{Name: name},
+ Path: &ast.BasicLit{Kind: 9, Value: path},
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/convert/package_rewriter.go b/vendor/github.com/onsi/ginkgo/ginkgo/convert/package_rewriter.go
new file mode 100644
index 000000000..ed09c460d
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/convert/package_rewriter.go
@@ -0,0 +1,127 @@
+package convert
+
+import (
+ "fmt"
+ "go/build"
+ "io/ioutil"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "regexp"
+)
+
+/*
+ * RewritePackage takes a name (eg: my-package/tools), finds its test files using
+ * Go's build package, and then rewrites them. A ginkgo test suite file will
+ * also be added for this package, and all of its child packages.
+ */
+func RewritePackage(packageName string) {
+ pkg, err := packageWithName(packageName)
+ if err != nil {
+ panic(fmt.Sprintf("unexpected error reading package: '%s'\n%s\n", packageName, err.Error()))
+ }
+
+ for _, filename := range findTestsInPackage(pkg) {
+ rewriteTestsInFile(filename)
+ }
+ return
+}
+
+/*
+ * Given a package, findTestsInPackage reads the test files in the directory,
+ * and then recurses on each child package, returning a slice of all test files
+ * found in this process.
+ */
+func findTestsInPackage(pkg *build.Package) (testfiles []string) {
+ for _, file := range append(pkg.TestGoFiles, pkg.XTestGoFiles...) {
+ testfiles = append(testfiles, filepath.Join(pkg.Dir, file))
+ }
+
+ dirFiles, err := ioutil.ReadDir(pkg.Dir)
+ if err != nil {
+ panic(fmt.Sprintf("unexpected error reading dir: '%s'\n%s\n", pkg.Dir, err.Error()))
+ }
+
+ re := regexp.MustCompile(`^[._]`)
+
+ for _, file := range dirFiles {
+ if !file.IsDir() {
+ continue
+ }
+
+ if re.Match([]byte(file.Name())) {
+ continue
+ }
+
+ packageName := filepath.Join(pkg.ImportPath, file.Name())
+ subPackage, err := packageWithName(packageName)
+ if err != nil {
+ panic(fmt.Sprintf("unexpected error reading package: '%s'\n%s\n", packageName, err.Error()))
+ }
+
+ testfiles = append(testfiles, findTestsInPackage(subPackage)...)
+ }
+
+ addGinkgoSuiteForPackage(pkg)
+ goFmtPackage(pkg)
+ return
+}
+
+/*
+ * Shells out to `ginkgo bootstrap` to create a test suite file
+ */
+func addGinkgoSuiteForPackage(pkg *build.Package) {
+ originalDir, err := os.Getwd()
+ if err != nil {
+ panic(err)
+ }
+
+ suite_test_file := filepath.Join(pkg.Dir, pkg.Name+"_suite_test.go")
+
+ _, err = os.Stat(suite_test_file)
+ if err == nil {
+ return // test file already exists, this should be a no-op
+ }
+
+ err = os.Chdir(pkg.Dir)
+ if err != nil {
+ panic(err)
+ }
+
+ output, err := exec.Command("ginkgo", "bootstrap").Output()
+
+ if err != nil {
+ panic(fmt.Sprintf("error running 'ginkgo bootstrap'.\nstdout: %s\n%s\n", output, err.Error()))
+ }
+
+ err = os.Chdir(originalDir)
+ if err != nil {
+ panic(err)
+ }
+}
+
+/*
+ * Shells out to `go fmt` to format the package
+ */
+func goFmtPackage(pkg *build.Package) {
+ output, err := exec.Command("go", "fmt", pkg.ImportPath).Output()
+
+ if err != nil {
+ fmt.Printf("Warning: Error running 'go fmt %s'.\nstdout: %s\n%s\n", pkg.ImportPath, output, err.Error())
+ }
+}
+
+/*
+ * Attempts to return a package with its test files already read.
+ * The ImportMode arg to build.Import lets you specify if you want go to read the
+ * buildable go files inside the package, but it fails if the package has no go files
+ */
+func packageWithName(name string) (pkg *build.Package, err error) {
+ pkg, err = build.Default.Import(name, ".", build.ImportMode(0))
+ if err == nil {
+ return
+ }
+
+ pkg, err = build.Default.Import(name, ".", build.ImportMode(1))
+ return
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/convert/test_finder.go b/vendor/github.com/onsi/ginkgo/ginkgo/convert/test_finder.go
new file mode 100644
index 000000000..b33595c9a
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/convert/test_finder.go
@@ -0,0 +1,56 @@
+package convert
+
+import (
+ "go/ast"
+ "regexp"
+)
+
+/*
+ * Given a root node, walks its top level statements and returns
+ * points to function nodes to rewrite as It statements.
+ * These functions, according to Go testing convention, must be named
+ * TestWithCamelCasedName and receive a single *testing.T argument.
+ */
+func findTestFuncs(rootNode *ast.File) (testsToRewrite []*ast.FuncDecl) {
+ testNameRegexp := regexp.MustCompile("^Test[0-9A-Z].+")
+
+ ast.Inspect(rootNode, func(node ast.Node) bool {
+ if node == nil {
+ return false
+ }
+
+ switch node := node.(type) {
+ case *ast.FuncDecl:
+ matches := testNameRegexp.MatchString(node.Name.Name)
+
+ if matches && receivesTestingT(node) {
+ testsToRewrite = append(testsToRewrite, node)
+ }
+ }
+
+ return true
+ })
+
+ return
+}
+
+/*
+ * convenience function that looks at args to a function and determines if its
+ * params include an argument of type *testing.T
+ */
+func receivesTestingT(node *ast.FuncDecl) bool {
+ if len(node.Type.Params.List) != 1 {
+ return false
+ }
+
+ base, ok := node.Type.Params.List[0].Type.(*ast.StarExpr)
+ if !ok {
+ return false
+ }
+
+ intermediate := base.X.(*ast.SelectorExpr)
+ isTestingPackage := intermediate.X.(*ast.Ident).Name == "testing"
+ isTestingT := intermediate.Sel.Name == "T"
+
+ return isTestingPackage && isTestingT
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/convert/testfile_rewriter.go b/vendor/github.com/onsi/ginkgo/ginkgo/convert/testfile_rewriter.go
new file mode 100644
index 000000000..4b001a7db
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/convert/testfile_rewriter.go
@@ -0,0 +1,163 @@
+package convert
+
+import (
+ "bytes"
+ "fmt"
+ "go/ast"
+ "go/format"
+ "go/parser"
+ "go/token"
+ "io/ioutil"
+ "os"
+)
+
+/*
+ * Given a file path, rewrites any tests in the Ginkgo format.
+ * First, we parse the AST, and update the imports declaration.
+ * Then, we walk the first child elements in the file, returning tests to rewrite.
+ * A top level init func is declared, with a single Describe func inside.
+ * Then the test functions to rewrite are inserted as It statements inside the Describe.
+ * Finally we walk the rest of the file, replacing other usages of *testing.T
+ * Once that is complete, we write the AST back out again to its file.
+ */
+func rewriteTestsInFile(pathToFile string) {
+ fileSet := token.NewFileSet()
+ rootNode, err := parser.ParseFile(fileSet, pathToFile, nil, 0)
+ if err != nil {
+ panic(fmt.Sprintf("Error parsing test file '%s':\n%s\n", pathToFile, err.Error()))
+ }
+
+ addGinkgoImports(rootNode)
+ removeTestingImport(rootNode)
+
+ varUnderscoreBlock := createVarUnderscoreBlock()
+ describeBlock := createDescribeBlock()
+ varUnderscoreBlock.Values = []ast.Expr{describeBlock}
+
+ for _, testFunc := range findTestFuncs(rootNode) {
+ rewriteTestFuncAsItStatement(testFunc, rootNode, describeBlock)
+ }
+
+ underscoreDecl := &ast.GenDecl{
+ Tok: 85, // gah, magick numbers are needed to make this work
+ TokPos: 14, // this tricks Go into writing "var _ = Describe"
+ Specs: []ast.Spec{varUnderscoreBlock},
+ }
+
+ imports := rootNode.Decls[0]
+ tail := rootNode.Decls[1:]
+ rootNode.Decls = append(append([]ast.Decl{imports}, underscoreDecl), tail...)
+ rewriteOtherFuncsToUseGinkgoT(rootNode.Decls)
+ walkNodesInRootNodeReplacingTestingT(rootNode)
+
+ var buffer bytes.Buffer
+ if err = format.Node(&buffer, fileSet, rootNode); err != nil {
+ panic(fmt.Sprintf("Error formatting ast node after rewriting tests.\n%s\n", err.Error()))
+ }
+
+ fileInfo, err := os.Stat(pathToFile)
+ if err != nil {
+ panic(fmt.Sprintf("Error stat'ing file: %s\n", pathToFile))
+ }
+
+ ioutil.WriteFile(pathToFile, buffer.Bytes(), fileInfo.Mode())
+ return
+}
+
+/*
+ * Given a test func named TestDoesSomethingNeat, rewrites it as
+ * It("does something neat", func() { __test_body_here__ }) and adds it
+ * to the Describe's list of statements
+ */
+func rewriteTestFuncAsItStatement(testFunc *ast.FuncDecl, rootNode *ast.File, describe *ast.CallExpr) {
+ var funcIndex int = -1
+ for index, child := range rootNode.Decls {
+ if child == testFunc {
+ funcIndex = index
+ break
+ }
+ }
+
+ if funcIndex < 0 {
+ panic(fmt.Sprintf("Assert failed: Error finding index for test node %s\n", testFunc.Name.Name))
+ }
+
+ var block *ast.BlockStmt = blockStatementFromDescribe(describe)
+ block.List = append(block.List, createItStatementForTestFunc(testFunc))
+ replaceTestingTsWithGinkgoT(block, namedTestingTArg(testFunc))
+
+ // remove the old test func from the root node's declarations
+ rootNode.Decls = append(rootNode.Decls[:funcIndex], rootNode.Decls[funcIndex+1:]...)
+ return
+}
+
+/*
+ * walks nodes inside of a test func's statements and replaces the usage of
+ * it's named *testing.T param with GinkgoT's
+ */
+func replaceTestingTsWithGinkgoT(statementsBlock *ast.BlockStmt, testingT string) {
+ ast.Inspect(statementsBlock, func(node ast.Node) bool {
+ if node == nil {
+ return false
+ }
+
+ keyValueExpr, ok := node.(*ast.KeyValueExpr)
+ if ok {
+ replaceNamedTestingTsInKeyValueExpression(keyValueExpr, testingT)
+ return true
+ }
+
+ funcLiteral, ok := node.(*ast.FuncLit)
+ if ok {
+ replaceTypeDeclTestingTsInFuncLiteral(funcLiteral)
+ return true
+ }
+
+ callExpr, ok := node.(*ast.CallExpr)
+ if !ok {
+ return true
+ }
+ replaceTestingTsInArgsLists(callExpr, testingT)
+
+ funCall, ok := callExpr.Fun.(*ast.SelectorExpr)
+ if ok {
+ replaceTestingTsMethodCalls(funCall, testingT)
+ }
+
+ return true
+ })
+}
+
+/*
+ * rewrite t.Fail() or any other *testing.T method by replacing with T().Fail()
+ * This function receives a selector expression (eg: t.Fail()) and
+ * the name of the *testing.T param from the function declaration. Rewrites the
+ * selector expression in place if the target was a *testing.T
+ */
+func replaceTestingTsMethodCalls(selectorExpr *ast.SelectorExpr, testingT string) {
+ ident, ok := selectorExpr.X.(*ast.Ident)
+ if !ok {
+ return
+ }
+
+ if ident.Name == testingT {
+ selectorExpr.X = newGinkgoTFromIdent(ident)
+ }
+}
+
+/*
+ * replaces usages of a named *testing.T param inside of a call expression
+ * with a new GinkgoT object
+ */
+func replaceTestingTsInArgsLists(callExpr *ast.CallExpr, testingT string) {
+ for index, arg := range callExpr.Args {
+ ident, ok := arg.(*ast.Ident)
+ if !ok {
+ continue
+ }
+
+ if ident.Name == testingT {
+ callExpr.Args[index] = newGinkgoTFromIdent(ident)
+ }
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/convert/testing_t_rewriter.go b/vendor/github.com/onsi/ginkgo/ginkgo/convert/testing_t_rewriter.go
new file mode 100644
index 000000000..418cdc4e5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/convert/testing_t_rewriter.go
@@ -0,0 +1,130 @@
+package convert
+
+import (
+ "go/ast"
+)
+
+/*
+ * Rewrites any other top level funcs that receive a *testing.T param
+ */
+func rewriteOtherFuncsToUseGinkgoT(declarations []ast.Decl) {
+ for _, decl := range declarations {
+ decl, ok := decl.(*ast.FuncDecl)
+ if !ok {
+ continue
+ }
+
+ for _, param := range decl.Type.Params.List {
+ starExpr, ok := param.Type.(*ast.StarExpr)
+ if !ok {
+ continue
+ }
+
+ selectorExpr, ok := starExpr.X.(*ast.SelectorExpr)
+ if !ok {
+ continue
+ }
+
+ xIdent, ok := selectorExpr.X.(*ast.Ident)
+ if !ok || xIdent.Name != "testing" {
+ continue
+ }
+
+ if selectorExpr.Sel.Name != "T" {
+ continue
+ }
+
+ param.Type = newGinkgoTInterface()
+ }
+ }
+}
+
+/*
+ * Walks all of the nodes in the file, replacing *testing.T in struct
+ * and func literal nodes. eg:
+ * type foo struct { *testing.T }
+ * var bar = func(t *testing.T) { }
+ */
+func walkNodesInRootNodeReplacingTestingT(rootNode *ast.File) {
+ ast.Inspect(rootNode, func(node ast.Node) bool {
+ if node == nil {
+ return false
+ }
+
+ switch node := node.(type) {
+ case *ast.StructType:
+ replaceTestingTsInStructType(node)
+ case *ast.FuncLit:
+ replaceTypeDeclTestingTsInFuncLiteral(node)
+ }
+
+ return true
+ })
+}
+
+/*
+ * replaces named *testing.T inside a composite literal
+ */
+func replaceNamedTestingTsInKeyValueExpression(kve *ast.KeyValueExpr, testingT string) {
+ ident, ok := kve.Value.(*ast.Ident)
+ if !ok {
+ return
+ }
+
+ if ident.Name == testingT {
+ kve.Value = newGinkgoTFromIdent(ident)
+ }
+}
+
+/*
+ * replaces *testing.T params in a func literal with GinkgoT
+ */
+func replaceTypeDeclTestingTsInFuncLiteral(functionLiteral *ast.FuncLit) {
+ for _, arg := range functionLiteral.Type.Params.List {
+ starExpr, ok := arg.Type.(*ast.StarExpr)
+ if !ok {
+ continue
+ }
+
+ selectorExpr, ok := starExpr.X.(*ast.SelectorExpr)
+ if !ok {
+ continue
+ }
+
+ target, ok := selectorExpr.X.(*ast.Ident)
+ if !ok {
+ continue
+ }
+
+ if target.Name == "testing" && selectorExpr.Sel.Name == "T" {
+ arg.Type = newGinkgoTInterface()
+ }
+ }
+}
+
+/*
+ * Replaces *testing.T types inside of a struct declaration with a GinkgoT
+ * eg: type foo struct { *testing.T }
+ */
+func replaceTestingTsInStructType(structType *ast.StructType) {
+ for _, field := range structType.Fields.List {
+ starExpr, ok := field.Type.(*ast.StarExpr)
+ if !ok {
+ continue
+ }
+
+ selectorExpr, ok := starExpr.X.(*ast.SelectorExpr)
+ if !ok {
+ continue
+ }
+
+ xIdent, ok := selectorExpr.X.(*ast.Ident)
+ if !ok {
+ continue
+ }
+
+ if xIdent.Name == "testing" && selectorExpr.Sel.Name == "T" {
+ field.Type = newGinkgoTInterface()
+ }
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/convert_command.go b/vendor/github.com/onsi/ginkgo/ginkgo/convert_command.go
new file mode 100644
index 000000000..5944ed85c
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/convert_command.go
@@ -0,0 +1,45 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "os"
+
+ "github.com/onsi/ginkgo/ginkgo/convert"
+)
+
+func BuildConvertCommand() *Command {
+ return &Command{
+ Name: "convert",
+ FlagSet: flag.NewFlagSet("convert", flag.ExitOnError),
+ UsageCommand: "ginkgo convert /path/to/package",
+ Usage: []string{
+ "Convert the package at the passed in path from an XUnit-style test to a Ginkgo-style test",
+ },
+ Command: convertPackage,
+ }
+}
+
+func convertPackage(args []string, additionalArgs []string) {
+ if len(args) != 1 {
+ println(fmt.Sprintf("usage: ginkgo convert /path/to/your/package"))
+ os.Exit(1)
+ }
+
+ defer func() {
+ err := recover()
+ if err != nil {
+ switch err := err.(type) {
+ case error:
+ println(err.Error())
+ case string:
+ println(err)
+ default:
+ println(fmt.Sprintf("unexpected error: %#v", err))
+ }
+ os.Exit(1)
+ }
+ }()
+
+ convert.RewritePackage(args[0])
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/generate_command.go b/vendor/github.com/onsi/ginkgo/ginkgo/generate_command.go
new file mode 100644
index 000000000..019fd2337
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/generate_command.go
@@ -0,0 +1,167 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "os"
+ "path/filepath"
+ "strings"
+ "text/template"
+)
+
+func BuildGenerateCommand() *Command {
+ var agouti, noDot, internal bool
+ flagSet := flag.NewFlagSet("generate", flag.ExitOnError)
+ flagSet.BoolVar(&agouti, "agouti", false, "If set, generate will generate a test file for writing Agouti tests")
+ flagSet.BoolVar(&noDot, "nodot", false, "If set, generate will generate a test file that does not . import ginkgo and gomega")
+ flagSet.BoolVar(&internal, "internal", false, "If set, generate will generate a test file that uses the regular package name")
+
+ return &Command{
+ Name: "generate",
+ FlagSet: flagSet,
+ UsageCommand: "ginkgo generate <filename(s)>",
+ Usage: []string{
+ "Generate a test file named filename_test.go",
+ "If the optional <filenames> argument is omitted, a file named after the package in the current directory will be created.",
+ "Accepts the following flags:",
+ },
+ Command: func(args []string, additionalArgs []string) {
+ generateSpec(args, agouti, noDot, internal)
+ },
+ }
+}
+
+var specText = `package {{.Package}}
+
+import (
+ {{if .IncludeImports}}. "github.com/onsi/ginkgo"{{end}}
+ {{if .IncludeImports}}. "github.com/onsi/gomega"{{end}}
+
+ {{if .DotImportPackage}}. "{{.PackageImportPath}}"{{end}}
+)
+
+var _ = Describe("{{.Subject}}", func() {
+
+})
+`
+
+var agoutiSpecText = `package {{.Package}}
+
+import (
+ {{if .IncludeImports}}. "github.com/onsi/ginkgo"{{end}}
+ {{if .IncludeImports}}. "github.com/onsi/gomega"{{end}}
+ "github.com/sclevine/agouti"
+ . "github.com/sclevine/agouti/matchers"
+
+ {{if .DotImportPackage}}. "{{.PackageImportPath}}"{{end}}
+)
+
+var _ = Describe("{{.Subject}}", func() {
+ var page *agouti.Page
+
+ BeforeEach(func() {
+ var err error
+ page, err = agoutiDriver.NewPage()
+ Expect(err).NotTo(HaveOccurred())
+ })
+
+ AfterEach(func() {
+ Expect(page.Destroy()).To(Succeed())
+ })
+})
+`
+
+type specData struct {
+ Package string
+ Subject string
+ PackageImportPath string
+ IncludeImports bool
+ DotImportPackage bool
+}
+
+func generateSpec(args []string, agouti, noDot, internal bool) {
+ if len(args) == 0 {
+ err := generateSpecForSubject("", agouti, noDot, internal)
+ if err != nil {
+ fmt.Println(err.Error())
+ fmt.Println("")
+ os.Exit(1)
+ }
+ fmt.Println("")
+ return
+ }
+
+ var failed bool
+ for _, arg := range args {
+ err := generateSpecForSubject(arg, agouti, noDot, internal)
+ if err != nil {
+ failed = true
+ fmt.Println(err.Error())
+ }
+ }
+ fmt.Println("")
+ if failed {
+ os.Exit(1)
+ }
+}
+
+func generateSpecForSubject(subject string, agouti, noDot, internal bool) error {
+ packageName, specFilePrefix, formattedName := getPackageAndFormattedName()
+ if subject != "" {
+ subject = strings.Split(subject, ".go")[0]
+ subject = strings.Split(subject, "_test")[0]
+ specFilePrefix = subject
+ formattedName = prettifyPackageName(subject)
+ }
+
+ data := specData{
+ Package: determinePackageName(packageName, internal),
+ Subject: formattedName,
+ PackageImportPath: getPackageImportPath(),
+ IncludeImports: !noDot,
+ DotImportPackage: !internal,
+ }
+
+ targetFile := fmt.Sprintf("%s_test.go", specFilePrefix)
+ if fileExists(targetFile) {
+ return fmt.Errorf("%s already exists.", targetFile)
+ } else {
+ fmt.Printf("Generating ginkgo test for %s in:\n %s\n", data.Subject, targetFile)
+ }
+
+ f, err := os.Create(targetFile)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+
+ var templateText string
+ if agouti {
+ templateText = agoutiSpecText
+ } else {
+ templateText = specText
+ }
+
+ specTemplate, err := template.New("spec").Parse(templateText)
+ if err != nil {
+ return err
+ }
+
+ specTemplate.Execute(f, data)
+ goFmt(targetFile)
+ return nil
+}
+
+func getPackageImportPath() string {
+ workingDir, err := os.Getwd()
+ if err != nil {
+ panic(err.Error())
+ }
+ sep := string(filepath.Separator)
+ paths := strings.Split(workingDir, sep+"src"+sep)
+ if len(paths) == 1 {
+ fmt.Printf("\nCouldn't identify package import path.\n\n\tginkgo generate\n\nMust be run within a package directory under $GOPATH/src/...\nYou're going to have to change UNKNOWN_PACKAGE_PATH in the generated file...\n\n")
+ return "UNKNOWN_PACKAGE_PATH"
+ }
+ return filepath.ToSlash(paths[len(paths)-1])
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/help_command.go b/vendor/github.com/onsi/ginkgo/ginkgo/help_command.go
new file mode 100644
index 000000000..23b1d2f11
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/help_command.go
@@ -0,0 +1,31 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+)
+
+func BuildHelpCommand() *Command {
+ return &Command{
+ Name: "help",
+ FlagSet: flag.NewFlagSet("help", flag.ExitOnError),
+ UsageCommand: "ginkgo help <COMMAND>",
+ Usage: []string{
+ "Print usage information. If a command is passed in, print usage information just for that command.",
+ },
+ Command: printHelp,
+ }
+}
+
+func printHelp(args []string, additionalArgs []string) {
+ if len(args) == 0 {
+ usage()
+ } else {
+ command, found := commandMatching(args[0])
+ if !found {
+ complainAndQuit(fmt.Sprintf("Unknown command: %s", args[0]))
+ }
+
+ usageForCommand(command, true)
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/interrupthandler/interrupt_handler.go b/vendor/github.com/onsi/ginkgo/ginkgo/interrupthandler/interrupt_handler.go
new file mode 100644
index 000000000..c15db0b02
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/interrupthandler/interrupt_handler.go
@@ -0,0 +1,52 @@
+package interrupthandler
+
+import (
+ "os"
+ "os/signal"
+ "sync"
+ "syscall"
+)
+
+type InterruptHandler struct {
+ interruptCount int
+ lock *sync.Mutex
+ C chan bool
+}
+
+func NewInterruptHandler() *InterruptHandler {
+ h := &InterruptHandler{
+ lock: &sync.Mutex{},
+ C: make(chan bool, 0),
+ }
+
+ go h.handleInterrupt()
+ SwallowSigQuit()
+
+ return h
+}
+
+func (h *InterruptHandler) WasInterrupted() bool {
+ h.lock.Lock()
+ defer h.lock.Unlock()
+
+ return h.interruptCount > 0
+}
+
+func (h *InterruptHandler) handleInterrupt() {
+ c := make(chan os.Signal, 1)
+ signal.Notify(c, os.Interrupt, syscall.SIGTERM)
+
+ <-c
+ signal.Stop(c)
+
+ h.lock.Lock()
+ h.interruptCount++
+ if h.interruptCount == 1 {
+ close(h.C)
+ } else if h.interruptCount > 5 {
+ os.Exit(1)
+ }
+ h.lock.Unlock()
+
+ go h.handleInterrupt()
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/interrupthandler/sigquit_swallower_unix.go b/vendor/github.com/onsi/ginkgo/ginkgo/interrupthandler/sigquit_swallower_unix.go
new file mode 100644
index 000000000..43c18544a
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/interrupthandler/sigquit_swallower_unix.go
@@ -0,0 +1,14 @@
+// +build freebsd openbsd netbsd dragonfly darwin linux solaris
+
+package interrupthandler
+
+import (
+ "os"
+ "os/signal"
+ "syscall"
+)
+
+func SwallowSigQuit() {
+ c := make(chan os.Signal, 1024)
+ signal.Notify(c, syscall.SIGQUIT)
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/interrupthandler/sigquit_swallower_windows.go b/vendor/github.com/onsi/ginkgo/ginkgo/interrupthandler/sigquit_swallower_windows.go
new file mode 100644
index 000000000..7f4a50e19
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/interrupthandler/sigquit_swallower_windows.go
@@ -0,0 +1,7 @@
+// +build windows
+
+package interrupthandler
+
+func SwallowSigQuit() {
+ //noop
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/main.go b/vendor/github.com/onsi/ginkgo/ginkgo/main.go
new file mode 100644
index 000000000..4a1aeef4f
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/main.go
@@ -0,0 +1,300 @@
+/*
+The Ginkgo CLI
+
+The Ginkgo CLI is fully documented [here](http://onsi.github.io/ginkgo/#the_ginkgo_cli)
+
+You can also learn more by running:
+
+ ginkgo help
+
+Here are some of the more commonly used commands:
+
+To install:
+
+ go install github.com/onsi/ginkgo/ginkgo
+
+To run tests:
+
+ ginkgo
+
+To run tests in all subdirectories:
+
+ ginkgo -r
+
+To run tests in particular packages:
+
+ ginkgo <flags> /path/to/package /path/to/another/package
+
+To pass arguments/flags to your tests:
+
+ ginkgo <flags> <packages> -- <pass-throughs>
+
+To run tests in parallel
+
+ ginkgo -p
+
+this will automatically detect the optimal number of nodes to use. Alternatively, you can specify the number of nodes with:
+
+ ginkgo -nodes=N
+
+(note that you don't need to provide -p in this case).
+
+By default the Ginkgo CLI will spin up a server that the individual test processes send test output to. The CLI aggregates this output and then presents coherent test output, one test at a time, as each test completes.
+An alternative is to have the parallel nodes run and stream interleaved output back. This useful for debugging, particularly in contexts where tests hang/fail to start. To get this interleaved output:
+
+ ginkgo -nodes=N -stream=true
+
+On windows, the default value for stream is true.
+
+By default, when running multiple tests (with -r or a list of packages) Ginkgo will abort when a test fails. To have Ginkgo run subsequent test suites instead you can:
+
+ ginkgo -keepGoing
+
+To fail if there are ginkgo tests in a directory but no test suite (missing `RunSpecs`)
+
+ ginkgo -requireSuite
+
+To monitor packages and rerun tests when changes occur:
+
+ ginkgo watch <-r> </path/to/package>
+
+passing `ginkgo watch` the `-r` flag will recursively detect all test suites under the current directory and monitor them.
+`watch` does not detect *new* packages. Moreover, changes in package X only rerun the tests for package X, tests for packages
+that depend on X are not rerun.
+
+[OSX & Linux only] To receive (desktop) notifications when a test run completes:
+
+ ginkgo -notify
+
+this is particularly useful with `ginkgo watch`. Notifications are currently only supported on OS X and require that you `brew install terminal-notifier`
+
+Sometimes (to suss out race conditions/flakey tests, for example) you want to keep running a test suite until it fails. You can do this with:
+
+ ginkgo -untilItFails
+
+To bootstrap a test suite:
+
+ ginkgo bootstrap
+
+To generate a test file:
+
+ ginkgo generate <test_file_name>
+
+To bootstrap/generate test files without using "." imports:
+
+ ginkgo bootstrap --nodot
+ ginkgo generate --nodot
+
+this will explicitly export all the identifiers in Ginkgo and Gomega allowing you to rename them to avoid collisions. When you pull to the latest Ginkgo/Gomega you'll want to run
+
+ ginkgo nodot
+
+to refresh this list and pull in any new identifiers. In particular, this will pull in any new Gomega matchers that get added.
+
+To convert an existing XUnit style test suite to a Ginkgo-style test suite:
+
+ ginkgo convert .
+
+To unfocus tests:
+
+ ginkgo unfocus
+
+or
+
+ ginkgo blur
+
+To compile a test suite:
+
+ ginkgo build <path-to-package>
+
+will output an executable file named `package.test`. This can be run directly or by invoking
+
+ ginkgo <path-to-package.test>
+
+To print out Ginkgo's version:
+
+ ginkgo version
+
+To get more help:
+
+ ginkgo help
+*/
+package main
+
+import (
+ "flag"
+ "fmt"
+ "os"
+ "os/exec"
+ "strings"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/ginkgo/testsuite"
+)
+
+const greenColor = "\x1b[32m"
+const redColor = "\x1b[91m"
+const defaultStyle = "\x1b[0m"
+const lightGrayColor = "\x1b[37m"
+
+type Command struct {
+ Name string
+ AltName string
+ FlagSet *flag.FlagSet
+ Usage []string
+ UsageCommand string
+ Command func(args []string, additionalArgs []string)
+ SuppressFlagDocumentation bool
+ FlagDocSubstitute []string
+}
+
+func (c *Command) Matches(name string) bool {
+ return c.Name == name || (c.AltName != "" && c.AltName == name)
+}
+
+func (c *Command) Run(args []string, additionalArgs []string) {
+ c.FlagSet.Parse(args)
+ c.Command(c.FlagSet.Args(), additionalArgs)
+}
+
+var DefaultCommand *Command
+var Commands []*Command
+
+func init() {
+ DefaultCommand = BuildRunCommand()
+ Commands = append(Commands, BuildWatchCommand())
+ Commands = append(Commands, BuildBuildCommand())
+ Commands = append(Commands, BuildBootstrapCommand())
+ Commands = append(Commands, BuildGenerateCommand())
+ Commands = append(Commands, BuildNodotCommand())
+ Commands = append(Commands, BuildConvertCommand())
+ Commands = append(Commands, BuildUnfocusCommand())
+ Commands = append(Commands, BuildVersionCommand())
+ Commands = append(Commands, BuildHelpCommand())
+}
+
+func main() {
+ args := []string{}
+ additionalArgs := []string{}
+
+ foundDelimiter := false
+
+ for _, arg := range os.Args[1:] {
+ if !foundDelimiter {
+ if arg == "--" {
+ foundDelimiter = true
+ continue
+ }
+ }
+
+ if foundDelimiter {
+ additionalArgs = append(additionalArgs, arg)
+ } else {
+ args = append(args, arg)
+ }
+ }
+
+ if len(args) > 0 {
+ commandToRun, found := commandMatching(args[0])
+ if found {
+ commandToRun.Run(args[1:], additionalArgs)
+ return
+ }
+ }
+
+ DefaultCommand.Run(args, additionalArgs)
+}
+
+func commandMatching(name string) (*Command, bool) {
+ for _, command := range Commands {
+ if command.Matches(name) {
+ return command, true
+ }
+ }
+ return nil, false
+}
+
+func usage() {
+ fmt.Fprintf(os.Stderr, "Ginkgo Version %s\n\n", config.VERSION)
+ usageForCommand(DefaultCommand, false)
+ for _, command := range Commands {
+ fmt.Fprintf(os.Stderr, "\n")
+ usageForCommand(command, false)
+ }
+}
+
+func usageForCommand(command *Command, longForm bool) {
+ fmt.Fprintf(os.Stderr, "%s\n%s\n", command.UsageCommand, strings.Repeat("-", len(command.UsageCommand)))
+ fmt.Fprintf(os.Stderr, "%s\n", strings.Join(command.Usage, "\n"))
+ if command.SuppressFlagDocumentation && !longForm {
+ fmt.Fprintf(os.Stderr, "%s\n", strings.Join(command.FlagDocSubstitute, "\n "))
+ } else {
+ command.FlagSet.PrintDefaults()
+ }
+}
+
+func complainAndQuit(complaint string) {
+ fmt.Fprintf(os.Stderr, "%s\nFor usage instructions:\n\tginkgo help\n", complaint)
+ os.Exit(1)
+}
+
+func findSuites(args []string, recurseForAll bool, skipPackage string, allowPrecompiled bool) ([]testsuite.TestSuite, []string) {
+ suites := []testsuite.TestSuite{}
+
+ if len(args) > 0 {
+ for _, arg := range args {
+ if allowPrecompiled {
+ suite, err := testsuite.PrecompiledTestSuite(arg)
+ if err == nil {
+ suites = append(suites, suite)
+ continue
+ }
+ }
+ recurseForSuite := recurseForAll
+ if strings.HasSuffix(arg, "/...") && arg != "/..." {
+ arg = arg[:len(arg)-4]
+ recurseForSuite = true
+ }
+ suites = append(suites, testsuite.SuitesInDir(arg, recurseForSuite)...)
+ }
+ } else {
+ suites = testsuite.SuitesInDir(".", recurseForAll)
+ }
+
+ skippedPackages := []string{}
+ if skipPackage != "" {
+ skipFilters := strings.Split(skipPackage, ",")
+ filteredSuites := []testsuite.TestSuite{}
+ for _, suite := range suites {
+ skip := false
+ for _, skipFilter := range skipFilters {
+ if strings.Contains(suite.Path, skipFilter) {
+ skip = true
+ break
+ }
+ }
+ if skip {
+ skippedPackages = append(skippedPackages, suite.Path)
+ } else {
+ filteredSuites = append(filteredSuites, suite)
+ }
+ }
+ suites = filteredSuites
+ }
+
+ return suites, skippedPackages
+}
+
+func goFmt(path string) {
+ err := exec.Command("go", "fmt", path).Run()
+ if err != nil {
+ complainAndQuit("Could not fmt: " + err.Error())
+ }
+}
+
+func pluralizedWord(singular, plural string, count int) string {
+ if count == 1 {
+ return singular
+ }
+ return plural
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/nodot/nodot.go b/vendor/github.com/onsi/ginkgo/ginkgo/nodot/nodot.go
new file mode 100644
index 000000000..3f7237c60
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/nodot/nodot.go
@@ -0,0 +1,194 @@
+package nodot
+
+import (
+ "fmt"
+ "go/ast"
+ "go/build"
+ "go/parser"
+ "go/token"
+ "path/filepath"
+ "strings"
+)
+
+func ApplyNoDot(data []byte) ([]byte, error) {
+ sections, err := generateNodotSections()
+ if err != nil {
+ return nil, err
+ }
+
+ for _, section := range sections {
+ data = section.createOrUpdateIn(data)
+ }
+
+ return data, nil
+}
+
+type nodotSection struct {
+ name string
+ pkg string
+ declarations []string
+ types []string
+}
+
+func (s nodotSection) createOrUpdateIn(data []byte) []byte {
+ renames := map[string]string{}
+
+ contents := string(data)
+
+ lines := strings.Split(contents, "\n")
+
+ comment := "// Declarations for " + s.name
+
+ newLines := []string{}
+ for _, line := range lines {
+ if line == comment {
+ continue
+ }
+
+ words := strings.Split(line, " ")
+ lastWord := words[len(words)-1]
+
+ if s.containsDeclarationOrType(lastWord) {
+ renames[lastWord] = words[1]
+ continue
+ }
+
+ newLines = append(newLines, line)
+ }
+
+ if len(newLines[len(newLines)-1]) > 0 {
+ newLines = append(newLines, "")
+ }
+
+ newLines = append(newLines, comment)
+
+ for _, typ := range s.types {
+ name, ok := renames[s.prefix(typ)]
+ if !ok {
+ name = typ
+ }
+ newLines = append(newLines, fmt.Sprintf("type %s %s", name, s.prefix(typ)))
+ }
+
+ for _, decl := range s.declarations {
+ name, ok := renames[s.prefix(decl)]
+ if !ok {
+ name = decl
+ }
+ newLines = append(newLines, fmt.Sprintf("var %s = %s", name, s.prefix(decl)))
+ }
+
+ newLines = append(newLines, "")
+
+ newContents := strings.Join(newLines, "\n")
+
+ return []byte(newContents)
+}
+
+func (s nodotSection) prefix(declOrType string) string {
+ return s.pkg + "." + declOrType
+}
+
+func (s nodotSection) containsDeclarationOrType(word string) bool {
+ for _, declaration := range s.declarations {
+ if s.prefix(declaration) == word {
+ return true
+ }
+ }
+
+ for _, typ := range s.types {
+ if s.prefix(typ) == word {
+ return true
+ }
+ }
+
+ return false
+}
+
+func generateNodotSections() ([]nodotSection, error) {
+ sections := []nodotSection{}
+
+ declarations, err := getExportedDeclerationsForPackage("github.com/onsi/ginkgo", "ginkgo_dsl.go", "GINKGO_VERSION", "GINKGO_PANIC")
+ if err != nil {
+ return nil, err
+ }
+ sections = append(sections, nodotSection{
+ name: "Ginkgo DSL",
+ pkg: "ginkgo",
+ declarations: declarations,
+ types: []string{"Done", "Benchmarker"},
+ })
+
+ declarations, err = getExportedDeclerationsForPackage("github.com/onsi/gomega", "gomega_dsl.go", "GOMEGA_VERSION")
+ if err != nil {
+ return nil, err
+ }
+ sections = append(sections, nodotSection{
+ name: "Gomega DSL",
+ pkg: "gomega",
+ declarations: declarations,
+ })
+
+ declarations, err = getExportedDeclerationsForPackage("github.com/onsi/gomega", "matchers.go")
+ if err != nil {
+ return nil, err
+ }
+ sections = append(sections, nodotSection{
+ name: "Gomega Matchers",
+ pkg: "gomega",
+ declarations: declarations,
+ })
+
+ return sections, nil
+}
+
+func getExportedDeclerationsForPackage(pkgPath string, filename string, blacklist ...string) ([]string, error) {
+ pkg, err := build.Import(pkgPath, ".", 0)
+ if err != nil {
+ return []string{}, err
+ }
+
+ declarations, err := getExportedDeclarationsForFile(filepath.Join(pkg.Dir, filename))
+ if err != nil {
+ return []string{}, err
+ }
+
+ blacklistLookup := map[string]bool{}
+ for _, declaration := range blacklist {
+ blacklistLookup[declaration] = true
+ }
+
+ filteredDeclarations := []string{}
+ for _, declaration := range declarations {
+ if blacklistLookup[declaration] {
+ continue
+ }
+ filteredDeclarations = append(filteredDeclarations, declaration)
+ }
+
+ return filteredDeclarations, nil
+}
+
+func getExportedDeclarationsForFile(path string) ([]string, error) {
+ fset := token.NewFileSet()
+ tree, err := parser.ParseFile(fset, path, nil, 0)
+ if err != nil {
+ return []string{}, err
+ }
+
+ declarations := []string{}
+ ast.FileExports(tree)
+ for _, decl := range tree.Decls {
+ switch x := decl.(type) {
+ case *ast.GenDecl:
+ switch s := x.Specs[0].(type) {
+ case *ast.ValueSpec:
+ declarations = append(declarations, s.Names[0].Name)
+ }
+ case *ast.FuncDecl:
+ declarations = append(declarations, x.Name.Name)
+ }
+ }
+
+ return declarations, nil
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/nodot/nodot_suite_test.go b/vendor/github.com/onsi/ginkgo/ginkgo/nodot/nodot_suite_test.go
new file mode 100644
index 000000000..72b733219
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/nodot/nodot_suite_test.go
@@ -0,0 +1,92 @@
+package nodot_test
+
+import (
+ "github.com/onsi/ginkgo"
+ "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestNodot(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Nodot Suite")
+}
+
+// Declarations for Ginkgo DSL
+type Done ginkgo.Done
+type Benchmarker ginkgo.Benchmarker
+
+var GinkgoWriter = ginkgo.GinkgoWriter
+var GinkgoParallelNode = ginkgo.GinkgoParallelNode
+var GinkgoT = ginkgo.GinkgoT
+var CurrentGinkgoTestDescription = ginkgo.CurrentGinkgoTestDescription
+var RunSpecs = ginkgo.RunSpecs
+var RunSpecsWithDefaultAndCustomReporters = ginkgo.RunSpecsWithDefaultAndCustomReporters
+var RunSpecsWithCustomReporters = ginkgo.RunSpecsWithCustomReporters
+var Fail = ginkgo.Fail
+var GinkgoRecover = ginkgo.GinkgoRecover
+var Describe = ginkgo.Describe
+var FDescribe = ginkgo.FDescribe
+var PDescribe = ginkgo.PDescribe
+var XDescribe = ginkgo.XDescribe
+var Context = ginkgo.Context
+var FContext = ginkgo.FContext
+var PContext = ginkgo.PContext
+var XContext = ginkgo.XContext
+var It = ginkgo.It
+var FIt = ginkgo.FIt
+var PIt = ginkgo.PIt
+var XIt = ginkgo.XIt
+var Measure = ginkgo.Measure
+var FMeasure = ginkgo.FMeasure
+var PMeasure = ginkgo.PMeasure
+var XMeasure = ginkgo.XMeasure
+var BeforeSuite = ginkgo.BeforeSuite
+var AfterSuite = ginkgo.AfterSuite
+var SynchronizedBeforeSuite = ginkgo.SynchronizedBeforeSuite
+var SynchronizedAfterSuite = ginkgo.SynchronizedAfterSuite
+var BeforeEach = ginkgo.BeforeEach
+var JustBeforeEach = ginkgo.JustBeforeEach
+var JustAfterEach = ginkgo.JustAfterEach
+var AfterEach = ginkgo.AfterEach
+
+// Declarations for Gomega DSL
+var RegisterFailHandler = gomega.RegisterFailHandler
+var RegisterTestingT = gomega.RegisterTestingT
+var InterceptGomegaFailures = gomega.InterceptGomegaFailures
+var Ω = gomega.Ω
+var Expect = gomega.Expect
+var ExpectWithOffset = gomega.ExpectWithOffset
+var Eventually = gomega.Eventually
+var EventuallyWithOffset = gomega.EventuallyWithOffset
+var Consistently = gomega.Consistently
+var ConsistentlyWithOffset = gomega.ConsistentlyWithOffset
+var SetDefaultEventuallyTimeout = gomega.SetDefaultEventuallyTimeout
+var SetDefaultEventuallyPollingInterval = gomega.SetDefaultEventuallyPollingInterval
+var SetDefaultConsistentlyDuration = gomega.SetDefaultConsistentlyDuration
+var SetDefaultConsistentlyPollingInterval = gomega.SetDefaultConsistentlyPollingInterval
+
+// Declarations for Gomega Matchers
+var Equal = gomega.Equal
+var BeEquivalentTo = gomega.BeEquivalentTo
+var BeNil = gomega.BeNil
+var BeTrue = gomega.BeTrue
+var BeFalse = gomega.BeFalse
+var HaveOccurred = gomega.HaveOccurred
+var MatchError = gomega.MatchError
+var BeClosed = gomega.BeClosed
+var Receive = gomega.Receive
+var MatchRegexp = gomega.MatchRegexp
+var ContainSubstring = gomega.ContainSubstring
+var MatchJSON = gomega.MatchJSON
+var BeEmpty = gomega.BeEmpty
+var HaveLen = gomega.HaveLen
+var BeZero = gomega.BeZero
+var ContainElement = gomega.ContainElement
+var ConsistOf = gomega.ConsistOf
+var HaveKey = gomega.HaveKey
+var HaveKeyWithValue = gomega.HaveKeyWithValue
+var BeNumerically = gomega.BeNumerically
+var BeTemporally = gomega.BeTemporally
+var BeAssignableToTypeOf = gomega.BeAssignableToTypeOf
+var Panic = gomega.Panic
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/nodot/nodot_test.go b/vendor/github.com/onsi/ginkgo/ginkgo/nodot/nodot_test.go
new file mode 100644
index 000000000..1470b7478
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/nodot/nodot_test.go
@@ -0,0 +1,82 @@
+package nodot_test
+
+import (
+ "strings"
+
+ . "github.com/onsi/ginkgo/ginkgo/nodot"
+)
+
+var _ = Describe("ApplyNoDot", func() {
+ var result string
+
+ apply := func(input string) string {
+ output, err := ApplyNoDot([]byte(input))
+ Ω(err).ShouldNot(HaveOccurred())
+ return string(output)
+ }
+
+ Context("when no declarations have been imported yet", func() {
+ BeforeEach(func() {
+ result = apply("")
+ })
+
+ It("should add headings for the various declarations", func() {
+ Ω(result).Should(ContainSubstring("// Declarations for Ginkgo DSL"))
+ Ω(result).Should(ContainSubstring("// Declarations for Gomega DSL"))
+ Ω(result).Should(ContainSubstring("// Declarations for Gomega Matchers"))
+ })
+
+ It("should import Ginkgo's declarations", func() {
+ Ω(result).Should(ContainSubstring("var It = ginkgo.It"))
+ Ω(result).Should(ContainSubstring("var XDescribe = ginkgo.XDescribe"))
+ })
+
+ It("should import Ginkgo's types", func() {
+ Ω(result).Should(ContainSubstring("type Done ginkgo.Done"))
+ Ω(result).Should(ContainSubstring("type Benchmarker ginkgo.Benchmarker"))
+ Ω(strings.Count(result, "type ")).Should(Equal(2))
+ })
+
+ It("should import Gomega's DSL and matchers", func() {
+ Ω(result).Should(ContainSubstring("var Ω = gomega.Ω"))
+ Ω(result).Should(ContainSubstring("var ContainSubstring = gomega.ContainSubstring"))
+ Ω(result).Should(ContainSubstring("var Equal = gomega.Equal"))
+ })
+
+ It("should not import blacklisted things", func() {
+ Ω(result).ShouldNot(ContainSubstring("GINKGO_VERSION"))
+ Ω(result).ShouldNot(ContainSubstring("GINKGO_PANIC"))
+ Ω(result).ShouldNot(ContainSubstring("GOMEGA_VERSION"))
+ })
+ })
+
+ It("should be idempotent (module empty lines - go fmt can fix those for us)", func() {
+ first := apply("")
+ second := apply(first)
+ first = strings.Trim(first, "\n")
+ second = strings.Trim(second, "\n")
+ Ω(first).Should(Equal(second))
+ })
+
+ It("should not mess with other things in the input", func() {
+ result = apply("var MyThing = SomethingThatsMine")
+ Ω(result).Should(ContainSubstring("var MyThing = SomethingThatsMine"))
+ })
+
+ Context("when the user has redefined a name", func() {
+ It("should honor the redefinition", func() {
+ result = apply(`
+var _ = gomega.Ω
+var When = ginkgo.It
+ `)
+
+ Ω(result).Should(ContainSubstring("var _ = gomega.Ω"))
+ Ω(result).ShouldNot(ContainSubstring("var Ω = gomega.Ω"))
+
+ Ω(result).Should(ContainSubstring("var When = ginkgo.It"))
+ Ω(result).ShouldNot(ContainSubstring("var It = ginkgo.It"))
+
+ Ω(result).Should(ContainSubstring("var Context = ginkgo.Context"))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/nodot_command.go b/vendor/github.com/onsi/ginkgo/ginkgo/nodot_command.go
new file mode 100644
index 000000000..39b88b5d1
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/nodot_command.go
@@ -0,0 +1,77 @@
+package main
+
+import (
+ "bufio"
+ "flag"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "regexp"
+
+ "github.com/onsi/ginkgo/ginkgo/nodot"
+)
+
+func BuildNodotCommand() *Command {
+ return &Command{
+ Name: "nodot",
+ FlagSet: flag.NewFlagSet("bootstrap", flag.ExitOnError),
+ UsageCommand: "ginkgo nodot",
+ Usage: []string{
+ "Update the nodot declarations in your test suite",
+ "Any missing declarations (from, say, a recently added matcher) will be added to your bootstrap file.",
+ "If you've renamed a declaration, that name will be honored and not overwritten.",
+ },
+ Command: updateNodot,
+ }
+}
+
+func updateNodot(args []string, additionalArgs []string) {
+ suiteFile, perm := findSuiteFile()
+
+ data, err := ioutil.ReadFile(suiteFile)
+ if err != nil {
+ complainAndQuit("Failed to update nodot declarations: " + err.Error())
+ }
+
+ content, err := nodot.ApplyNoDot(data)
+ if err != nil {
+ complainAndQuit("Failed to update nodot declarations: " + err.Error())
+ }
+ ioutil.WriteFile(suiteFile, content, perm)
+
+ goFmt(suiteFile)
+}
+
+func findSuiteFile() (string, os.FileMode) {
+ workingDir, err := os.Getwd()
+ if err != nil {
+ complainAndQuit("Could not find suite file for nodot: " + err.Error())
+ }
+
+ files, err := ioutil.ReadDir(workingDir)
+ if err != nil {
+ complainAndQuit("Could not find suite file for nodot: " + err.Error())
+ }
+
+ re := regexp.MustCompile(`RunSpecs\(|RunSpecsWithDefaultAndCustomReporters\(|RunSpecsWithCustomReporters\(`)
+
+ for _, file := range files {
+ if file.IsDir() {
+ continue
+ }
+ path := filepath.Join(workingDir, file.Name())
+ f, err := os.Open(path)
+ if err != nil {
+ complainAndQuit("Could not find suite file for nodot: " + err.Error())
+ }
+ defer f.Close()
+
+ if re.MatchReader(bufio.NewReader(f)) {
+ return path, file.Mode()
+ }
+ }
+
+ complainAndQuit("Could not find a suite file for nodot: you need a bootstrap file that call's Ginkgo's RunSpecs() command.\nTry running ginkgo bootstrap first.")
+
+ return "", 0
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/notifications.go b/vendor/github.com/onsi/ginkgo/ginkgo/notifications.go
new file mode 100644
index 000000000..368d61fb3
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/notifications.go
@@ -0,0 +1,141 @@
+package main
+
+import (
+ "fmt"
+ "os"
+ "os/exec"
+ "regexp"
+ "runtime"
+ "strings"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/ginkgo/testsuite"
+)
+
+type Notifier struct {
+ commandFlags *RunWatchAndBuildCommandFlags
+}
+
+func NewNotifier(commandFlags *RunWatchAndBuildCommandFlags) *Notifier {
+ return &Notifier{
+ commandFlags: commandFlags,
+ }
+}
+
+func (n *Notifier) VerifyNotificationsAreAvailable() {
+ if n.commandFlags.Notify {
+ onLinux := (runtime.GOOS == "linux")
+ onOSX := (runtime.GOOS == "darwin")
+ if onOSX {
+
+ _, err := exec.LookPath("terminal-notifier")
+ if err != nil {
+ fmt.Printf(`--notify requires terminal-notifier, which you don't seem to have installed.
+
+OSX:
+
+To remedy this:
+
+ brew install terminal-notifier
+
+To learn more about terminal-notifier:
+
+ https://github.com/alloy/terminal-notifier
+`)
+ os.Exit(1)
+ }
+
+ } else if onLinux {
+
+ _, err := exec.LookPath("notify-send")
+ if err != nil {
+ fmt.Printf(`--notify requires terminal-notifier or notify-send, which you don't seem to have installed.
+
+Linux:
+
+Download and install notify-send for your distribution
+`)
+ os.Exit(1)
+ }
+
+ }
+ }
+}
+
+func (n *Notifier) SendSuiteCompletionNotification(suite testsuite.TestSuite, suitePassed bool) {
+ if suitePassed {
+ n.SendNotification("Ginkgo [PASS]", fmt.Sprintf(`Test suite for "%s" passed.`, suite.PackageName))
+ } else {
+ n.SendNotification("Ginkgo [FAIL]", fmt.Sprintf(`Test suite for "%s" failed.`, suite.PackageName))
+ }
+}
+
+func (n *Notifier) SendNotification(title string, subtitle string) {
+
+ if n.commandFlags.Notify {
+ onLinux := (runtime.GOOS == "linux")
+ onOSX := (runtime.GOOS == "darwin")
+
+ if onOSX {
+
+ _, err := exec.LookPath("terminal-notifier")
+ if err == nil {
+ args := []string{"-title", title, "-subtitle", subtitle, "-group", "com.onsi.ginkgo"}
+ terminal := os.Getenv("TERM_PROGRAM")
+ if terminal == "iTerm.app" {
+ args = append(args, "-activate", "com.googlecode.iterm2")
+ } else if terminal == "Apple_Terminal" {
+ args = append(args, "-activate", "com.apple.Terminal")
+ }
+
+ exec.Command("terminal-notifier", args...).Run()
+ }
+
+ } else if onLinux {
+
+ _, err := exec.LookPath("notify-send")
+ if err == nil {
+ args := []string{"-a", "ginkgo", title, subtitle}
+ exec.Command("notify-send", args...).Run()
+ }
+
+ }
+ }
+}
+
+func (n *Notifier) RunCommand(suite testsuite.TestSuite, suitePassed bool) {
+
+ command := n.commandFlags.AfterSuiteHook
+ if command != "" {
+
+ // Allow for string replacement to pass input to the command
+ passed := "[FAIL]"
+ if suitePassed {
+ passed = "[PASS]"
+ }
+ command = strings.Replace(command, "(ginkgo-suite-passed)", passed, -1)
+ command = strings.Replace(command, "(ginkgo-suite-name)", suite.PackageName, -1)
+
+ // Must break command into parts
+ splitArgs := regexp.MustCompile(`'.+'|".+"|\S+`)
+ parts := splitArgs.FindAllString(command, -1)
+
+ output, err := exec.Command(parts[0], parts[1:]...).CombinedOutput()
+ if err != nil {
+ fmt.Println("Post-suite command failed:")
+ if config.DefaultReporterConfig.NoColor {
+ fmt.Printf("\t%s\n", output)
+ } else {
+ fmt.Printf("\t%s%s%s\n", redColor, string(output), defaultStyle)
+ }
+ n.SendNotification("Ginkgo [ERROR]", fmt.Sprintf(`After suite command "%s" failed`, n.commandFlags.AfterSuiteHook))
+ } else {
+ fmt.Println("Post-suite command succeeded:")
+ if config.DefaultReporterConfig.NoColor {
+ fmt.Printf("\t%s\n", output)
+ } else {
+ fmt.Printf("\t%s%s%s\n", greenColor, string(output), defaultStyle)
+ }
+ }
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/run_command.go b/vendor/github.com/onsi/ginkgo/ginkgo/run_command.go
new file mode 100644
index 000000000..569b6a29c
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/run_command.go
@@ -0,0 +1,275 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "math/rand"
+ "os"
+ "strings"
+ "time"
+
+ "io/ioutil"
+ "path/filepath"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/ginkgo/interrupthandler"
+ "github.com/onsi/ginkgo/ginkgo/testrunner"
+ "github.com/onsi/ginkgo/types"
+)
+
+func BuildRunCommand() *Command {
+ commandFlags := NewRunCommandFlags(flag.NewFlagSet("ginkgo", flag.ExitOnError))
+ notifier := NewNotifier(commandFlags)
+ interruptHandler := interrupthandler.NewInterruptHandler()
+ runner := &SpecRunner{
+ commandFlags: commandFlags,
+ notifier: notifier,
+ interruptHandler: interruptHandler,
+ suiteRunner: NewSuiteRunner(notifier, interruptHandler),
+ }
+
+ return &Command{
+ Name: "",
+ FlagSet: commandFlags.FlagSet,
+ UsageCommand: "ginkgo <FLAGS> <PACKAGES> -- <PASS-THROUGHS>",
+ Usage: []string{
+ "Run the tests in the passed in <PACKAGES> (or the package in the current directory if left blank).",
+ "Any arguments after -- will be passed to the test.",
+ "Accepts the following flags:",
+ },
+ Command: runner.RunSpecs,
+ }
+}
+
+type SpecRunner struct {
+ commandFlags *RunWatchAndBuildCommandFlags
+ notifier *Notifier
+ interruptHandler *interrupthandler.InterruptHandler
+ suiteRunner *SuiteRunner
+}
+
+func (r *SpecRunner) RunSpecs(args []string, additionalArgs []string) {
+ r.commandFlags.computeNodes()
+ r.notifier.VerifyNotificationsAreAvailable()
+
+ suites, skippedPackages := findSuites(args, r.commandFlags.Recurse, r.commandFlags.SkipPackage, true)
+ if len(skippedPackages) > 0 {
+ fmt.Println("Will skip:")
+ for _, skippedPackage := range skippedPackages {
+ fmt.Println(" " + skippedPackage)
+ }
+ }
+
+ if len(skippedPackages) > 0 && len(suites) == 0 {
+ fmt.Println("All tests skipped! Exiting...")
+ os.Exit(0)
+ }
+
+ if len(suites) == 0 {
+ complainAndQuit("Found no test suites")
+ }
+
+ r.ComputeSuccinctMode(len(suites))
+
+ t := time.Now()
+
+ runners := []*testrunner.TestRunner{}
+ for _, suite := range suites {
+ runners = append(runners, testrunner.New(suite, r.commandFlags.NumCPU, r.commandFlags.ParallelStream, r.commandFlags.Timeout, r.commandFlags.GoOpts, additionalArgs))
+ }
+
+ numSuites := 0
+ runResult := testrunner.PassingRunResult()
+ if r.commandFlags.UntilItFails {
+ iteration := 0
+ for {
+ r.UpdateSeed()
+ randomizedRunners := r.randomizeOrder(runners)
+ runResult, numSuites = r.suiteRunner.RunSuites(randomizedRunners, r.commandFlags.NumCompilers, r.commandFlags.KeepGoing, nil)
+ iteration++
+
+ if r.interruptHandler.WasInterrupted() {
+ break
+ }
+
+ if runResult.Passed {
+ fmt.Printf("\nAll tests passed...\nWill keep running them until they fail.\nThis was attempt #%d\n%s\n", iteration, orcMessage(iteration))
+ } else {
+ fmt.Printf("\nTests failed on attempt #%d\n\n", iteration)
+ break
+ }
+ }
+ } else {
+ randomizedRunners := r.randomizeOrder(runners)
+ runResult, numSuites = r.suiteRunner.RunSuites(randomizedRunners, r.commandFlags.NumCompilers, r.commandFlags.KeepGoing, nil)
+ }
+
+ for _, runner := range runners {
+ runner.CleanUp()
+ }
+
+ if r.isInCoverageMode() {
+ if r.getOutputDir() != "" {
+ // If coverprofile is set, combine coverages
+ if r.getCoverprofile() != "" {
+ if err := r.combineCoverprofiles(runners); err != nil {
+ fmt.Println(err.Error())
+ os.Exit(1)
+ }
+ } else {
+ // Just move them
+ r.moveCoverprofiles(runners)
+ }
+ }
+ }
+
+ fmt.Printf("\nGinkgo ran %d %s in %s\n", numSuites, pluralizedWord("suite", "suites", numSuites), time.Since(t))
+
+ if runResult.Passed {
+ if runResult.HasProgrammaticFocus && strings.TrimSpace(os.Getenv("GINKGO_EDITOR_INTEGRATION")) == "" {
+ fmt.Printf("Test Suite Passed\n")
+ fmt.Printf("Detected Programmatic Focus - setting exit status to %d\n", types.GINKGO_FOCUS_EXIT_CODE)
+ os.Exit(types.GINKGO_FOCUS_EXIT_CODE)
+ } else {
+ fmt.Printf("Test Suite Passed\n")
+ os.Exit(0)
+ }
+ } else {
+ fmt.Printf("Test Suite Failed\n")
+ os.Exit(1)
+ }
+}
+
+// Moves all generated profiles to specified directory
+func (r *SpecRunner) moveCoverprofiles(runners []*testrunner.TestRunner) {
+ for _, runner := range runners {
+ _, filename := filepath.Split(runner.CoverageFile)
+ err := os.Rename(runner.CoverageFile, filepath.Join(r.getOutputDir(), filename))
+
+ if err != nil {
+ fmt.Printf("Unable to move coverprofile %s, %v\n", runner.CoverageFile, err)
+ return
+ }
+ }
+}
+
+// Combines all generated profiles in the specified directory
+func (r *SpecRunner) combineCoverprofiles(runners []*testrunner.TestRunner) error {
+
+ path, _ := filepath.Abs(r.getOutputDir())
+ if !fileExists(path) {
+ return fmt.Errorf("Unable to create combined profile, outputdir does not exist: %s", r.getOutputDir())
+ }
+
+ fmt.Println("path is " + path)
+
+ combined, err := os.OpenFile(filepath.Join(path, r.getCoverprofile()),
+ os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0666)
+
+ if err != nil {
+ fmt.Printf("Unable to create combined profile, %v\n", err)
+ return nil // non-fatal error
+ }
+
+ for _, runner := range runners {
+ contents, err := ioutil.ReadFile(runner.CoverageFile)
+
+ if err != nil {
+ fmt.Printf("Unable to read coverage file %s to combine, %v\n", runner.CoverageFile, err)
+ return nil // non-fatal error
+ }
+
+ _, err = combined.Write(contents)
+
+ if err != nil {
+ fmt.Printf("Unable to append to coverprofile, %v\n", err)
+ return nil // non-fatal error
+ }
+ }
+
+ fmt.Println("All profiles combined")
+ return nil
+}
+
+func (r *SpecRunner) isInCoverageMode() bool {
+ opts := r.commandFlags.GoOpts
+ return *opts["cover"].(*bool) || *opts["coverpkg"].(*string) != "" || *opts["covermode"].(*string) != ""
+}
+
+func (r *SpecRunner) getCoverprofile() string {
+ return *r.commandFlags.GoOpts["coverprofile"].(*string)
+}
+
+func (r *SpecRunner) getOutputDir() string {
+ return *r.commandFlags.GoOpts["outputdir"].(*string)
+}
+
+func (r *SpecRunner) ComputeSuccinctMode(numSuites int) {
+ if config.DefaultReporterConfig.Verbose {
+ config.DefaultReporterConfig.Succinct = false
+ return
+ }
+
+ if numSuites == 1 {
+ return
+ }
+
+ if numSuites > 1 && !r.commandFlags.wasSet("succinct") {
+ config.DefaultReporterConfig.Succinct = true
+ }
+}
+
+func (r *SpecRunner) UpdateSeed() {
+ if !r.commandFlags.wasSet("seed") {
+ config.GinkgoConfig.RandomSeed = time.Now().Unix()
+ }
+}
+
+func (r *SpecRunner) randomizeOrder(runners []*testrunner.TestRunner) []*testrunner.TestRunner {
+ if !r.commandFlags.RandomizeSuites {
+ return runners
+ }
+
+ if len(runners) <= 1 {
+ return runners
+ }
+
+ randomizedRunners := make([]*testrunner.TestRunner, len(runners))
+ randomizer := rand.New(rand.NewSource(config.GinkgoConfig.RandomSeed))
+ permutation := randomizer.Perm(len(runners))
+ for i, j := range permutation {
+ randomizedRunners[i] = runners[j]
+ }
+ return randomizedRunners
+}
+
+func orcMessage(iteration int) string {
+ if iteration < 10 {
+ return ""
+ } else if iteration < 30 {
+ return []string{
+ "If at first you succeed...",
+ "...try, try again.",
+ "Looking good!",
+ "Still good...",
+ "I think your tests are fine....",
+ "Yep, still passing",
+ "Oh boy, here I go testin' again!",
+ "Even the gophers are getting bored",
+ "Did you try -race?",
+ "Maybe you should stop now?",
+ "I'm getting tired...",
+ "What if I just made you a sandwich?",
+ "Hit ^C, hit ^C, please hit ^C",
+ "Make it stop. Please!",
+ "Come on! Enough is enough!",
+ "Dave, this conversation can serve no purpose anymore. Goodbye.",
+ "Just what do you think you're doing, Dave? ",
+ "I, Sisyphus",
+ "Insanity: doing the same thing over and over again and expecting different results. -Einstein",
+ "I guess Einstein never tried to churn butter",
+ }[iteration-10] + "\n"
+ } else {
+ return "No, seriously... you can probably stop now.\n"
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/run_watch_and_build_command_flags.go b/vendor/github.com/onsi/ginkgo/ginkgo/run_watch_and_build_command_flags.go
new file mode 100644
index 000000000..b7cb7f566
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/run_watch_and_build_command_flags.go
@@ -0,0 +1,167 @@
+package main
+
+import (
+ "flag"
+ "runtime"
+
+ "time"
+
+ "github.com/onsi/ginkgo/config"
+)
+
+type RunWatchAndBuildCommandFlags struct {
+ Recurse bool
+ SkipPackage string
+ GoOpts map[string]interface{}
+
+ //for run and watch commands
+ NumCPU int
+ NumCompilers int
+ ParallelStream bool
+ Notify bool
+ AfterSuiteHook string
+ AutoNodes bool
+ Timeout time.Duration
+
+ //only for run command
+ KeepGoing bool
+ UntilItFails bool
+ RandomizeSuites bool
+
+ //only for watch command
+ Depth int
+ WatchRegExp string
+
+ FlagSet *flag.FlagSet
+}
+
+const runMode = 1
+const watchMode = 2
+const buildMode = 3
+
+func NewRunCommandFlags(flagSet *flag.FlagSet) *RunWatchAndBuildCommandFlags {
+ c := &RunWatchAndBuildCommandFlags{
+ FlagSet: flagSet,
+ }
+ c.flags(runMode)
+ return c
+}
+
+func NewWatchCommandFlags(flagSet *flag.FlagSet) *RunWatchAndBuildCommandFlags {
+ c := &RunWatchAndBuildCommandFlags{
+ FlagSet: flagSet,
+ }
+ c.flags(watchMode)
+ return c
+}
+
+func NewBuildCommandFlags(flagSet *flag.FlagSet) *RunWatchAndBuildCommandFlags {
+ c := &RunWatchAndBuildCommandFlags{
+ FlagSet: flagSet,
+ }
+ c.flags(buildMode)
+ return c
+}
+
+func (c *RunWatchAndBuildCommandFlags) wasSet(flagName string) bool {
+ wasSet := false
+ c.FlagSet.Visit(func(f *flag.Flag) {
+ if f.Name == flagName {
+ wasSet = true
+ }
+ })
+
+ return wasSet
+}
+
+func (c *RunWatchAndBuildCommandFlags) computeNodes() {
+ if c.wasSet("nodes") {
+ return
+ }
+ if c.AutoNodes {
+ switch n := runtime.NumCPU(); {
+ case n <= 4:
+ c.NumCPU = n
+ default:
+ c.NumCPU = n - 1
+ }
+ }
+}
+
+func (c *RunWatchAndBuildCommandFlags) stringSlot(slot string) *string {
+ var opt string
+ c.GoOpts[slot] = &opt
+ return &opt
+}
+
+func (c *RunWatchAndBuildCommandFlags) boolSlot(slot string) *bool {
+ var opt bool
+ c.GoOpts[slot] = &opt
+ return &opt
+}
+
+func (c *RunWatchAndBuildCommandFlags) intSlot(slot string) *int {
+ var opt int
+ c.GoOpts[slot] = &opt
+ return &opt
+}
+
+func (c *RunWatchAndBuildCommandFlags) flags(mode int) {
+ c.GoOpts = make(map[string]interface{})
+
+ onWindows := (runtime.GOOS == "windows")
+
+ c.FlagSet.BoolVar(&(c.Recurse), "r", false, "Find and run test suites under the current directory recursively.")
+ c.FlagSet.BoolVar(c.boolSlot("race"), "race", false, "Run tests with race detection enabled.")
+ c.FlagSet.BoolVar(c.boolSlot("cover"), "cover", false, "Run tests with coverage analysis, will generate coverage profiles with the package name in the current directory.")
+ c.FlagSet.StringVar(c.stringSlot("coverpkg"), "coverpkg", "", "Run tests with coverage on the given external modules.")
+ c.FlagSet.StringVar(&(c.SkipPackage), "skipPackage", "", "A comma-separated list of package names to be skipped. If any part of the package's path matches, that package is ignored.")
+ c.FlagSet.StringVar(c.stringSlot("tags"), "tags", "", "A list of build tags to consider satisfied during the build.")
+ c.FlagSet.StringVar(c.stringSlot("gcflags"), "gcflags", "", "Arguments to pass on each go tool compile invocation.")
+ c.FlagSet.StringVar(c.stringSlot("covermode"), "covermode", "", "Set the mode for coverage analysis.")
+ c.FlagSet.BoolVar(c.boolSlot("a"), "a", false, "Force rebuilding of packages that are already up-to-date.")
+ c.FlagSet.BoolVar(c.boolSlot("n"), "n", false, "Have `go test` print the commands but do not run them.")
+ c.FlagSet.BoolVar(c.boolSlot("msan"), "msan", false, "Enable interoperation with memory sanitizer.")
+ c.FlagSet.BoolVar(c.boolSlot("x"), "x", false, "Have `go test` print the commands.")
+ c.FlagSet.BoolVar(c.boolSlot("work"), "work", false, "Print the name of the temporary work directory and do not delete it when exiting.")
+ c.FlagSet.StringVar(c.stringSlot("asmflags"), "asmflags", "", "Arguments to pass on each go tool asm invocation.")
+ c.FlagSet.StringVar(c.stringSlot("buildmode"), "buildmode", "", "Build mode to use. See 'go help buildmode' for more.")
+ c.FlagSet.StringVar(c.stringSlot("compiler"), "compiler", "", "Name of compiler to use, as in runtime.Compiler (gccgo or gc).")
+ c.FlagSet.StringVar(c.stringSlot("gccgoflags"), "gccgoflags", "", "Arguments to pass on each gccgo compiler/linker invocation.")
+ c.FlagSet.StringVar(c.stringSlot("installsuffix"), "installsuffix", "", "A suffix to use in the name of the package installation directory.")
+ c.FlagSet.StringVar(c.stringSlot("ldflags"), "ldflags", "", "Arguments to pass on each go tool link invocation.")
+ c.FlagSet.BoolVar(c.boolSlot("linkshared"), "linkshared", false, "Link against shared libraries previously created with -buildmode=shared.")
+ c.FlagSet.StringVar(c.stringSlot("pkgdir"), "pkgdir", "", "install and load all packages from the given dir instead of the usual locations.")
+ c.FlagSet.StringVar(c.stringSlot("toolexec"), "toolexec", "", "a program to use to invoke toolchain programs like vet and asm.")
+ c.FlagSet.IntVar(c.intSlot("blockprofilerate"), "blockprofilerate", 1, "Control the detail provided in goroutine blocking profiles by calling runtime.SetBlockProfileRate with the given value.")
+ c.FlagSet.StringVar(c.stringSlot("coverprofile"), "coverprofile", "", "Write a coverage profile to the specified file after all tests have passed.")
+ c.FlagSet.StringVar(c.stringSlot("cpuprofile"), "cpuprofile", "", "Write a CPU profile to the specified file before exiting.")
+ c.FlagSet.StringVar(c.stringSlot("memprofile"), "memprofile", "", "Write a memory profile to the specified file after all tests have passed.")
+ c.FlagSet.IntVar(c.intSlot("memprofilerate"), "memprofilerate", 0, "Enable more precise (and expensive) memory profiles by setting runtime.MemProfileRate.")
+ c.FlagSet.StringVar(c.stringSlot("outputdir"), "outputdir", "", "Place output files from profiling in the specified directory.")
+ c.FlagSet.BoolVar(c.boolSlot("requireSuite"), "requireSuite", false, "Fail if there are ginkgo tests in a directory but no test suite (missing RunSpecs)")
+
+ if mode == runMode || mode == watchMode {
+ config.Flags(c.FlagSet, "", false)
+ c.FlagSet.IntVar(&(c.NumCPU), "nodes", 1, "The number of parallel test nodes to run")
+ c.FlagSet.IntVar(&(c.NumCompilers), "compilers", 0, "The number of concurrent compilations to run (0 will autodetect)")
+ c.FlagSet.BoolVar(&(c.AutoNodes), "p", false, "Run in parallel with auto-detected number of nodes")
+ c.FlagSet.BoolVar(&(c.ParallelStream), "stream", onWindows, "stream parallel test output in real time: less coherent, but useful for debugging")
+ if !onWindows {
+ c.FlagSet.BoolVar(&(c.Notify), "notify", false, "Send desktop notifications when a test run completes")
+ }
+ c.FlagSet.StringVar(&(c.AfterSuiteHook), "afterSuiteHook", "", "Run a command when a suite test run completes")
+ c.FlagSet.DurationVar(&(c.Timeout), "timeout", 24*time.Hour, "Suite fails if it does not complete within the specified timeout")
+ }
+
+ if mode == runMode {
+ c.FlagSet.BoolVar(&(c.KeepGoing), "keepGoing", false, "When true, failures from earlier test suites do not prevent later test suites from running")
+ c.FlagSet.BoolVar(&(c.UntilItFails), "untilItFails", false, "When true, Ginkgo will keep rerunning tests until a failure occurs")
+ c.FlagSet.BoolVar(&(c.RandomizeSuites), "randomizeSuites", false, "When true, Ginkgo will randomize the order in which test suites run")
+ }
+
+ if mode == watchMode {
+ c.FlagSet.IntVar(&(c.Depth), "depth", 1, "Ginkgo will watch dependencies down to this depth in the dependency tree")
+ c.FlagSet.StringVar(&(c.WatchRegExp), "watchRegExp", `\.go$`, "Files matching this regular expression will be watched for changes")
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/suite_runner.go b/vendor/github.com/onsi/ginkgo/ginkgo/suite_runner.go
new file mode 100644
index 000000000..ce6c94602
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/suite_runner.go
@@ -0,0 +1,173 @@
+package main
+
+import (
+ "fmt"
+ "runtime"
+ "sync"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/ginkgo/interrupthandler"
+ "github.com/onsi/ginkgo/ginkgo/testrunner"
+ "github.com/onsi/ginkgo/ginkgo/testsuite"
+ colorable "github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable"
+)
+
+type compilationInput struct {
+ runner *testrunner.TestRunner
+ result chan compilationOutput
+}
+
+type compilationOutput struct {
+ runner *testrunner.TestRunner
+ err error
+}
+
+type SuiteRunner struct {
+ notifier *Notifier
+ interruptHandler *interrupthandler.InterruptHandler
+}
+
+func NewSuiteRunner(notifier *Notifier, interruptHandler *interrupthandler.InterruptHandler) *SuiteRunner {
+ return &SuiteRunner{
+ notifier: notifier,
+ interruptHandler: interruptHandler,
+ }
+}
+
+func (r *SuiteRunner) compileInParallel(runners []*testrunner.TestRunner, numCompilers int, willCompile func(suite testsuite.TestSuite)) chan compilationOutput {
+ //we return this to the consumer, it will return each runner in order as it compiles
+ compilationOutputs := make(chan compilationOutput, len(runners))
+
+ //an array of channels - the nth runner's compilation output is sent to the nth channel in this array
+ //we read from these channels in order to ensure we run the suites in order
+ orderedCompilationOutputs := []chan compilationOutput{}
+ for _ = range runners {
+ orderedCompilationOutputs = append(orderedCompilationOutputs, make(chan compilationOutput, 1))
+ }
+
+ //we're going to spin up numCompilers compilers - they're going to run concurrently and will consume this channel
+ //we prefill the channel then close it, this ensures we compile things in the correct order
+ workPool := make(chan compilationInput, len(runners))
+ for i, runner := range runners {
+ workPool <- compilationInput{runner, orderedCompilationOutputs[i]}
+ }
+ close(workPool)
+
+ //pick a reasonable numCompilers
+ if numCompilers == 0 {
+ numCompilers = runtime.NumCPU()
+ }
+
+ //a WaitGroup to help us wait for all compilers to shut down
+ wg := &sync.WaitGroup{}
+ wg.Add(numCompilers)
+
+ //spin up the concurrent compilers
+ for i := 0; i < numCompilers; i++ {
+ go func() {
+ defer wg.Done()
+ for input := range workPool {
+ if r.interruptHandler.WasInterrupted() {
+ return
+ }
+
+ if willCompile != nil {
+ willCompile(input.runner.Suite)
+ }
+
+ //We retry because Go sometimes steps on itself when multiple compiles happen in parallel. This is ugly, but should help resolve flakiness...
+ var err error
+ retries := 0
+ for retries <= 5 {
+ if r.interruptHandler.WasInterrupted() {
+ return
+ }
+ if err = input.runner.Compile(); err == nil {
+ break
+ }
+ retries++
+ }
+
+ input.result <- compilationOutput{input.runner, err}
+ }
+ }()
+ }
+
+ //read from the compilation output channels *in order* and send them to the caller
+ //close the compilationOutputs channel to tell the caller we're done
+ go func() {
+ defer close(compilationOutputs)
+ for _, orderedCompilationOutput := range orderedCompilationOutputs {
+ select {
+ case compilationOutput := <-orderedCompilationOutput:
+ compilationOutputs <- compilationOutput
+ case <-r.interruptHandler.C:
+ //interrupt detected, wait for the compilers to shut down then bail
+ //this ensure we clean up after ourselves as we don't leave any compilation processes running
+ wg.Wait()
+ return
+ }
+ }
+ }()
+
+ return compilationOutputs
+}
+
+func (r *SuiteRunner) RunSuites(runners []*testrunner.TestRunner, numCompilers int, keepGoing bool, willCompile func(suite testsuite.TestSuite)) (testrunner.RunResult, int) {
+ runResult := testrunner.PassingRunResult()
+
+ compilationOutputs := r.compileInParallel(runners, numCompilers, willCompile)
+
+ numSuitesThatRan := 0
+ suitesThatFailed := []testsuite.TestSuite{}
+ for compilationOutput := range compilationOutputs {
+ if compilationOutput.err != nil {
+ fmt.Print(compilationOutput.err.Error())
+ }
+ numSuitesThatRan++
+ suiteRunResult := testrunner.FailingRunResult()
+ if compilationOutput.err == nil {
+ suiteRunResult = compilationOutput.runner.Run()
+ }
+ r.notifier.SendSuiteCompletionNotification(compilationOutput.runner.Suite, suiteRunResult.Passed)
+ r.notifier.RunCommand(compilationOutput.runner.Suite, suiteRunResult.Passed)
+ runResult = runResult.Merge(suiteRunResult)
+ if !suiteRunResult.Passed {
+ suitesThatFailed = append(suitesThatFailed, compilationOutput.runner.Suite)
+ if !keepGoing {
+ break
+ }
+ }
+ if numSuitesThatRan < len(runners) && !config.DefaultReporterConfig.Succinct {
+ fmt.Println("")
+ }
+ }
+
+ if keepGoing && !runResult.Passed {
+ r.listFailedSuites(suitesThatFailed)
+ }
+
+ return runResult, numSuitesThatRan
+}
+
+func (r *SuiteRunner) listFailedSuites(suitesThatFailed []testsuite.TestSuite) {
+ fmt.Println("")
+ fmt.Println("There were failures detected in the following suites:")
+
+ maxPackageNameLength := 0
+ for _, suite := range suitesThatFailed {
+ if len(suite.PackageName) > maxPackageNameLength {
+ maxPackageNameLength = len(suite.PackageName)
+ }
+ }
+
+ packageNameFormatter := fmt.Sprintf("%%%ds", maxPackageNameLength)
+
+ for _, suite := range suitesThatFailed {
+ if config.DefaultReporterConfig.NoColor {
+ fmt.Printf("\t"+packageNameFormatter+" %s\n", suite.PackageName, suite.Path)
+ } else {
+ fmt.Fprintf(colorable.NewColorableStdout(), "\t%s"+packageNameFormatter+"%s %s%s%s\n", redColor, suite.PackageName, defaultStyle, lightGrayColor, suite.Path, defaultStyle)
+ }
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/build_args.go b/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/build_args.go
new file mode 100644
index 000000000..3b1a238c2
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/build_args.go
@@ -0,0 +1,7 @@
+// +build go1.10
+
+package testrunner
+
+var (
+ buildArgs = []string{"test", "-c"}
+)
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/build_args_old.go b/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/build_args_old.go
new file mode 100644
index 000000000..14d70dbcc
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/build_args_old.go
@@ -0,0 +1,7 @@
+// +build !go1.10
+
+package testrunner
+
+var (
+ buildArgs = []string{"test", "-c", "-i"}
+)
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/log_writer.go b/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/log_writer.go
new file mode 100644
index 000000000..a73a6e379
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/log_writer.go
@@ -0,0 +1,52 @@
+package testrunner
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "log"
+ "strings"
+ "sync"
+)
+
+type logWriter struct {
+ buffer *bytes.Buffer
+ lock *sync.Mutex
+ log *log.Logger
+}
+
+func newLogWriter(target io.Writer, node int) *logWriter {
+ return &logWriter{
+ buffer: &bytes.Buffer{},
+ lock: &sync.Mutex{},
+ log: log.New(target, fmt.Sprintf("[%d] ", node), 0),
+ }
+}
+
+func (w *logWriter) Write(data []byte) (n int, err error) {
+ w.lock.Lock()
+ defer w.lock.Unlock()
+
+ w.buffer.Write(data)
+ contents := w.buffer.String()
+
+ lines := strings.Split(contents, "\n")
+ for _, line := range lines[0 : len(lines)-1] {
+ w.log.Println(line)
+ }
+
+ w.buffer.Reset()
+ w.buffer.Write([]byte(lines[len(lines)-1]))
+ return len(data), nil
+}
+
+func (w *logWriter) Close() error {
+ w.lock.Lock()
+ defer w.lock.Unlock()
+
+ if w.buffer.Len() > 0 {
+ w.log.Println(w.buffer.String())
+ }
+
+ return nil
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/run_result.go b/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/run_result.go
new file mode 100644
index 000000000..5d472acb8
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/run_result.go
@@ -0,0 +1,27 @@
+package testrunner
+
+type RunResult struct {
+ Passed bool
+ HasProgrammaticFocus bool
+}
+
+func PassingRunResult() RunResult {
+ return RunResult{
+ Passed: true,
+ HasProgrammaticFocus: false,
+ }
+}
+
+func FailingRunResult() RunResult {
+ return RunResult{
+ Passed: false,
+ HasProgrammaticFocus: false,
+ }
+}
+
+func (r RunResult) Merge(o RunResult) RunResult {
+ return RunResult{
+ Passed: r.Passed && o.Passed,
+ HasProgrammaticFocus: r.HasProgrammaticFocus || o.HasProgrammaticFocus,
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/test_runner.go b/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/test_runner.go
new file mode 100644
index 000000000..a0113e136
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/test_runner.go
@@ -0,0 +1,556 @@
+package testrunner
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "io/ioutil"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strconv"
+ "strings"
+ "syscall"
+ "time"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/ginkgo/testsuite"
+ "github.com/onsi/ginkgo/internal/remote"
+ "github.com/onsi/ginkgo/reporters/stenographer"
+ colorable "github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable"
+ "github.com/onsi/ginkgo/types"
+)
+
+type TestRunner struct {
+ Suite testsuite.TestSuite
+
+ compiled bool
+ compilationTargetPath string
+
+ numCPU int
+ parallelStream bool
+ timeout time.Duration
+ goOpts map[string]interface{}
+ additionalArgs []string
+ stderr *bytes.Buffer
+
+ CoverageFile string
+}
+
+func New(suite testsuite.TestSuite, numCPU int, parallelStream bool, timeout time.Duration, goOpts map[string]interface{}, additionalArgs []string) *TestRunner {
+ runner := &TestRunner{
+ Suite: suite,
+ numCPU: numCPU,
+ parallelStream: parallelStream,
+ goOpts: goOpts,
+ additionalArgs: additionalArgs,
+ timeout: timeout,
+ stderr: new(bytes.Buffer),
+ }
+
+ if !suite.Precompiled {
+ dir, err := ioutil.TempDir("", "ginkgo")
+ if err != nil {
+ panic(fmt.Sprintf("couldn't create temporary directory... might be time to rm -rf:\n%s", err.Error()))
+ }
+ runner.compilationTargetPath = filepath.Join(dir, suite.PackageName+".test")
+ }
+
+ return runner
+}
+
+func (t *TestRunner) Compile() error {
+ return t.CompileTo(t.compilationTargetPath)
+}
+
+func (t *TestRunner) BuildArgs(path string) []string {
+ args := make([]string, len(buildArgs), len(buildArgs)+3)
+ copy(args, buildArgs)
+ args = append(args, "-o", path, t.Suite.Path)
+
+ if t.getCoverMode() != "" {
+ args = append(args, "-cover", fmt.Sprintf("-covermode=%s", t.getCoverMode()))
+ } else {
+ if t.shouldCover() || t.getCoverPackage() != "" {
+ args = append(args, "-cover", "-covermode=atomic")
+ }
+ }
+
+ boolOpts := []string{
+ "a",
+ "n",
+ "msan",
+ "race",
+ "x",
+ "work",
+ "linkshared",
+ }
+
+ for _, opt := range boolOpts {
+ if s, found := t.goOpts[opt].(*bool); found && *s {
+ args = append(args, fmt.Sprintf("-%s", opt))
+ }
+ }
+
+ intOpts := []string{
+ "memprofilerate",
+ "blockprofilerate",
+ }
+
+ for _, opt := range intOpts {
+ if s, found := t.goOpts[opt].(*int); found {
+ args = append(args, fmt.Sprintf("-%s=%d", opt, *s))
+ }
+ }
+
+ stringOpts := []string{
+ "asmflags",
+ "buildmode",
+ "compiler",
+ "gccgoflags",
+ "installsuffix",
+ "ldflags",
+ "pkgdir",
+ "toolexec",
+ "coverprofile",
+ "cpuprofile",
+ "memprofile",
+ "outputdir",
+ "coverpkg",
+ "tags",
+ "gcflags",
+ }
+
+ for _, opt := range stringOpts {
+ if s, found := t.goOpts[opt].(*string); found && *s != "" {
+ args = append(args, fmt.Sprintf("-%s=%s", opt, *s))
+ }
+ }
+ return args
+}
+
+func (t *TestRunner) CompileTo(path string) error {
+ if t.compiled {
+ return nil
+ }
+
+ if t.Suite.Precompiled {
+ return nil
+ }
+
+ args := t.BuildArgs(path)
+ cmd := exec.Command("go", args...)
+
+ output, err := cmd.CombinedOutput()
+
+ if err != nil {
+ if len(output) > 0 {
+ return fmt.Errorf("Failed to compile %s:\n\n%s", t.Suite.PackageName, output)
+ }
+ return fmt.Errorf("Failed to compile %s", t.Suite.PackageName)
+ }
+
+ if len(output) > 0 {
+ fmt.Println(string(output))
+ }
+
+ if fileExists(path) == false {
+ compiledFile := t.Suite.PackageName + ".test"
+ if fileExists(compiledFile) {
+ // seems like we are on an old go version that does not support the -o flag on go test
+ // move the compiled test file to the desired location by hand
+ err = os.Rename(compiledFile, path)
+ if err != nil {
+ // We cannot move the file, perhaps because the source and destination
+ // are on different partitions. We can copy the file, however.
+ err = copyFile(compiledFile, path)
+ if err != nil {
+ return fmt.Errorf("Failed to copy compiled file: %s", err)
+ }
+ }
+ } else {
+ return fmt.Errorf("Failed to compile %s: output file %q could not be found", t.Suite.PackageName, path)
+ }
+ }
+
+ t.compiled = true
+
+ return nil
+}
+
+func fileExists(path string) bool {
+ _, err := os.Stat(path)
+ return err == nil || os.IsNotExist(err) == false
+}
+
+// copyFile copies the contents of the file named src to the file named
+// by dst. The file will be created if it does not already exist. If the
+// destination file exists, all it's contents will be replaced by the contents
+// of the source file.
+func copyFile(src, dst string) error {
+ srcInfo, err := os.Stat(src)
+ if err != nil {
+ return err
+ }
+ mode := srcInfo.Mode()
+
+ in, err := os.Open(src)
+ if err != nil {
+ return err
+ }
+
+ defer in.Close()
+
+ out, err := os.Create(dst)
+ if err != nil {
+ return err
+ }
+
+ defer func() {
+ closeErr := out.Close()
+ if err == nil {
+ err = closeErr
+ }
+ }()
+
+ _, err = io.Copy(out, in)
+ if err != nil {
+ return err
+ }
+
+ err = out.Sync()
+ if err != nil {
+ return err
+ }
+
+ return out.Chmod(mode)
+}
+
+func (t *TestRunner) Run() RunResult {
+ if t.Suite.IsGinkgo {
+ if t.numCPU > 1 {
+ if t.parallelStream {
+ return t.runAndStreamParallelGinkgoSuite()
+ } else {
+ return t.runParallelGinkgoSuite()
+ }
+ } else {
+ return t.runSerialGinkgoSuite()
+ }
+ } else {
+ return t.runGoTestSuite()
+ }
+}
+
+func (t *TestRunner) CleanUp() {
+ if t.Suite.Precompiled {
+ return
+ }
+ os.RemoveAll(filepath.Dir(t.compilationTargetPath))
+}
+
+func (t *TestRunner) runSerialGinkgoSuite() RunResult {
+ ginkgoArgs := config.BuildFlagArgs("ginkgo", config.GinkgoConfig, config.DefaultReporterConfig)
+ return t.run(t.cmd(ginkgoArgs, os.Stdout, 1), nil)
+}
+
+func (t *TestRunner) runGoTestSuite() RunResult {
+ return t.run(t.cmd([]string{"-test.v"}, os.Stdout, 1), nil)
+}
+
+func (t *TestRunner) runAndStreamParallelGinkgoSuite() RunResult {
+ completions := make(chan RunResult)
+ writers := make([]*logWriter, t.numCPU)
+
+ server, err := remote.NewServer(t.numCPU)
+ if err != nil {
+ panic("Failed to start parallel spec server")
+ }
+
+ server.Start()
+ defer server.Close()
+
+ for cpu := 0; cpu < t.numCPU; cpu++ {
+ config.GinkgoConfig.ParallelNode = cpu + 1
+ config.GinkgoConfig.ParallelTotal = t.numCPU
+ config.GinkgoConfig.SyncHost = server.Address()
+
+ ginkgoArgs := config.BuildFlagArgs("ginkgo", config.GinkgoConfig, config.DefaultReporterConfig)
+
+ writers[cpu] = newLogWriter(os.Stdout, cpu+1)
+
+ cmd := t.cmd(ginkgoArgs, writers[cpu], cpu+1)
+
+ server.RegisterAlive(cpu+1, func() bool {
+ if cmd.ProcessState == nil {
+ return true
+ }
+ return !cmd.ProcessState.Exited()
+ })
+
+ go t.run(cmd, completions)
+ }
+
+ res := PassingRunResult()
+
+ for cpu := 0; cpu < t.numCPU; cpu++ {
+ res = res.Merge(<-completions)
+ }
+
+ for _, writer := range writers {
+ writer.Close()
+ }
+
+ os.Stdout.Sync()
+
+ if t.shouldCombineCoverprofiles() {
+ t.combineCoverprofiles()
+ }
+
+ return res
+}
+
+func (t *TestRunner) runParallelGinkgoSuite() RunResult {
+ result := make(chan bool)
+ completions := make(chan RunResult)
+ writers := make([]*logWriter, t.numCPU)
+ reports := make([]*bytes.Buffer, t.numCPU)
+
+ stenographer := stenographer.New(!config.DefaultReporterConfig.NoColor, config.GinkgoConfig.FlakeAttempts > 1, colorable.NewColorableStdout())
+ aggregator := remote.NewAggregator(t.numCPU, result, config.DefaultReporterConfig, stenographer)
+
+ server, err := remote.NewServer(t.numCPU)
+ if err != nil {
+ panic("Failed to start parallel spec server")
+ }
+ server.RegisterReporters(aggregator)
+ server.Start()
+ defer server.Close()
+
+ for cpu := 0; cpu < t.numCPU; cpu++ {
+ config.GinkgoConfig.ParallelNode = cpu + 1
+ config.GinkgoConfig.ParallelTotal = t.numCPU
+ config.GinkgoConfig.SyncHost = server.Address()
+ config.GinkgoConfig.StreamHost = server.Address()
+
+ ginkgoArgs := config.BuildFlagArgs("ginkgo", config.GinkgoConfig, config.DefaultReporterConfig)
+
+ reports[cpu] = &bytes.Buffer{}
+ writers[cpu] = newLogWriter(reports[cpu], cpu+1)
+
+ cmd := t.cmd(ginkgoArgs, writers[cpu], cpu+1)
+
+ server.RegisterAlive(cpu+1, func() bool {
+ if cmd.ProcessState == nil {
+ return true
+ }
+ return !cmd.ProcessState.Exited()
+ })
+
+ go t.run(cmd, completions)
+ }
+
+ res := PassingRunResult()
+
+ for cpu := 0; cpu < t.numCPU; cpu++ {
+ res = res.Merge(<-completions)
+ }
+
+ //all test processes are done, at this point
+ //we should be able to wait for the aggregator to tell us that it's done
+
+ select {
+ case <-result:
+ fmt.Println("")
+ case <-time.After(time.Second):
+ //the aggregator never got back to us! something must have gone wrong
+ fmt.Println(`
+ -------------------------------------------------------------------
+ | |
+ | Ginkgo timed out waiting for all parallel nodes to report back! |
+ | |
+ -------------------------------------------------------------------`)
+ fmt.Println("\n", t.Suite.PackageName, "timed out. path:", t.Suite.Path)
+ os.Stdout.Sync()
+
+ for _, writer := range writers {
+ writer.Close()
+ }
+
+ for _, report := range reports {
+ fmt.Print(report.String())
+ }
+
+ os.Stdout.Sync()
+ }
+
+ if t.shouldCombineCoverprofiles() {
+ t.combineCoverprofiles()
+ }
+
+ return res
+}
+
+const CoverProfileSuffix = ".coverprofile"
+
+func (t *TestRunner) cmd(ginkgoArgs []string, stream io.Writer, node int) *exec.Cmd {
+ args := []string{"--test.timeout=" + t.timeout.String()}
+
+ coverProfile := t.getCoverProfile()
+
+ if t.shouldCombineCoverprofiles() {
+
+ testCoverProfile := "--test.coverprofile="
+
+ coverageFile := ""
+ // Set default name for coverage results
+ if coverProfile == "" {
+ coverageFile = t.Suite.PackageName + CoverProfileSuffix
+ } else {
+ coverageFile = coverProfile
+ }
+
+ testCoverProfile += coverageFile
+
+ t.CoverageFile = filepath.Join(t.Suite.Path, coverageFile)
+
+ if t.numCPU > 1 {
+ testCoverProfile = fmt.Sprintf("%s.%d", testCoverProfile, node)
+ }
+ args = append(args, testCoverProfile)
+ }
+
+ args = append(args, ginkgoArgs...)
+ args = append(args, t.additionalArgs...)
+
+ path := t.compilationTargetPath
+ if t.Suite.Precompiled {
+ path, _ = filepath.Abs(filepath.Join(t.Suite.Path, fmt.Sprintf("%s.test", t.Suite.PackageName)))
+ }
+
+ cmd := exec.Command(path, args...)
+
+ cmd.Dir = t.Suite.Path
+ cmd.Stderr = io.MultiWriter(stream, t.stderr)
+ cmd.Stdout = stream
+
+ return cmd
+}
+
+func (t *TestRunner) shouldCover() bool {
+ return *t.goOpts["cover"].(*bool)
+}
+
+func (t *TestRunner) shouldRequireSuite() bool {
+ return *t.goOpts["requireSuite"].(*bool)
+}
+
+func (t *TestRunner) getCoverProfile() string {
+ return *t.goOpts["coverprofile"].(*string)
+}
+
+func (t *TestRunner) getCoverPackage() string {
+ return *t.goOpts["coverpkg"].(*string)
+}
+
+func (t *TestRunner) getCoverMode() string {
+ return *t.goOpts["covermode"].(*string)
+}
+
+func (t *TestRunner) shouldCombineCoverprofiles() bool {
+ return t.shouldCover() || t.getCoverPackage() != "" || t.getCoverMode() != ""
+}
+
+func (t *TestRunner) run(cmd *exec.Cmd, completions chan RunResult) RunResult {
+ var res RunResult
+
+ defer func() {
+ if completions != nil {
+ completions <- res
+ }
+ }()
+
+ err := cmd.Start()
+ if err != nil {
+ fmt.Printf("Failed to run test suite!\n\t%s", err.Error())
+ return res
+ }
+
+ cmd.Wait()
+
+ exitStatus := cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
+ res.Passed = (exitStatus == 0) || (exitStatus == types.GINKGO_FOCUS_EXIT_CODE)
+ res.HasProgrammaticFocus = (exitStatus == types.GINKGO_FOCUS_EXIT_CODE)
+
+ if strings.Contains(t.stderr.String(), "warning: no tests to run") {
+ if t.shouldRequireSuite() {
+ res.Passed = false
+ }
+ fmt.Fprintf(os.Stderr, `Found no test suites, did you forget to run "ginkgo bootstrap"?`)
+ }
+
+ return res
+}
+
+func (t *TestRunner) combineCoverprofiles() {
+ profiles := []string{}
+
+ coverProfile := t.getCoverProfile()
+
+ for cpu := 1; cpu <= t.numCPU; cpu++ {
+ var coverFile string
+ if coverProfile == "" {
+ coverFile = fmt.Sprintf("%s%s.%d", t.Suite.PackageName, CoverProfileSuffix, cpu)
+ } else {
+ coverFile = fmt.Sprintf("%s.%d", coverProfile, cpu)
+ }
+
+ coverFile = filepath.Join(t.Suite.Path, coverFile)
+ coverProfile, err := ioutil.ReadFile(coverFile)
+ os.Remove(coverFile)
+
+ if err == nil {
+ profiles = append(profiles, string(coverProfile))
+ }
+ }
+
+ if len(profiles) != t.numCPU {
+ return
+ }
+
+ lines := map[string]int{}
+ lineOrder := []string{}
+ for i, coverProfile := range profiles {
+ for _, line := range strings.Split(string(coverProfile), "\n")[1:] {
+ if len(line) == 0 {
+ continue
+ }
+ components := strings.Split(line, " ")
+ count, _ := strconv.Atoi(components[len(components)-1])
+ prefix := strings.Join(components[0:len(components)-1], " ")
+ lines[prefix] += count
+ if i == 0 {
+ lineOrder = append(lineOrder, prefix)
+ }
+ }
+ }
+
+ output := []string{"mode: atomic"}
+ for _, line := range lineOrder {
+ output = append(output, fmt.Sprintf("%s %d", line, lines[line]))
+ }
+ finalOutput := strings.Join(output, "\n")
+
+ finalFilename := ""
+
+ if coverProfile != "" {
+ finalFilename = coverProfile
+ } else {
+ finalFilename = fmt.Sprintf("%s%s", t.Suite.PackageName, CoverProfileSuffix)
+ }
+
+ coverageFilepath := filepath.Join(t.Suite.Path, finalFilename)
+ ioutil.WriteFile(coverageFilepath, []byte(finalOutput), 0666)
+
+ t.CoverageFile = coverageFilepath
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/test_runner_test.go b/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/test_runner_test.go
new file mode 100644
index 000000000..691917043
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/testrunner/test_runner_test.go
@@ -0,0 +1,60 @@
+package testrunner_test
+
+import (
+ "testing"
+
+ . "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/ginkgo/testrunner"
+ "github.com/onsi/ginkgo/ginkgo/testsuite"
+ . "github.com/onsi/gomega"
+)
+
+func strAddr(s string) interface{} {
+ return &s
+}
+
+func boolAddr(s bool) interface{} {
+ return &s
+}
+
+func intAddr(s int) interface{} {
+ return &s
+}
+
+var _ = Describe("TestRunner", func() {
+ It("should pass through go opts", func() {
+ //var opts map[string]interface{}
+ opts := map[string]interface{}{
+ "asmflags": strAddr("a"),
+ "pkgdir": strAddr("b"),
+ "gcflags": strAddr("c"),
+ "covermode": strAddr(""),
+ "coverpkg": strAddr(""),
+ "cover": boolAddr(false),
+ "blockprofilerate": intAddr(100),
+ }
+ tr := testrunner.New(testsuite.TestSuite{}, 1, false, 0, opts, []string{})
+
+ args := tr.BuildArgs(".")
+ // Remove the "-i" argument; This is discarded in Golang 1.10+.
+ if args[2] == "-i" {
+ args = append(args[0:2], args[3:]...)
+ }
+ Ω(args).Should(Equal([]string{
+ "test",
+ "-c",
+ "-o",
+ ".",
+ "",
+ "-blockprofilerate=100",
+ "-asmflags=a",
+ "-pkgdir=b",
+ "-gcflags=c",
+ }))
+ })
+})
+
+func TestTestRunner(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Test Runner Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/test_suite.go b/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/test_suite.go
new file mode 100644
index 000000000..9de8c2bb4
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/test_suite.go
@@ -0,0 +1,115 @@
+package testsuite
+
+import (
+ "errors"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "regexp"
+ "strings"
+)
+
+type TestSuite struct {
+ Path string
+ PackageName string
+ IsGinkgo bool
+ Precompiled bool
+}
+
+func PrecompiledTestSuite(path string) (TestSuite, error) {
+ info, err := os.Stat(path)
+ if err != nil {
+ return TestSuite{}, err
+ }
+
+ if info.IsDir() {
+ return TestSuite{}, errors.New("this is a directory, not a file")
+ }
+
+ if filepath.Ext(path) != ".test" {
+ return TestSuite{}, errors.New("this is not a .test binary")
+ }
+
+ if info.Mode()&0111 == 0 {
+ return TestSuite{}, errors.New("this is not executable")
+ }
+
+ dir := relPath(filepath.Dir(path))
+ packageName := strings.TrimSuffix(filepath.Base(path), filepath.Ext(path))
+
+ return TestSuite{
+ Path: dir,
+ PackageName: packageName,
+ IsGinkgo: true,
+ Precompiled: true,
+ }, nil
+}
+
+func SuitesInDir(dir string, recurse bool) []TestSuite {
+ suites := []TestSuite{}
+
+ if vendorExperimentCheck(dir) {
+ return suites
+ }
+
+ files, _ := ioutil.ReadDir(dir)
+ re := regexp.MustCompile(`^[^._].*_test\.go$`)
+ for _, file := range files {
+ if !file.IsDir() && re.Match([]byte(file.Name())) {
+ suites = append(suites, New(dir, files))
+ break
+ }
+ }
+
+ if recurse {
+ re = regexp.MustCompile(`^[._]`)
+ for _, file := range files {
+ if file.IsDir() && !re.Match([]byte(file.Name())) {
+ suites = append(suites, SuitesInDir(dir+"/"+file.Name(), recurse)...)
+ }
+ }
+ }
+
+ return suites
+}
+
+func relPath(dir string) string {
+ dir, _ = filepath.Abs(dir)
+ cwd, _ := os.Getwd()
+ dir, _ = filepath.Rel(cwd, filepath.Clean(dir))
+
+ if string(dir[0]) != "." {
+ dir = "." + string(filepath.Separator) + dir
+ }
+
+ return dir
+}
+
+func New(dir string, files []os.FileInfo) TestSuite {
+ return TestSuite{
+ Path: relPath(dir),
+ PackageName: packageNameForSuite(dir),
+ IsGinkgo: filesHaveGinkgoSuite(dir, files),
+ }
+}
+
+func packageNameForSuite(dir string) string {
+ path, _ := filepath.Abs(dir)
+ return filepath.Base(path)
+}
+
+func filesHaveGinkgoSuite(dir string, files []os.FileInfo) bool {
+ reTestFile := regexp.MustCompile(`_test\.go$`)
+ reGinkgo := regexp.MustCompile(`package ginkgo|\/ginkgo"`)
+
+ for _, file := range files {
+ if !file.IsDir() && reTestFile.Match([]byte(file.Name())) {
+ contents, _ := ioutil.ReadFile(dir + "/" + file.Name())
+ if reGinkgo.Match(contents) {
+ return true
+ }
+ }
+ }
+
+ return false
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/testsuite_suite_test.go b/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/testsuite_suite_test.go
new file mode 100644
index 000000000..d1e8b21d3
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/testsuite_suite_test.go
@@ -0,0 +1,13 @@
+package testsuite_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestTestsuite(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Testsuite Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/testsuite_test.go b/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/testsuite_test.go
new file mode 100644
index 000000000..7a0753bf5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/testsuite_test.go
@@ -0,0 +1,212 @@
+// +build go1.6
+
+package testsuite_test
+
+import (
+ "io/ioutil"
+ "os"
+ "path/filepath"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/ginkgo/testsuite"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("TestSuite", func() {
+ var tmpDir string
+ var relTmpDir string
+
+ writeFile := func(folder string, filename string, content string, mode os.FileMode) {
+ path := filepath.Join(tmpDir, folder)
+ err := os.MkdirAll(path, 0700)
+ Ω(err).ShouldNot(HaveOccurred())
+
+ path = filepath.Join(path, filename)
+ ioutil.WriteFile(path, []byte(content), mode)
+ }
+
+ var origVendor string
+
+ BeforeSuite(func() {
+ origVendor = os.Getenv("GO15VENDOREXPERIMENT")
+ })
+
+ AfterSuite(func() {
+ os.Setenv("GO15VENDOREXPERIMENT", origVendor)
+ })
+
+ BeforeEach(func() {
+ var err error
+ tmpDir, err = ioutil.TempDir("/tmp", "ginkgo")
+ Ω(err).ShouldNot(HaveOccurred())
+
+ cwd, err := os.Getwd()
+ Ω(err).ShouldNot(HaveOccurred())
+ relTmpDir, err = filepath.Rel(cwd, tmpDir)
+ Ω(err).ShouldNot(HaveOccurred())
+
+ //go files in the root directory (no tests)
+ writeFile("/", "main.go", "package main", 0666)
+
+ //non-go files in a nested directory
+ writeFile("/redherring", "big_test.jpg", "package ginkgo", 0666)
+
+ //ginkgo tests in ignored go files
+ writeFile("/ignored", ".ignore_dot_test.go", `import "github.com/onsi/ginkgo"`, 0666)
+ writeFile("/ignored", "_ignore_underscore_test.go", `import "github.com/onsi/ginkgo"`, 0666)
+
+ //non-ginkgo tests in a nested directory
+ writeFile("/professorplum", "professorplum_test.go", `import "testing"`, 0666)
+
+ //ginkgo tests in a nested directory
+ writeFile("/colonelmustard", "colonelmustard_test.go", `import "github.com/onsi/ginkgo"`, 0666)
+
+ //ginkgo tests in a deeply nested directory
+ writeFile("/colonelmustard/library", "library_test.go", `import "github.com/onsi/ginkgo"`, 0666)
+
+ //ginkgo tests deeply nested in a vendored dependency
+ writeFile("/vendor/mrspeacock/lounge", "lounge_test.go", `import "github.com/onsi/ginkgo"`, 0666)
+
+ //a precompiled ginkgo test
+ writeFile("/precompiled-dir", "precompiled.test", `fake-binary-file`, 0777)
+ writeFile("/precompiled-dir", "some-other-binary", `fake-binary-file`, 0777)
+ writeFile("/precompiled-dir", "nonexecutable.test", `fake-binary-file`, 0666)
+ })
+
+ AfterEach(func() {
+ os.RemoveAll(tmpDir)
+ })
+
+ Describe("Finding precompiled test suites", func() {
+ Context("if pointed at an executable file that ends with .test", func() {
+ It("should return a precompiled test suite", func() {
+ suite, err := PrecompiledTestSuite(filepath.Join(tmpDir, "precompiled-dir", "precompiled.test"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(suite).Should(Equal(TestSuite{
+ Path: relTmpDir + "/precompiled-dir",
+ PackageName: "precompiled",
+ IsGinkgo: true,
+ Precompiled: true,
+ }))
+ })
+ })
+
+ Context("if pointed at a directory", func() {
+ It("should error", func() {
+ suite, err := PrecompiledTestSuite(filepath.Join(tmpDir, "precompiled-dir"))
+ Ω(suite).Should(BeZero())
+ Ω(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("if pointed at an executable that doesn't have .test", func() {
+ It("should error", func() {
+ suite, err := PrecompiledTestSuite(filepath.Join(tmpDir, "precompiled-dir", "some-other-binary"))
+ Ω(suite).Should(BeZero())
+ Ω(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("if pointed at a .test that isn't executable", func() {
+ It("should error", func() {
+ suite, err := PrecompiledTestSuite(filepath.Join(tmpDir, "precompiled-dir", "nonexecutable.test"))
+ Ω(suite).Should(BeZero())
+ Ω(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("if pointed at a nonexisting file", func() {
+ It("should error", func() {
+ suite, err := PrecompiledTestSuite(filepath.Join(tmpDir, "precompiled-dir", "nope-nothing-to-see-here"))
+ Ω(suite).Should(BeZero())
+ Ω(err).Should(HaveOccurred())
+ })
+ })
+ })
+
+ Describe("scanning for suites in a directory", func() {
+ Context("when there are no tests in the specified directory", func() {
+ It("should come up empty", func() {
+ suites := SuitesInDir(tmpDir, false)
+ Ω(suites).Should(BeEmpty())
+ })
+ })
+
+ Context("when there are ginkgo tests in the specified directory", func() {
+ It("should return an appropriately configured suite", func() {
+ suites := SuitesInDir(filepath.Join(tmpDir, "colonelmustard"), false)
+ Ω(suites).Should(HaveLen(1))
+
+ Ω(suites[0].Path).Should(Equal(relTmpDir + "/colonelmustard"))
+ Ω(suites[0].PackageName).Should(Equal("colonelmustard"))
+ Ω(suites[0].IsGinkgo).Should(BeTrue())
+ Ω(suites[0].Precompiled).Should(BeFalse())
+ })
+ })
+
+ Context("when there are ginkgo tests that are ignored by go in the specified directory ", func() {
+ It("should come up empty", func() {
+ suites := SuitesInDir(filepath.Join(tmpDir, "ignored"), false)
+ Ω(suites).Should(BeEmpty())
+ })
+ })
+
+ Context("when there are non-ginkgo tests in the specified directory", func() {
+ It("should return an appropriately configured suite", func() {
+ suites := SuitesInDir(filepath.Join(tmpDir, "professorplum"), false)
+ Ω(suites).Should(HaveLen(1))
+
+ Ω(suites[0].Path).Should(Equal(relTmpDir + "/professorplum"))
+ Ω(suites[0].PackageName).Should(Equal("professorplum"))
+ Ω(suites[0].IsGinkgo).Should(BeFalse())
+ Ω(suites[0].Precompiled).Should(BeFalse())
+ })
+ })
+
+ Context("given GO15VENDOREXPERIMENT disabled", func() {
+ BeforeEach(func() {
+ os.Setenv("GO15VENDOREXPERIMENT", "0")
+ })
+
+ AfterEach(func() {
+ os.Setenv("GO15VENDOREXPERIMENT", "")
+ })
+
+ It("should not skip vendor dirs", func() {
+ suites := SuitesInDir(filepath.Join(tmpDir+"/vendor"), true)
+ Ω(suites).Should(HaveLen(1))
+ })
+
+ It("should recurse into vendor dirs", func() {
+ suites := SuitesInDir(filepath.Join(tmpDir), true)
+ Ω(suites).Should(HaveLen(4))
+ })
+ })
+
+ Context("when recursively scanning", func() {
+ It("should return suites for corresponding test suites, only", func() {
+ suites := SuitesInDir(tmpDir, true)
+ Ω(suites).Should(HaveLen(3))
+
+ Ω(suites).Should(ContainElement(TestSuite{
+ Path: relTmpDir + "/colonelmustard",
+ PackageName: "colonelmustard",
+ IsGinkgo: true,
+ Precompiled: false,
+ }))
+ Ω(suites).Should(ContainElement(TestSuite{
+ Path: relTmpDir + "/professorplum",
+ PackageName: "professorplum",
+ IsGinkgo: false,
+ Precompiled: false,
+ }))
+ Ω(suites).Should(ContainElement(TestSuite{
+ Path: relTmpDir + "/colonelmustard/library",
+ PackageName: "library",
+ IsGinkgo: true,
+ Precompiled: false,
+ }))
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/vendor_check_go15.go b/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/vendor_check_go15.go
new file mode 100644
index 000000000..75f827a12
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/vendor_check_go15.go
@@ -0,0 +1,16 @@
+// +build !go1.6
+
+package testsuite
+
+import (
+ "os"
+ "path"
+)
+
+// "This change will only be enabled if the go command is run with
+// GO15VENDOREXPERIMENT=1 in its environment."
+// c.f. the vendor-experiment proposal https://goo.gl/2ucMeC
+func vendorExperimentCheck(dir string) bool {
+ vendorExperiment := os.Getenv("GO15VENDOREXPERIMENT")
+ return vendorExperiment == "1" && path.Base(dir) == "vendor"
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/vendor_check_go15_test.go b/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/vendor_check_go15_test.go
new file mode 100644
index 000000000..dc3ca2a94
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/vendor_check_go15_test.go
@@ -0,0 +1,201 @@
+// +build !go1.6
+
+package testsuite_test
+
+import (
+ "io/ioutil"
+ "os"
+ "path/filepath"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/ginkgo/testsuite"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("TestSuite", func() {
+ var tmpDir string
+ var relTmpDir string
+
+ writeFile := func(folder string, filename string, content string, mode os.FileMode) {
+ path := filepath.Join(tmpDir, folder)
+ err := os.MkdirAll(path, 0700)
+ Ω(err).ShouldNot(HaveOccurred())
+
+ path = filepath.Join(path, filename)
+ ioutil.WriteFile(path, []byte(content), mode)
+ }
+
+ var origVendor string
+
+ BeforeSuite(func() {
+ origVendor = os.Getenv("GO15VENDOREXPERIMENT")
+ })
+
+ AfterSuite(func() {
+ os.Setenv("GO15VENDOREXPERIMENT", origVendor)
+ })
+
+ BeforeEach(func() {
+ var err error
+ tmpDir, err = ioutil.TempDir("/tmp", "ginkgo")
+ Ω(err).ShouldNot(HaveOccurred())
+
+ cwd, err := os.Getwd()
+ Ω(err).ShouldNot(HaveOccurred())
+ relTmpDir, err = filepath.Rel(cwd, tmpDir)
+ Ω(err).ShouldNot(HaveOccurred())
+
+ //go files in the root directory (no tests)
+ writeFile("/", "main.go", "package main", 0666)
+
+ //non-go files in a nested directory
+ writeFile("/redherring", "big_test.jpg", "package ginkgo", 0666)
+
+ //non-ginkgo tests in a nested directory
+ writeFile("/professorplum", "professorplum_test.go", `import "testing"`, 0666)
+
+ //ginkgo tests in a nested directory
+ writeFile("/colonelmustard", "colonelmustard_test.go", `import "github.com/onsi/ginkgo"`, 0666)
+
+ //ginkgo tests in a deeply nested directory
+ writeFile("/colonelmustard/library", "library_test.go", `import "github.com/onsi/ginkgo"`, 0666)
+
+ //ginkgo tests deeply nested in a vendored dependency
+ writeFile("/vendor/mrspeacock/lounge", "lounge_test.go", `import "github.com/onsi/ginkgo"`, 0666)
+
+ //a precompiled ginkgo test
+ writeFile("/precompiled-dir", "precompiled.test", `fake-binary-file`, 0777)
+ writeFile("/precompiled-dir", "some-other-binary", `fake-binary-file`, 0777)
+ writeFile("/precompiled-dir", "nonexecutable.test", `fake-binary-file`, 0666)
+ })
+
+ AfterEach(func() {
+ os.RemoveAll(tmpDir)
+ })
+
+ Describe("Finding precompiled test suites", func() {
+ Context("if pointed at an executable file that ends with .test", func() {
+ It("should return a precompiled test suite", func() {
+ suite, err := PrecompiledTestSuite(filepath.Join(tmpDir, "precompiled-dir", "precompiled.test"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(suite).Should(Equal(TestSuite{
+ Path: relTmpDir + "/precompiled-dir",
+ PackageName: "precompiled",
+ IsGinkgo: true,
+ Precompiled: true,
+ }))
+ })
+ })
+
+ Context("if pointed at a directory", func() {
+ It("should error", func() {
+ suite, err := PrecompiledTestSuite(filepath.Join(tmpDir, "precompiled-dir"))
+ Ω(suite).Should(BeZero())
+ Ω(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("if pointed at an executable that doesn't have .test", func() {
+ It("should error", func() {
+ suite, err := PrecompiledTestSuite(filepath.Join(tmpDir, "precompiled-dir", "some-other-binary"))
+ Ω(suite).Should(BeZero())
+ Ω(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("if pointed at a .test that isn't executable", func() {
+ It("should error", func() {
+ suite, err := PrecompiledTestSuite(filepath.Join(tmpDir, "precompiled-dir", "nonexecutable.test"))
+ Ω(suite).Should(BeZero())
+ Ω(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("if pointed at a nonexisting file", func() {
+ It("should error", func() {
+ suite, err := PrecompiledTestSuite(filepath.Join(tmpDir, "precompiled-dir", "nope-nothing-to-see-here"))
+ Ω(suite).Should(BeZero())
+ Ω(err).Should(HaveOccurred())
+ })
+ })
+ })
+
+ Describe("scanning for suites in a directory", func() {
+ Context("when there are no tests in the specified directory", func() {
+ It("should come up empty", func() {
+ suites := SuitesInDir(tmpDir, false)
+ Ω(suites).Should(BeEmpty())
+ })
+ })
+
+ Context("when there are ginkgo tests in the specified directory", func() {
+ It("should return an appropriately configured suite", func() {
+ suites := SuitesInDir(filepath.Join(tmpDir, "colonelmustard"), false)
+ Ω(suites).Should(HaveLen(1))
+
+ Ω(suites[0].Path).Should(Equal(relTmpDir + "/colonelmustard"))
+ Ω(suites[0].PackageName).Should(Equal("colonelmustard"))
+ Ω(suites[0].IsGinkgo).Should(BeTrue())
+ Ω(suites[0].Precompiled).Should(BeFalse())
+ })
+ })
+
+ Context("when there are non-ginkgo tests in the specified directory", func() {
+ It("should return an appropriately configured suite", func() {
+ suites := SuitesInDir(filepath.Join(tmpDir, "professorplum"), false)
+ Ω(suites).Should(HaveLen(1))
+
+ Ω(suites[0].Path).Should(Equal(relTmpDir + "/professorplum"))
+ Ω(suites[0].PackageName).Should(Equal("professorplum"))
+ Ω(suites[0].IsGinkgo).Should(BeFalse())
+ Ω(suites[0].Precompiled).Should(BeFalse())
+ })
+ })
+
+ Context("given GO15VENDOREXPERIMENT", func() {
+ BeforeEach(func() {
+ os.Setenv("GO15VENDOREXPERIMENT", "1")
+ })
+
+ AfterEach(func() {
+ os.Setenv("GO15VENDOREXPERIMENT", "")
+ })
+
+ It("should skip vendor dirs", func() {
+ suites := SuitesInDir(filepath.Join(tmpDir+"/vendor"), false)
+ Ω(suites).Should(HaveLen(0))
+ })
+
+ It("should not recurse into vendor dirs", func() {
+ suites := SuitesInDir(filepath.Join(tmpDir), true)
+ Ω(suites).Should(HaveLen(3))
+ })
+ })
+
+ Context("when recursively scanning", func() {
+ It("should return suites for corresponding test suites, only", func() {
+ suites := SuitesInDir(tmpDir, true)
+ Ω(suites).Should(HaveLen(4))
+
+ Ω(suites).Should(ContainElement(TestSuite{
+ Path: relTmpDir + "/colonelmustard",
+ PackageName: "colonelmustard",
+ IsGinkgo: true,
+ Precompiled: false,
+ }))
+ Ω(suites).Should(ContainElement(TestSuite{
+ Path: relTmpDir + "/professorplum",
+ PackageName: "professorplum",
+ IsGinkgo: false,
+ Precompiled: false,
+ }))
+ Ω(suites).Should(ContainElement(TestSuite{
+ Path: relTmpDir + "/colonelmustard/library",
+ PackageName: "library",
+ IsGinkgo: true,
+ Precompiled: false,
+ }))
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/vendor_check_go16.go b/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/vendor_check_go16.go
new file mode 100644
index 000000000..596e5e5c1
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/testsuite/vendor_check_go16.go
@@ -0,0 +1,15 @@
+// +build go1.6
+
+package testsuite
+
+import (
+ "os"
+ "path"
+)
+
+// in 1.6 the vendor directory became the default go behaviour, so now
+// check if its disabled.
+func vendorExperimentCheck(dir string) bool {
+ vendorExperiment := os.Getenv("GO15VENDOREXPERIMENT")
+ return vendorExperiment != "0" && path.Base(dir) == "vendor"
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/unfocus_command.go b/vendor/github.com/onsi/ginkgo/ginkgo/unfocus_command.go
new file mode 100644
index 000000000..cedc2b59c
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/unfocus_command.go
@@ -0,0 +1,61 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "os/exec"
+ "strings"
+)
+
+func BuildUnfocusCommand() *Command {
+ return &Command{
+ Name: "unfocus",
+ AltName: "blur",
+ FlagSet: flag.NewFlagSet("unfocus", flag.ExitOnError),
+ UsageCommand: "ginkgo unfocus (or ginkgo blur)",
+ Usage: []string{
+ "Recursively unfocuses any focused tests under the current directory",
+ },
+ Command: unfocusSpecs,
+ }
+}
+
+func unfocusSpecs([]string, []string) {
+ unfocus("Describe")
+ unfocus("Context")
+ unfocus("It")
+ unfocus("Measure")
+ unfocus("DescribeTable")
+ unfocus("Entry")
+ unfocus("Specify")
+ unfocus("When")
+}
+
+func unfocus(component string) {
+ fmt.Printf("Removing F%s...\n", component)
+ files, err := ioutil.ReadDir(".")
+ if err != nil {
+ fmt.Println(err.Error())
+ return
+ }
+ for _, f := range files {
+ // Exclude "vendor" directory
+ if f.IsDir() && f.Name() == "vendor" {
+ continue
+ }
+ // Exclude non-go files in the current directory
+ if !f.IsDir() && !strings.HasSuffix(f.Name(), ".go") {
+ continue
+ }
+ // Recursively run `gofmt` otherwise
+ cmd := exec.Command("gofmt", fmt.Sprintf("-r=F%s -> %s", component, component), "-w", f.Name())
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ fmt.Println(err.Error())
+ }
+ if string(out) != "" {
+ fmt.Println(string(out))
+ }
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/version_command.go b/vendor/github.com/onsi/ginkgo/ginkgo/version_command.go
new file mode 100644
index 000000000..f586908e8
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/version_command.go
@@ -0,0 +1,24 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+
+ "github.com/onsi/ginkgo/config"
+)
+
+func BuildVersionCommand() *Command {
+ return &Command{
+ Name: "version",
+ FlagSet: flag.NewFlagSet("version", flag.ExitOnError),
+ UsageCommand: "ginkgo version",
+ Usage: []string{
+ "Print Ginkgo's version",
+ },
+ Command: printVersion,
+ }
+}
+
+func printVersion([]string, []string) {
+ fmt.Printf("Ginkgo Version %s\n", config.VERSION)
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/watch/delta.go b/vendor/github.com/onsi/ginkgo/ginkgo/watch/delta.go
new file mode 100644
index 000000000..6c485c5b1
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/watch/delta.go
@@ -0,0 +1,22 @@
+package watch
+
+import "sort"
+
+type Delta struct {
+ ModifiedPackages []string
+
+ NewSuites []*Suite
+ RemovedSuites []*Suite
+ modifiedSuites []*Suite
+}
+
+type DescendingByDelta []*Suite
+
+func (a DescendingByDelta) Len() int { return len(a) }
+func (a DescendingByDelta) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
+func (a DescendingByDelta) Less(i, j int) bool { return a[i].Delta() > a[j].Delta() }
+
+func (d Delta) ModifiedSuites() []*Suite {
+ sort.Sort(DescendingByDelta(d.modifiedSuites))
+ return d.modifiedSuites
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/watch/delta_tracker.go b/vendor/github.com/onsi/ginkgo/ginkgo/watch/delta_tracker.go
new file mode 100644
index 000000000..a628303d7
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/watch/delta_tracker.go
@@ -0,0 +1,75 @@
+package watch
+
+import (
+ "fmt"
+
+ "regexp"
+
+ "github.com/onsi/ginkgo/ginkgo/testsuite"
+)
+
+type SuiteErrors map[testsuite.TestSuite]error
+
+type DeltaTracker struct {
+ maxDepth int
+ watchRegExp *regexp.Regexp
+ suites map[string]*Suite
+ packageHashes *PackageHashes
+}
+
+func NewDeltaTracker(maxDepth int, watchRegExp *regexp.Regexp) *DeltaTracker {
+ return &DeltaTracker{
+ maxDepth: maxDepth,
+ watchRegExp: watchRegExp,
+ packageHashes: NewPackageHashes(watchRegExp),
+ suites: map[string]*Suite{},
+ }
+}
+
+func (d *DeltaTracker) Delta(suites []testsuite.TestSuite) (delta Delta, errors SuiteErrors) {
+ errors = SuiteErrors{}
+ delta.ModifiedPackages = d.packageHashes.CheckForChanges()
+
+ providedSuitePaths := map[string]bool{}
+ for _, suite := range suites {
+ providedSuitePaths[suite.Path] = true
+ }
+
+ d.packageHashes.StartTrackingUsage()
+
+ for _, suite := range d.suites {
+ if providedSuitePaths[suite.Suite.Path] {
+ if suite.Delta() > 0 {
+ delta.modifiedSuites = append(delta.modifiedSuites, suite)
+ }
+ } else {
+ delta.RemovedSuites = append(delta.RemovedSuites, suite)
+ }
+ }
+
+ d.packageHashes.StopTrackingUsageAndPrune()
+
+ for _, suite := range suites {
+ _, ok := d.suites[suite.Path]
+ if !ok {
+ s, err := NewSuite(suite, d.maxDepth, d.packageHashes)
+ if err != nil {
+ errors[suite] = err
+ continue
+ }
+ d.suites[suite.Path] = s
+ delta.NewSuites = append(delta.NewSuites, s)
+ }
+ }
+
+ return delta, errors
+}
+
+func (d *DeltaTracker) WillRun(suite testsuite.TestSuite) error {
+ s, ok := d.suites[suite.Path]
+ if !ok {
+ return fmt.Errorf("unknown suite %s", suite.Path)
+ }
+
+ return s.MarkAsRunAndRecomputedDependencies(d.maxDepth)
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/watch/dependencies.go b/vendor/github.com/onsi/ginkgo/ginkgo/watch/dependencies.go
new file mode 100644
index 000000000..82c25face
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/watch/dependencies.go
@@ -0,0 +1,91 @@
+package watch
+
+import (
+ "go/build"
+ "regexp"
+)
+
+var ginkgoAndGomegaFilter = regexp.MustCompile(`github\.com/onsi/ginkgo|github\.com/onsi/gomega`)
+
+type Dependencies struct {
+ deps map[string]int
+}
+
+func NewDependencies(path string, maxDepth int) (Dependencies, error) {
+ d := Dependencies{
+ deps: map[string]int{},
+ }
+
+ if maxDepth == 0 {
+ return d, nil
+ }
+
+ err := d.seedWithDepsForPackageAtPath(path)
+ if err != nil {
+ return d, err
+ }
+
+ for depth := 1; depth < maxDepth; depth++ {
+ n := len(d.deps)
+ d.addDepsForDepth(depth)
+ if n == len(d.deps) {
+ break
+ }
+ }
+
+ return d, nil
+}
+
+func (d Dependencies) Dependencies() map[string]int {
+ return d.deps
+}
+
+func (d Dependencies) seedWithDepsForPackageAtPath(path string) error {
+ pkg, err := build.ImportDir(path, 0)
+ if err != nil {
+ return err
+ }
+
+ d.resolveAndAdd(pkg.Imports, 1)
+ d.resolveAndAdd(pkg.TestImports, 1)
+ d.resolveAndAdd(pkg.XTestImports, 1)
+
+ delete(d.deps, pkg.Dir)
+ return nil
+}
+
+func (d Dependencies) addDepsForDepth(depth int) {
+ for dep, depDepth := range d.deps {
+ if depDepth == depth {
+ d.addDepsForDep(dep, depth+1)
+ }
+ }
+}
+
+func (d Dependencies) addDepsForDep(dep string, depth int) {
+ pkg, err := build.ImportDir(dep, 0)
+ if err != nil {
+ println(err.Error())
+ return
+ }
+ d.resolveAndAdd(pkg.Imports, depth)
+}
+
+func (d Dependencies) resolveAndAdd(deps []string, depth int) {
+ for _, dep := range deps {
+ pkg, err := build.Import(dep, ".", 0)
+ if err != nil {
+ continue
+ }
+ if pkg.Goroot == false && !ginkgoAndGomegaFilter.Match([]byte(pkg.Dir)) {
+ d.addDepIfNotPresent(pkg.Dir, depth)
+ }
+ }
+}
+
+func (d Dependencies) addDepIfNotPresent(dep string, depth int) {
+ _, ok := d.deps[dep]
+ if !ok {
+ d.deps[dep] = depth
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/watch/package_hash.go b/vendor/github.com/onsi/ginkgo/ginkgo/watch/package_hash.go
new file mode 100644
index 000000000..7e1e4192d
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/watch/package_hash.go
@@ -0,0 +1,104 @@
+package watch
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+ "regexp"
+ "time"
+)
+
+var goTestRegExp = regexp.MustCompile(`_test\.go$`)
+
+type PackageHash struct {
+ CodeModifiedTime time.Time
+ TestModifiedTime time.Time
+ Deleted bool
+
+ path string
+ codeHash string
+ testHash string
+ watchRegExp *regexp.Regexp
+}
+
+func NewPackageHash(path string, watchRegExp *regexp.Regexp) *PackageHash {
+ p := &PackageHash{
+ path: path,
+ watchRegExp: watchRegExp,
+ }
+
+ p.codeHash, _, p.testHash, _, p.Deleted = p.computeHashes()
+
+ return p
+}
+
+func (p *PackageHash) CheckForChanges() bool {
+ codeHash, codeModifiedTime, testHash, testModifiedTime, deleted := p.computeHashes()
+
+ if deleted {
+ if p.Deleted == false {
+ t := time.Now()
+ p.CodeModifiedTime = t
+ p.TestModifiedTime = t
+ }
+ p.Deleted = true
+ return true
+ }
+
+ modified := false
+ p.Deleted = false
+
+ if p.codeHash != codeHash {
+ p.CodeModifiedTime = codeModifiedTime
+ modified = true
+ }
+ if p.testHash != testHash {
+ p.TestModifiedTime = testModifiedTime
+ modified = true
+ }
+
+ p.codeHash = codeHash
+ p.testHash = testHash
+ return modified
+}
+
+func (p *PackageHash) computeHashes() (codeHash string, codeModifiedTime time.Time, testHash string, testModifiedTime time.Time, deleted bool) {
+ infos, err := ioutil.ReadDir(p.path)
+
+ if err != nil {
+ deleted = true
+ return
+ }
+
+ for _, info := range infos {
+ if info.IsDir() {
+ continue
+ }
+
+ if goTestRegExp.Match([]byte(info.Name())) {
+ testHash += p.hashForFileInfo(info)
+ if info.ModTime().After(testModifiedTime) {
+ testModifiedTime = info.ModTime()
+ }
+ continue
+ }
+
+ if p.watchRegExp.Match([]byte(info.Name())) {
+ codeHash += p.hashForFileInfo(info)
+ if info.ModTime().After(codeModifiedTime) {
+ codeModifiedTime = info.ModTime()
+ }
+ }
+ }
+
+ testHash += codeHash
+ if codeModifiedTime.After(testModifiedTime) {
+ testModifiedTime = codeModifiedTime
+ }
+
+ return
+}
+
+func (p *PackageHash) hashForFileInfo(info os.FileInfo) string {
+ return fmt.Sprintf("%s_%d_%d", info.Name(), info.Size(), info.ModTime().UnixNano())
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/watch/package_hashes.go b/vendor/github.com/onsi/ginkgo/ginkgo/watch/package_hashes.go
new file mode 100644
index 000000000..b4892bebf
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/watch/package_hashes.go
@@ -0,0 +1,85 @@
+package watch
+
+import (
+ "path/filepath"
+ "regexp"
+ "sync"
+)
+
+type PackageHashes struct {
+ PackageHashes map[string]*PackageHash
+ usedPaths map[string]bool
+ watchRegExp *regexp.Regexp
+ lock *sync.Mutex
+}
+
+func NewPackageHashes(watchRegExp *regexp.Regexp) *PackageHashes {
+ return &PackageHashes{
+ PackageHashes: map[string]*PackageHash{},
+ usedPaths: nil,
+ watchRegExp: watchRegExp,
+ lock: &sync.Mutex{},
+ }
+}
+
+func (p *PackageHashes) CheckForChanges() []string {
+ p.lock.Lock()
+ defer p.lock.Unlock()
+
+ modified := []string{}
+
+ for _, packageHash := range p.PackageHashes {
+ if packageHash.CheckForChanges() {
+ modified = append(modified, packageHash.path)
+ }
+ }
+
+ return modified
+}
+
+func (p *PackageHashes) Add(path string) *PackageHash {
+ p.lock.Lock()
+ defer p.lock.Unlock()
+
+ path, _ = filepath.Abs(path)
+ _, ok := p.PackageHashes[path]
+ if !ok {
+ p.PackageHashes[path] = NewPackageHash(path, p.watchRegExp)
+ }
+
+ if p.usedPaths != nil {
+ p.usedPaths[path] = true
+ }
+ return p.PackageHashes[path]
+}
+
+func (p *PackageHashes) Get(path string) *PackageHash {
+ p.lock.Lock()
+ defer p.lock.Unlock()
+
+ path, _ = filepath.Abs(path)
+ if p.usedPaths != nil {
+ p.usedPaths[path] = true
+ }
+ return p.PackageHashes[path]
+}
+
+func (p *PackageHashes) StartTrackingUsage() {
+ p.lock.Lock()
+ defer p.lock.Unlock()
+
+ p.usedPaths = map[string]bool{}
+}
+
+func (p *PackageHashes) StopTrackingUsageAndPrune() {
+ p.lock.Lock()
+ defer p.lock.Unlock()
+
+ for path := range p.PackageHashes {
+ if !p.usedPaths[path] {
+ delete(p.PackageHashes, path)
+ }
+ }
+
+ p.usedPaths = nil
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/watch/suite.go b/vendor/github.com/onsi/ginkgo/ginkgo/watch/suite.go
new file mode 100644
index 000000000..5deaba7cb
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/watch/suite.go
@@ -0,0 +1,87 @@
+package watch
+
+import (
+ "fmt"
+ "math"
+ "time"
+
+ "github.com/onsi/ginkgo/ginkgo/testsuite"
+)
+
+type Suite struct {
+ Suite testsuite.TestSuite
+ RunTime time.Time
+ Dependencies Dependencies
+
+ sharedPackageHashes *PackageHashes
+}
+
+func NewSuite(suite testsuite.TestSuite, maxDepth int, sharedPackageHashes *PackageHashes) (*Suite, error) {
+ deps, err := NewDependencies(suite.Path, maxDepth)
+ if err != nil {
+ return nil, err
+ }
+
+ sharedPackageHashes.Add(suite.Path)
+ for dep := range deps.Dependencies() {
+ sharedPackageHashes.Add(dep)
+ }
+
+ return &Suite{
+ Suite: suite,
+ Dependencies: deps,
+
+ sharedPackageHashes: sharedPackageHashes,
+ }, nil
+}
+
+func (s *Suite) Delta() float64 {
+ delta := s.delta(s.Suite.Path, true, 0) * 1000
+ for dep, depth := range s.Dependencies.Dependencies() {
+ delta += s.delta(dep, false, depth)
+ }
+ return delta
+}
+
+func (s *Suite) MarkAsRunAndRecomputedDependencies(maxDepth int) error {
+ s.RunTime = time.Now()
+
+ deps, err := NewDependencies(s.Suite.Path, maxDepth)
+ if err != nil {
+ return err
+ }
+
+ s.sharedPackageHashes.Add(s.Suite.Path)
+ for dep := range deps.Dependencies() {
+ s.sharedPackageHashes.Add(dep)
+ }
+
+ s.Dependencies = deps
+
+ return nil
+}
+
+func (s *Suite) Description() string {
+ numDeps := len(s.Dependencies.Dependencies())
+ pluralizer := "ies"
+ if numDeps == 1 {
+ pluralizer = "y"
+ }
+ return fmt.Sprintf("%s [%d dependenc%s]", s.Suite.Path, numDeps, pluralizer)
+}
+
+func (s *Suite) delta(packagePath string, includeTests bool, depth int) float64 {
+ return math.Max(float64(s.dt(packagePath, includeTests)), 0) / float64(depth+1)
+}
+
+func (s *Suite) dt(packagePath string, includeTests bool) time.Duration {
+ packageHash := s.sharedPackageHashes.Get(packagePath)
+ var modifiedTime time.Time
+ if includeTests {
+ modifiedTime = packageHash.TestModifiedTime
+ } else {
+ modifiedTime = packageHash.CodeModifiedTime
+ }
+
+ return modifiedTime.Sub(s.RunTime)
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo/watch_command.go b/vendor/github.com/onsi/ginkgo/ginkgo/watch_command.go
new file mode 100644
index 000000000..a6ef053c8
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo/watch_command.go
@@ -0,0 +1,175 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "regexp"
+ "time"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/ginkgo/interrupthandler"
+ "github.com/onsi/ginkgo/ginkgo/testrunner"
+ "github.com/onsi/ginkgo/ginkgo/testsuite"
+ "github.com/onsi/ginkgo/ginkgo/watch"
+ colorable "github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable"
+)
+
+func BuildWatchCommand() *Command {
+ commandFlags := NewWatchCommandFlags(flag.NewFlagSet("watch", flag.ExitOnError))
+ interruptHandler := interrupthandler.NewInterruptHandler()
+ notifier := NewNotifier(commandFlags)
+ watcher := &SpecWatcher{
+ commandFlags: commandFlags,
+ notifier: notifier,
+ interruptHandler: interruptHandler,
+ suiteRunner: NewSuiteRunner(notifier, interruptHandler),
+ }
+
+ return &Command{
+ Name: "watch",
+ FlagSet: commandFlags.FlagSet,
+ UsageCommand: "ginkgo watch <FLAGS> <PACKAGES> -- <PASS-THROUGHS>",
+ Usage: []string{
+ "Watches the tests in the passed in <PACKAGES> and runs them when changes occur.",
+ "Any arguments after -- will be passed to the test.",
+ },
+ Command: watcher.WatchSpecs,
+ SuppressFlagDocumentation: true,
+ FlagDocSubstitute: []string{
+ "Accepts all the flags that the ginkgo command accepts except for --keepGoing and --untilItFails",
+ },
+ }
+}
+
+type SpecWatcher struct {
+ commandFlags *RunWatchAndBuildCommandFlags
+ notifier *Notifier
+ interruptHandler *interrupthandler.InterruptHandler
+ suiteRunner *SuiteRunner
+}
+
+func (w *SpecWatcher) WatchSpecs(args []string, additionalArgs []string) {
+ w.commandFlags.computeNodes()
+ w.notifier.VerifyNotificationsAreAvailable()
+
+ w.WatchSuites(args, additionalArgs)
+}
+
+func (w *SpecWatcher) runnersForSuites(suites []testsuite.TestSuite, additionalArgs []string) []*testrunner.TestRunner {
+ runners := []*testrunner.TestRunner{}
+
+ for _, suite := range suites {
+ runners = append(runners, testrunner.New(suite, w.commandFlags.NumCPU, w.commandFlags.ParallelStream, w.commandFlags.Timeout, w.commandFlags.GoOpts, additionalArgs))
+ }
+
+ return runners
+}
+
+func (w *SpecWatcher) WatchSuites(args []string, additionalArgs []string) {
+ suites, _ := findSuites(args, w.commandFlags.Recurse, w.commandFlags.SkipPackage, false)
+
+ if len(suites) == 0 {
+ complainAndQuit("Found no test suites")
+ }
+
+ fmt.Printf("Identified %d test %s. Locating dependencies to a depth of %d (this may take a while)...\n", len(suites), pluralizedWord("suite", "suites", len(suites)), w.commandFlags.Depth)
+ deltaTracker := watch.NewDeltaTracker(w.commandFlags.Depth, regexp.MustCompile(w.commandFlags.WatchRegExp))
+ delta, errors := deltaTracker.Delta(suites)
+
+ fmt.Printf("Watching %d %s:\n", len(delta.NewSuites), pluralizedWord("suite", "suites", len(delta.NewSuites)))
+ for _, suite := range delta.NewSuites {
+ fmt.Println(" " + suite.Description())
+ }
+
+ for suite, err := range errors {
+ fmt.Printf("Failed to watch %s: %s\n", suite.PackageName, err)
+ }
+
+ if len(suites) == 1 {
+ runners := w.runnersForSuites(suites, additionalArgs)
+ w.suiteRunner.RunSuites(runners, w.commandFlags.NumCompilers, true, nil)
+ runners[0].CleanUp()
+ }
+
+ ticker := time.NewTicker(time.Second)
+
+ for {
+ select {
+ case <-ticker.C:
+ suites, _ := findSuites(args, w.commandFlags.Recurse, w.commandFlags.SkipPackage, false)
+ delta, _ := deltaTracker.Delta(suites)
+ coloredStream := colorable.NewColorableStdout()
+
+ suitesToRun := []testsuite.TestSuite{}
+
+ if len(delta.NewSuites) > 0 {
+ fmt.Fprintf(coloredStream, greenColor+"Detected %d new %s:\n"+defaultStyle, len(delta.NewSuites), pluralizedWord("suite", "suites", len(delta.NewSuites)))
+ for _, suite := range delta.NewSuites {
+ suitesToRun = append(suitesToRun, suite.Suite)
+ fmt.Fprintln(coloredStream, " "+suite.Description())
+ }
+ }
+
+ modifiedSuites := delta.ModifiedSuites()
+ if len(modifiedSuites) > 0 {
+ fmt.Fprintln(coloredStream, greenColor+"\nDetected changes in:"+defaultStyle)
+ for _, pkg := range delta.ModifiedPackages {
+ fmt.Fprintln(coloredStream, " "+pkg)
+ }
+ fmt.Fprintf(coloredStream, greenColor+"Will run %d %s:\n"+defaultStyle, len(modifiedSuites), pluralizedWord("suite", "suites", len(modifiedSuites)))
+ for _, suite := range modifiedSuites {
+ suitesToRun = append(suitesToRun, suite.Suite)
+ fmt.Fprintln(coloredStream, " "+suite.Description())
+ }
+ fmt.Fprintln(coloredStream, "")
+ }
+
+ if len(suitesToRun) > 0 {
+ w.UpdateSeed()
+ w.ComputeSuccinctMode(len(suitesToRun))
+ runners := w.runnersForSuites(suitesToRun, additionalArgs)
+ result, _ := w.suiteRunner.RunSuites(runners, w.commandFlags.NumCompilers, true, func(suite testsuite.TestSuite) {
+ deltaTracker.WillRun(suite)
+ })
+ for _, runner := range runners {
+ runner.CleanUp()
+ }
+ if !w.interruptHandler.WasInterrupted() {
+ color := redColor
+ if result.Passed {
+ color = greenColor
+ }
+ fmt.Fprintln(coloredStream, color+"\nDone. Resuming watch..."+defaultStyle)
+ }
+ }
+
+ case <-w.interruptHandler.C:
+ return
+ }
+ }
+}
+
+func (w *SpecWatcher) ComputeSuccinctMode(numSuites int) {
+ if config.DefaultReporterConfig.Verbose {
+ config.DefaultReporterConfig.Succinct = false
+ return
+ }
+
+ if w.commandFlags.wasSet("succinct") {
+ return
+ }
+
+ if numSuites == 1 {
+ config.DefaultReporterConfig.Succinct = false
+ }
+
+ if numSuites > 1 {
+ config.DefaultReporterConfig.Succinct = true
+ }
+}
+
+func (w *SpecWatcher) UpdateSeed() {
+ if !w.commandFlags.wasSet("seed") {
+ config.GinkgoConfig.RandomSeed = time.Now().Unix()
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/ginkgo_dsl.go b/vendor/github.com/onsi/ginkgo/ginkgo_dsl.go
new file mode 100644
index 000000000..5aa96b4d9
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/ginkgo_dsl.go
@@ -0,0 +1,619 @@
+/*
+Ginkgo is a BDD-style testing framework for Golang
+
+The godoc documentation describes Ginkgo's API. More comprehensive documentation (with examples!) is available at http://onsi.github.io/ginkgo/
+
+Ginkgo's preferred matcher library is [Gomega](http://github.com/onsi/gomega)
+
+Ginkgo on Github: http://github.com/onsi/ginkgo
+
+Ginkgo is MIT-Licensed
+*/
+package ginkgo
+
+import (
+ "flag"
+ "fmt"
+ "io"
+ "net/http"
+ "os"
+ "strings"
+ "time"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/internal/codelocation"
+ "github.com/onsi/ginkgo/internal/failer"
+ "github.com/onsi/ginkgo/internal/remote"
+ "github.com/onsi/ginkgo/internal/suite"
+ "github.com/onsi/ginkgo/internal/testingtproxy"
+ "github.com/onsi/ginkgo/internal/writer"
+ "github.com/onsi/ginkgo/reporters"
+ "github.com/onsi/ginkgo/reporters/stenographer"
+ colorable "github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable"
+ "github.com/onsi/ginkgo/types"
+)
+
+const GINKGO_VERSION = config.VERSION
+const GINKGO_PANIC = `
+Your test failed.
+Ginkgo panics to prevent subsequent assertions from running.
+Normally Ginkgo rescues this panic so you shouldn't see it.
+
+But, if you make an assertion in a goroutine, Ginkgo can't capture the panic.
+To circumvent this, you should call
+
+ defer GinkgoRecover()
+
+at the top of the goroutine that caused this panic.
+`
+const defaultTimeout = 1
+
+var globalSuite *suite.Suite
+var globalFailer *failer.Failer
+
+func init() {
+ config.Flags(flag.CommandLine, "ginkgo", true)
+ GinkgoWriter = writer.New(os.Stdout)
+ globalFailer = failer.New()
+ globalSuite = suite.New(globalFailer)
+}
+
+//GinkgoWriter implements an io.Writer
+//When running in verbose mode any writes to GinkgoWriter will be immediately printed
+//to stdout. Otherwise, GinkgoWriter will buffer any writes produced during the current test and flush them to screen
+//only if the current test fails.
+var GinkgoWriter io.Writer
+
+//The interface by which Ginkgo receives *testing.T
+type GinkgoTestingT interface {
+ Fail()
+}
+
+//GinkgoRandomSeed returns the seed used to randomize spec execution order. It is
+//useful for seeding your own pseudorandom number generators (PRNGs) to ensure
+//consistent executions from run to run, where your tests contain variability (for
+//example, when selecting random test data).
+func GinkgoRandomSeed() int64 {
+ return config.GinkgoConfig.RandomSeed
+}
+
+//GinkgoParallelNode returns the parallel node number for the current ginkgo process
+//The node number is 1-indexed
+func GinkgoParallelNode() int {
+ return config.GinkgoConfig.ParallelNode
+}
+
+//Some matcher libraries or legacy codebases require a *testing.T
+//GinkgoT implements an interface analogous to *testing.T and can be used if
+//the library in question accepts *testing.T through an interface
+//
+// For example, with testify:
+// assert.Equal(GinkgoT(), 123, 123, "they should be equal")
+//
+// Or with gomock:
+// gomock.NewController(GinkgoT())
+//
+// GinkgoT() takes an optional offset argument that can be used to get the
+// correct line number associated with the failure.
+func GinkgoT(optionalOffset ...int) GinkgoTInterface {
+ offset := 3
+ if len(optionalOffset) > 0 {
+ offset = optionalOffset[0]
+ }
+ return testingtproxy.New(GinkgoWriter, Fail, offset)
+}
+
+//The interface returned by GinkgoT(). This covers most of the methods
+//in the testing package's T.
+type GinkgoTInterface interface {
+ Fail()
+ Error(args ...interface{})
+ Errorf(format string, args ...interface{})
+ FailNow()
+ Fatal(args ...interface{})
+ Fatalf(format string, args ...interface{})
+ Log(args ...interface{})
+ Logf(format string, args ...interface{})
+ Failed() bool
+ Parallel()
+ Skip(args ...interface{})
+ Skipf(format string, args ...interface{})
+ SkipNow()
+ Skipped() bool
+}
+
+//Custom Ginkgo test reporters must implement the Reporter interface.
+//
+//The custom reporter is passed in a SuiteSummary when the suite begins and ends,
+//and a SpecSummary just before a spec begins and just after a spec ends
+type Reporter reporters.Reporter
+
+//Asynchronous specs are given a channel of the Done type. You must close or write to the channel
+//to tell Ginkgo that your async test is done.
+type Done chan<- interface{}
+
+//GinkgoTestDescription represents the information about the current running test returned by CurrentGinkgoTestDescription
+// FullTestText: a concatenation of ComponentTexts and the TestText
+// ComponentTexts: a list of all texts for the Describes & Contexts leading up to the current test
+// TestText: the text in the actual It or Measure node
+// IsMeasurement: true if the current test is a measurement
+// FileName: the name of the file containing the current test
+// LineNumber: the line number for the current test
+// Failed: if the current test has failed, this will be true (useful in an AfterEach)
+type GinkgoTestDescription struct {
+ FullTestText string
+ ComponentTexts []string
+ TestText string
+
+ IsMeasurement bool
+
+ FileName string
+ LineNumber int
+
+ Failed bool
+ Duration time.Duration
+}
+
+//CurrentGinkgoTestDescripton returns information about the current running test.
+func CurrentGinkgoTestDescription() GinkgoTestDescription {
+ summary, ok := globalSuite.CurrentRunningSpecSummary()
+ if !ok {
+ return GinkgoTestDescription{}
+ }
+
+ subjectCodeLocation := summary.ComponentCodeLocations[len(summary.ComponentCodeLocations)-1]
+
+ return GinkgoTestDescription{
+ ComponentTexts: summary.ComponentTexts[1:],
+ FullTestText: strings.Join(summary.ComponentTexts[1:], " "),
+ TestText: summary.ComponentTexts[len(summary.ComponentTexts)-1],
+ IsMeasurement: summary.IsMeasurement,
+ FileName: subjectCodeLocation.FileName,
+ LineNumber: subjectCodeLocation.LineNumber,
+ Failed: summary.HasFailureState(),
+ Duration: summary.RunTime,
+ }
+}
+
+//Measurement tests receive a Benchmarker.
+//
+//You use the Time() function to time how long the passed in body function takes to run
+//You use the RecordValue() function to track arbitrary numerical measurements.
+//The RecordValueWithPrecision() function can be used alternatively to provide the unit
+//and resolution of the numeric measurement.
+//The optional info argument is passed to the test reporter and can be used to
+// provide the measurement data to a custom reporter with context.
+//
+//See http://onsi.github.io/ginkgo/#benchmark_tests for more details
+type Benchmarker interface {
+ Time(name string, body func(), info ...interface{}) (elapsedTime time.Duration)
+ RecordValue(name string, value float64, info ...interface{})
+ RecordValueWithPrecision(name string, value float64, units string, precision int, info ...interface{})
+}
+
+//RunSpecs is the entry point for the Ginkgo test runner.
+//You must call this within a Golang testing TestX(t *testing.T) function.
+//
+//To bootstrap a test suite you can use the Ginkgo CLI:
+//
+// ginkgo bootstrap
+func RunSpecs(t GinkgoTestingT, description string) bool {
+ specReporters := []Reporter{buildDefaultReporter()}
+ return RunSpecsWithCustomReporters(t, description, specReporters)
+}
+
+//To run your tests with Ginkgo's default reporter and your custom reporter(s), replace
+//RunSpecs() with this method.
+func RunSpecsWithDefaultAndCustomReporters(t GinkgoTestingT, description string, specReporters []Reporter) bool {
+ specReporters = append(specReporters, buildDefaultReporter())
+ return RunSpecsWithCustomReporters(t, description, specReporters)
+}
+
+//To run your tests with your custom reporter(s) (and *not* Ginkgo's default reporter), replace
+//RunSpecs() with this method. Note that parallel tests will not work correctly without the default reporter
+func RunSpecsWithCustomReporters(t GinkgoTestingT, description string, specReporters []Reporter) bool {
+ writer := GinkgoWriter.(*writer.Writer)
+ writer.SetStream(config.DefaultReporterConfig.Verbose)
+ reporters := make([]reporters.Reporter, len(specReporters))
+ for i, reporter := range specReporters {
+ reporters[i] = reporter
+ }
+ passed, hasFocusedTests := globalSuite.Run(t, description, reporters, writer, config.GinkgoConfig)
+ if passed && hasFocusedTests && strings.TrimSpace(os.Getenv("GINKGO_EDITOR_INTEGRATION")) == "" {
+ fmt.Println("PASS | FOCUSED")
+ os.Exit(types.GINKGO_FOCUS_EXIT_CODE)
+ }
+ return passed
+}
+
+func buildDefaultReporter() Reporter {
+ remoteReportingServer := config.GinkgoConfig.StreamHost
+ if remoteReportingServer == "" {
+ stenographer := stenographer.New(!config.DefaultReporterConfig.NoColor, config.GinkgoConfig.FlakeAttempts > 1, colorable.NewColorableStdout())
+ return reporters.NewDefaultReporter(config.DefaultReporterConfig, stenographer)
+ } else {
+ debugFile := ""
+ if config.GinkgoConfig.DebugParallel {
+ debugFile = fmt.Sprintf("ginkgo-node-%d.log", config.GinkgoConfig.ParallelNode)
+ }
+ return remote.NewForwardingReporter(config.DefaultReporterConfig, remoteReportingServer, &http.Client{}, remote.NewOutputInterceptor(), GinkgoWriter.(*writer.Writer), debugFile)
+ }
+}
+
+//Skip notifies Ginkgo that the current spec was skipped.
+func Skip(message string, callerSkip ...int) {
+ skip := 0
+ if len(callerSkip) > 0 {
+ skip = callerSkip[0]
+ }
+
+ globalFailer.Skip(message, codelocation.New(skip+1))
+ panic(GINKGO_PANIC)
+}
+
+//Fail notifies Ginkgo that the current spec has failed. (Gomega will call Fail for you automatically when an assertion fails.)
+func Fail(message string, callerSkip ...int) {
+ skip := 0
+ if len(callerSkip) > 0 {
+ skip = callerSkip[0]
+ }
+
+ globalFailer.Fail(message, codelocation.New(skip+1))
+ panic(GINKGO_PANIC)
+}
+
+//GinkgoRecover should be deferred at the top of any spawned goroutine that (may) call `Fail`
+//Since Gomega assertions call fail, you should throw a `defer GinkgoRecover()` at the top of any goroutine that
+//calls out to Gomega
+//
+//Here's why: Ginkgo's `Fail` method records the failure and then panics to prevent
+//further assertions from running. This panic must be recovered. Ginkgo does this for you
+//if the panic originates in a Ginkgo node (an It, BeforeEach, etc...)
+//
+//Unfortunately, if a panic originates on a goroutine *launched* from one of these nodes there's no
+//way for Ginkgo to rescue the panic. To do this, you must remember to `defer GinkgoRecover()` at the top of such a goroutine.
+func GinkgoRecover() {
+ e := recover()
+ if e != nil {
+ globalFailer.Panic(codelocation.New(1), e)
+ }
+}
+
+//Describe blocks allow you to organize your specs. A Describe block can contain any number of
+//BeforeEach, AfterEach, JustBeforeEach, It, and Measurement blocks.
+//
+//In addition you can nest Describe, Context and When blocks. Describe, Context and When blocks are functionally
+//equivalent. The difference is purely semantic -- you typical Describe the behavior of an object
+//or method and, within that Describe, outline a number of Contexts and Whens.
+func Describe(text string, body func()) bool {
+ globalSuite.PushContainerNode(text, body, types.FlagTypeNone, codelocation.New(1))
+ return true
+}
+
+//You can focus the tests within a describe block using FDescribe
+func FDescribe(text string, body func()) bool {
+ globalSuite.PushContainerNode(text, body, types.FlagTypeFocused, codelocation.New(1))
+ return true
+}
+
+//You can mark the tests within a describe block as pending using PDescribe
+func PDescribe(text string, body func()) bool {
+ globalSuite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1))
+ return true
+}
+
+//You can mark the tests within a describe block as pending using XDescribe
+func XDescribe(text string, body func()) bool {
+ globalSuite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1))
+ return true
+}
+
+//Context blocks allow you to organize your specs. A Context block can contain any number of
+//BeforeEach, AfterEach, JustBeforeEach, It, and Measurement blocks.
+//
+//In addition you can nest Describe, Context and When blocks. Describe, Context and When blocks are functionally
+//equivalent. The difference is purely semantic -- you typical Describe the behavior of an object
+//or method and, within that Describe, outline a number of Contexts and Whens.
+func Context(text string, body func()) bool {
+ globalSuite.PushContainerNode(text, body, types.FlagTypeNone, codelocation.New(1))
+ return true
+}
+
+//You can focus the tests within a describe block using FContext
+func FContext(text string, body func()) bool {
+ globalSuite.PushContainerNode(text, body, types.FlagTypeFocused, codelocation.New(1))
+ return true
+}
+
+//You can mark the tests within a describe block as pending using PContext
+func PContext(text string, body func()) bool {
+ globalSuite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1))
+ return true
+}
+
+//You can mark the tests within a describe block as pending using XContext
+func XContext(text string, body func()) bool {
+ globalSuite.PushContainerNode(text, body, types.FlagTypePending, codelocation.New(1))
+ return true
+}
+
+//When blocks allow you to organize your specs. A When block can contain any number of
+//BeforeEach, AfterEach, JustBeforeEach, It, and Measurement blocks.
+//
+//In addition you can nest Describe, Context and When blocks. Describe, Context and When blocks are functionally
+//equivalent. The difference is purely semantic -- you typical Describe the behavior of an object
+//or method and, within that Describe, outline a number of Contexts and Whens.
+func When(text string, body func()) bool {
+ globalSuite.PushContainerNode("when "+text, body, types.FlagTypeNone, codelocation.New(1))
+ return true
+}
+
+//You can focus the tests within a describe block using FWhen
+func FWhen(text string, body func()) bool {
+ globalSuite.PushContainerNode("when "+text, body, types.FlagTypeFocused, codelocation.New(1))
+ return true
+}
+
+//You can mark the tests within a describe block as pending using PWhen
+func PWhen(text string, body func()) bool {
+ globalSuite.PushContainerNode("when "+text, body, types.FlagTypePending, codelocation.New(1))
+ return true
+}
+
+//You can mark the tests within a describe block as pending using XWhen
+func XWhen(text string, body func()) bool {
+ globalSuite.PushContainerNode("when "+text, body, types.FlagTypePending, codelocation.New(1))
+ return true
+}
+
+//It blocks contain your test code and assertions. You cannot nest any other Ginkgo blocks
+//within an It block.
+//
+//Ginkgo will normally run It blocks synchronously. To perform asynchronous tests, pass a
+//function that accepts a Done channel. When you do this, you can also provide an optional timeout.
+func It(text string, body interface{}, timeout ...float64) bool {
+ globalSuite.PushItNode(text, body, types.FlagTypeNone, codelocation.New(1), parseTimeout(timeout...))
+ return true
+}
+
+//You can focus individual Its using FIt
+func FIt(text string, body interface{}, timeout ...float64) bool {
+ globalSuite.PushItNode(text, body, types.FlagTypeFocused, codelocation.New(1), parseTimeout(timeout...))
+ return true
+}
+
+//You can mark Its as pending using PIt
+func PIt(text string, _ ...interface{}) bool {
+ globalSuite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0)
+ return true
+}
+
+//You can mark Its as pending using XIt
+func XIt(text string, _ ...interface{}) bool {
+ globalSuite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0)
+ return true
+}
+
+//Specify blocks are aliases for It blocks and allow for more natural wording in situations
+//which "It" does not fit into a natural sentence flow. All the same protocols apply for Specify blocks
+//which apply to It blocks.
+func Specify(text string, body interface{}, timeout ...float64) bool {
+ globalSuite.PushItNode(text, body, types.FlagTypeNone, codelocation.New(1), parseTimeout(timeout...))
+ return true
+}
+
+//You can focus individual Specifys using FSpecify
+func FSpecify(text string, body interface{}, timeout ...float64) bool {
+ globalSuite.PushItNode(text, body, types.FlagTypeFocused, codelocation.New(1), parseTimeout(timeout...))
+ return true
+}
+
+//You can mark Specifys as pending using PSpecify
+func PSpecify(text string, is ...interface{}) bool {
+ globalSuite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0)
+ return true
+}
+
+//You can mark Specifys as pending using XSpecify
+func XSpecify(text string, is ...interface{}) bool {
+ globalSuite.PushItNode(text, func() {}, types.FlagTypePending, codelocation.New(1), 0)
+ return true
+}
+
+//By allows you to better document large Its.
+//
+//Generally you should try to keep your Its short and to the point. This is not always possible, however,
+//especially in the context of integration tests that capture a particular workflow.
+//
+//By allows you to document such flows. By must be called within a runnable node (It, BeforeEach, Measure, etc...)
+//By will simply log the passed in text to the GinkgoWriter. If By is handed a function it will immediately run the function.
+func By(text string, callbacks ...func()) {
+ preamble := "\x1b[1mSTEP\x1b[0m"
+ if config.DefaultReporterConfig.NoColor {
+ preamble = "STEP"
+ }
+ fmt.Fprintln(GinkgoWriter, preamble+": "+text)
+ if len(callbacks) == 1 {
+ callbacks[0]()
+ }
+ if len(callbacks) > 1 {
+ panic("just one callback per By, please")
+ }
+}
+
+//Measure blocks run the passed in body function repeatedly (determined by the samples argument)
+//and accumulate metrics provided to the Benchmarker by the body function.
+//
+//The body function must have the signature:
+// func(b Benchmarker)
+func Measure(text string, body interface{}, samples int) bool {
+ globalSuite.PushMeasureNode(text, body, types.FlagTypeNone, codelocation.New(1), samples)
+ return true
+}
+
+//You can focus individual Measures using FMeasure
+func FMeasure(text string, body interface{}, samples int) bool {
+ globalSuite.PushMeasureNode(text, body, types.FlagTypeFocused, codelocation.New(1), samples)
+ return true
+}
+
+//You can mark Maeasurements as pending using PMeasure
+func PMeasure(text string, _ ...interface{}) bool {
+ globalSuite.PushMeasureNode(text, func(b Benchmarker) {}, types.FlagTypePending, codelocation.New(1), 0)
+ return true
+}
+
+//You can mark Maeasurements as pending using XMeasure
+func XMeasure(text string, _ ...interface{}) bool {
+ globalSuite.PushMeasureNode(text, func(b Benchmarker) {}, types.FlagTypePending, codelocation.New(1), 0)
+ return true
+}
+
+//BeforeSuite blocks are run just once before any specs are run. When running in parallel, each
+//parallel node process will call BeforeSuite.
+//
+//BeforeSuite blocks can be made asynchronous by providing a body function that accepts a Done channel
+//
+//You may only register *one* BeforeSuite handler per test suite. You typically do so in your bootstrap file at the top level.
+func BeforeSuite(body interface{}, timeout ...float64) bool {
+ globalSuite.SetBeforeSuiteNode(body, codelocation.New(1), parseTimeout(timeout...))
+ return true
+}
+
+//AfterSuite blocks are *always* run after all the specs regardless of whether specs have passed or failed.
+//Moreover, if Ginkgo receives an interrupt signal (^C) it will attempt to run the AfterSuite before exiting.
+//
+//When running in parallel, each parallel node process will call AfterSuite.
+//
+//AfterSuite blocks can be made asynchronous by providing a body function that accepts a Done channel
+//
+//You may only register *one* AfterSuite handler per test suite. You typically do so in your bootstrap file at the top level.
+func AfterSuite(body interface{}, timeout ...float64) bool {
+ globalSuite.SetAfterSuiteNode(body, codelocation.New(1), parseTimeout(timeout...))
+ return true
+}
+
+//SynchronizedBeforeSuite blocks are primarily meant to solve the problem of setting up singleton external resources shared across
+//nodes when running tests in parallel. For example, say you have a shared database that you can only start one instance of that
+//must be used in your tests. When running in parallel, only one node should set up the database and all other nodes should wait
+//until that node is done before running.
+//
+//SynchronizedBeforeSuite accomplishes this by taking *two* function arguments. The first is only run on parallel node #1. The second is
+//run on all nodes, but *only* after the first function completes succesfully. Ginkgo also makes it possible to send data from the first function (on Node 1)
+//to the second function (on all the other nodes).
+//
+//The functions have the following signatures. The first function (which only runs on node 1) has the signature:
+//
+// func() []byte
+//
+//or, to run asynchronously:
+//
+// func(done Done) []byte
+//
+//The byte array returned by the first function is then passed to the second function, which has the signature:
+//
+// func(data []byte)
+//
+//or, to run asynchronously:
+//
+// func(data []byte, done Done)
+//
+//Here's a simple pseudo-code example that starts a shared database on Node 1 and shares the database's address with the other nodes:
+//
+// var dbClient db.Client
+// var dbRunner db.Runner
+//
+// var _ = SynchronizedBeforeSuite(func() []byte {
+// dbRunner = db.NewRunner()
+// err := dbRunner.Start()
+// Ω(err).ShouldNot(HaveOccurred())
+// return []byte(dbRunner.URL)
+// }, func(data []byte) {
+// dbClient = db.NewClient()
+// err := dbClient.Connect(string(data))
+// Ω(err).ShouldNot(HaveOccurred())
+// })
+func SynchronizedBeforeSuite(node1Body interface{}, allNodesBody interface{}, timeout ...float64) bool {
+ globalSuite.SetSynchronizedBeforeSuiteNode(
+ node1Body,
+ allNodesBody,
+ codelocation.New(1),
+ parseTimeout(timeout...),
+ )
+ return true
+}
+
+//SynchronizedAfterSuite blocks complement the SynchronizedBeforeSuite blocks in solving the problem of setting up
+//external singleton resources shared across nodes when running tests in parallel.
+//
+//SynchronizedAfterSuite accomplishes this by taking *two* function arguments. The first runs on all nodes. The second runs only on parallel node #1
+//and *only* after all other nodes have finished and exited. This ensures that node 1, and any resources it is running, remain alive until
+//all other nodes are finished.
+//
+//Both functions have the same signature: either func() or func(done Done) to run asynchronously.
+//
+//Here's a pseudo-code example that complements that given in SynchronizedBeforeSuite. Here, SynchronizedAfterSuite is used to tear down the shared database
+//only after all nodes have finished:
+//
+// var _ = SynchronizedAfterSuite(func() {
+// dbClient.Cleanup()
+// }, func() {
+// dbRunner.Stop()
+// })
+func SynchronizedAfterSuite(allNodesBody interface{}, node1Body interface{}, timeout ...float64) bool {
+ globalSuite.SetSynchronizedAfterSuiteNode(
+ allNodesBody,
+ node1Body,
+ codelocation.New(1),
+ parseTimeout(timeout...),
+ )
+ return true
+}
+
+//BeforeEach blocks are run before It blocks. When multiple BeforeEach blocks are defined in nested
+//Describe and Context blocks the outermost BeforeEach blocks are run first.
+//
+//Like It blocks, BeforeEach blocks can be made asynchronous by providing a body function that accepts
+//a Done channel
+func BeforeEach(body interface{}, timeout ...float64) bool {
+ globalSuite.PushBeforeEachNode(body, codelocation.New(1), parseTimeout(timeout...))
+ return true
+}
+
+//JustBeforeEach blocks are run before It blocks but *after* all BeforeEach blocks. For more details,
+//read the [documentation](http://onsi.github.io/ginkgo/#separating_creation_and_configuration_)
+//
+//Like It blocks, BeforeEach blocks can be made asynchronous by providing a body function that accepts
+//a Done channel
+func JustBeforeEach(body interface{}, timeout ...float64) bool {
+ globalSuite.PushJustBeforeEachNode(body, codelocation.New(1), parseTimeout(timeout...))
+ return true
+}
+
+//JustAfterEach blocks are run after It blocks but *before* all AfterEach blocks. For more details,
+//read the [documentation](http://onsi.github.io/ginkgo/#separating_creation_and_configuration_)
+//
+//Like It blocks, JustAfterEach blocks can be made asynchronous by providing a body function that accepts
+//a Done channel
+func JustAfterEach(body interface{}, timeout ...float64) bool {
+ globalSuite.PushJustAfterEachNode(body, codelocation.New(1), parseTimeout(timeout...))
+ return true
+}
+
+//AfterEach blocks are run after It blocks. When multiple AfterEach blocks are defined in nested
+//Describe and Context blocks the innermost AfterEach blocks are run first.
+//
+//Like It blocks, AfterEach blocks can be made asynchronous by providing a body function that accepts
+//a Done channel
+func AfterEach(body interface{}, timeout ...float64) bool {
+ globalSuite.PushAfterEachNode(body, codelocation.New(1), parseTimeout(timeout...))
+ return true
+}
+
+func parseTimeout(timeout ...float64) time.Duration {
+ if len(timeout) == 0 {
+ return time.Duration(defaultTimeout * int64(time.Second))
+ } else {
+ return time.Duration(timeout[0] * float64(time.Second))
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/coverage.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/coverage.go
new file mode 100644
index 000000000..10c1c1bd1
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/coverage.go
@@ -0,0 +1,21 @@
+package first_package
+
+func A() string {
+ return "A"
+}
+
+func B() string {
+ return "B"
+}
+
+func C() string {
+ return "C"
+}
+
+func D() string {
+ return "D"
+}
+
+func E() string {
+ return "untested"
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/coverage_fixture_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/coverage_fixture_suite_test.go
new file mode 100644
index 000000000..4e0976cd5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/coverage_fixture_suite_test.go
@@ -0,0 +1,13 @@
+package first_package_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestCoverageFixture(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "CombinedFixture First Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/coverage_fixture_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/coverage_fixture_test.go
new file mode 100644
index 000000000..dfe3e1127
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/coverage_fixture_test.go
@@ -0,0 +1,31 @@
+package first_package_test
+
+import (
+ . "github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package"
+ . "github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/external_coverage_fixture"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("CoverageFixture", func() {
+ It("should test A", func() {
+ Ω(A()).Should(Equal("A"))
+ })
+
+ It("should test B", func() {
+ Ω(B()).Should(Equal("B"))
+ })
+
+ It("should test C", func() {
+ Ω(C()).Should(Equal("C"))
+ })
+
+ It("should test D", func() {
+ Ω(D()).Should(Equal("D"))
+ })
+
+ It("should test external package", func() {
+ Ω(Tested()).Should(Equal("tested"))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/external_coverage_fixture/external_coverage.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/external_coverage_fixture/external_coverage.go
new file mode 100644
index 000000000..5280d4ddf
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/first_package/external_coverage_fixture/external_coverage.go
@@ -0,0 +1,9 @@
+package external_coverage
+
+func Tested() string {
+ return "tested"
+}
+
+func Untested() string {
+ return "untested"
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/second_package/coverage.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/second_package/coverage.go
new file mode 100644
index 000000000..52160989b
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/second_package/coverage.go
@@ -0,0 +1,21 @@
+package second_package
+
+func A() string {
+ return "A"
+}
+
+func B() string {
+ return "B"
+}
+
+func C() string {
+ return "C"
+}
+
+func D() string {
+ return "D"
+}
+
+func E() string {
+ return "E"
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/second_package/coverage_fixture_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/second_package/coverage_fixture_suite_test.go
new file mode 100644
index 000000000..583a0af20
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/second_package/coverage_fixture_suite_test.go
@@ -0,0 +1,13 @@
+package second_package_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestCoverageFixture(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "CombinedFixture Second Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/second_package/coverage_fixture_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/second_package/coverage_fixture_test.go
new file mode 100644
index 000000000..2692bec9b
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/second_package/coverage_fixture_test.go
@@ -0,0 +1,29 @@
+package second_package_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/integration/_fixtures/combined_coverage_fixture/second_package"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("CoverageFixture", func() {
+ It("should test A", func() {
+ Ω(A()).Should(Equal("A"))
+ })
+
+ It("should test B", func() {
+ Ω(B()).Should(Equal("B"))
+ })
+
+ It("should test C", func() {
+ Ω(C()).Should(Equal("C"))
+ })
+
+ It("should test D", func() {
+ Ω(D()).Should(Equal("D"))
+ })
+
+ It("should test E", func() {
+ Ω(E()).Should(Equal("E"))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/extra_functions_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/extra_functions_test.go
new file mode 100644
index 000000000..ccb3669a5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/extra_functions_test.go
@@ -0,0 +1,14 @@
+package tmp
+
+import (
+ "testing"
+)
+
+func TestSomethingLessImportant(t *testing.T) {
+ strp := "hello!"
+ somethingImportant(t, &strp)
+}
+
+func somethingImportant(t *testing.T, message *string) {
+ t.Log("Something important happened in a test: " + *message)
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/nested/nested_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/nested/nested_test.go
new file mode 100644
index 000000000..cde42e470
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/nested/nested_test.go
@@ -0,0 +1,10 @@
+package nested
+
+import (
+ "testing"
+)
+
+func TestSomethingLessImportant(t *testing.T) {
+ whatever := &UselessStruct{}
+ t.Fail(whatever.ImportantField != "SECRET_PASSWORD")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/nested_without_gofiles/subpackage/nested_subpackage_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/nested_without_gofiles/subpackage/nested_subpackage_test.go
new file mode 100644
index 000000000..7cdd326c5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/nested_without_gofiles/subpackage/nested_subpackage_test.go
@@ -0,0 +1,9 @@
+package subpackage
+
+import (
+ "testing"
+)
+
+func TestNestedSubPackages(t *testing.T) {
+ t.Fail(true)
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/outside_package_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/outside_package_test.go
new file mode 100644
index 000000000..a682eeaff
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/outside_package_test.go
@@ -0,0 +1,16 @@
+package tmp_test
+
+import (
+ "testing"
+)
+
+type UselessStruct struct {
+ ImportantField string
+}
+
+func TestSomethingImportant(t *testing.T) {
+ whatever := &UselessStruct{}
+ if whatever.ImportantField != "SECRET_PASSWORD" {
+ t.Fail()
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/xunit_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/xunit_test.go
new file mode 100644
index 000000000..049829a7d
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_fixtures/xunit_test.go
@@ -0,0 +1,41 @@
+package tmp
+
+import (
+ "testing"
+)
+
+type UselessStruct struct {
+ ImportantField string
+ T *testing.T
+}
+
+var testFunc = func(t *testing.T, arg *string) {}
+
+func assertEqual(t *testing.T, arg1, arg2 interface{}) {
+ if arg1 != arg2 {
+ t.Fail()
+ }
+}
+
+func TestSomethingImportant(t *testing.T) {
+ whatever := &UselessStruct{
+ T: t,
+ ImportantField: "SECRET_PASSWORD",
+ }
+ something := &UselessStruct{ImportantField: "string value"}
+ assertEqual(t, whatever.ImportantField, "SECRET_PASSWORD")
+ assertEqual(t, something.ImportantField, "string value")
+
+ var foo = func(t *testing.T) {}
+ foo(t)
+
+ strp := "something"
+ testFunc(t, &strp)
+ t.Fail()
+}
+
+func Test3Things(t *testing.T) {
+ if 3 != 3 {
+ t.Fail()
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/extra_functions_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/extra_functions_test.go
new file mode 100644
index 000000000..1c2c56cea
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/extra_functions_test.go
@@ -0,0 +1,17 @@
+package tmp
+
+import (
+ . "github.com/onsi/ginkgo"
+)
+
+var _ = Describe("Testing with Ginkgo", func() {
+ It("something less important", func() {
+
+ strp := "hello!"
+ somethingImportant(GinkgoT(), &strp)
+ })
+})
+
+func somethingImportant(t GinkgoTInterface, message *string) {
+ t.Log("Something important happened in a test: " + *message)
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/fixtures_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/fixtures_suite_test.go
new file mode 100644
index 000000000..a9a404b5c
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/fixtures_suite_test.go
@@ -0,0 +1,13 @@
+package tmp
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestTmp(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Tmp Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/nested_subpackage_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/nested_subpackage_test.go
new file mode 100644
index 000000000..3653eae82
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/nested_subpackage_test.go
@@ -0,0 +1,11 @@
+package subpackage
+
+import (
+ . "github.com/onsi/ginkgo"
+)
+
+var _ = Describe("Testing with Ginkgo", func() {
+ It("nested sub packages", func() {
+ GinkgoT().Fail(true)
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/nested_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/nested_suite_test.go
new file mode 100644
index 000000000..721d0f2c3
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/nested_suite_test.go
@@ -0,0 +1,13 @@
+package nested_test
+
+import (
+ "testing"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+func TestNested(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Nested Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/nested_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/nested_test.go
new file mode 100644
index 000000000..47364b814
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/nested_test.go
@@ -0,0 +1,13 @@
+package nested
+
+import (
+ . "github.com/onsi/ginkgo"
+)
+
+var _ = Describe("Testing with Ginkgo", func() {
+ It("something less important", func() {
+
+ whatever := &UselessStruct{}
+ GinkgoT().Fail(whatever.ImportantField != "SECRET_PASSWORD")
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/outside_package_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/outside_package_test.go
new file mode 100644
index 000000000..1f2e332c4
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/outside_package_test.go
@@ -0,0 +1,19 @@
+package tmp_test
+
+import (
+ . "github.com/onsi/ginkgo"
+)
+
+var _ = Describe("Testing with Ginkgo", func() {
+ It("something important", func() {
+
+ whatever := &UselessStruct{}
+ if whatever.ImportantField != "SECRET_PASSWORD" {
+ GinkgoT().Fail()
+ }
+ })
+})
+
+type UselessStruct struct {
+ ImportantField string
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/suite_test.go
new file mode 100644
index 000000000..9ea229135
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/suite_test.go
@@ -0,0 +1,13 @@
+package tmp_test
+
+import (
+ "testing"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+func TestConvertFixtures(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "ConvertFixtures Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/xunit_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/xunit_test.go
new file mode 100644
index 000000000..dbe3b419d
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/convert_goldmasters/xunit_test.go
@@ -0,0 +1,44 @@
+package tmp
+
+import (
+ . "github.com/onsi/ginkgo"
+)
+
+var _ = Describe("Testing with Ginkgo", func() {
+ It("something important", func() {
+
+ whatever := &UselessStruct{
+ T: GinkgoT(),
+ ImportantField: "SECRET_PASSWORD",
+ }
+ something := &UselessStruct{ImportantField: "string value"}
+ assertEqual(GinkgoT(), whatever.ImportantField, "SECRET_PASSWORD")
+ assertEqual(GinkgoT(), something.ImportantField, "string value")
+
+ var foo = func(t GinkgoTInterface) {}
+ foo(GinkgoT())
+
+ strp := "something"
+ testFunc(GinkgoT(), &strp)
+ GinkgoT().Fail()
+ })
+ It("3 things", func() {
+
+ if 3 != 3 {
+ GinkgoT().Fail()
+ }
+ })
+})
+
+type UselessStruct struct {
+ ImportantField string
+ T GinkgoTInterface
+}
+
+var testFunc = func(t GinkgoTInterface, arg *string) {}
+
+func assertEqual(t GinkgoTInterface, arg1, arg2 interface{}) {
+ if arg1 != arg2 {
+ t.Fail()
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/coverage.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/coverage.go
new file mode 100644
index 000000000..e4d7e43b1
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/coverage.go
@@ -0,0 +1,25 @@
+package coverage_fixture
+
+import (
+ _ "github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/external_coverage_fixture"
+)
+
+func A() string {
+ return "A"
+}
+
+func B() string {
+ return "B"
+}
+
+func C() string {
+ return "C"
+}
+
+func D() string {
+ return "D"
+}
+
+func E() string {
+ return "untested"
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/coverage_fixture_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/coverage_fixture_suite_test.go
new file mode 100644
index 000000000..2831bf7d2
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/coverage_fixture_suite_test.go
@@ -0,0 +1,13 @@
+package coverage_fixture_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestCoverageFixture(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "CoverageFixture Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/coverage_fixture_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/coverage_fixture_test.go
new file mode 100644
index 000000000..12a72dce8
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/coverage_fixture_test.go
@@ -0,0 +1,31 @@
+package coverage_fixture_test
+
+import (
+ . "github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture"
+ . "github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/external_coverage_fixture"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("CoverageFixture", func() {
+ It("should test A", func() {
+ Ω(A()).Should(Equal("A"))
+ })
+
+ It("should test B", func() {
+ Ω(B()).Should(Equal("B"))
+ })
+
+ It("should test C", func() {
+ Ω(C()).Should(Equal("C"))
+ })
+
+ It("should test D", func() {
+ Ω(D()).Should(Equal("D"))
+ })
+
+ It("should test external package", func() {
+ Ω(Tested()).Should(Equal("tested"))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/external_coverage_fixture/external_coverage.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/external_coverage_fixture/external_coverage.go
new file mode 100644
index 000000000..5280d4ddf
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/external_coverage_fixture/external_coverage.go
@@ -0,0 +1,9 @@
+package external_coverage
+
+func Tested() string {
+ return "tested"
+}
+
+func Untested() string {
+ return "untested"
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/debug_parallel_fixture/debug_parallel_fixture_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/debug_parallel_fixture/debug_parallel_fixture_suite_test.go
new file mode 100644
index 000000000..429aebc5f
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/debug_parallel_fixture/debug_parallel_fixture_suite_test.go
@@ -0,0 +1,13 @@
+package debug_parallel_fixture_test
+
+import (
+ "testing"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+func TestDebugParallelFixture(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "DebugParallelFixture Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/debug_parallel_fixture/debug_parallel_fixture_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/debug_parallel_fixture/debug_parallel_fixture_test.go
new file mode 100644
index 000000000..b609a8bca
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/debug_parallel_fixture/debug_parallel_fixture_test.go
@@ -0,0 +1,18 @@
+package debug_parallel_fixture_test
+
+import (
+ "fmt"
+ "time"
+
+ . "github.com/onsi/ginkgo"
+)
+
+var _ = Describe("DebugParallelFixture", func() {
+ It("emits output to a file", func() {
+ for i := 0; i < 10; i += 1 {
+ fmt.Printf("StdOut %d\n", i)
+ GinkgoWriter.Write([]byte(fmt.Sprintf("GinkgoWriter %d\n", i)))
+ }
+ time.Sleep(time.Second)
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/does_not_compile/does_not_compile_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/does_not_compile/does_not_compile_suite_test.go
new file mode 100644
index 000000000..01e792696
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/does_not_compile/does_not_compile_suite_test.go
@@ -0,0 +1,13 @@
+package does_not_compile_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestDoes_not_compile(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Does_not_compile Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/does_not_compile/does_not_compile_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/does_not_compile/does_not_compile_test.go
new file mode 100644
index 000000000..e4f22b3cc
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/does_not_compile/does_not_compile_test.go
@@ -0,0 +1,11 @@
+package does_not_compile_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/integration/_fixtures/does_not_compile"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("DoesNotCompile", func() {
+
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/eventually_failing/eventually_failing_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/eventually_failing/eventually_failing_suite_test.go
new file mode 100644
index 000000000..97fa2e775
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/eventually_failing/eventually_failing_suite_test.go
@@ -0,0 +1,13 @@
+package eventually_failing_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestEventuallyFailing(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "EventuallyFailing Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/eventually_failing/eventually_failing_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/eventually_failing/eventually_failing_test.go
new file mode 100644
index 000000000..6c83b4258
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/eventually_failing/eventually_failing_test.go
@@ -0,0 +1,29 @@
+package eventually_failing_test
+
+import (
+ "fmt"
+ "io/ioutil"
+ "strings"
+ "time"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("EventuallyFailing", func() {
+ It("should fail on the third try", func() {
+ time.Sleep(time.Second)
+ files, err := ioutil.ReadDir(".")
+ Ω(err).ShouldNot(HaveOccurred())
+
+ numRuns := 1
+ for _, file := range files {
+ if strings.HasPrefix(file.Name(), "counter") {
+ numRuns++
+ }
+ }
+
+ Ω(numRuns).Should(BeNumerically("<", 3))
+ ioutil.WriteFile(fmt.Sprintf("./counter-%d", numRuns), []byte("foo"), 0777)
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/exiting_synchronized_setup_tests/exiting_synchronized_setup_tests_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/exiting_synchronized_setup_tests/exiting_synchronized_setup_tests_suite_test.go
new file mode 100644
index 000000000..045ca7c66
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/exiting_synchronized_setup_tests/exiting_synchronized_setup_tests_suite_test.go
@@ -0,0 +1,35 @@
+package synchronized_setup_tests_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "fmt"
+ "os"
+ "testing"
+)
+
+func TestSynchronized_setup_tests(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Synchronized_setup_tests Suite")
+}
+
+var beforeData string
+
+var _ = SynchronizedBeforeSuite(func() []byte {
+ fmt.Printf("BEFORE_A_%d\n", GinkgoParallelNode())
+ os.Exit(1)
+ return []byte("WHAT EVZ")
+}, func(data []byte) {
+ println("NEVER SEE THIS")
+})
+
+var _ = Describe("Synchronized Setup", func() {
+ It("should do nothing", func() {
+ Ω(true).Should(BeTrue())
+ })
+
+ It("should do nothing", func() {
+ Ω(true).Should(BeTrue())
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/fail_fixture/fail_fixture_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/fail_fixture/fail_fixture_suite_test.go
new file mode 100644
index 000000000..6e822643a
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/fail_fixture/fail_fixture_suite_test.go
@@ -0,0 +1,13 @@
+package fail_fixture_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestFail_fixture(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Fail_fixture Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/fail_fixture/fail_fixture_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/fail_fixture/fail_fixture_test.go
new file mode 100644
index 000000000..ea6f71ca9
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/fail_fixture/fail_fixture_test.go
@@ -0,0 +1,103 @@
+package fail_fixture_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = It("handles top level failures", func() {
+ Ω("a top level failure on line 9").Should(Equal("nope"))
+ println("NEVER SEE THIS")
+})
+
+var _ = It("handles async top level failures", func(done Done) {
+ Fail("an async top level failure on line 14")
+ println("NEVER SEE THIS")
+}, 0.1)
+
+var _ = It("FAIL in a goroutine", func(done Done) {
+ go func() {
+ defer GinkgoRecover()
+ Fail("a top level goroutine failure on line 21")
+ println("NEVER SEE THIS")
+ }()
+}, 0.1)
+
+var _ = Describe("Excercising different failure modes", func() {
+ It("synchronous failures", func() {
+ Ω("a sync failure").Should(Equal("nope"))
+ println("NEVER SEE THIS")
+ })
+
+ It("synchronous panics", func() {
+ panic("a sync panic")
+ println("NEVER SEE THIS")
+ })
+
+ It("synchronous failures with FAIL", func() {
+ Fail("a sync FAIL failure")
+ println("NEVER SEE THIS")
+ })
+
+ It("async timeout", func(done Done) {
+ Ω(true).Should(BeTrue())
+ }, 0.1)
+
+ It("async failure", func(done Done) {
+ Ω("an async failure").Should(Equal("nope"))
+ println("NEVER SEE THIS")
+ }, 0.1)
+
+ It("async panic", func(done Done) {
+ panic("an async panic")
+ println("NEVER SEE THIS")
+ }, 0.1)
+
+ It("async failure with FAIL", func(done Done) {
+ Fail("an async FAIL failure")
+ println("NEVER SEE THIS")
+ }, 0.1)
+
+ It("FAIL in a goroutine", func(done Done) {
+ go func() {
+ defer GinkgoRecover()
+ Fail("a goroutine FAIL failure")
+ println("NEVER SEE THIS")
+ }()
+ }, 0.1)
+
+ It("Gomega in a goroutine", func(done Done) {
+ go func() {
+ defer GinkgoRecover()
+ Ω("a goroutine failure").Should(Equal("nope"))
+ println("NEVER SEE THIS")
+ }()
+ }, 0.1)
+
+ It("Panic in a goroutine", func(done Done) {
+ go func() {
+ defer GinkgoRecover()
+ panic("a goroutine panic")
+ println("NEVER SEE THIS")
+ }()
+ }, 0.1)
+
+ Measure("a FAIL measure", func(Benchmarker) {
+ Fail("a measure FAIL failure")
+ println("NEVER SEE THIS")
+ }, 1)
+
+ Measure("a gomega failed measure", func(Benchmarker) {
+ Ω("a measure failure").Should(Equal("nope"))
+ println("NEVER SEE THIS")
+ }, 1)
+
+ Measure("a panicking measure", func(Benchmarker) {
+ panic("a measure panic")
+ println("NEVER SEE THIS")
+ }, 1)
+})
+
+var _ = Specify("a top level specify", func() {
+ Fail("fail the test")
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_after_suite/failing_after_suite_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_after_suite/failing_after_suite_suite_test.go
new file mode 100644
index 000000000..0e410aaea
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_after_suite/failing_after_suite_suite_test.go
@@ -0,0 +1,22 @@
+package failing_before_suite_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestFailingAfterSuite(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "FailingAfterSuite Suite")
+}
+
+var _ = BeforeSuite(func() {
+ println("BEFORE SUITE")
+})
+
+var _ = AfterSuite(func() {
+ println("AFTER SUITE")
+ panic("BAM!")
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_after_suite/failing_after_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_after_suite/failing_after_suite_test.go
new file mode 100644
index 000000000..3902ec6c5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_after_suite/failing_after_suite_test.go
@@ -0,0 +1,15 @@
+package failing_before_suite_test
+
+import (
+ . "github.com/onsi/ginkgo"
+)
+
+var _ = Describe("FailingBeforeSuite", func() {
+ It("should run", func() {
+ println("A TEST")
+ })
+
+ It("should run", func() {
+ println("A TEST")
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_before_suite/failing_before_suite_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_before_suite/failing_before_suite_suite_test.go
new file mode 100644
index 000000000..109ea3608
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_before_suite/failing_before_suite_suite_test.go
@@ -0,0 +1,22 @@
+package failing_before_suite_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestFailing_before_suite(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Failing_before_suite Suite")
+}
+
+var _ = BeforeSuite(func() {
+ println("BEFORE SUITE")
+ panic("BAM!")
+})
+
+var _ = AfterSuite(func() {
+ println("AFTER SUITE")
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_before_suite/failing_before_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_before_suite/failing_before_suite_test.go
new file mode 100644
index 000000000..e8697c64a
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_before_suite/failing_before_suite_test.go
@@ -0,0 +1,15 @@
+package failing_before_suite_test
+
+import (
+ . "github.com/onsi/ginkgo"
+)
+
+var _ = Describe("FailingBeforeSuite", func() {
+ It("should never run", func() {
+ println("NEVER SEE THIS")
+ })
+
+ It("should never run", func() {
+ println("NEVER SEE THIS")
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_ginkgo_tests/failing_ginkgo_tests.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_ginkgo_tests/failing_ginkgo_tests.go
new file mode 100644
index 000000000..e32cd619e
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_ginkgo_tests/failing_ginkgo_tests.go
@@ -0,0 +1,5 @@
+package failing_ginkgo_tests
+
+func AlwaysFalse() bool {
+ return false
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_ginkgo_tests/failing_ginkgo_tests_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_ginkgo_tests/failing_ginkgo_tests_suite_test.go
new file mode 100644
index 000000000..49939bda5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_ginkgo_tests/failing_ginkgo_tests_suite_test.go
@@ -0,0 +1,13 @@
+package failing_ginkgo_tests_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestFailing_ginkgo_tests(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Failing_ginkgo_tests Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_ginkgo_tests/failing_ginkgo_tests_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_ginkgo_tests/failing_ginkgo_tests_test.go
new file mode 100644
index 000000000..d9c01e32c
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/failing_ginkgo_tests/failing_ginkgo_tests_test.go
@@ -0,0 +1,17 @@
+package failing_ginkgo_tests_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/integration/_fixtures/failing_ginkgo_tests"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("FailingGinkgoTests", func() {
+ It("should fail", func() {
+ Ω(AlwaysFalse()).Should(BeTrue())
+ })
+
+ It("should pass", func() {
+ Ω(AlwaysFalse()).Should(BeFalse())
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/flags_tests/flags.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/flags_tests/flags.go
new file mode 100644
index 000000000..a440abdaa
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/flags_tests/flags.go
@@ -0,0 +1,9 @@
+package flags
+
+func Tested() string {
+ return "tested"
+}
+
+func Untested() string {
+ return "untested"
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/flags_tests/flags_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/flags_tests/flags_suite_test.go
new file mode 100644
index 000000000..0b3071f62
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/flags_tests/flags_suite_test.go
@@ -0,0 +1,13 @@
+package flags_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestFlags(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Flags Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/flags_tests/flags_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/flags_tests/flags_test.go
new file mode 100644
index 000000000..27dadf19c
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/flags_tests/flags_test.go
@@ -0,0 +1,97 @@
+package flags_test
+
+import (
+ "flag"
+ "fmt"
+ remapped "math"
+ _ "math/cmplx"
+ "time"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/integration/_fixtures/flags_tests"
+ . "github.com/onsi/gomega"
+)
+
+var customFlag string
+
+func init() {
+ flag.StringVar(&customFlag, "customFlag", "default", "custom flag!")
+}
+
+var _ = Describe("Testing various flags", func() {
+ FDescribe("the focused set", func() {
+ Measure("a measurement", func(b Benchmarker) {
+ b.RecordValue("a value", 3)
+ }, 3)
+
+ It("should honor -cover", func() {
+ Ω(Tested()).Should(Equal("tested"))
+ })
+
+ It("should allow gcflags", func() {
+ fmt.Printf("NaN returns %T\n", remapped.NaN())
+ })
+
+ PIt("should honor -failOnPending and -noisyPendings")
+
+ Describe("smores", func() {
+ It("should honor -skip: marshmallow", func() {
+ println("marshmallow")
+ })
+
+ It("should honor -focus: chocolate", func() {
+ println("chocolate")
+ })
+ })
+
+ It("should detect races", func(done Done) {
+ var a string
+ go func() {
+ a = "now you don't"
+ close(done)
+ }()
+ a = "now you see me"
+ println(a)
+ })
+
+ It("should randomize A", func() {
+ println("RANDOM_A")
+ })
+
+ It("should randomize B", func() {
+ println("RANDOM_B")
+ })
+
+ It("should randomize C", func() {
+ println("RANDOM_C")
+ })
+
+ It("should honor -slowSpecThreshold", func() {
+ time.Sleep(100 * time.Millisecond)
+ })
+
+ It("should pass in additional arguments after '--' directly to the test process", func() {
+ fmt.Printf("CUSTOM_FLAG: %s", customFlag)
+ })
+ })
+
+ Describe("more smores", func() {
+ It("should not run these unless -focus is set", func() {
+ println("smores")
+ })
+ })
+
+ Describe("a failing test", func() {
+ It("should fail", func() {
+ Ω(true).Should(Equal(false))
+ })
+ })
+
+ Describe("a flaky test", func() {
+ runs := 0
+ It("should only pass the second time it's run", func() {
+ runs++
+ Ω(runs).Should(BeNumerically("==", 2))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture/README.md b/vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture/README.md
new file mode 100644
index 000000000..2b501a25d
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture/README.md
@@ -0,0 +1 @@
+This file should remain the same, regardless the fact that contains FIt, FDescribe, or FWhen.
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture/focused_fixture_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture/focused_fixture_suite_test.go
new file mode 100644
index 000000000..92d0c6e48
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture/focused_fixture_suite_test.go
@@ -0,0 +1,13 @@
+package focused_fixture_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestFocused_fixture(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Focused_fixture Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture/focused_fixture_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture/focused_fixture_test.go
new file mode 100644
index 000000000..ea500eaf0
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture/focused_fixture_test.go
@@ -0,0 +1,73 @@
+package focused_fixture_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/extensions/table"
+)
+
+var _ = Describe("FocusedFixture", func() {
+ FDescribe("focused", func() {
+ It("focused", func() {
+
+ })
+ })
+
+ FContext("focused", func() {
+ It("focused", func() {
+
+ })
+ })
+
+ FWhen("focused", func() {
+ It("focused", func() {
+
+ })
+ })
+
+ FIt("focused", func() {
+
+ })
+
+ FSpecify("focused", func() {
+
+ })
+
+ FMeasure("focused", func(b Benchmarker) {
+
+ }, 2)
+
+ FDescribeTable("focused",
+ func() {},
+ Entry("focused"),
+ )
+
+ DescribeTable("focused",
+ func() {},
+ FEntry("focused"),
+ )
+
+ Describe("not focused", func() {
+ It("not focused", func() {
+
+ })
+ })
+
+ Context("not focused", func() {
+ It("not focused", func() {
+
+ })
+ })
+
+ It("not focused", func() {
+
+ })
+
+ Measure("not focused", func(b Benchmarker) {
+
+ }, 2)
+
+ DescribeTable("not focused",
+ func() {},
+ Entry("not focused"),
+ )
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture_with_vendor/focused_fixture_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture_with_vendor/focused_fixture_suite_test.go
new file mode 100644
index 000000000..92d0c6e48
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture_with_vendor/focused_fixture_suite_test.go
@@ -0,0 +1,13 @@
+package focused_fixture_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestFocused_fixture(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Focused_fixture Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture_with_vendor/focused_fixture_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture_with_vendor/focused_fixture_test.go
new file mode 100644
index 000000000..ea500eaf0
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/focused_fixture_with_vendor/focused_fixture_test.go
@@ -0,0 +1,73 @@
+package focused_fixture_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/extensions/table"
+)
+
+var _ = Describe("FocusedFixture", func() {
+ FDescribe("focused", func() {
+ It("focused", func() {
+
+ })
+ })
+
+ FContext("focused", func() {
+ It("focused", func() {
+
+ })
+ })
+
+ FWhen("focused", func() {
+ It("focused", func() {
+
+ })
+ })
+
+ FIt("focused", func() {
+
+ })
+
+ FSpecify("focused", func() {
+
+ })
+
+ FMeasure("focused", func(b Benchmarker) {
+
+ }, 2)
+
+ FDescribeTable("focused",
+ func() {},
+ Entry("focused"),
+ )
+
+ DescribeTable("focused",
+ func() {},
+ FEntry("focused"),
+ )
+
+ Describe("not focused", func() {
+ It("not focused", func() {
+
+ })
+ })
+
+ Context("not focused", func() {
+ It("not focused", func() {
+
+ })
+ })
+
+ It("not focused", func() {
+
+ })
+
+ Measure("not focused", func(b Benchmarker) {
+
+ }, 2)
+
+ DescribeTable("not focused",
+ func() {},
+ Entry("not focused"),
+ )
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/hanging_suite/hanging_suite_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/hanging_suite/hanging_suite_suite_test.go
new file mode 100644
index 000000000..e8dd54b52
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/hanging_suite/hanging_suite_suite_test.go
@@ -0,0 +1,13 @@
+package hanging_suite_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestHangingSuite(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "HangingSuite Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/hanging_suite/hanging_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/hanging_suite/hanging_suite_test.go
new file mode 100644
index 000000000..6a5a070e1
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/hanging_suite/hanging_suite_test.go
@@ -0,0 +1,30 @@
+package hanging_suite_test
+
+import (
+ "fmt"
+ "time"
+
+ . "github.com/onsi/ginkgo"
+)
+
+var _ = AfterSuite(func() {
+ fmt.Println("Heading Out After Suite")
+})
+
+var _ = Describe("HangingSuite", func() {
+ BeforeEach(func() {
+ fmt.Fprintln(GinkgoWriter, "Just beginning")
+ })
+
+ Context("inner context", func() {
+ BeforeEach(func() {
+ fmt.Fprintln(GinkgoWriter, "Almost there...")
+ })
+
+ It("should hang out for a while", func() {
+ fmt.Fprintln(GinkgoWriter, "Hanging Out")
+ fmt.Println("Sleeping...")
+ time.Sleep(time.Hour)
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/more_ginkgo_tests/more_ginkgo_tests.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/more_ginkgo_tests/more_ginkgo_tests.go
new file mode 100644
index 000000000..ca12c0d93
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/more_ginkgo_tests/more_ginkgo_tests.go
@@ -0,0 +1,5 @@
+package more_ginkgo_tests
+
+func AlwaysTrue() bool {
+ return true
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/more_ginkgo_tests/more_ginkgo_tests_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/more_ginkgo_tests/more_ginkgo_tests_suite_test.go
new file mode 100644
index 000000000..1e15c8857
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/more_ginkgo_tests/more_ginkgo_tests_suite_test.go
@@ -0,0 +1,13 @@
+package more_ginkgo_tests_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestMore_ginkgo_tests(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "More_ginkgo_tests Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/more_ginkgo_tests/more_ginkgo_tests_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/more_ginkgo_tests/more_ginkgo_tests_test.go
new file mode 100644
index 000000000..0549f62fb
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/more_ginkgo_tests/more_ginkgo_tests_test.go
@@ -0,0 +1,17 @@
+package more_ginkgo_tests_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/integration/_fixtures/more_ginkgo_tests"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("MoreGinkgoTests", func() {
+ It("should pass", func() {
+ Ω(AlwaysTrue()).Should(BeTrue())
+ })
+
+ It("should always pass", func() {
+ Ω(AlwaysTrue()).Should(BeTrue())
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/no_test_fn/no_test_fn.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/no_test_fn/no_test_fn.go
new file mode 100644
index 000000000..bdf1b54b5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/no_test_fn/no_test_fn.go
@@ -0,0 +1,5 @@
+package no_test_fn
+
+func StringIdentity(a string) string {
+ return a
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/no_test_fn/no_test_fn_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/no_test_fn/no_test_fn_test.go
new file mode 100644
index 000000000..6c38b1e43
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/no_test_fn/no_test_fn_test.go
@@ -0,0 +1,13 @@
+package no_test_fn_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/integration/_fixtures/no_test_fn"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("NoTestFn", func() {
+ It("should proxy strings", func() {
+ Ω(StringIdentity("foo")).Should(Equal("foo"))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/no_tests/no_tests.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/no_tests/no_tests.go
new file mode 100644
index 000000000..da29a2cad
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/no_tests/no_tests.go
@@ -0,0 +1,4 @@
+package main
+
+func main() {
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_ginkgo_tests/passing_ginkgo_tests.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_ginkgo_tests/passing_ginkgo_tests.go
new file mode 100644
index 000000000..b710dd129
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_ginkgo_tests/passing_ginkgo_tests.go
@@ -0,0 +1,9 @@
+package passing_ginkgo_tests
+
+func StringIdentity(a string) string {
+ return a
+}
+
+func IntegerIdentity(a int) int {
+ return a
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_ginkgo_tests/passing_ginkgo_tests_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_ginkgo_tests/passing_ginkgo_tests_suite_test.go
new file mode 100644
index 000000000..31a3f7d0c
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_ginkgo_tests/passing_ginkgo_tests_suite_test.go
@@ -0,0 +1,13 @@
+package passing_ginkgo_tests_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestPassing_ginkgo_tests(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Passing_ginkgo_tests Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_ginkgo_tests/passing_ginkgo_tests_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_ginkgo_tests/passing_ginkgo_tests_test.go
new file mode 100644
index 000000000..a5822fdd7
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_ginkgo_tests/passing_ginkgo_tests_test.go
@@ -0,0 +1,30 @@
+package passing_ginkgo_tests_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/integration/_fixtures/passing_ginkgo_tests"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("PassingGinkgoTests", func() {
+ It("should proxy strings", func() {
+ Ω(StringIdentity("foo")).Should(Equal("foo"))
+ })
+
+ It("should proxy integers", func() {
+ Ω(IntegerIdentity(3)).Should(Equal(3))
+ })
+
+ It("should do it again", func() {
+ Ω(StringIdentity("foo")).Should(Equal("foo"))
+ Ω(IntegerIdentity(3)).Should(Equal(3))
+ })
+
+ It("should be able to run Bys", func() {
+ By("emitting one By")
+ Ω(3).Should(Equal(3))
+
+ By("emitting another By")
+ Ω(4).Should(Equal(4))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_suite_setup/passing_suite_setup_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_suite_setup/passing_suite_setup_suite_test.go
new file mode 100644
index 000000000..86c9aa2ab
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_suite_setup/passing_suite_setup_suite_test.go
@@ -0,0 +1,26 @@
+package passing_before_suite_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestPassingSuiteSetup(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "PassingSuiteSetup Suite")
+}
+
+var a string
+var b string
+
+var _ = BeforeSuite(func() {
+ a = "ran before suite"
+ println("BEFORE SUITE")
+})
+
+var _ = AfterSuite(func() {
+ b = "ran after suite"
+ println("AFTER SUITE")
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_suite_setup/passing_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_suite_setup/passing_suite_test.go
new file mode 100644
index 000000000..f139e1d22
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/passing_suite_setup/passing_suite_test.go
@@ -0,0 +1,28 @@
+package passing_before_suite_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("PassingSuiteSetup", func() {
+ It("should pass", func() {
+ Ω(a).Should(Equal("ran before suite"))
+ Ω(b).Should(BeEmpty())
+ })
+
+ It("should pass", func() {
+ Ω(a).Should(Equal("ran before suite"))
+ Ω(b).Should(BeEmpty())
+ })
+
+ It("should pass", func() {
+ Ω(a).Should(Equal("ran before suite"))
+ Ω(b).Should(BeEmpty())
+ })
+
+ It("should pass", func() {
+ Ω(a).Should(Equal("ran before suite"))
+ Ω(b).Should(BeEmpty())
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/progress_fixture/progress_fixture_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/progress_fixture/progress_fixture_suite_test.go
new file mode 100644
index 000000000..74262bbc1
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/progress_fixture/progress_fixture_suite_test.go
@@ -0,0 +1,13 @@
+package progress_fixture_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestProgressFixture(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "ProgressFixture Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/progress_fixture/progress_fixture_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/progress_fixture/progress_fixture_test.go
new file mode 100644
index 000000000..b7f26c25b
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/progress_fixture/progress_fixture_test.go
@@ -0,0 +1,49 @@
+package progress_fixture_test
+
+import (
+ "fmt"
+
+ . "github.com/onsi/ginkgo"
+)
+
+var _ = Describe("ProgressFixture", func() {
+ BeforeEach(func() {
+ fmt.Fprintln(GinkgoWriter, ">outer before<")
+ })
+
+ JustBeforeEach(func() {
+ fmt.Fprintln(GinkgoWriter, ">outer just before<")
+ })
+
+ AfterEach(func() {
+ fmt.Fprintln(GinkgoWriter, ">outer after<")
+ })
+
+ Context("Inner Context", func() {
+ BeforeEach(func() {
+ fmt.Fprintln(GinkgoWriter, ">inner before<")
+ })
+
+ JustBeforeEach(func() {
+ fmt.Fprintln(GinkgoWriter, ">inner just before<")
+ })
+
+ AfterEach(func() {
+ fmt.Fprintln(GinkgoWriter, ">inner after<")
+ })
+
+ When("Inner When", func() {
+ BeforeEach(func() {
+ fmt.Fprintln(GinkgoWriter, ">inner before<")
+ })
+
+ It("should emit progress as it goes", func() {
+ fmt.Fprintln(GinkgoWriter, ">it<")
+ })
+ })
+ })
+
+ Specify("should emit progress as it goes", func() {
+ fmt.Fprintln(GinkgoWriter, ">specify<")
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/skip_fixture/skip_fixture_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/skip_fixture/skip_fixture_suite_test.go
new file mode 100644
index 000000000..b2028cf55
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/skip_fixture/skip_fixture_suite_test.go
@@ -0,0 +1,13 @@
+package fail_fixture_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestFail_fixture(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Skip_fixture Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/skip_fixture/skip_fixture_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/skip_fixture/skip_fixture_test.go
new file mode 100644
index 000000000..e406aeb46
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/skip_fixture/skip_fixture_test.go
@@ -0,0 +1,71 @@
+package fail_fixture_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = It("handles top level skips", func() {
+ Skip("a top level skip on line 9")
+ println("NEVER SEE THIS")
+})
+
+var _ = It("handles async top level skips", func(done Done) {
+ Skip("an async top level skip on line 14")
+ println("NEVER SEE THIS")
+}, 0.1)
+
+var _ = It("SKIP in a goroutine", func(done Done) {
+ go func() {
+ defer GinkgoRecover()
+ Skip("a top level goroutine skip on line 21")
+ println("NEVER SEE THIS")
+ }()
+}, 0.1)
+
+var _ = Describe("Excercising different skip modes", func() {
+ It("synchronous skip", func() {
+ Skip("a sync SKIP")
+ println("NEVER SEE THIS")
+ })
+
+ It("async skip", func(done Done) {
+ Skip("an async SKIP")
+ println("NEVER SEE THIS")
+ }, 0.1)
+
+ It("SKIP in a goroutine", func(done Done) {
+ go func() {
+ defer GinkgoRecover()
+ Skip("a goroutine SKIP")
+ println("NEVER SEE THIS")
+ }()
+ }, 0.1)
+
+ Measure("a SKIP measure", func(Benchmarker) {
+ Skip("a measure SKIP")
+ println("NEVER SEE THIS")
+ }, 1)
+})
+
+var _ = Describe("SKIP in a BeforeEach", func() {
+ BeforeEach(func() {
+ Skip("a BeforeEach SKIP")
+ println("NEVER SEE THIS")
+ })
+
+ It("a SKIP BeforeEach", func() {
+ println("NEVER SEE THIS")
+ })
+})
+
+var _ = Describe("SKIP in an AfterEach", func() {
+ AfterEach(func() {
+ Skip("an AfterEach SKIP")
+ println("NEVER SEE THIS")
+ })
+
+ It("a SKIP AfterEach", func() {
+ Expect(true).To(BeTrue())
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/suite_command_tests/suite_command.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/suite_command_tests/suite_command.go
new file mode 100644
index 000000000..1d6704881
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/suite_command_tests/suite_command.go
@@ -0,0 +1,9 @@
+package suite_command
+
+func Tested() string {
+ return "tested"
+}
+
+func Untested() string {
+ return "untested"
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/suite_command_tests/suite_command_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/suite_command_tests/suite_command_suite_test.go
new file mode 100644
index 000000000..7f76d8b8f
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/suite_command_tests/suite_command_suite_test.go
@@ -0,0 +1,13 @@
+package suite_command_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestSuiteCommand(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Suite Command Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/suite_command_tests/suite_command_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/suite_command_tests/suite_command_test.go
new file mode 100644
index 000000000..e083d27a2
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/suite_command_tests/suite_command_test.go
@@ -0,0 +1,18 @@
+package suite_command_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Testing suite command", func() {
+ It("it should succeed", func() {
+ Ω(true).Should(Equal(true))
+ })
+
+ PIt("a failing test", func() {
+ It("should fail", func() {
+ Ω(true).Should(Equal(false))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/synchronized_setup_tests/synchronized_setup_tests_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/synchronized_setup_tests/synchronized_setup_tests_suite_test.go
new file mode 100644
index 000000000..b734854ee
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/synchronized_setup_tests/synchronized_setup_tests_suite_test.go
@@ -0,0 +1,43 @@
+package synchronized_setup_tests_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "fmt"
+ "testing"
+ "time"
+)
+
+func TestSynchronized_setup_tests(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Synchronized_setup_tests Suite")
+}
+
+var beforeData string
+
+var _ = SynchronizedBeforeSuite(func() []byte {
+ fmt.Printf("BEFORE_A_%d\n", GinkgoParallelNode())
+ time.Sleep(100 * time.Millisecond)
+ return []byte("DATA")
+}, func(data []byte) {
+ fmt.Printf("BEFORE_B_%d: %s\n", GinkgoParallelNode(), string(data))
+ beforeData += string(data) + "OTHER"
+})
+
+var _ = SynchronizedAfterSuite(func() {
+ fmt.Printf("\nAFTER_A_%d\n", GinkgoParallelNode())
+ time.Sleep(100 * time.Millisecond)
+}, func() {
+ fmt.Printf("AFTER_B_%d\n", GinkgoParallelNode())
+})
+
+var _ = Describe("Synchronized Setup", func() {
+ It("should run the before suite once", func() {
+ Ω(beforeData).Should(Equal("DATAOTHER"))
+ })
+
+ It("should run the before suite once", func() {
+ Ω(beforeData).Should(Equal("DATAOTHER"))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/tags_tests/ignored_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/tags_tests/ignored_test.go
new file mode 100644
index 000000000..517623536
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/tags_tests/ignored_test.go
@@ -0,0 +1,17 @@
+// +build complex_tests
+
+package tags_tests_test
+
+import (
+ . "github.com/onsi/ginkgo"
+)
+
+var _ = Describe("Ignored", func() {
+ It("should not have these tests", func() {
+
+ })
+
+ It("should not have these tests", func() {
+
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/tags_tests/tags_tests_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/tags_tests/tags_tests_suite_test.go
new file mode 100644
index 000000000..dcb11bb1b
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/tags_tests/tags_tests_suite_test.go
@@ -0,0 +1,13 @@
+package tags_tests_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestTagsTests(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "TagsTests Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/tags_tests/tags_tests_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/tags_tests/tags_tests_test.go
new file mode 100644
index 000000000..b91a8923a
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/tags_tests/tags_tests_test.go
@@ -0,0 +1,11 @@
+package tags_tests_test
+
+import (
+ . "github.com/onsi/ginkgo"
+)
+
+var _ = Describe("TagsTests", func() {
+ It("should have a test", func() {
+
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/test_description/test_description_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/test_description/test_description_suite_test.go
new file mode 100644
index 000000000..8976370d3
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/test_description/test_description_suite_test.go
@@ -0,0 +1,13 @@
+package test_description_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestTestDescription(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "TestDescription Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/test_description/test_description_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/test_description/test_description_test.go
new file mode 100644
index 000000000..53c2779ea
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/test_description/test_description_test.go
@@ -0,0 +1,23 @@
+package test_description_test
+
+import (
+ "fmt"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("TestDescription", func() {
+ It("should pass", func() {
+ Ω(true).Should(BeTrue())
+ })
+
+ It("should fail", func() {
+ Ω(true).Should(BeFalse())
+ })
+
+ AfterEach(func() {
+ description := CurrentGinkgoTestDescription()
+ fmt.Printf("%s:%t\n", description.FullTestText, description.Failed)
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A/A.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A/A.go
new file mode 100644
index 000000000..de2c6bbb7
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A/A.go
@@ -0,0 +1,7 @@
+package A
+
+import "github.com/onsi/B"
+
+func DoIt() string {
+ return B.DoIt()
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A/A_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A/A_suite_test.go
new file mode 100644
index 000000000..1b6cff4c7
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A/A_suite_test.go
@@ -0,0 +1,13 @@
+package A_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestA(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "A Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A/A_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A/A_test.go
new file mode 100644
index 000000000..003530aae
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A/A_test.go
@@ -0,0 +1,14 @@
+package A_test
+
+import (
+ . "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/A"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("A", func() {
+ It("should do it", func() {
+ Ω(DoIt()).Should(Equal("done!"))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B/B.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B/B.go
new file mode 100644
index 000000000..990bab365
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B/B.go
@@ -0,0 +1,7 @@
+package B
+
+import "github.com/onsi/C"
+
+func DoIt() string {
+ return C.DoIt()
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B/B_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B/B_suite_test.go
new file mode 100644
index 000000000..e54fce668
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B/B_suite_test.go
@@ -0,0 +1,13 @@
+package B_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestB(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "B Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B/B_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B/B_test.go
new file mode 100644
index 000000000..b147913c0
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B/B_test.go
@@ -0,0 +1,14 @@
+package B_test
+
+import (
+ . "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/B"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("B", func() {
+ It("should do it", func() {
+ Ω(DoIt()).Should(Equal("done!"))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C.go
new file mode 100644
index 000000000..205b68886
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C.go
@@ -0,0 +1,5 @@
+package C
+
+func DoIt() string {
+ return "done!"
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C.json b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C.json
new file mode 100644
index 000000000..421d025e0
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C.json
@@ -0,0 +1,3 @@
+{
+ "fixture": "data"
+} \ No newline at end of file
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C_suite_test.go
new file mode 100644
index 000000000..57a7a96ba
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C_suite_test.go
@@ -0,0 +1,13 @@
+package C_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestC(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "C Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C_test.go
new file mode 100644
index 000000000..7703fefa3
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C/C_test.go
@@ -0,0 +1,14 @@
+package C_test
+
+import (
+ . "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("C", func() {
+ It("should do it", func() {
+ Ω(DoIt()).Should(Equal("done!"))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/D/D.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/D/D.go
new file mode 100644
index 000000000..4371b852f
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/D/D.go
@@ -0,0 +1,7 @@
+package D
+
+import "github.com/onsi/C"
+
+func DoIt() string {
+ return C.DoIt()
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/D/D_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/D/D_suite_test.go
new file mode 100644
index 000000000..0ebefe6b7
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/D/D_suite_test.go
@@ -0,0 +1,13 @@
+package D_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestD(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "D Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/D/D_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/D/D_test.go
new file mode 100644
index 000000000..097945bf9
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/D/D_test.go
@@ -0,0 +1,14 @@
+package D_test
+
+import (
+ . "github.com/onsi/ginkgo/integration/_fixtures/watch_fixtures/C"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("D", func() {
+ It("should do it", func() {
+ Ω(DoIt()).Should(Equal("done!"))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/xunit_tests/xunit_tests.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/xunit_tests/xunit_tests.go
new file mode 100644
index 000000000..cb8fc8bc2
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/xunit_tests/xunit_tests.go
@@ -0,0 +1,5 @@
+package xunit_tests
+
+func AlwaysTrue() bool {
+ return true
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/_fixtures/xunit_tests/xunit_tests_test.go b/vendor/github.com/onsi/ginkgo/integration/_fixtures/xunit_tests/xunit_tests_test.go
new file mode 100644
index 000000000..a6ebbe147
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/_fixtures/xunit_tests/xunit_tests_test.go
@@ -0,0 +1,11 @@
+package xunit_tests
+
+import (
+ "testing"
+)
+
+func TestAlwaysTrue(t *testing.T) {
+ if AlwaysTrue() != true {
+ t.Errorf("Expected true, got false")
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/convert_test.go b/vendor/github.com/onsi/ginkgo/integration/convert_test.go
new file mode 100644
index 000000000..f4fd678c5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/convert_test.go
@@ -0,0 +1,121 @@
+package integration_test
+
+import (
+ "io/ioutil"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strings"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("ginkgo convert", func() {
+ var tmpDir string
+
+ readConvertedFileNamed := func(pathComponents ...string) string {
+ pathToFile := filepath.Join(tmpDir, "convert_fixtures", filepath.Join(pathComponents...))
+ bytes, err := ioutil.ReadFile(pathToFile)
+ ExpectWithOffset(1, err).NotTo(HaveOccurred())
+
+ return string(bytes)
+ }
+
+ readGoldMasterNamed := func(filename string) string {
+ bytes, err := ioutil.ReadFile(filepath.Join("_fixtures", "convert_goldmasters", filename))
+ Ω(err).ShouldNot(HaveOccurred())
+
+ return string(bytes)
+ }
+
+ BeforeEach(func() {
+ var err error
+
+ tmpDir, err = ioutil.TempDir("", "ginkgo-convert")
+ Ω(err).ShouldNot(HaveOccurred())
+
+ err = exec.Command("cp", "-r", filepath.Join("_fixtures", "convert_fixtures"), tmpDir).Run()
+ Ω(err).ShouldNot(HaveOccurred())
+ })
+
+ JustBeforeEach(func() {
+ cwd, err := os.Getwd()
+ Ω(err).ShouldNot(HaveOccurred())
+
+ relPath, err := filepath.Rel(cwd, filepath.Join(tmpDir, "convert_fixtures"))
+ Ω(err).ShouldNot(HaveOccurred())
+
+ cmd := exec.Command(pathToGinkgo, "convert", relPath)
+ cmd.Env = os.Environ()
+ for i, env := range cmd.Env {
+ if strings.HasPrefix(env, "PATH") {
+ cmd.Env[i] = cmd.Env[i] + ":" + filepath.Dir(pathToGinkgo)
+ break
+ }
+ }
+ err = cmd.Run()
+ Ω(err).ShouldNot(HaveOccurred())
+ })
+
+ AfterEach(func() {
+ err := os.RemoveAll(tmpDir)
+ Ω(err).ShouldNot(HaveOccurred())
+ })
+
+ It("rewrites xunit tests as ginkgo tests", func() {
+ convertedFile := readConvertedFileNamed("xunit_test.go")
+ goldMaster := readGoldMasterNamed("xunit_test.go")
+ Ω(convertedFile).Should(Equal(goldMaster))
+ })
+
+ It("rewrites all usages of *testing.T as mr.T()", func() {
+ convertedFile := readConvertedFileNamed("extra_functions_test.go")
+ goldMaster := readGoldMasterNamed("extra_functions_test.go")
+ Ω(convertedFile).Should(Equal(goldMaster))
+ })
+
+ It("rewrites tests in the package dir that belong to other packages", func() {
+ convertedFile := readConvertedFileNamed("outside_package_test.go")
+ goldMaster := readGoldMasterNamed("outside_package_test.go")
+ Ω(convertedFile).Should(Equal(goldMaster))
+ })
+
+ It("rewrites tests in nested packages", func() {
+ convertedFile := readConvertedFileNamed("nested", "nested_test.go")
+ goldMaster := readGoldMasterNamed("nested_test.go")
+ Ω(convertedFile).Should(Equal(goldMaster))
+ })
+
+ Context("ginkgo test suite files", func() {
+ It("creates a ginkgo test suite file for the package you specified", func() {
+ testsuite := readConvertedFileNamed("convert_fixtures_suite_test.go")
+ goldMaster := readGoldMasterNamed("suite_test.go")
+ Ω(testsuite).Should(Equal(goldMaster))
+ })
+
+ It("converts go tests in deeply nested packages (some may not contain go files)", func() {
+ testsuite := readConvertedFileNamed("nested_without_gofiles", "subpackage", "nested_subpackage_test.go")
+ goldMaster := readGoldMasterNamed("nested_subpackage_test.go")
+ Ω(testsuite).Should(Equal(goldMaster))
+ })
+
+ It("creates ginkgo test suites for all nested packages", func() {
+ testsuite := readConvertedFileNamed("nested", "nested_suite_test.go")
+ goldMaster := readGoldMasterNamed("nested_suite_test.go")
+ Ω(testsuite).Should(Equal(goldMaster))
+ })
+ })
+
+ Context("with an existing test suite file", func() {
+ BeforeEach(func() {
+ goldMaster := readGoldMasterNamed("fixtures_suite_test.go")
+ err := ioutil.WriteFile(filepath.Join(tmpDir, "convert_fixtures", "tmp_suite_test.go"), []byte(goldMaster), 0600)
+ Ω(err).ShouldNot(HaveOccurred())
+ })
+
+ It("gracefully handles existing test suite files", func() {
+ //nothing should have gone wrong!
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/coverage_test.go b/vendor/github.com/onsi/ginkgo/integration/coverage_test.go
new file mode 100644
index 000000000..a1d24bfed
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/coverage_test.go
@@ -0,0 +1,147 @@
+package integration_test
+
+import (
+ "os/exec"
+
+ "fmt"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gbytes"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("Coverage Specs", func() {
+ Context("when it runs coverage analysis in series and in parallel", func() {
+ AfterEach(func() {
+ removeSuccessfully("./_fixtures/coverage_fixture/coverage_fixture.coverprofile")
+ })
+ It("works", func() {
+ session := startGinkgo("./_fixtures/coverage_fixture", "-cover")
+ Eventually(session).Should(gexec.Exit(0))
+
+ Ω(session.Out).Should(gbytes.Say(("coverage: 80.0% of statements")))
+
+ coverFile := "./_fixtures/coverage_fixture/coverage_fixture.coverprofile"
+ serialCoverProfileOutput, err := exec.Command("go", "tool", "cover", fmt.Sprintf("-func=%s", coverFile)).CombinedOutput()
+ Ω(err).ShouldNot(HaveOccurred())
+
+ removeSuccessfully(coverFile)
+
+ Eventually(startGinkgo("./_fixtures/coverage_fixture", "-cover", "-nodes=4")).Should(gexec.Exit(0))
+
+ parallelCoverProfileOutput, err := exec.Command("go", "tool", "cover", fmt.Sprintf("-func=%s", coverFile)).CombinedOutput()
+ Ω(err).ShouldNot(HaveOccurred())
+
+ Ω(parallelCoverProfileOutput).Should(Equal(serialCoverProfileOutput))
+
+ By("handling external packages", func() {
+ session = startGinkgo("./_fixtures/coverage_fixture", "-coverpkg=github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture,github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/external_coverage_fixture")
+ Eventually(session).Should(gexec.Exit(0))
+
+ Ω(session.Out).Should(gbytes.Say("coverage: 71.4% of statements in github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture, github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/external_coverage_fixture"))
+
+ serialCoverProfileOutput, err = exec.Command("go", "tool", "cover", fmt.Sprintf("-func=%s", coverFile)).CombinedOutput()
+ Ω(err).ShouldNot(HaveOccurred())
+
+ removeSuccessfully("./_fixtures/coverage_fixture/coverage_fixture.coverprofile")
+
+ Eventually(startGinkgo("./_fixtures/coverage_fixture", "-coverpkg=github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture,github.com/onsi/ginkgo/integration/_fixtures/coverage_fixture/external_coverage_fixture", "-nodes=4")).Should(gexec.Exit(0))
+
+ parallelCoverProfileOutput, err = exec.Command("go", "tool", "cover", fmt.Sprintf("-func=%s", coverFile)).CombinedOutput()
+ Ω(err).ShouldNot(HaveOccurred())
+
+ Ω(parallelCoverProfileOutput).Should(Equal(serialCoverProfileOutput))
+ })
+ })
+ })
+
+ Context("when a custom profile name is specified", func() {
+ AfterEach(func() {
+ removeSuccessfully("./_fixtures/coverage_fixture/coverage.txt")
+ })
+
+ It("generates cover profiles with the specified name", func() {
+ session := startGinkgo("./_fixtures/coverage_fixture", "-cover", "-coverprofile=coverage.txt")
+ Eventually(session).Should(gexec.Exit(0))
+
+ Ω("./_fixtures/coverage_fixture/coverage.txt").Should(BeARegularFile())
+ })
+ })
+
+ Context("when run in recursive mode", func() {
+ AfterEach(func() {
+ removeSuccessfully("./_fixtures/combined_coverage_fixture/coverage-recursive.txt")
+ removeSuccessfully("./_fixtures/combined_coverage_fixture/first_package/coverage-recursive.txt")
+ removeSuccessfully("./_fixtures/combined_coverage_fixture/second_package/coverage-recursive.txt")
+ })
+
+ It("generates a coverage file per package", func() {
+ session := startGinkgo("./_fixtures/combined_coverage_fixture", "-r", "-cover", "-coverprofile=coverage-recursive.txt")
+ Eventually(session).Should(gexec.Exit(0))
+
+ Ω("./_fixtures/combined_coverage_fixture/first_package/coverage-recursive.txt").Should(BeARegularFile())
+ Ω("./_fixtures/combined_coverage_fixture/second_package/coverage-recursive.txt").Should(BeARegularFile())
+ })
+ })
+
+ Context("when run in parallel mode", func() {
+ AfterEach(func() {
+ removeSuccessfully("./_fixtures/coverage_fixture/coverage-parallel.txt")
+ })
+
+ It("works", func() {
+ session := startGinkgo("./_fixtures/coverage_fixture", "-p", "-cover", "-coverprofile=coverage-parallel.txt")
+
+ Eventually(session).Should(gexec.Exit(0))
+
+ Ω("./_fixtures/coverage_fixture/coverage-parallel.txt").Should(BeARegularFile())
+ })
+ })
+
+ Context("when run in recursive mode specifying a coverprofile", func() {
+ AfterEach(func() {
+ removeSuccessfully("./_fixtures/combined_coverage_fixture/coverprofile-recursive.txt")
+ removeSuccessfully("./_fixtures/combined_coverage_fixture/first_package/coverprofile-recursive.txt")
+ removeSuccessfully("./_fixtures/combined_coverage_fixture/second_package/coverprofile-recursive.txt")
+ })
+
+ It("combines the coverages", func() {
+ session := startGinkgo("./_fixtures/combined_coverage_fixture", "-outputdir=./", "-r", "-cover", "-coverprofile=coverprofile-recursive.txt")
+ Eventually(session).Should(gexec.Exit(0))
+
+ By("generating a combined coverage file", func() {
+ Ω("./_fixtures/combined_coverage_fixture/coverprofile-recursive.txt").Should(BeARegularFile())
+ })
+
+ By("also generating the single package coverage files", func() {
+ Ω("./_fixtures/combined_coverage_fixture/first_package/coverprofile-recursive.txt").Should(BeARegularFile())
+ Ω("./_fixtures/combined_coverage_fixture/second_package/coverprofile-recursive.txt").Should(BeARegularFile())
+ })
+ })
+ })
+
+ It("Fails with an error if output dir and coverprofile were set, but the output dir did not exist", func() {
+ session := startGinkgo("./_fixtures/combined_coverage_fixture", "-outputdir=./all/profiles/here", "-r", "-cover", "-coverprofile=coverage.txt")
+
+ Eventually(session).Should(gexec.Exit(1))
+ output := session.Out.Contents()
+ Ω(string(output)).Should(ContainSubstring("Unable to create combined profile, outputdir does not exist: ./all/profiles/here"))
+ })
+
+ Context("when only output dir was set", func() {
+ AfterEach(func() {
+ removeSuccessfully("./_fixtures/combined_coverage_fixture/first_package.coverprofile")
+ removeSuccessfully("./_fixtures/combined_coverage_fixture/first_package/coverage.txt")
+ removeSuccessfully("./_fixtures/combined_coverage_fixture/second_package.coverprofile")
+ removeSuccessfully("./_fixtures/combined_coverage_fixture/second_package/coverage.txt")
+ })
+ It("moves coverages", func() {
+ session := startGinkgo("./_fixtures/combined_coverage_fixture", "-outputdir=./", "-r", "-cover")
+ Eventually(session).Should(gexec.Exit(0))
+
+ Ω("./_fixtures/combined_coverage_fixture/first_package.coverprofile").Should(BeARegularFile())
+ Ω("./_fixtures/combined_coverage_fixture/second_package.coverprofile").Should(BeARegularFile())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/fail_test.go b/vendor/github.com/onsi/ginkgo/integration/fail_test.go
new file mode 100644
index 000000000..53b2a67b4
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/fail_test.go
@@ -0,0 +1,55 @@
+package integration_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("Failing Specs", func() {
+ var pathToTest string
+
+ BeforeEach(func() {
+ pathToTest = tmpPath("failing")
+ copyIn(fixturePath("fail_fixture"), pathToTest, false)
+ })
+
+ It("should fail in all the possible ways", func() {
+ session := startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(1))
+ output := string(session.Out.Contents())
+
+ Ω(output).ShouldNot(ContainSubstring("NEVER SEE THIS"))
+
+ Ω(output).Should(ContainSubstring("a top level failure on line 9"))
+ Ω(output).Should(ContainSubstring("fail_fixture_test.go:9"))
+ Ω(output).Should(ContainSubstring("an async top level failure on line 14"))
+ Ω(output).Should(ContainSubstring("fail_fixture_test.go:14"))
+ Ω(output).Should(ContainSubstring("a top level goroutine failure on line 21"))
+ Ω(output).Should(ContainSubstring("fail_fixture_test.go:21"))
+
+ Ω(output).Should(ContainSubstring("a sync failure"))
+ Ω(output).Should(MatchRegexp(`Test Panicked\n\s+a sync panic`))
+ Ω(output).Should(ContainSubstring("a sync FAIL failure"))
+ Ω(output).Should(ContainSubstring("async timeout [It]"))
+ Ω(output).Should(ContainSubstring("Timed out"))
+ Ω(output).Should(ContainSubstring("an async failure"))
+ Ω(output).Should(MatchRegexp(`Test Panicked\n\s+an async panic`))
+ Ω(output).Should(ContainSubstring("an async FAIL failure"))
+ Ω(output).Should(ContainSubstring("a goroutine FAIL failure"))
+ Ω(output).Should(ContainSubstring("a goroutine failure"))
+ Ω(output).Should(MatchRegexp(`Test Panicked\n\s+a goroutine panic`))
+ Ω(output).Should(ContainSubstring("a measure failure"))
+ Ω(output).Should(ContainSubstring("a measure FAIL failure"))
+ Ω(output).Should(MatchRegexp(`Test Panicked\n\s+a measure panic`))
+
+ Ω(output).Should(ContainSubstring("a top level specify"))
+ Ω(output).ShouldNot(ContainSubstring("ginkgo_dsl.go"))
+ // depending on the go version this could be the first line of the Specify
+ // block (>= go1.9) or the last line of the Specify block (< go1.9)
+ Ω(output).Should(Or(ContainSubstring("fail_fixture_test.go:101"), ContainSubstring("fail_fixture_test.go:103")))
+ Ω(output).Should(ContainSubstring("fail_fixture_test.go:102"))
+
+ Ω(output).Should(ContainSubstring("0 Passed | 17 Failed"))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/flags_test.go b/vendor/github.com/onsi/ginkgo/integration/flags_test.go
new file mode 100644
index 000000000..d84eb46cc
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/flags_test.go
@@ -0,0 +1,237 @@
+package integration_test
+
+import (
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "strings"
+
+ . "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/types"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("Flags Specs", func() {
+ var pathToTest string
+
+ BeforeEach(func() {
+ pathToTest = tmpPath("flags")
+ copyIn(fixturePath("flags_tests"), pathToTest, false)
+ })
+
+ getRandomOrders := func(output string) []int {
+ return []int{strings.Index(output, "RANDOM_A"), strings.Index(output, "RANDOM_B"), strings.Index(output, "RANDOM_C")}
+ }
+
+ It("normally passes, runs measurements, prints out noisy pendings, does not randomize tests, and honors the programmatic focus", func() {
+ session := startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("Ran 3 samples:"), "has a measurement")
+ Ω(output).Should(ContainSubstring("11 Passed"))
+ Ω(output).Should(ContainSubstring("0 Failed"))
+ Ω(output).Should(ContainSubstring("1 Pending"))
+ Ω(output).Should(ContainSubstring("3 Skipped"))
+ Ω(output).Should(ContainSubstring("[PENDING]"))
+ Ω(output).Should(ContainSubstring("marshmallow"))
+ Ω(output).Should(ContainSubstring("chocolate"))
+ Ω(output).Should(ContainSubstring("CUSTOM_FLAG: default"))
+ Ω(output).Should(ContainSubstring("Detected Programmatic Focus - setting exit status to %d", types.GINKGO_FOCUS_EXIT_CODE))
+ Ω(output).ShouldNot(ContainSubstring("smores"))
+ Ω(output).ShouldNot(ContainSubstring("SLOW TEST"))
+ Ω(output).ShouldNot(ContainSubstring("should honor -slowSpecThreshold"))
+
+ orders := getRandomOrders(output)
+ Ω(orders[0]).Should(BeNumerically("<", orders[1]))
+ Ω(orders[1]).Should(BeNumerically("<", orders[2]))
+ })
+
+ It("should run a coverprofile when passed -cover", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--cover", "--focus=the focused set")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ _, err := os.Stat(filepath.Join(pathToTest, "flags.coverprofile"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(output).Should(ContainSubstring("coverage: "))
+ })
+
+ It("should fail when there are pending tests and it is passed --failOnPending", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--failOnPending")
+ Eventually(session).Should(gexec.Exit(1))
+ })
+
+ It("should fail if the test suite takes longer than the timeout", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--timeout=1ms")
+ Eventually(session).Should(gexec.Exit(1))
+ })
+
+ It("should not print out pendings when --noisyPendings=false", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--noisyPendings=false")
+ Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
+ output := string(session.Out.Contents())
+
+ Ω(output).ShouldNot(ContainSubstring("[PENDING]"))
+ Ω(output).Should(ContainSubstring("1 Pending"))
+ })
+
+ It("should override the programmatic focus when told to focus", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--focus=smores")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("marshmallow"))
+ Ω(output).Should(ContainSubstring("chocolate"))
+ Ω(output).Should(ContainSubstring("smores"))
+ Ω(output).Should(ContainSubstring("3 Passed"))
+ Ω(output).Should(ContainSubstring("0 Failed"))
+ Ω(output).Should(ContainSubstring("0 Pending"))
+ Ω(output).Should(ContainSubstring("12 Skipped"))
+ })
+
+ It("should override the programmatic focus when told to skip", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--skip=marshmallow|failing|flaky")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).ShouldNot(ContainSubstring("marshmallow"))
+ Ω(output).Should(ContainSubstring("chocolate"))
+ Ω(output).Should(ContainSubstring("smores"))
+ Ω(output).Should(ContainSubstring("11 Passed"))
+ Ω(output).Should(ContainSubstring("0 Failed"))
+ Ω(output).Should(ContainSubstring("1 Pending"))
+ Ω(output).Should(ContainSubstring("3 Skipped"))
+ })
+
+ It("should run the race detector when told to", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--race")
+ Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("WARNING: DATA RACE"))
+ })
+
+ It("should randomize tests when told to", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--randomizeAllSpecs", "--seed=17")
+ Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
+ output := string(session.Out.Contents())
+
+ orders := getRandomOrders(output)
+ Ω(orders[0]).ShouldNot(BeNumerically("<", orders[1]))
+ })
+
+ It("should skip measurements when told to", func() {
+ session := startGinkgo(pathToTest, "--skipMeasurements")
+ Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
+ output := string(session.Out.Contents())
+
+ Ω(output).ShouldNot(ContainSubstring("Ran 3 samples:"), "has a measurement")
+ Ω(output).Should(ContainSubstring("4 Skipped"))
+ })
+
+ It("should watch for slow specs", func() {
+ session := startGinkgo(pathToTest, "--slowSpecThreshold=0.05")
+ Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("SLOW TEST"))
+ Ω(output).Should(ContainSubstring("should honor -slowSpecThreshold"))
+ })
+
+ It("should pass additional arguments in", func() {
+ session := startGinkgo(pathToTest, "--", "--customFlag=madagascar")
+ Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("CUSTOM_FLAG: madagascar"))
+ })
+
+ It("should print out full stack traces for failures when told to", func() {
+ session := startGinkgo(pathToTest, "--focus=a failing test", "--trace")
+ Eventually(session).Should(gexec.Exit(1))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("Full Stack Trace"))
+ })
+
+ It("should fail fast when told to", func() {
+ pathToTest = tmpPath("fail")
+ copyIn(fixturePath("fail_fixture"), pathToTest, false)
+ session := startGinkgo(pathToTest, "--failFast")
+ Eventually(session).Should(gexec.Exit(1))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("1 Failed"))
+ Ω(output).Should(ContainSubstring("16 Skipped"))
+ })
+
+ Context("with a flaky test", func() {
+ It("should normally fail", func() {
+ session := startGinkgo(pathToTest, "--focus=flaky")
+ Eventually(session).Should(gexec.Exit(1))
+ })
+
+ It("should pass if retries are requested", func() {
+ session := startGinkgo(pathToTest, "--focus=flaky --flakeAttempts=2")
+ Eventually(session).Should(gexec.Exit(0))
+ })
+ })
+
+ It("should perform a dry run when told to", func() {
+ pathToTest = tmpPath("fail")
+ copyIn(fixturePath("fail_fixture"), pathToTest, false)
+ session := startGinkgo(pathToTest, "--dryRun", "-v")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("synchronous failures"))
+ Ω(output).Should(ContainSubstring("17 Specs"))
+ Ω(output).Should(ContainSubstring("0 Passed"))
+ Ω(output).Should(ContainSubstring("0 Failed"))
+ })
+
+ regextest := func(regexOption string, skipOrFocus string) string {
+ pathToTest = tmpPath("passing")
+ copyIn(fixturePath("passing_ginkgo_tests"), pathToTest, false)
+ session := startGinkgo(pathToTest, regexOption, "--dryRun", "-v", skipOrFocus)
+ Eventually(session).Should(gexec.Exit(0))
+ return string(session.Out.Contents())
+ }
+
+ It("regexScansFilePath (enabled) should skip and focus on file names", func() {
+ output := regextest("-regexScansFilePath=true", "-skip=/passing/") // everything gets skipped (nothing runs)
+ Ω(output).Should(ContainSubstring("0 of 4 Specs"))
+ output = regextest("-regexScansFilePath=true", "-focus=/passing/") // everything gets focused (everything runs)
+ Ω(output).Should(ContainSubstring("4 of 4 Specs"))
+ })
+
+ It("regexScansFilePath (disabled) should not effect normal filtering", func() {
+ output := regextest("-regexScansFilePath=false", "-skip=/passing/") // nothing gets skipped (everything runs)
+ Ω(output).Should(ContainSubstring("4 of 4 Specs"))
+ output = regextest("-regexScansFilePath=false", "-focus=/passing/") // nothing gets focused (nothing runs)
+ Ω(output).Should(ContainSubstring("0 of 4 Specs"))
+ })
+
+ It("should honor compiler flags", func() {
+ session := startGinkgo(pathToTest, "-gcflags=-importmap 'math=math/cmplx'")
+ Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
+ output := string(session.Out.Contents())
+ Ω(output).Should(ContainSubstring("NaN returns complex128"))
+ })
+
+ It("should honor covermode flag", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--covermode=count", "--focus=the focused set")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+ Ω(output).Should(ContainSubstring("coverage: "))
+
+ coverageFile := filepath.Join(pathToTest, "flags.coverprofile")
+ _, err := os.Stat(coverageFile)
+ Ω(err).ShouldNot(HaveOccurred())
+ contents, err := ioutil.ReadFile(coverageFile)
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(contents).Should(ContainSubstring("mode: count"))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/integration.go b/vendor/github.com/onsi/ginkgo/integration/integration.go
new file mode 100644
index 000000000..76ab1b728
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/integration.go
@@ -0,0 +1 @@
+package integration
diff --git a/vendor/github.com/onsi/ginkgo/integration/integration_suite_test.go b/vendor/github.com/onsi/ginkgo/integration/integration_suite_test.go
new file mode 100644
index 000000000..32ec741c9
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/integration_suite_test.go
@@ -0,0 +1,129 @@
+package integration_test
+
+import (
+ "io"
+ "io/ioutil"
+ "os"
+ "os/exec"
+ "path/filepath"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gexec"
+
+ "testing"
+ "time"
+)
+
+var tmpDir string
+var pathToGinkgo string
+
+func TestIntegration(t *testing.T) {
+ SetDefaultEventuallyTimeout(30 * time.Second)
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Integration Suite")
+}
+
+var _ = SynchronizedBeforeSuite(func() []byte {
+ pathToGinkgo, err := gexec.Build("github.com/onsi/ginkgo/ginkgo")
+ Ω(err).ShouldNot(HaveOccurred())
+ return []byte(pathToGinkgo)
+}, func(computedPathToGinkgo []byte) {
+ pathToGinkgo = string(computedPathToGinkgo)
+})
+
+var _ = BeforeEach(func() {
+ var err error
+ tmpDir, err = ioutil.TempDir("", "ginkgo-run")
+ Ω(err).ShouldNot(HaveOccurred())
+})
+
+var _ = AfterEach(func() {
+ err := os.RemoveAll(tmpDir)
+ Ω(err).ShouldNot(HaveOccurred())
+})
+
+var _ = SynchronizedAfterSuite(func() {}, func() {
+ gexec.CleanupBuildArtifacts()
+})
+
+func tmpPath(destination string) string {
+ return filepath.Join(tmpDir, destination)
+}
+
+func fixturePath(name string) string {
+ return filepath.Join("_fixtures", name)
+}
+
+func copyIn(sourcePath, destinationPath string, recursive bool) {
+ err := os.MkdirAll(destinationPath, 0777)
+ Expect(err).NotTo(HaveOccurred())
+
+ files, err := ioutil.ReadDir(sourcePath)
+ Expect(err).NotTo(HaveOccurred())
+ for _, f := range files {
+ srcPath := filepath.Join(sourcePath, f.Name())
+ dstPath := filepath.Join(destinationPath, f.Name())
+ if f.IsDir() {
+ if recursive {
+ copyIn(srcPath, dstPath, recursive)
+ }
+ continue
+ }
+
+ src, err := os.Open(srcPath)
+
+ Expect(err).NotTo(HaveOccurred())
+ defer src.Close()
+
+ dst, err := os.Create(dstPath)
+ Expect(err).NotTo(HaveOccurred())
+ defer dst.Close()
+
+ _, err = io.Copy(dst, src)
+ Expect(err).NotTo(HaveOccurred())
+ }
+}
+
+func sameFile(filePath, otherFilePath string) bool {
+ content, readErr := ioutil.ReadFile(filePath)
+ Expect(readErr).NotTo(HaveOccurred())
+ otherContent, readErr := ioutil.ReadFile(otherFilePath)
+ Expect(readErr).NotTo(HaveOccurred())
+ Expect(string(content)).To(Equal(string(otherContent)))
+ return true
+}
+
+func sameFolder(sourcePath, destinationPath string) bool {
+ files, err := ioutil.ReadDir(sourcePath)
+ Expect(err).NotTo(HaveOccurred())
+ for _, f := range files {
+ srcPath := filepath.Join(sourcePath, f.Name())
+ dstPath := filepath.Join(destinationPath, f.Name())
+ if f.IsDir() {
+ sameFolder(srcPath, dstPath)
+ continue
+ }
+ Expect(sameFile(srcPath, dstPath)).To(BeTrue())
+ }
+ return true
+}
+
+func ginkgoCommand(dir string, args ...string) *exec.Cmd {
+ cmd := exec.Command(pathToGinkgo, args...)
+ cmd.Dir = dir
+
+ return cmd
+}
+
+func startGinkgo(dir string, args ...string) *gexec.Session {
+ cmd := ginkgoCommand(dir, args...)
+ session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
+ Ω(err).ShouldNot(HaveOccurred())
+ return session
+}
+
+func removeSuccessfully(path string) {
+ err := os.RemoveAll(path)
+ Expect(err).NotTo(HaveOccurred())
+}
diff --git a/vendor/github.com/onsi/ginkgo/integration/interrupt_test.go b/vendor/github.com/onsi/ginkgo/integration/interrupt_test.go
new file mode 100644
index 000000000..d4158b806
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/interrupt_test.go
@@ -0,0 +1,51 @@
+package integration_test
+
+import (
+ "os/exec"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gbytes"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("Interrupt", func() {
+ var pathToTest string
+ BeforeEach(func() {
+ pathToTest = tmpPath("hanging")
+ copyIn(fixturePath("hanging_suite"), pathToTest, false)
+ })
+
+ Context("when interrupting a suite", func() {
+ var session *gexec.Session
+ BeforeEach(func() {
+ //we need to signal the actual process, so we must compile the test first
+ var err error
+ cmd := exec.Command("go", "test", "-c")
+ cmd.Dir = pathToTest
+ session, err = gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
+ Ω(err).ShouldNot(HaveOccurred())
+ Eventually(session).Should(gexec.Exit(0))
+
+ //then run the compiled test directly
+ cmd = exec.Command("./hanging.test", "--test.v=true", "--ginkgo.noColor")
+ cmd.Dir = pathToTest
+ session, err = gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
+ Ω(err).ShouldNot(HaveOccurred())
+
+ Eventually(session).Should(gbytes.Say("Sleeping..."))
+ session.Interrupt()
+ Eventually(session, 1000).Should(gexec.Exit(1))
+ })
+
+ It("should emit the contents of the GinkgoWriter", func() {
+ Ω(session).Should(gbytes.Say("Just beginning"))
+ Ω(session).Should(gbytes.Say("Almost there..."))
+ Ω(session).Should(gbytes.Say("Hanging Out"))
+ })
+
+ It("should run the AfterSuite", func() {
+ Ω(session).Should(gbytes.Say("Heading Out After Suite"))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/precompiled_test.go b/vendor/github.com/onsi/ginkgo/integration/precompiled_test.go
new file mode 100644
index 000000000..55724a9b8
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/precompiled_test.go
@@ -0,0 +1,53 @@
+package integration_test
+
+import (
+ "os"
+ "os/exec"
+ "path/filepath"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gbytes"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("ginkgo build", func() {
+ var pathToTest string
+
+ BeforeEach(func() {
+ pathToTest = tmpPath("passing_ginkgo_tests")
+ copyIn(fixturePath("passing_ginkgo_tests"), pathToTest, false)
+ session := startGinkgo(pathToTest, "build")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+ Ω(output).Should(ContainSubstring("Compiling passing_ginkgo_tests"))
+ Ω(output).Should(ContainSubstring("compiled passing_ginkgo_tests.test"))
+ })
+
+ It("should build a test binary", func() {
+ _, err := os.Stat(filepath.Join(pathToTest, "passing_ginkgo_tests.test"))
+ Ω(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should be possible to run the test binary directly", func() {
+ cmd := exec.Command("./passing_ginkgo_tests.test")
+ cmd.Dir = pathToTest
+ session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
+ Ω(err).ShouldNot(HaveOccurred())
+ Eventually(session).Should(gexec.Exit(0))
+ Ω(session).Should(gbytes.Say("Running Suite: Passing_ginkgo_tests Suite"))
+ })
+
+ It("should be possible to run the test binary via ginkgo", func() {
+ session := startGinkgo(pathToTest, "./passing_ginkgo_tests.test")
+ Eventually(session).Should(gexec.Exit(0))
+ Ω(session).Should(gbytes.Say("Running Suite: Passing_ginkgo_tests Suite"))
+ })
+
+ It("should be possible to run the test binary in parallel", func() {
+ session := startGinkgo(pathToTest, "--nodes=4", "--noColor", "./passing_ginkgo_tests.test")
+ Eventually(session).Should(gexec.Exit(0))
+ Ω(session).Should(gbytes.Say("Running Suite: Passing_ginkgo_tests Suite"))
+ Ω(session).Should(gbytes.Say("Running in parallel across 4 nodes"))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/progress_test.go b/vendor/github.com/onsi/ginkgo/integration/progress_test.go
new file mode 100644
index 000000000..cda86b6ea
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/progress_test.go
@@ -0,0 +1,94 @@
+package integration_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gbytes"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("Emitting progress", func() {
+ var pathToTest string
+ var session *gexec.Session
+ var args []string
+
+ BeforeEach(func() {
+ args = []string{"--noColor"}
+ pathToTest = tmpPath("progress")
+ copyIn(fixturePath("progress_fixture"), pathToTest, false)
+ })
+
+ JustBeforeEach(func() {
+ session = startGinkgo(pathToTest, args...)
+ Eventually(session).Should(gexec.Exit(0))
+ })
+
+ Context("with the -progress flag, but no -v flag", func() {
+ BeforeEach(func() {
+ args = append(args, "-progress")
+ })
+
+ It("should not emit progress", func() {
+ Ω(session).ShouldNot(gbytes.Say("[bB]efore"))
+ })
+ })
+
+ Context("with the -v flag", func() {
+ BeforeEach(func() {
+ args = append(args, "-v")
+ })
+
+ It("should not emit progress", func() {
+ Ω(session).ShouldNot(gbytes.Say(`\[BeforeEach\]`))
+ Ω(session).Should(gbytes.Say(`>outer before<`))
+ })
+ })
+
+ Context("with the -progress flag and the -v flag", func() {
+ BeforeEach(func() {
+ args = append(args, "-progress", "-v")
+ })
+
+ It("should emit progress (by writing to the GinkgoWriter)", func() {
+ // First spec
+
+ Ω(session).Should(gbytes.Say(`\[BeforeEach\] ProgressFixture`))
+ Ω(session).Should(gbytes.Say(`>outer before<`))
+
+ Ω(session).Should(gbytes.Say(`\[BeforeEach\] Inner Context`))
+ Ω(session).Should(gbytes.Say(`>inner before<`))
+
+ Ω(session).Should(gbytes.Say(`\[BeforeEach\] when Inner When`))
+ Ω(session).Should(gbytes.Say(`>inner before<`))
+
+ Ω(session).Should(gbytes.Say(`\[JustBeforeEach\] ProgressFixture`))
+ Ω(session).Should(gbytes.Say(`>outer just before<`))
+
+ Ω(session).Should(gbytes.Say(`\[JustBeforeEach\] Inner Context`))
+ Ω(session).Should(gbytes.Say(`>inner just before<`))
+
+ Ω(session).Should(gbytes.Say(`\[It\] should emit progress as it goes`))
+ Ω(session).Should(gbytes.Say(`>it<`))
+
+ Ω(session).Should(gbytes.Say(`\[AfterEach\] Inner Context`))
+ Ω(session).Should(gbytes.Say(`>inner after<`))
+
+ Ω(session).Should(gbytes.Say(`\[AfterEach\] ProgressFixture`))
+ Ω(session).Should(gbytes.Say(`>outer after<`))
+
+ // Second spec
+
+ Ω(session).Should(gbytes.Say(`\[BeforeEach\] ProgressFixture`))
+ Ω(session).Should(gbytes.Say(`>outer before<`))
+
+ Ω(session).Should(gbytes.Say(`\[JustBeforeEach\] ProgressFixture`))
+ Ω(session).Should(gbytes.Say(`>outer just before<`))
+
+ Ω(session).Should(gbytes.Say(`\[It\] should emit progress as it goes`))
+ Ω(session).Should(gbytes.Say(`>specify<`))
+
+ Ω(session).Should(gbytes.Say(`\[AfterEach\] ProgressFixture`))
+ Ω(session).Should(gbytes.Say(`>outer after<`))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/run_test.go b/vendor/github.com/onsi/ginkgo/integration/run_test.go
new file mode 100644
index 000000000..6c270b61b
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/run_test.go
@@ -0,0 +1,483 @@
+package integration_test
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+ "regexp"
+ "runtime"
+ "strings"
+
+ . "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/types"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gbytes"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("Running Specs", func() {
+ var pathToTest string
+
+ isWindows := (runtime.GOOS == "windows")
+ denoter := "•"
+
+ if isWindows {
+ denoter = "+"
+ }
+
+ Context("when pointed at the current directory", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("ginkgo")
+ copyIn(fixturePath("passing_ginkgo_tests"), pathToTest, false)
+ })
+
+ It("should run the tests in the working directory", func() {
+ session := startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
+ Ω(output).Should(ContainSubstring(strings.Repeat(denoter, 4)))
+ Ω(output).Should(ContainSubstring("SUCCESS! -- 4 Passed"))
+ Ω(output).Should(ContainSubstring("Test Suite Passed"))
+ })
+ })
+
+ Context("when passed an explicit package to run", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("ginkgo")
+ copyIn(fixturePath("passing_ginkgo_tests"), pathToTest, false)
+ })
+
+ It("should run the ginkgo style tests", func() {
+ session := startGinkgo(tmpDir, "--noColor", pathToTest)
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
+ Ω(output).Should(ContainSubstring(strings.Repeat(denoter, 4)))
+ Ω(output).Should(ContainSubstring("SUCCESS! -- 4 Passed"))
+ Ω(output).Should(ContainSubstring("Test Suite Passed"))
+ })
+ })
+
+ Context("when passed a number of packages to run", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("ginkgo")
+ otherPathToTest := tmpPath("other")
+ copyIn(fixturePath("passing_ginkgo_tests"), pathToTest, false)
+ copyIn(fixturePath("more_ginkgo_tests"), otherPathToTest, false)
+ })
+
+ It("should run the ginkgo style tests", func() {
+ session := startGinkgo(tmpDir, "--noColor", "--succinct=false", "ginkgo", "./other")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
+ Ω(output).Should(ContainSubstring("Running Suite: More_ginkgo_tests Suite"))
+ Ω(output).Should(ContainSubstring("Test Suite Passed"))
+ })
+ })
+
+ Context("when passed a number of packages to run, some of which have focused tests", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("ginkgo")
+ otherPathToTest := tmpPath("other")
+ focusedPathToTest := tmpPath("focused")
+ copyIn(fixturePath("passing_ginkgo_tests"), pathToTest, false)
+ copyIn(fixturePath("more_ginkgo_tests"), otherPathToTest, false)
+ copyIn(fixturePath("focused_fixture"), focusedPathToTest, false)
+ })
+
+ It("should exit with a status code of 2 and explain why", func() {
+ session := startGinkgo(tmpDir, "--noColor", "--succinct=false", "-r")
+ Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
+ Ω(output).Should(ContainSubstring("Running Suite: More_ginkgo_tests Suite"))
+ Ω(output).Should(ContainSubstring("Test Suite Passed"))
+ Ω(output).Should(ContainSubstring("Detected Programmatic Focus - setting exit status to %d", types.GINKGO_FOCUS_EXIT_CODE))
+ })
+
+ Context("when the GINKGO_EDITOR_INTEGRATION environment variable is set", func() {
+ BeforeEach(func() {
+ os.Setenv("GINKGO_EDITOR_INTEGRATION", "true")
+ })
+ AfterEach(func() {
+ os.Setenv("GINKGO_EDITOR_INTEGRATION", "")
+ })
+ It("should exit with a status code of 0 to allow a coverage file to be generated", func() {
+ session := startGinkgo(tmpDir, "--noColor", "--succinct=false", "-r")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
+ Ω(output).Should(ContainSubstring("Running Suite: More_ginkgo_tests Suite"))
+ Ω(output).Should(ContainSubstring("Test Suite Passed"))
+ })
+ })
+ })
+
+ Context("when told to skipPackages", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("ginkgo")
+ otherPathToTest := tmpPath("other")
+ focusedPathToTest := tmpPath("focused")
+ copyIn(fixturePath("passing_ginkgo_tests"), pathToTest, false)
+ copyIn(fixturePath("more_ginkgo_tests"), otherPathToTest, false)
+ copyIn(fixturePath("focused_fixture"), focusedPathToTest, false)
+ })
+
+ It("should skip packages that match the list", func() {
+ session := startGinkgo(tmpDir, "--noColor", "--skipPackage=other,focused", "-r")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("Passing_ginkgo_tests Suite"))
+ Ω(output).ShouldNot(ContainSubstring("More_ginkgo_tests Suite"))
+ Ω(output).ShouldNot(ContainSubstring("Focused_fixture Suite"))
+ Ω(output).Should(ContainSubstring("Test Suite Passed"))
+ })
+
+ Context("when all packages are skipped", func() {
+ It("should not run anything, but still exit 0", func() {
+ session := startGinkgo(tmpDir, "--noColor", "--skipPackage=other,focused,ginkgo", "-r")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("All tests skipped!"))
+ Ω(output).ShouldNot(ContainSubstring("Passing_ginkgo_tests Suite"))
+ Ω(output).ShouldNot(ContainSubstring("More_ginkgo_tests Suite"))
+ Ω(output).ShouldNot(ContainSubstring("Focused_fixture Suite"))
+ Ω(output).ShouldNot(ContainSubstring("Test Suite Passed"))
+ })
+ })
+ })
+
+ Context("when there are no tests to run", func() {
+ It("should exit 1", func() {
+ session := startGinkgo(tmpDir, "--noColor", "--skipPackage=other,focused", "-r")
+ Eventually(session).Should(gexec.Exit(1))
+ output := string(session.Err.Contents())
+
+ Ω(output).Should(ContainSubstring("Found no test suites"))
+ })
+ })
+
+ Context("when there are test files but `go test` reports there are no tests to run", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("ginkgo")
+ copyIn(fixturePath("no_test_fn"), pathToTest, false)
+ })
+
+ It("suggests running ginkgo bootstrap", func() {
+ session := startGinkgo(tmpDir, "--noColor", "--skipPackage=other,focused", "-r")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Err.Contents())
+
+ Ω(output).Should(ContainSubstring(`Found no test suites, did you forget to run "ginkgo bootstrap"?`))
+ })
+
+ It("fails if told to requireSuite", func() {
+ session := startGinkgo(tmpDir, "--noColor", "--skipPackage=other,focused", "-r", "-requireSuite")
+ Eventually(session).Should(gexec.Exit(1))
+ output := string(session.Err.Contents())
+
+ Ω(output).Should(ContainSubstring(`Found no test suites, did you forget to run "ginkgo bootstrap"?`))
+ })
+ })
+
+ Context("when told to randomizeSuites", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("ginkgo")
+ otherPathToTest := tmpPath("other")
+ copyIn(fixturePath("passing_ginkgo_tests"), pathToTest, false)
+ copyIn(fixturePath("more_ginkgo_tests"), otherPathToTest, false)
+ })
+
+ It("should skip packages that match the regexp", func() {
+ session := startGinkgo(tmpDir, "--noColor", "--randomizeSuites", "-r", "--seed=2")
+ Eventually(session).Should(gexec.Exit(0))
+
+ Ω(session).Should(gbytes.Say("More_ginkgo_tests Suite"))
+ Ω(session).Should(gbytes.Say("Passing_ginkgo_tests Suite"))
+
+ session = startGinkgo(tmpDir, "--noColor", "--randomizeSuites", "-r", "--seed=3")
+ Eventually(session).Should(gexec.Exit(0))
+
+ Ω(session).Should(gbytes.Say("Passing_ginkgo_tests Suite"))
+ Ω(session).Should(gbytes.Say("More_ginkgo_tests Suite"))
+ })
+ })
+
+ Context("when pointed at a package with xunit style tests", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("xunit")
+ copyIn(fixturePath("xunit_tests"), pathToTest, false)
+ })
+
+ It("should run the xunit style tests", func() {
+ session := startGinkgo(pathToTest)
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("--- PASS: TestAlwaysTrue"))
+ Ω(output).Should(ContainSubstring("Test Suite Passed"))
+ })
+ })
+
+ Context("when pointed at a package with no tests", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("no_tests")
+ copyIn(fixturePath("no_tests"), pathToTest, false)
+ })
+
+ It("should fail", func() {
+ session := startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(1))
+
+ Ω(session.Err.Contents()).Should(ContainSubstring("Found no test suites"))
+ })
+ })
+
+ Context("when pointed at a package that fails to compile", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("does_not_compile")
+ copyIn(fixturePath("does_not_compile"), pathToTest, false)
+ })
+
+ It("should fail", func() {
+ session := startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(1))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("Failed to compile"))
+ })
+ })
+
+ Context("when running in parallel", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("ginkgo")
+ copyIn(fixturePath("passing_ginkgo_tests"), pathToTest, false)
+ })
+
+ Context("with a specific number of -nodes", func() {
+ It("should use the specified number of nodes", func() {
+ session := startGinkgo(pathToTest, "--noColor", "-succinct", "-nodes=2")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4 specs - 2 nodes [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]s`, regexp.QuoteMeta(denoter)))
+ Ω(output).Should(ContainSubstring("Test Suite Passed"))
+ })
+ })
+
+ Context("with -p", func() {
+ It("it should autocompute the number of nodes", func() {
+ session := startGinkgo(pathToTest, "--noColor", "-succinct", "-p")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ nodes := runtime.NumCPU()
+ if nodes == 1 {
+ Skip("Can't test parallel testings with 1 CPU")
+ }
+ if nodes > 4 {
+ nodes = nodes - 1
+ }
+ Ω(output).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4 specs - %d nodes [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]?s`, nodes, regexp.QuoteMeta(denoter)))
+ Ω(output).Should(ContainSubstring("Test Suite Passed"))
+ })
+ })
+ })
+
+ Context("when running in parallel with -debug", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("ginkgo")
+ copyIn(fixturePath("debug_parallel_fixture"), pathToTest, false)
+ })
+
+ Context("without -v", func() {
+ It("should emit node output to files on disk", func() {
+ session := startGinkgo(pathToTest, "--nodes=2", "--debug")
+ Eventually(session).Should(gexec.Exit(0))
+
+ f0, err := ioutil.ReadFile(pathToTest + "/ginkgo-node-1.log")
+ Ω(err).ShouldNot(HaveOccurred())
+ f1, err := ioutil.ReadFile(pathToTest + "/ginkgo-node-2.log")
+ Ω(err).ShouldNot(HaveOccurred())
+ content := string(append(f0, f1...))
+
+ for i := 0; i < 10; i += 1 {
+ Ω(content).Should(ContainSubstring("StdOut %d\n", i))
+ Ω(content).Should(ContainSubstring("GinkgoWriter %d\n", i))
+ }
+ })
+ })
+
+ Context("without -v", func() {
+ It("should emit node output to files on disk, without duplicating the GinkgoWriter output", func() {
+ session := startGinkgo(pathToTest, "--nodes=2", "--debug", "-v")
+ Eventually(session).Should(gexec.Exit(0))
+
+ f0, err := ioutil.ReadFile(pathToTest + "/ginkgo-node-1.log")
+ Ω(err).ShouldNot(HaveOccurred())
+ f1, err := ioutil.ReadFile(pathToTest + "/ginkgo-node-2.log")
+ Ω(err).ShouldNot(HaveOccurred())
+ content := string(append(f0, f1...))
+
+ out := strings.Split(content, "GinkgoWriter 2")
+ Ω(out).Should(HaveLen(2))
+ })
+ })
+ })
+
+ Context("when streaming in parallel", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("ginkgo")
+ copyIn(fixturePath("passing_ginkgo_tests"), pathToTest, false)
+ })
+
+ It("should print output in realtime", func() {
+ session := startGinkgo(pathToTest, "--noColor", "-stream", "-nodes=2")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring(`[1] Parallel test node 1/2.`))
+ Ω(output).Should(ContainSubstring(`[2] Parallel test node 2/2.`))
+ Ω(output).Should(ContainSubstring(`[1] SUCCESS!`))
+ Ω(output).Should(ContainSubstring(`[2] SUCCESS!`))
+ Ω(output).Should(ContainSubstring("Test Suite Passed"))
+ })
+ })
+
+ Context("when running recursively", func() {
+ BeforeEach(func() {
+ passingTest := tmpPath("A")
+ otherPassingTest := tmpPath("E")
+ copyIn(fixturePath("passing_ginkgo_tests"), passingTest, false)
+ copyIn(fixturePath("more_ginkgo_tests"), otherPassingTest, false)
+ })
+
+ Context("when all the tests pass", func() {
+ Context("with the -r flag", func() {
+ It("should run all the tests (in succinct mode) and succeed", func() {
+ session := startGinkgo(tmpDir, "--noColor", "-r", ".")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ outputLines := strings.Split(output, "\n")
+ Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
+ Ω(outputLines[1]).Should(MatchRegexp(`\[\d+\] More_ginkgo_tests Suite - 2/2 specs [%s]{2} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
+ Ω(output).Should(ContainSubstring("Test Suite Passed"))
+ })
+ })
+ Context("with a trailing /...", func() {
+ It("should run all the tests (in succinct mode) and succeed", func() {
+ session := startGinkgo(tmpDir, "--noColor", "./...")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ outputLines := strings.Split(output, "\n")
+ Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
+ Ω(outputLines[1]).Should(MatchRegexp(`\[\d+\] More_ginkgo_tests Suite - 2/2 specs [%s]{2} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
+ Ω(output).Should(ContainSubstring("Test Suite Passed"))
+ })
+ })
+ })
+
+ Context("when one of the packages has a failing tests", func() {
+ BeforeEach(func() {
+ failingTest := tmpPath("C")
+ copyIn(fixturePath("failing_ginkgo_tests"), failingTest, false)
+ })
+
+ It("should fail and stop running tests", func() {
+ session := startGinkgo(tmpDir, "--noColor", "-r")
+ Eventually(session).Should(gexec.Exit(1))
+ output := string(session.Out.Contents())
+
+ outputLines := strings.Split(output, "\n")
+ Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
+ Ω(outputLines[1]).Should(MatchRegexp(`\[\d+\] Failing_ginkgo_tests Suite - 2/2 specs`))
+ Ω(output).Should(ContainSubstring(fmt.Sprintf("%s Failure", denoter)))
+ Ω(output).ShouldNot(ContainSubstring("More_ginkgo_tests Suite"))
+ Ω(output).Should(ContainSubstring("Test Suite Failed"))
+
+ Ω(output).Should(ContainSubstring("Summarizing 1 Failure:"))
+ Ω(output).Should(ContainSubstring("[Fail] FailingGinkgoTests [It] should fail"))
+ })
+ })
+
+ Context("when one of the packages fails to compile", func() {
+ BeforeEach(func() {
+ doesNotCompileTest := tmpPath("C")
+ copyIn(fixturePath("does_not_compile"), doesNotCompileTest, false)
+ })
+
+ It("should fail and stop running tests", func() {
+ session := startGinkgo(tmpDir, "--noColor", "-r")
+ Eventually(session).Should(gexec.Exit(1))
+ output := string(session.Out.Contents())
+
+ outputLines := strings.Split(output, "\n")
+ Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
+ Ω(outputLines[1]).Should(ContainSubstring("Failed to compile C:"))
+ Ω(output).ShouldNot(ContainSubstring("More_ginkgo_tests Suite"))
+ Ω(output).Should(ContainSubstring("Test Suite Failed"))
+ })
+ })
+
+ Context("when either is the case, but the keepGoing flag is set", func() {
+ BeforeEach(func() {
+ doesNotCompileTest := tmpPath("B")
+ copyIn(fixturePath("does_not_compile"), doesNotCompileTest, false)
+
+ failingTest := tmpPath("C")
+ copyIn(fixturePath("failing_ginkgo_tests"), failingTest, false)
+ })
+
+ It("should soldier on", func() {
+ session := startGinkgo(tmpDir, "--noColor", "-r", "-keepGoing")
+ Eventually(session).Should(gexec.Exit(1))
+ output := string(session.Out.Contents())
+
+ outputLines := strings.Split(output, "\n")
+ Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
+ Ω(outputLines[1]).Should(ContainSubstring("Failed to compile B:"))
+ Ω(output).Should(MatchRegexp(`\[\d+\] Failing_ginkgo_tests Suite - 2/2 specs`))
+ Ω(output).Should(ContainSubstring(fmt.Sprintf("%s Failure", denoter)))
+ Ω(output).Should(MatchRegexp(`\[\d+\] More_ginkgo_tests Suite - 2/2 specs [%s]{2} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
+ Ω(output).Should(ContainSubstring("Test Suite Failed"))
+ })
+ })
+ })
+
+ Context("when told to keep going --untilItFails", func() {
+ BeforeEach(func() {
+ copyIn(fixturePath("eventually_failing"), tmpDir, false)
+ })
+
+ It("should keep rerunning the tests, until a failure occurs", func() {
+ session := startGinkgo(tmpDir, "--untilItFails", "--noColor")
+ Eventually(session).Should(gexec.Exit(1))
+ Ω(session).Should(gbytes.Say("This was attempt #1"))
+ Ω(session).Should(gbytes.Say("This was attempt #2"))
+ Ω(session).Should(gbytes.Say("Tests failed on attempt #3"))
+
+ //it should change the random seed between each test
+ lines := strings.Split(string(session.Out.Contents()), "\n")
+ randomSeeds := []string{}
+ for _, line := range lines {
+ if strings.Contains(line, "Random Seed:") {
+ randomSeeds = append(randomSeeds, strings.Split(line, ": ")[1])
+ }
+ }
+ Ω(randomSeeds[0]).ShouldNot(Equal(randomSeeds[1]))
+ Ω(randomSeeds[1]).ShouldNot(Equal(randomSeeds[2]))
+ Ω(randomSeeds[0]).ShouldNot(Equal(randomSeeds[2]))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/skip_test.go b/vendor/github.com/onsi/ginkgo/integration/skip_test.go
new file mode 100644
index 000000000..f0fc9d5ee
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/skip_test.go
@@ -0,0 +1,43 @@
+package integration_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("Skipping Specs", func() {
+ var pathToTest string
+
+ BeforeEach(func() {
+ pathToTest = tmpPath("skipping")
+ copyIn(fixturePath("skip_fixture"), pathToTest, false)
+ })
+
+ It("should skip in all the possible ways", func() {
+ session := startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).ShouldNot(ContainSubstring("NEVER SEE THIS"))
+
+ Ω(output).Should(ContainSubstring("a top level skip on line 9"))
+ Ω(output).Should(ContainSubstring("skip_fixture_test.go:9"))
+ Ω(output).Should(ContainSubstring("an async top level skip on line 14"))
+ Ω(output).Should(ContainSubstring("skip_fixture_test.go:14"))
+ Ω(output).Should(ContainSubstring("a top level goroutine skip on line 21"))
+ Ω(output).Should(ContainSubstring("skip_fixture_test.go:21"))
+
+ Ω(output).Should(ContainSubstring("a sync SKIP"))
+ Ω(output).Should(ContainSubstring("an async SKIP"))
+ Ω(output).Should(ContainSubstring("a goroutine SKIP"))
+ Ω(output).Should(ContainSubstring("a measure SKIP"))
+
+ Ω(output).Should(ContainSubstring("S [SKIPPING] in Spec Setup (BeforeEach) ["))
+ Ω(output).Should(ContainSubstring("a BeforeEach SKIP"))
+ Ω(output).Should(ContainSubstring("S [SKIPPING] in Spec Teardown (AfterEach) ["))
+ Ω(output).Should(ContainSubstring("an AfterEach SKIP"))
+
+ Ω(output).Should(ContainSubstring("0 Passed | 0 Failed | 0 Pending | 9 Skipped"))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/subcommand_test.go b/vendor/github.com/onsi/ginkgo/integration/subcommand_test.go
new file mode 100644
index 000000000..fec197f56
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/subcommand_test.go
@@ -0,0 +1,419 @@
+package integration_test
+
+import (
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "strings"
+
+ . "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/types"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("Subcommand", func() {
+ Describe("ginkgo bootstrap", func() {
+ var pkgPath string
+ BeforeEach(func() {
+ pkgPath = tmpPath("foo")
+ os.Mkdir(pkgPath, 0777)
+ })
+
+ It("should generate a bootstrap file, as long as one does not exist", func() {
+ session := startGinkgo(pkgPath, "bootstrap")
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("foo_suite_test.go"))
+
+ content, err := ioutil.ReadFile(filepath.Join(pkgPath, "foo_suite_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package foo_test"))
+ Ω(content).Should(ContainSubstring("func TestFoo(t *testing.T) {"))
+ Ω(content).Should(ContainSubstring("RegisterFailHandler"))
+ Ω(content).Should(ContainSubstring("RunSpecs"))
+
+ Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/ginkgo"`))
+ Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/gomega"`))
+
+ session = startGinkgo(pkgPath, "bootstrap")
+ Eventually(session).Should(gexec.Exit(1))
+ output = session.Out.Contents()
+ Ω(output).Should(ContainSubstring("foo_suite_test.go already exists"))
+ })
+
+ It("should import nodot declarations when told to", func() {
+ session := startGinkgo(pkgPath, "bootstrap", "--nodot")
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("foo_suite_test.go"))
+
+ content, err := ioutil.ReadFile(filepath.Join(pkgPath, "foo_suite_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package foo_test"))
+ Ω(content).Should(ContainSubstring("func TestFoo(t *testing.T) {"))
+ Ω(content).Should(ContainSubstring("RegisterFailHandler"))
+ Ω(content).Should(ContainSubstring("RunSpecs"))
+
+ Ω(content).Should(ContainSubstring("var It = ginkgo.It"))
+ Ω(content).Should(ContainSubstring("var Ω = gomega.Ω"))
+
+ Ω(content).Should(ContainSubstring("\t" + `"github.com/onsi/ginkgo"`))
+ Ω(content).Should(ContainSubstring("\t" + `"github.com/onsi/gomega"`))
+ })
+
+ It("should generate an agouti bootstrap file when told to", func() {
+ session := startGinkgo(pkgPath, "bootstrap", "--agouti")
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("foo_suite_test.go"))
+
+ content, err := ioutil.ReadFile(filepath.Join(pkgPath, "foo_suite_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package foo_test"))
+ Ω(content).Should(ContainSubstring("func TestFoo(t *testing.T) {"))
+ Ω(content).Should(ContainSubstring("RegisterFailHandler"))
+ Ω(content).Should(ContainSubstring("RunSpecs"))
+
+ Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/ginkgo"`))
+ Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/gomega"`))
+ Ω(content).Should(ContainSubstring("\t" + `"github.com/sclevine/agouti"`))
+ })
+
+ It("should generate a bootstrap file using a template when told to", func() {
+ templateFile := filepath.Join(pkgPath, ".bootstrap")
+ ioutil.WriteFile(templateFile, []byte(`package {{.Package}}
+
+ import (
+ {{.GinkgoImport}}
+ {{.GomegaImport}}
+
+ "testing"
+ "binary"
+ )
+
+ func Test{{.FormattedName}}(t *testing.T) {
+ // This is a {{.Package}} test
+ }`), 0666)
+ session := startGinkgo(pkgPath, "bootstrap", "--template", templateFile)
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("foo_suite_test.go"))
+
+ content, err := ioutil.ReadFile(filepath.Join(pkgPath, "foo_suite_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package foo_test"))
+ Ω(content).Should(ContainSubstring(`. "github.com/onsi/ginkgo"`))
+ Ω(content).Should(ContainSubstring(`. "github.com/onsi/gomega"`))
+ Ω(content).Should(ContainSubstring(`"binary"`))
+ Ω(content).Should(ContainSubstring("// This is a foo_test test"))
+ })
+ })
+
+ Describe("nodot", func() {
+ It("should update the declarations in the bootstrap file", func() {
+ pkgPath := tmpPath("foo")
+ os.Mkdir(pkgPath, 0777)
+
+ session := startGinkgo(pkgPath, "bootstrap", "--nodot")
+ Eventually(session).Should(gexec.Exit(0))
+
+ byteContent, err := ioutil.ReadFile(filepath.Join(pkgPath, "foo_suite_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+
+ content := string(byteContent)
+ content = strings.Replace(content, "var It =", "var MyIt =", -1)
+ content = strings.Replace(content, "var Ω = gomega.Ω\n", "", -1)
+
+ err = ioutil.WriteFile(filepath.Join(pkgPath, "foo_suite_test.go"), []byte(content), os.ModePerm)
+ Ω(err).ShouldNot(HaveOccurred())
+
+ session = startGinkgo(pkgPath, "nodot")
+ Eventually(session).Should(gexec.Exit(0))
+
+ byteContent, err = ioutil.ReadFile(filepath.Join(pkgPath, "foo_suite_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+
+ Ω(byteContent).Should(ContainSubstring("var MyIt = ginkgo.It"))
+ Ω(byteContent).ShouldNot(ContainSubstring("var It = ginkgo.It"))
+ Ω(byteContent).Should(ContainSubstring("var Ω = gomega.Ω"))
+ })
+ })
+
+ Describe("ginkgo generate", func() {
+ var pkgPath string
+
+ BeforeEach(func() {
+ pkgPath = tmpPath("foo_bar")
+ os.Mkdir(pkgPath, 0777)
+ })
+
+ Context("with no arguments", func() {
+ It("should generate a test file named after the package", func() {
+ session := startGinkgo(pkgPath, "generate")
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("foo_bar_test.go"))
+
+ content, err := ioutil.ReadFile(filepath.Join(pkgPath, "foo_bar_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package foo_bar_test"))
+ Ω(content).Should(ContainSubstring(`var _ = Describe("FooBar", func() {`))
+ Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/ginkgo"`))
+ Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/gomega"`))
+
+ session = startGinkgo(pkgPath, "generate")
+ Eventually(session).Should(gexec.Exit(1))
+ output = session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("foo_bar_test.go already exists"))
+ })
+ })
+
+ Context("with an argument of the form: foo", func() {
+ It("should generate a test file named after the argument", func() {
+ session := startGinkgo(pkgPath, "generate", "baz_buzz")
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("baz_buzz_test.go"))
+
+ content, err := ioutil.ReadFile(filepath.Join(pkgPath, "baz_buzz_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package foo_bar_test"))
+ Ω(content).Should(ContainSubstring(`var _ = Describe("BazBuzz", func() {`))
+ })
+ })
+
+ Context("with an argument of the form: foo.go", func() {
+ It("should generate a test file named after the argument", func() {
+ session := startGinkgo(pkgPath, "generate", "baz_buzz.go")
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("baz_buzz_test.go"))
+
+ content, err := ioutil.ReadFile(filepath.Join(pkgPath, "baz_buzz_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package foo_bar_test"))
+ Ω(content).Should(ContainSubstring(`var _ = Describe("BazBuzz", func() {`))
+
+ })
+ })
+
+ Context("with an argument of the form: foo_test", func() {
+ It("should generate a test file named after the argument", func() {
+ session := startGinkgo(pkgPath, "generate", "baz_buzz_test")
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("baz_buzz_test.go"))
+
+ content, err := ioutil.ReadFile(filepath.Join(pkgPath, "baz_buzz_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package foo_bar_test"))
+ Ω(content).Should(ContainSubstring(`var _ = Describe("BazBuzz", func() {`))
+ })
+ })
+
+ Context("with an argument of the form: foo_test.go", func() {
+ It("should generate a test file named after the argument", func() {
+ session := startGinkgo(pkgPath, "generate", "baz_buzz_test.go")
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("baz_buzz_test.go"))
+
+ content, err := ioutil.ReadFile(filepath.Join(pkgPath, "baz_buzz_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package foo_bar_test"))
+ Ω(content).Should(ContainSubstring(`var _ = Describe("BazBuzz", func() {`))
+ })
+ })
+
+ Context("with multiple arguments", func() {
+ It("should generate a test file named after the argument", func() {
+ session := startGinkgo(pkgPath, "generate", "baz", "buzz")
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("baz_test.go"))
+ Ω(output).Should(ContainSubstring("buzz_test.go"))
+
+ content, err := ioutil.ReadFile(filepath.Join(pkgPath, "baz_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package foo_bar_test"))
+ Ω(content).Should(ContainSubstring(`var _ = Describe("Baz", func() {`))
+
+ content, err = ioutil.ReadFile(filepath.Join(pkgPath, "buzz_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package foo_bar_test"))
+ Ω(content).Should(ContainSubstring(`var _ = Describe("Buzz", func() {`))
+ })
+ })
+
+ Context("with nodot", func() {
+ It("should not import ginkgo or gomega", func() {
+ session := startGinkgo(pkgPath, "generate", "--nodot")
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("foo_bar_test.go"))
+
+ content, err := ioutil.ReadFile(filepath.Join(pkgPath, "foo_bar_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package foo_bar_test"))
+ Ω(content).ShouldNot(ContainSubstring("\t" + `. "github.com/onsi/ginkgo"`))
+ Ω(content).ShouldNot(ContainSubstring("\t" + `. "github.com/onsi/gomega"`))
+ })
+ })
+
+ Context("with agouti", func() {
+ It("should generate an agouti test file", func() {
+ session := startGinkgo(pkgPath, "generate", "--agouti")
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("foo_bar_test.go"))
+
+ content, err := ioutil.ReadFile(filepath.Join(pkgPath, "foo_bar_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package foo_bar_test"))
+ Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/ginkgo"`))
+ Ω(content).Should(ContainSubstring("\t" + `. "github.com/onsi/gomega"`))
+ Ω(content).Should(ContainSubstring("\t" + `. "github.com/sclevine/agouti/matchers"`))
+ Ω(content).Should(ContainSubstring("\t" + `"github.com/sclevine/agouti"`))
+ Ω(content).Should(ContainSubstring("page, err = agoutiDriver.NewPage()"))
+ })
+ })
+ })
+
+ Describe("ginkgo bootstrap/generate", func() {
+ var pkgPath string
+ BeforeEach(func() {
+ pkgPath = tmpPath("some crazy-thing")
+ os.Mkdir(pkgPath, 0777)
+ })
+
+ Context("when the working directory is empty", func() {
+ It("generates correctly named bootstrap and generate files with a package name derived from the directory", func() {
+ session := startGinkgo(pkgPath, "bootstrap")
+ Eventually(session).Should(gexec.Exit(0))
+
+ content, err := ioutil.ReadFile(filepath.Join(pkgPath, "some_crazy_thing_suite_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package some_crazy_thing_test"))
+ Ω(content).Should(ContainSubstring("SomeCrazyThing Suite"))
+
+ session = startGinkgo(pkgPath, "generate")
+ Eventually(session).Should(gexec.Exit(0))
+
+ content, err = ioutil.ReadFile(filepath.Join(pkgPath, "some_crazy_thing_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package some_crazy_thing_test"))
+ Ω(content).Should(ContainSubstring("SomeCrazyThing"))
+ })
+ })
+
+ Context("when the working directory contains a file with a package name", func() {
+ BeforeEach(func() {
+ Ω(ioutil.WriteFile(filepath.Join(pkgPath, "foo.go"), []byte("package main\n\nfunc main() {}"), 0777)).Should(Succeed())
+ })
+
+ It("generates correctly named bootstrap and generate files with the package name", func() {
+ session := startGinkgo(pkgPath, "bootstrap")
+ Eventually(session).Should(gexec.Exit(0))
+
+ content, err := ioutil.ReadFile(filepath.Join(pkgPath, "some_crazy_thing_suite_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package main_test"))
+ Ω(content).Should(ContainSubstring("SomeCrazyThing Suite"))
+
+ session = startGinkgo(pkgPath, "generate")
+ Eventually(session).Should(gexec.Exit(0))
+
+ content, err = ioutil.ReadFile(filepath.Join(pkgPath, "some_crazy_thing_test.go"))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(content).Should(ContainSubstring("package main_test"))
+ Ω(content).Should(ContainSubstring("SomeCrazyThing"))
+ })
+ })
+ })
+
+ Describe("ginkgo blur", func() {
+ It("should unfocus tests", func() {
+ pathToTest := tmpPath("focused")
+ fixture := fixturePath("focused_fixture")
+ copyIn(fixture, pathToTest, false)
+
+ session := startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(types.GINKGO_FOCUS_EXIT_CODE))
+ output := session.Out.Contents()
+
+ Ω(string(output)).Should(ContainSubstring("8 Passed"))
+ Ω(string(output)).Should(ContainSubstring("5 Skipped"))
+
+ session = startGinkgo(pathToTest, "blur")
+ Eventually(session).Should(gexec.Exit(0))
+ output = session.Out.Contents()
+ Ω(string(output)).ShouldNot(ContainSubstring("expected 'package'"))
+
+ session = startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(0))
+ output = session.Out.Contents()
+ Ω(string(output)).Should(ContainSubstring("13 Passed"))
+ Ω(string(output)).Should(ContainSubstring("0 Skipped"))
+
+ Expect(sameFile(filepath.Join(pathToTest, "README.md"), filepath.Join(fixture, "README.md"))).To(BeTrue())
+ })
+
+ It("should ignore the 'vendor' folder", func() {
+ pathToTest := tmpPath("focused_fixture_with_vendor")
+ copyIn(fixturePath("focused_fixture_with_vendor"), pathToTest, true)
+
+ session := startGinkgo(pathToTest, "blur")
+ Eventually(session).Should(gexec.Exit(0))
+
+ session = startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+ Expect(string(output)).To(ContainSubstring("13 Passed"))
+ Expect(string(output)).To(ContainSubstring("0 Skipped"))
+
+ vendorPath := fixturePath("focused_fixture_with_vendor/vendor")
+ otherVendorPath := filepath.Join(pathToTest, "vendor")
+
+ Expect(sameFolder(vendorPath, otherVendorPath)).To(BeTrue())
+ })
+ })
+
+ Describe("ginkgo version", func() {
+ It("should print out the version info", func() {
+ session := startGinkgo("", "version")
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(MatchRegexp(`Ginkgo Version \d+\.\d+\.\d+`))
+ })
+ })
+
+ Describe("ginkgo help", func() {
+ It("should print out usage information", func() {
+ session := startGinkgo("", "help")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Err.Contents())
+
+ Ω(output).Should(MatchRegexp(`Ginkgo Version \d+\.\d+\.\d+`))
+ Ω(output).Should(ContainSubstring("ginkgo watch"))
+ Ω(output).Should(ContainSubstring("-succinct"))
+ Ω(output).Should(ContainSubstring("-nodes"))
+ Ω(output).Should(ContainSubstring("ginkgo generate"))
+ Ω(output).Should(ContainSubstring("ginkgo help <COMMAND>"))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/suite_command_test.go b/vendor/github.com/onsi/ginkgo/integration/suite_command_test.go
new file mode 100644
index 000000000..4aec1bc41
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/suite_command_test.go
@@ -0,0 +1,63 @@
+package integration_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("Suite Command Specs", func() {
+ var pathToTest string
+
+ BeforeEach(func() {
+ pathToTest = tmpPath("suite_command")
+ copyIn(fixturePath("suite_command_tests"), pathToTest, false)
+ })
+
+ It("Runs command after suite echoing out suite data, properly reporting suite name and passing status in successful command output", func() {
+ command := "-afterSuiteHook=echo THIS IS A (ginkgo-suite-passed) TEST OF THE (ginkgo-suite-name) SYSTEM, THIS IS ONLY A TEST"
+ expected := "THIS IS A [PASS] TEST OF THE suite_command SYSTEM, THIS IS ONLY A TEST"
+ session := startGinkgo(pathToTest, command)
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("1 Passed"))
+ Ω(output).Should(ContainSubstring("0 Failed"))
+ Ω(output).Should(ContainSubstring("1 Pending"))
+ Ω(output).Should(ContainSubstring("0 Skipped"))
+ Ω(output).Should(ContainSubstring("Test Suite Passed"))
+ Ω(output).Should(ContainSubstring("Post-suite command succeeded:"))
+ Ω(output).Should(ContainSubstring(expected))
+ })
+
+ It("Runs command after suite reporting that command failed", func() {
+ command := "-afterSuiteHook=exit 1"
+ session := startGinkgo(pathToTest, command)
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("1 Passed"))
+ Ω(output).Should(ContainSubstring("0 Failed"))
+ Ω(output).Should(ContainSubstring("1 Pending"))
+ Ω(output).Should(ContainSubstring("0 Skipped"))
+ Ω(output).Should(ContainSubstring("Test Suite Passed"))
+ Ω(output).Should(ContainSubstring("Post-suite command failed:"))
+ })
+
+ It("Runs command after suite echoing out suite data, properly reporting suite name and failing status in successful command output", func() {
+ command := "-afterSuiteHook=echo THIS IS A (ginkgo-suite-passed) TEST OF THE (ginkgo-suite-name) SYSTEM, THIS IS ONLY A TEST"
+ expected := "THIS IS A [FAIL] TEST OF THE suite_command SYSTEM, THIS IS ONLY A TEST"
+ session := startGinkgo(pathToTest, "-failOnPending=true", command)
+ Eventually(session).Should(gexec.Exit(1))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("1 Passed"))
+ Ω(output).Should(ContainSubstring("0 Failed"))
+ Ω(output).Should(ContainSubstring("1 Pending"))
+ Ω(output).Should(ContainSubstring("0 Skipped"))
+ Ω(output).Should(ContainSubstring("Test Suite Failed"))
+ Ω(output).Should(ContainSubstring("Post-suite command succeeded:"))
+ Ω(output).Should(ContainSubstring(expected))
+ })
+
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/suite_setup_test.go b/vendor/github.com/onsi/ginkgo/integration/suite_setup_test.go
new file mode 100644
index 000000000..33ff5b983
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/suite_setup_test.go
@@ -0,0 +1,178 @@
+package integration_test
+
+import (
+ "strings"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("SuiteSetup", func() {
+ var pathToTest string
+
+ Context("when the BeforeSuite and AfterSuite pass", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("suite_setup")
+ copyIn(fixturePath("passing_suite_setup"), pathToTest, false)
+ })
+
+ It("should run the BeforeSuite once, then run all the tests", func() {
+ session := startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(1))
+ Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(1))
+ })
+
+ It("should run the BeforeSuite once per parallel node, then run all the tests", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--nodes=2")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(2))
+ Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(2))
+ })
+ })
+
+ Context("when the BeforeSuite fails", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("suite_setup")
+ copyIn(fixturePath("failing_before_suite"), pathToTest, false)
+ })
+
+ It("should run the BeforeSuite once, none of the tests, but it should run the AfterSuite", func() {
+ session := startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(1))
+ output := string(session.Out.Contents())
+
+ Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(1))
+ Ω(strings.Count(output, "Test Panicked")).Should(Equal(1))
+ Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(1))
+ Ω(output).ShouldNot(ContainSubstring("NEVER SEE THIS"))
+ })
+
+ It("should run the BeforeSuite once per parallel node, none of the tests, but it should run the AfterSuite for each node", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--nodes=2")
+ Eventually(session).Should(gexec.Exit(1))
+ output := string(session.Out.Contents())
+
+ Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(2))
+ Ω(strings.Count(output, "Test Panicked")).Should(Equal(2))
+ Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(2))
+ Ω(output).ShouldNot(ContainSubstring("NEVER SEE THIS"))
+ })
+ })
+
+ Context("when the AfterSuite fails", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("suite_setup")
+ copyIn(fixturePath("failing_after_suite"), pathToTest, false)
+ })
+
+ It("should run the BeforeSuite once, none of the tests, but it should run the AfterSuite", func() {
+ session := startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(1))
+ output := string(session.Out.Contents())
+
+ Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(1))
+ Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(1))
+ Ω(strings.Count(output, "Test Panicked")).Should(Equal(1))
+ Ω(strings.Count(output, "A TEST")).Should(Equal(2))
+ })
+
+ It("should run the BeforeSuite once per parallel node, none of the tests, but it should run the AfterSuite for each node", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--nodes=2")
+ Eventually(session).Should(gexec.Exit(1))
+ output := string(session.Out.Contents())
+
+ Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(2))
+ Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(2))
+ Ω(strings.Count(output, "Test Panicked")).Should(Equal(2))
+ Ω(strings.Count(output, "A TEST")).Should(Equal(2))
+ })
+ })
+
+ Context("With passing synchronized before and after suites", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("suite_setup")
+ copyIn(fixturePath("synchronized_setup_tests"), pathToTest, false)
+ })
+
+ Context("when run with one node", func() {
+ It("should do all the work on that one node", func() {
+ session := startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("BEFORE_A_1\nBEFORE_B_1: DATA"))
+ Ω(output).Should(ContainSubstring("AFTER_A_1\nAFTER_B_1"))
+ })
+ })
+
+ Context("when run across multiple nodes", func() {
+ It("should run the first BeforeSuite function (BEFORE_A) on node 1, the second (BEFORE_B) on all the nodes, the first AfterSuite (AFTER_A) on all the nodes, and then the second (AFTER_B) on Node 1 *after* everything else is finished", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--nodes=3")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("BEFORE_A_1"))
+ Ω(output).Should(ContainSubstring("BEFORE_B_1: DATA"))
+ Ω(output).Should(ContainSubstring("BEFORE_B_2: DATA"))
+ Ω(output).Should(ContainSubstring("BEFORE_B_3: DATA"))
+
+ Ω(output).ShouldNot(ContainSubstring("BEFORE_A_2"))
+ Ω(output).ShouldNot(ContainSubstring("BEFORE_A_3"))
+
+ Ω(output).Should(ContainSubstring("AFTER_A_1"))
+ Ω(output).Should(ContainSubstring("AFTER_A_2"))
+ Ω(output).Should(ContainSubstring("AFTER_A_3"))
+ Ω(output).Should(ContainSubstring("AFTER_B_1"))
+
+ Ω(output).ShouldNot(ContainSubstring("AFTER_B_2"))
+ Ω(output).ShouldNot(ContainSubstring("AFTER_B_3"))
+ })
+ })
+
+ Context("when streaming across multiple nodes", func() {
+ It("should run the first BeforeSuite function (BEFORE_A) on node 1, the second (BEFORE_B) on all the nodes, the first AfterSuite (AFTER_A) on all the nodes, and then the second (AFTER_B) on Node 1 *after* everything else is finished", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--nodes=3", "--stream")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("[1] BEFORE_A_1"))
+ Ω(output).Should(ContainSubstring("[1] BEFORE_B_1: DATA"))
+ Ω(output).Should(ContainSubstring("[2] BEFORE_B_2: DATA"))
+ Ω(output).Should(ContainSubstring("[3] BEFORE_B_3: DATA"))
+
+ Ω(output).ShouldNot(ContainSubstring("BEFORE_A_2"))
+ Ω(output).ShouldNot(ContainSubstring("BEFORE_A_3"))
+
+ Ω(output).Should(ContainSubstring("[1] AFTER_A_1"))
+ Ω(output).Should(ContainSubstring("[2] AFTER_A_2"))
+ Ω(output).Should(ContainSubstring("[3] AFTER_A_3"))
+ Ω(output).Should(ContainSubstring("[1] AFTER_B_1"))
+
+ Ω(output).ShouldNot(ContainSubstring("AFTER_B_2"))
+ Ω(output).ShouldNot(ContainSubstring("AFTER_B_3"))
+ })
+ })
+ })
+
+ Context("With a failing synchronized before suite", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("suite_setup")
+ copyIn(fixturePath("exiting_synchronized_setup_tests"), pathToTest, false)
+ })
+
+ It("should fail and let the user know that node 1 disappeared prematurely", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--nodes=3")
+ Eventually(session).Should(gexec.Exit(1))
+ output := string(session.Out.Contents())
+
+ Ω(output).Should(ContainSubstring("Node 1 disappeared before completing BeforeSuite"))
+ Ω(output).Should(ContainSubstring("Ginkgo timed out waiting for all parallel nodes to report back!"))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/tags_test.go b/vendor/github.com/onsi/ginkgo/integration/tags_test.go
new file mode 100644
index 000000000..fc2ff5e5c
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/tags_test.go
@@ -0,0 +1,27 @@
+package integration_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("Tags", func() {
+ var pathToTest string
+ BeforeEach(func() {
+ pathToTest = tmpPath("tags")
+ copyIn(fixturePath("tags_tests"), pathToTest, false)
+ })
+
+ It("should honor the passed in -tags flag", func() {
+ session := startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(0))
+ output := string(session.Out.Contents())
+ Ω(output).Should(ContainSubstring("Ran 1 of 1 Specs"))
+
+ session = startGinkgo(pathToTest, "--noColor", "-tags=complex_tests")
+ Eventually(session).Should(gexec.Exit(0))
+ output = string(session.Out.Contents())
+ Ω(output).Should(ContainSubstring("Ran 3 of 3 Specs"))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/test_description_test.go b/vendor/github.com/onsi/ginkgo/integration/test_description_test.go
new file mode 100644
index 000000000..6739871fb
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/test_description_test.go
@@ -0,0 +1,25 @@
+package integration_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gbytes"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("TestDescription", func() {
+ var pathToTest string
+
+ BeforeEach(func() {
+ pathToTest = tmpPath("test_description")
+ copyIn(fixturePath("test_description"), pathToTest, false)
+ })
+
+ It("should capture and emit information about the current test", func() {
+ session := startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(1))
+
+ Ω(session).Should(gbytes.Say("TestDescription should pass:false"))
+ Ω(session).Should(gbytes.Say("TestDescription should fail:true"))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/verbose_and_succinct_test.go b/vendor/github.com/onsi/ginkgo/integration/verbose_and_succinct_test.go
new file mode 100644
index 000000000..8238762d1
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/verbose_and_succinct_test.go
@@ -0,0 +1,90 @@
+package integration_test
+
+import (
+ "regexp"
+ "runtime"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("Verbose And Succinct Mode", func() {
+ var pathToTest string
+ var otherPathToTest string
+
+ isWindows := (runtime.GOOS == "windows")
+ denoter := "•"
+
+ if isWindows {
+ denoter = "+"
+ }
+
+ Context("when running one package", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("ginkgo")
+ copyIn(fixturePath("passing_ginkgo_tests"), pathToTest, false)
+ })
+
+ It("should default to non-succinct mode", func() {
+ session := startGinkgo(pathToTest, "--noColor")
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
+ })
+ })
+
+ Context("when running more than one package", func() {
+ BeforeEach(func() {
+ pathToTest = tmpPath("ginkgo")
+ copyIn(fixturePath("passing_ginkgo_tests"), pathToTest, false)
+ otherPathToTest = tmpPath("more_ginkgo")
+ copyIn(fixturePath("more_ginkgo_tests"), otherPathToTest, false)
+ })
+
+ Context("with no flags set", func() {
+ It("should default to succinct mode", func() {
+ session := startGinkgo(pathToTest, "--noColor", pathToTest, otherPathToTest)
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(MatchRegexp(`\] Passing_ginkgo_tests Suite - 4/4 specs [%s]{4} SUCCESS!`, regexp.QuoteMeta(denoter)))
+ Ω(output).Should(MatchRegexp(`\] More_ginkgo_tests Suite - 2/2 specs [%s]{2} SUCCESS!`, regexp.QuoteMeta(denoter)))
+ })
+ })
+
+ Context("with --succinct=false", func() {
+ It("should not be in succinct mode", func() {
+ session := startGinkgo(pathToTest, "--noColor", "--succinct=false", pathToTest, otherPathToTest)
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
+ Ω(output).Should(ContainSubstring("Running Suite: More_ginkgo_tests Suite"))
+ })
+ })
+
+ Context("with -v", func() {
+ It("should not be in succinct mode, but should be verbose", func() {
+ session := startGinkgo(pathToTest, "--noColor", "-v", pathToTest, otherPathToTest)
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
+ Ω(output).Should(ContainSubstring("Running Suite: More_ginkgo_tests Suite"))
+ Ω(output).Should(ContainSubstring("should proxy strings"))
+ Ω(output).Should(ContainSubstring("should always pass"))
+ })
+
+ It("should emit output from Bys", func() {
+ session := startGinkgo(pathToTest, "--noColor", "-v", pathToTest)
+ Eventually(session).Should(gexec.Exit(0))
+ output := session.Out.Contents()
+
+ Ω(output).Should(ContainSubstring("emitting one By"))
+ Ω(output).Should(ContainSubstring("emitting another By"))
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/integration/watch_test.go b/vendor/github.com/onsi/ginkgo/integration/watch_test.go
new file mode 100644
index 000000000..1d65702a7
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/integration/watch_test.go
@@ -0,0 +1,275 @@
+package integration_test
+
+import (
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "time"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gbytes"
+ "github.com/onsi/gomega/gexec"
+)
+
+var _ = Describe("Watch", func() {
+ var rootPath string
+ var pathA string
+ var pathB string
+ var pathC string
+ var session *gexec.Session
+
+ BeforeEach(func() {
+ rootPath = tmpPath("root")
+ pathA = filepath.Join(rootPath, "src", "github.com", "onsi", "A")
+ pathB = filepath.Join(rootPath, "src", "github.com", "onsi", "B")
+ pathC = filepath.Join(rootPath, "src", "github.com", "onsi", "C")
+
+ err := os.MkdirAll(pathA, 0700)
+ Ω(err).ShouldNot(HaveOccurred())
+
+ err = os.MkdirAll(pathB, 0700)
+ Ω(err).ShouldNot(HaveOccurred())
+
+ err = os.MkdirAll(pathC, 0700)
+ Ω(err).ShouldNot(HaveOccurred())
+
+ copyIn(fixturePath(filepath.Join("watch_fixtures", "A")), pathA, false)
+ copyIn(fixturePath(filepath.Join("watch_fixtures", "B")), pathB, false)
+ copyIn(fixturePath(filepath.Join("watch_fixtures", "C")), pathC, false)
+ })
+
+ startGinkgoWithGopath := func(args ...string) *gexec.Session {
+ cmd := ginkgoCommand(rootPath, args...)
+ os.Setenv("GOPATH", rootPath+":"+os.Getenv("GOPATH"))
+ session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
+ Ω(err).ShouldNot(HaveOccurred())
+ return session
+ }
+
+ modifyFile := func(path string) {
+ time.Sleep(time.Second)
+ content, err := ioutil.ReadFile(path)
+ Ω(err).ShouldNot(HaveOccurred())
+ content = append(content, []byte("//")...)
+ err = ioutil.WriteFile(path, content, 0666)
+ Ω(err).ShouldNot(HaveOccurred())
+ }
+
+ modifyCode := func(pkgToModify string) {
+ modifyFile(filepath.Join(rootPath, "src", "github.com", "onsi", pkgToModify, pkgToModify+".go"))
+ }
+
+ modifyJSON := func(pkgToModify string) {
+ modifyFile(filepath.Join(rootPath, "src", "github.com", "onsi", pkgToModify, pkgToModify+".json"))
+ }
+
+ modifyTest := func(pkgToModify string) {
+ modifyFile(filepath.Join(rootPath, "src", "github.com", "onsi", pkgToModify, pkgToModify+"_test.go"))
+ }
+
+ AfterEach(func() {
+ if session != nil {
+ session.Kill().Wait()
+ }
+ })
+
+ It("should be set up correctly", func() {
+ session = startGinkgoWithGopath("-r")
+ Eventually(session).Should(gexec.Exit(0))
+ Ω(session.Out.Contents()).Should(ContainSubstring("A Suite"))
+ Ω(session.Out.Contents()).Should(ContainSubstring("B Suite"))
+ Ω(session.Out.Contents()).Should(ContainSubstring("C Suite"))
+ Ω(session.Out.Contents()).Should(ContainSubstring("Ginkgo ran 3 suites"))
+ })
+
+ Context("when watching just one test suite", func() {
+ It("should immediately run, and should rerun when the test suite changes", func() {
+ session = startGinkgoWithGopath("watch", "-succinct", pathA)
+ Eventually(session).Should(gbytes.Say("A Suite"))
+ modifyCode("A")
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("A Suite"))
+ session.Kill().Wait()
+ })
+ })
+
+ Context("when watching several test suites", func() {
+ It("should not immediately run, but should rerun a test when its code changes", func() {
+ session = startGinkgoWithGopath("watch", "-succinct", "-r")
+ Eventually(session).Should(gbytes.Say("Identified 3 test suites"))
+ Consistently(session).ShouldNot(gbytes.Say("A Suite|B Suite|C Suite"))
+ modifyCode("A")
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("A Suite"))
+ Consistently(session).ShouldNot(gbytes.Say("B Suite|C Suite"))
+ session.Kill().Wait()
+ })
+ })
+
+ Describe("watching dependencies", func() {
+ Context("with a depth of 2", func() {
+ It("should watch down to that depth", func() {
+ session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=2")
+ Eventually(session).Should(gbytes.Say("Identified 3 test suites"))
+ Eventually(session).Should(gbytes.Say(`A \[2 dependencies\]`))
+ Eventually(session).Should(gbytes.Say(`B \[1 dependency\]`))
+ Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`))
+
+ modifyCode("A")
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("A Suite"))
+ Consistently(session).ShouldNot(gbytes.Say("B Suite|C Suite"))
+
+ modifyCode("B")
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("B Suite"))
+ Eventually(session).Should(gbytes.Say("A Suite"))
+ Consistently(session).ShouldNot(gbytes.Say("C Suite"))
+
+ modifyCode("C")
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("C Suite"))
+ Eventually(session).Should(gbytes.Say("B Suite"))
+ Eventually(session).Should(gbytes.Say("A Suite"))
+ })
+ })
+
+ Context("with a depth of 1", func() {
+ It("should watch down to that depth", func() {
+ session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=1")
+ Eventually(session).Should(gbytes.Say("Identified 3 test suites"))
+ Eventually(session).Should(gbytes.Say(`A \[1 dependency\]`))
+ Eventually(session).Should(gbytes.Say(`B \[1 dependency\]`))
+ Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`))
+
+ modifyCode("A")
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("A Suite"))
+ Consistently(session).ShouldNot(gbytes.Say("B Suite|C Suite"))
+
+ modifyCode("B")
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("B Suite"))
+ Eventually(session).Should(gbytes.Say("A Suite"))
+ Consistently(session).ShouldNot(gbytes.Say("C Suite"))
+
+ modifyCode("C")
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("C Suite"))
+ Eventually(session).Should(gbytes.Say("B Suite"))
+ Consistently(session).ShouldNot(gbytes.Say("A Suite"))
+ })
+ })
+
+ Context("with a depth of 0", func() {
+ It("should not watch any dependencies", func() {
+ session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=0")
+ Eventually(session).Should(gbytes.Say("Identified 3 test suites"))
+ Eventually(session).Should(gbytes.Say(`A \[0 dependencies\]`))
+ Eventually(session).Should(gbytes.Say(`B \[0 dependencies\]`))
+ Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`))
+
+ modifyCode("A")
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("A Suite"))
+ Consistently(session).ShouldNot(gbytes.Say("B Suite|C Suite"))
+
+ modifyCode("B")
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("B Suite"))
+ Consistently(session).ShouldNot(gbytes.Say("A Suite|C Suite"))
+
+ modifyCode("C")
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("C Suite"))
+ Consistently(session).ShouldNot(gbytes.Say("A Suite|B Suite"))
+ })
+ })
+
+ It("should not trigger dependents when tests are changed", func() {
+ session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=2")
+ Eventually(session).Should(gbytes.Say("Identified 3 test suites"))
+ Eventually(session).Should(gbytes.Say(`A \[2 dependencies\]`))
+ Eventually(session).Should(gbytes.Say(`B \[1 dependency\]`))
+ Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`))
+
+ modifyTest("A")
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("A Suite"))
+ Consistently(session).ShouldNot(gbytes.Say("B Suite|C Suite"))
+
+ modifyTest("B")
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("B Suite"))
+ Consistently(session).ShouldNot(gbytes.Say("A Suite|C Suite"))
+
+ modifyTest("C")
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("C Suite"))
+ Consistently(session).ShouldNot(gbytes.Say("A Suite|B Suite"))
+ })
+ })
+
+ Describe("adjusting the watch regular expression", func() {
+ Describe("the default regular expression", func() {
+ It("should only trigger when go files are changed", func() {
+ session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=2")
+ Eventually(session).Should(gbytes.Say("Identified 3 test suites"))
+ Eventually(session).Should(gbytes.Say(`A \[2 dependencies\]`))
+ Eventually(session).Should(gbytes.Say(`B \[1 dependency\]`))
+ Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`))
+
+ modifyJSON("C")
+ Consistently(session).ShouldNot(gbytes.Say("Detected changes in"))
+ Consistently(session).ShouldNot(gbytes.Say("A Suite|B Suite|C Suite"))
+ })
+ })
+
+ Describe("modifying the regular expression", func() {
+ It("should trigger if the regexp matches", func() {
+ session = startGinkgoWithGopath("watch", "-succinct", "-r", "-depth=2", `-watchRegExp=\.json$`)
+ Eventually(session).Should(gbytes.Say("Identified 3 test suites"))
+ Eventually(session).Should(gbytes.Say(`A \[2 dependencies\]`))
+ Eventually(session).Should(gbytes.Say(`B \[1 dependency\]`))
+ Eventually(session).Should(gbytes.Say(`C \[0 dependencies\]`))
+
+ modifyJSON("C")
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("C Suite"))
+ Eventually(session).Should(gbytes.Say("B Suite"))
+ Eventually(session).Should(gbytes.Say("A Suite"))
+ })
+ })
+ })
+
+ Describe("when new test suite is added", func() {
+ It("should start monitoring that test suite", func() {
+ session = startGinkgoWithGopath("watch", "-succinct", "-r")
+
+ Eventually(session).Should(gbytes.Say("Watching 3 suites"))
+
+ pathD := filepath.Join(rootPath, "src", "github.com", "onsi", "D")
+
+ err := os.MkdirAll(pathD, 0700)
+ Ω(err).ShouldNot(HaveOccurred())
+
+ copyIn(fixturePath(filepath.Join("watch_fixtures", "D")), pathD, false)
+
+ Eventually(session).Should(gbytes.Say("Detected 1 new suite"))
+ Eventually(session).Should(gbytes.Say(`D \[1 dependency\]`))
+ Eventually(session).Should(gbytes.Say("D Suite"))
+
+ modifyCode("D")
+
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("D Suite"))
+
+ modifyCode("C")
+
+ Eventually(session).Should(gbytes.Say("Detected changes in"))
+ Eventually(session).Should(gbytes.Say("C Suite"))
+ Eventually(session).Should(gbytes.Say("D Suite"))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/codelocation/code_location.go b/vendor/github.com/onsi/ginkgo/internal/codelocation/code_location.go
new file mode 100644
index 000000000..fa2f0bf73
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/codelocation/code_location.go
@@ -0,0 +1,32 @@
+package codelocation
+
+import (
+ "regexp"
+ "runtime"
+ "runtime/debug"
+ "strings"
+
+ "github.com/onsi/ginkgo/types"
+)
+
+func New(skip int) types.CodeLocation {
+ _, file, line, _ := runtime.Caller(skip + 1)
+ stackTrace := PruneStack(string(debug.Stack()), skip)
+ return types.CodeLocation{FileName: file, LineNumber: line, FullStackTrace: stackTrace}
+}
+
+func PruneStack(fullStackTrace string, skip int) string {
+ stack := strings.Split(fullStackTrace, "\n")
+ if len(stack) > 2*(skip+1) {
+ stack = stack[2*(skip+1):]
+ }
+ prunedStack := []string{}
+ re := regexp.MustCompile(`\/ginkgo\/|\/pkg\/testing\/|\/pkg\/runtime\/`)
+ for i := 0; i < len(stack)/2; i++ {
+ if !re.Match([]byte(stack[i*2])) {
+ prunedStack = append(prunedStack, stack[i*2])
+ prunedStack = append(prunedStack, stack[i*2+1])
+ }
+ }
+ return strings.Join(prunedStack, "\n")
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_suite_test.go b/vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_suite_test.go
new file mode 100644
index 000000000..f06abf3c5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_suite_test.go
@@ -0,0 +1,13 @@
+package codelocation_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestCodelocation(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "CodeLocation Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_test.go b/vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_test.go
new file mode 100644
index 000000000..cca75a449
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/codelocation/code_location_test.go
@@ -0,0 +1,80 @@
+package codelocation_test
+
+import (
+ "runtime"
+
+ . "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/internal/codelocation"
+ "github.com/onsi/ginkgo/types"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("CodeLocation", func() {
+ var (
+ codeLocation types.CodeLocation
+ expectedFileName string
+ expectedLineNumber int
+ )
+
+ caller0 := func() {
+ codeLocation = codelocation.New(1)
+ }
+
+ caller1 := func() {
+ _, expectedFileName, expectedLineNumber, _ = runtime.Caller(0)
+ expectedLineNumber += 2
+ caller0()
+ }
+
+ BeforeEach(func() {
+ caller1()
+ })
+
+ It("should use the passed in skip parameter to pick out the correct file & line number", func() {
+ Ω(codeLocation.FileName).Should(Equal(expectedFileName))
+ Ω(codeLocation.LineNumber).Should(Equal(expectedLineNumber))
+ })
+
+ Describe("stringer behavior", func() {
+ It("should stringify nicely", func() {
+ Ω(codeLocation.String()).Should(ContainSubstring("code_location_test.go:%d", expectedLineNumber))
+ })
+ })
+
+ //There's no better way than to test this private method as it
+ //goes out of its way to prune out ginkgo related code in the stack trace
+ Describe("PruneStack", func() {
+ It("should remove any references to ginkgo and pkg/testing and pkg/runtime", func() {
+ input := `/Skip/me
+Skip: skip()
+/Skip/me
+Skip: skip()
+/Users/whoever/gospace/src/github.com/onsi/ginkgo/whatever.go:10 (0x12314)
+Something: Func()
+/Users/whoever/gospace/src/github.com/onsi/ginkgo/whatever_else.go:10 (0x12314)
+SomethingInternalToGinkgo: Func()
+/usr/goroot/pkg/strings/oops.go:10 (0x12341)
+Oops: BlowUp()
+/Users/whoever/gospace/src/mycode/code.go:10 (0x12341)
+MyCode: Func()
+/Users/whoever/gospace/src/mycode/code_test.go:10 (0x12341)
+MyCodeTest: Func()
+/Users/whoever/gospace/src/mycode/code_suite_test.go:12 (0x37f08)
+TestFoo: RunSpecs(t, "Foo Suite")
+/usr/goroot/pkg/testing/testing.go:12 (0x37f08)
+TestingT: Blah()
+/usr/goroot/pkg/runtime/runtime.go:12 (0x37f08)
+Something: Func()
+`
+ prunedStack := codelocation.PruneStack(input, 1)
+ Ω(prunedStack).Should(Equal(`/usr/goroot/pkg/strings/oops.go:10 (0x12341)
+Oops: BlowUp()
+/Users/whoever/gospace/src/mycode/code.go:10 (0x12341)
+MyCode: Func()
+/Users/whoever/gospace/src/mycode/code_test.go:10 (0x12341)
+MyCodeTest: Func()
+/Users/whoever/gospace/src/mycode/code_suite_test.go:12 (0x37f08)
+TestFoo: RunSpecs(t, "Foo Suite")`))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/containernode/container_node.go b/vendor/github.com/onsi/ginkgo/internal/containernode/container_node.go
new file mode 100644
index 000000000..0737746dc
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/containernode/container_node.go
@@ -0,0 +1,151 @@
+package containernode
+
+import (
+ "math/rand"
+ "sort"
+
+ "github.com/onsi/ginkgo/internal/leafnodes"
+ "github.com/onsi/ginkgo/types"
+)
+
+type subjectOrContainerNode struct {
+ containerNode *ContainerNode
+ subjectNode leafnodes.SubjectNode
+}
+
+func (n subjectOrContainerNode) text() string {
+ if n.containerNode != nil {
+ return n.containerNode.Text()
+ } else {
+ return n.subjectNode.Text()
+ }
+}
+
+type CollatedNodes struct {
+ Containers []*ContainerNode
+ Subject leafnodes.SubjectNode
+}
+
+type ContainerNode struct {
+ text string
+ flag types.FlagType
+ codeLocation types.CodeLocation
+
+ setupNodes []leafnodes.BasicNode
+ subjectAndContainerNodes []subjectOrContainerNode
+}
+
+func New(text string, flag types.FlagType, codeLocation types.CodeLocation) *ContainerNode {
+ return &ContainerNode{
+ text: text,
+ flag: flag,
+ codeLocation: codeLocation,
+ }
+}
+
+func (container *ContainerNode) Shuffle(r *rand.Rand) {
+ sort.Sort(container)
+ permutation := r.Perm(len(container.subjectAndContainerNodes))
+ shuffledNodes := make([]subjectOrContainerNode, len(container.subjectAndContainerNodes))
+ for i, j := range permutation {
+ shuffledNodes[i] = container.subjectAndContainerNodes[j]
+ }
+ container.subjectAndContainerNodes = shuffledNodes
+}
+
+func (node *ContainerNode) BackPropagateProgrammaticFocus() bool {
+ if node.flag == types.FlagTypePending {
+ return false
+ }
+
+ shouldUnfocus := false
+ for _, subjectOrContainerNode := range node.subjectAndContainerNodes {
+ if subjectOrContainerNode.containerNode != nil {
+ shouldUnfocus = subjectOrContainerNode.containerNode.BackPropagateProgrammaticFocus() || shouldUnfocus
+ } else {
+ shouldUnfocus = (subjectOrContainerNode.subjectNode.Flag() == types.FlagTypeFocused) || shouldUnfocus
+ }
+ }
+
+ if shouldUnfocus {
+ if node.flag == types.FlagTypeFocused {
+ node.flag = types.FlagTypeNone
+ }
+ return true
+ }
+
+ return node.flag == types.FlagTypeFocused
+}
+
+func (node *ContainerNode) Collate() []CollatedNodes {
+ return node.collate([]*ContainerNode{})
+}
+
+func (node *ContainerNode) collate(enclosingContainers []*ContainerNode) []CollatedNodes {
+ collated := make([]CollatedNodes, 0)
+
+ containers := make([]*ContainerNode, len(enclosingContainers))
+ copy(containers, enclosingContainers)
+ containers = append(containers, node)
+
+ for _, subjectOrContainer := range node.subjectAndContainerNodes {
+ if subjectOrContainer.containerNode != nil {
+ collated = append(collated, subjectOrContainer.containerNode.collate(containers)...)
+ } else {
+ collated = append(collated, CollatedNodes{
+ Containers: containers,
+ Subject: subjectOrContainer.subjectNode,
+ })
+ }
+ }
+
+ return collated
+}
+
+func (node *ContainerNode) PushContainerNode(container *ContainerNode) {
+ node.subjectAndContainerNodes = append(node.subjectAndContainerNodes, subjectOrContainerNode{containerNode: container})
+}
+
+func (node *ContainerNode) PushSubjectNode(subject leafnodes.SubjectNode) {
+ node.subjectAndContainerNodes = append(node.subjectAndContainerNodes, subjectOrContainerNode{subjectNode: subject})
+}
+
+func (node *ContainerNode) PushSetupNode(setupNode leafnodes.BasicNode) {
+ node.setupNodes = append(node.setupNodes, setupNode)
+}
+
+func (node *ContainerNode) SetupNodesOfType(nodeType types.SpecComponentType) []leafnodes.BasicNode {
+ nodes := []leafnodes.BasicNode{}
+ for _, setupNode := range node.setupNodes {
+ if setupNode.Type() == nodeType {
+ nodes = append(nodes, setupNode)
+ }
+ }
+ return nodes
+}
+
+func (node *ContainerNode) Text() string {
+ return node.text
+}
+
+func (node *ContainerNode) CodeLocation() types.CodeLocation {
+ return node.codeLocation
+}
+
+func (node *ContainerNode) Flag() types.FlagType {
+ return node.flag
+}
+
+//sort.Interface
+
+func (node *ContainerNode) Len() int {
+ return len(node.subjectAndContainerNodes)
+}
+
+func (node *ContainerNode) Less(i, j int) bool {
+ return node.subjectAndContainerNodes[i].text() < node.subjectAndContainerNodes[j].text()
+}
+
+func (node *ContainerNode) Swap(i, j int) {
+ node.subjectAndContainerNodes[i], node.subjectAndContainerNodes[j] = node.subjectAndContainerNodes[j], node.subjectAndContainerNodes[i]
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/containernode/container_node_suite_test.go b/vendor/github.com/onsi/ginkgo/internal/containernode/container_node_suite_test.go
new file mode 100644
index 000000000..c6fc314ff
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/containernode/container_node_suite_test.go
@@ -0,0 +1,13 @@
+package containernode_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestContainernode(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Containernode Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/containernode/container_node_test.go b/vendor/github.com/onsi/ginkgo/internal/containernode/container_node_test.go
new file mode 100644
index 000000000..11ac9b70b
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/containernode/container_node_test.go
@@ -0,0 +1,213 @@
+package containernode_test
+
+import (
+ "math/rand"
+
+ "github.com/onsi/ginkgo/internal/leafnodes"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "github.com/onsi/ginkgo/internal/codelocation"
+ . "github.com/onsi/ginkgo/internal/containernode"
+ "github.com/onsi/ginkgo/types"
+)
+
+var _ = Describe("Container Node", func() {
+ var (
+ codeLocation types.CodeLocation
+ container *ContainerNode
+ )
+
+ BeforeEach(func() {
+ codeLocation = codelocation.New(0)
+ container = New("description text", types.FlagTypeFocused, codeLocation)
+ })
+
+ Describe("creating a container node", func() {
+ It("can answer questions about itself", func() {
+ Ω(container.Text()).Should(Equal("description text"))
+ Ω(container.Flag()).Should(Equal(types.FlagTypeFocused))
+ Ω(container.CodeLocation()).Should(Equal(codeLocation))
+ })
+ })
+
+ Describe("pushing setup nodes", func() {
+ It("can append setup nodes of various types and fetch them by type", func() {
+ befA := leafnodes.NewBeforeEachNode(func() {}, codelocation.New(0), 0, nil, 0)
+ befB := leafnodes.NewBeforeEachNode(func() {}, codelocation.New(0), 0, nil, 0)
+ aftA := leafnodes.NewAfterEachNode(func() {}, codelocation.New(0), 0, nil, 0)
+ aftB := leafnodes.NewAfterEachNode(func() {}, codelocation.New(0), 0, nil, 0)
+ jusBefA := leafnodes.NewJustBeforeEachNode(func() {}, codelocation.New(0), 0, nil, 0)
+ jusBefB := leafnodes.NewJustBeforeEachNode(func() {}, codelocation.New(0), 0, nil, 0)
+
+ container.PushSetupNode(befA)
+ container.PushSetupNode(befB)
+ container.PushSetupNode(aftA)
+ container.PushSetupNode(aftB)
+ container.PushSetupNode(jusBefA)
+ container.PushSetupNode(jusBefB)
+
+ subject := leafnodes.NewItNode("subject", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
+ container.PushSubjectNode(subject)
+
+ Ω(container.SetupNodesOfType(types.SpecComponentTypeBeforeEach)).Should(Equal([]leafnodes.BasicNode{befA, befB}))
+ Ω(container.SetupNodesOfType(types.SpecComponentTypeAfterEach)).Should(Equal([]leafnodes.BasicNode{aftA, aftB}))
+ Ω(container.SetupNodesOfType(types.SpecComponentTypeJustBeforeEach)).Should(Equal([]leafnodes.BasicNode{jusBefA, jusBefB}))
+ Ω(container.SetupNodesOfType(types.SpecComponentTypeIt)).Should(BeEmpty()) //subjects are not setup nodes
+ })
+ })
+
+ Context("With appended containers and subject nodes", func() {
+ var (
+ itA, itB, innerItA, innerItB leafnodes.SubjectNode
+ innerContainer *ContainerNode
+ )
+
+ BeforeEach(func() {
+ itA = leafnodes.NewItNode("Banana", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
+ itB = leafnodes.NewItNode("Apple", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
+
+ innerItA = leafnodes.NewItNode("inner A", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
+ innerItB = leafnodes.NewItNode("inner B", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
+
+ innerContainer = New("Orange", types.FlagTypeNone, codelocation.New(0))
+
+ container.PushSubjectNode(itA)
+ container.PushContainerNode(innerContainer)
+ innerContainer.PushSubjectNode(innerItA)
+ innerContainer.PushSubjectNode(innerItB)
+ container.PushSubjectNode(itB)
+ })
+
+ Describe("Collating", func() {
+ It("should return a collated set of containers and subject nodes in the correct order", func() {
+ collated := container.Collate()
+ Ω(collated).Should(HaveLen(4))
+
+ Ω(collated[0]).Should(Equal(CollatedNodes{
+ Containers: []*ContainerNode{container},
+ Subject: itA,
+ }))
+
+ Ω(collated[1]).Should(Equal(CollatedNodes{
+ Containers: []*ContainerNode{container, innerContainer},
+ Subject: innerItA,
+ }))
+
+ Ω(collated[2]).Should(Equal(CollatedNodes{
+ Containers: []*ContainerNode{container, innerContainer},
+ Subject: innerItB,
+ }))
+
+ Ω(collated[3]).Should(Equal(CollatedNodes{
+ Containers: []*ContainerNode{container},
+ Subject: itB,
+ }))
+ })
+ })
+
+ Describe("Backpropagating Programmatic Focus", func() {
+ //This allows inner focused specs to override the focus of outer focussed
+ //specs and more closely maps to what a developer wants to happen
+ //when debugging a test suite
+
+ Context("when a parent is focused *and* an inner subject is focused", func() {
+ BeforeEach(func() {
+ container = New("description text", types.FlagTypeFocused, codeLocation)
+ itA = leafnodes.NewItNode("A", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
+ container.PushSubjectNode(itA)
+
+ innerContainer = New("Orange", types.FlagTypeNone, codelocation.New(0))
+ container.PushContainerNode(innerContainer)
+ innerItA = leafnodes.NewItNode("inner A", func() {}, types.FlagTypeFocused, codelocation.New(0), 0, nil, 0)
+ innerContainer.PushSubjectNode(innerItA)
+ })
+
+ It("should unfocus the parent", func() {
+ container.BackPropagateProgrammaticFocus()
+
+ Ω(container.Flag()).Should(Equal(types.FlagTypeNone))
+ Ω(itA.Flag()).Should(Equal(types.FlagTypeNone))
+ Ω(innerContainer.Flag()).Should(Equal(types.FlagTypeNone))
+ Ω(innerItA.Flag()).Should(Equal(types.FlagTypeFocused))
+ })
+ })
+
+ Context("when a parent is focused *and* an inner container is focused", func() {
+ BeforeEach(func() {
+ container = New("description text", types.FlagTypeFocused, codeLocation)
+ itA = leafnodes.NewItNode("A", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
+ container.PushSubjectNode(itA)
+
+ innerContainer = New("Orange", types.FlagTypeFocused, codelocation.New(0))
+ container.PushContainerNode(innerContainer)
+ innerItA = leafnodes.NewItNode("inner A", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
+ innerContainer.PushSubjectNode(innerItA)
+ })
+
+ It("should unfocus the parent", func() {
+ container.BackPropagateProgrammaticFocus()
+
+ Ω(container.Flag()).Should(Equal(types.FlagTypeNone))
+ Ω(itA.Flag()).Should(Equal(types.FlagTypeNone))
+ Ω(innerContainer.Flag()).Should(Equal(types.FlagTypeFocused))
+ Ω(innerItA.Flag()).Should(Equal(types.FlagTypeNone))
+ })
+ })
+
+ Context("when a parent is pending and a child is focused", func() {
+ BeforeEach(func() {
+ container = New("description text", types.FlagTypeFocused, codeLocation)
+ itA = leafnodes.NewItNode("A", func() {}, types.FlagTypeNone, codelocation.New(0), 0, nil, 0)
+ container.PushSubjectNode(itA)
+
+ innerContainer = New("Orange", types.FlagTypePending, codelocation.New(0))
+ container.PushContainerNode(innerContainer)
+ innerItA = leafnodes.NewItNode("inner A", func() {}, types.FlagTypeFocused, codelocation.New(0), 0, nil, 0)
+ innerContainer.PushSubjectNode(innerItA)
+ })
+
+ It("should not do anything", func() {
+ container.BackPropagateProgrammaticFocus()
+
+ Ω(container.Flag()).Should(Equal(types.FlagTypeFocused))
+ Ω(itA.Flag()).Should(Equal(types.FlagTypeNone))
+ Ω(innerContainer.Flag()).Should(Equal(types.FlagTypePending))
+ Ω(innerItA.Flag()).Should(Equal(types.FlagTypeFocused))
+ })
+ })
+ })
+
+ Describe("Shuffling", func() {
+ var unshuffledCollation []CollatedNodes
+ BeforeEach(func() {
+ unshuffledCollation = container.Collate()
+
+ r := rand.New(rand.NewSource(17))
+ container.Shuffle(r)
+ })
+
+ It("should sort, and then shuffle, the top level contents of the container", func() {
+ shuffledCollation := container.Collate()
+ Ω(shuffledCollation).Should(HaveLen(len(unshuffledCollation)))
+ Ω(shuffledCollation).ShouldNot(Equal(unshuffledCollation))
+
+ for _, entry := range unshuffledCollation {
+ Ω(shuffledCollation).Should(ContainElement(entry))
+ }
+
+ innerAIndex, innerBIndex := 0, 0
+ for i, entry := range shuffledCollation {
+ if entry.Subject == innerItA {
+ innerAIndex = i
+ } else if entry.Subject == innerItB {
+ innerBIndex = i
+ }
+ }
+
+ Ω(innerAIndex).Should(Equal(innerBIndex - 1))
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/failer/failer.go b/vendor/github.com/onsi/ginkgo/internal/failer/failer.go
new file mode 100644
index 000000000..678ea2514
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/failer/failer.go
@@ -0,0 +1,92 @@
+package failer
+
+import (
+ "fmt"
+ "sync"
+
+ "github.com/onsi/ginkgo/types"
+)
+
+type Failer struct {
+ lock *sync.Mutex
+ failure types.SpecFailure
+ state types.SpecState
+}
+
+func New() *Failer {
+ return &Failer{
+ lock: &sync.Mutex{},
+ state: types.SpecStatePassed,
+ }
+}
+
+func (f *Failer) Panic(location types.CodeLocation, forwardedPanic interface{}) {
+ f.lock.Lock()
+ defer f.lock.Unlock()
+
+ if f.state == types.SpecStatePassed {
+ f.state = types.SpecStatePanicked
+ f.failure = types.SpecFailure{
+ Message: "Test Panicked",
+ Location: location,
+ ForwardedPanic: fmt.Sprintf("%v", forwardedPanic),
+ }
+ }
+}
+
+func (f *Failer) Timeout(location types.CodeLocation) {
+ f.lock.Lock()
+ defer f.lock.Unlock()
+
+ if f.state == types.SpecStatePassed {
+ f.state = types.SpecStateTimedOut
+ f.failure = types.SpecFailure{
+ Message: "Timed out",
+ Location: location,
+ }
+ }
+}
+
+func (f *Failer) Fail(message string, location types.CodeLocation) {
+ f.lock.Lock()
+ defer f.lock.Unlock()
+
+ if f.state == types.SpecStatePassed {
+ f.state = types.SpecStateFailed
+ f.failure = types.SpecFailure{
+ Message: message,
+ Location: location,
+ }
+ }
+}
+
+func (f *Failer) Drain(componentType types.SpecComponentType, componentIndex int, componentCodeLocation types.CodeLocation) (types.SpecFailure, types.SpecState) {
+ f.lock.Lock()
+ defer f.lock.Unlock()
+
+ failure := f.failure
+ outcome := f.state
+ if outcome != types.SpecStatePassed {
+ failure.ComponentType = componentType
+ failure.ComponentIndex = componentIndex
+ failure.ComponentCodeLocation = componentCodeLocation
+ }
+
+ f.state = types.SpecStatePassed
+ f.failure = types.SpecFailure{}
+
+ return failure, outcome
+}
+
+func (f *Failer) Skip(message string, location types.CodeLocation) {
+ f.lock.Lock()
+ defer f.lock.Unlock()
+
+ if f.state == types.SpecStatePassed {
+ f.state = types.SpecStateSkipped
+ f.failure = types.SpecFailure{
+ Message: message,
+ Location: location,
+ }
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/failer/failer_suite_test.go b/vendor/github.com/onsi/ginkgo/internal/failer/failer_suite_test.go
new file mode 100644
index 000000000..8dce7be9a
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/failer/failer_suite_test.go
@@ -0,0 +1,13 @@
+package failer_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestFailer(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Failer Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/failer/failer_test.go b/vendor/github.com/onsi/ginkgo/internal/failer/failer_test.go
new file mode 100644
index 000000000..65210a40a
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/failer/failer_test.go
@@ -0,0 +1,141 @@
+package failer_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/internal/failer"
+ . "github.com/onsi/gomega"
+
+ "github.com/onsi/ginkgo/internal/codelocation"
+ "github.com/onsi/ginkgo/types"
+)
+
+var _ = Describe("Failer", func() {
+ var (
+ failer *Failer
+ codeLocationA types.CodeLocation
+ codeLocationB types.CodeLocation
+ )
+
+ BeforeEach(func() {
+ codeLocationA = codelocation.New(0)
+ codeLocationB = codelocation.New(0)
+ failer = New()
+ })
+
+ Context("with no failures", func() {
+ It("should return success when drained", func() {
+ failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
+ Ω(failure).Should(BeZero())
+ Ω(state).Should(Equal(types.SpecStatePassed))
+ })
+ })
+
+ Describe("Skip", func() {
+ It("should handle failures", func() {
+ failer.Skip("something skipped", codeLocationA)
+ failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
+ Ω(failure).Should(Equal(types.SpecFailure{
+ Message: "something skipped",
+ Location: codeLocationA,
+ ForwardedPanic: "",
+ ComponentType: types.SpecComponentTypeIt,
+ ComponentIndex: 3,
+ ComponentCodeLocation: codeLocationB,
+ }))
+ Ω(state).Should(Equal(types.SpecStateSkipped))
+ })
+ })
+
+ Describe("Fail", func() {
+ It("should handle failures", func() {
+ failer.Fail("something failed", codeLocationA)
+ failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
+ Ω(failure).Should(Equal(types.SpecFailure{
+ Message: "something failed",
+ Location: codeLocationA,
+ ForwardedPanic: "",
+ ComponentType: types.SpecComponentTypeIt,
+ ComponentIndex: 3,
+ ComponentCodeLocation: codeLocationB,
+ }))
+ Ω(state).Should(Equal(types.SpecStateFailed))
+ })
+ })
+
+ Describe("Panic", func() {
+ It("should handle panics", func() {
+ failer.Panic(codeLocationA, "some forwarded panic")
+ failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
+ Ω(failure).Should(Equal(types.SpecFailure{
+ Message: "Test Panicked",
+ Location: codeLocationA,
+ ForwardedPanic: "some forwarded panic",
+ ComponentType: types.SpecComponentTypeIt,
+ ComponentIndex: 3,
+ ComponentCodeLocation: codeLocationB,
+ }))
+ Ω(state).Should(Equal(types.SpecStatePanicked))
+ })
+ })
+
+ Describe("Timeout", func() {
+ It("should handle timeouts", func() {
+ failer.Timeout(codeLocationA)
+ failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
+ Ω(failure).Should(Equal(types.SpecFailure{
+ Message: "Timed out",
+ Location: codeLocationA,
+ ForwardedPanic: "",
+ ComponentType: types.SpecComponentTypeIt,
+ ComponentIndex: 3,
+ ComponentCodeLocation: codeLocationB,
+ }))
+ Ω(state).Should(Equal(types.SpecStateTimedOut))
+ })
+ })
+
+ Context("when multiple failures are registered", func() {
+ BeforeEach(func() {
+ failer.Fail("something failed", codeLocationA)
+ failer.Fail("something else failed", codeLocationA)
+ })
+
+ It("should only report the first one when drained", func() {
+ failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
+
+ Ω(failure).Should(Equal(types.SpecFailure{
+ Message: "something failed",
+ Location: codeLocationA,
+ ForwardedPanic: "",
+ ComponentType: types.SpecComponentTypeIt,
+ ComponentIndex: 3,
+ ComponentCodeLocation: codeLocationB,
+ }))
+ Ω(state).Should(Equal(types.SpecStateFailed))
+ })
+
+ It("should report subsequent failures after being drained", func() {
+ failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
+ failer.Fail("yet another thing failed", codeLocationA)
+
+ failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
+
+ Ω(failure).Should(Equal(types.SpecFailure{
+ Message: "yet another thing failed",
+ Location: codeLocationA,
+ ForwardedPanic: "",
+ ComponentType: types.SpecComponentTypeIt,
+ ComponentIndex: 3,
+ ComponentCodeLocation: codeLocationB,
+ }))
+ Ω(state).Should(Equal(types.SpecStateFailed))
+ })
+
+ It("should report sucess on subsequent drains if no errors occur", func() {
+ failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
+ failure, state := failer.Drain(types.SpecComponentTypeIt, 3, codeLocationB)
+ Ω(failure).Should(BeZero())
+ Ω(state).Should(Equal(types.SpecStatePassed))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/benchmarker.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/benchmarker.go
new file mode 100644
index 000000000..d6d54234c
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/benchmarker.go
@@ -0,0 +1,103 @@
+package leafnodes
+
+import (
+ "math"
+ "time"
+
+ "sync"
+
+ "github.com/onsi/ginkgo/types"
+)
+
+type benchmarker struct {
+ mu sync.Mutex
+ measurements map[string]*types.SpecMeasurement
+ orderCounter int
+}
+
+func newBenchmarker() *benchmarker {
+ return &benchmarker{
+ measurements: make(map[string]*types.SpecMeasurement, 0),
+ }
+}
+
+func (b *benchmarker) Time(name string, body func(), info ...interface{}) (elapsedTime time.Duration) {
+ t := time.Now()
+ body()
+ elapsedTime = time.Since(t)
+
+ b.mu.Lock()
+ defer b.mu.Unlock()
+ measurement := b.getMeasurement(name, "Fastest Time", "Slowest Time", "Average Time", "s", 3, info...)
+ measurement.Results = append(measurement.Results, elapsedTime.Seconds())
+
+ return
+}
+
+func (b *benchmarker) RecordValue(name string, value float64, info ...interface{}) {
+ b.mu.Lock()
+ measurement := b.getMeasurement(name, "Smallest", " Largest", " Average", "", 3, info...)
+ defer b.mu.Unlock()
+ measurement.Results = append(measurement.Results, value)
+}
+
+func (b *benchmarker) RecordValueWithPrecision(name string, value float64, units string, precision int, info ...interface{}) {
+ b.mu.Lock()
+ measurement := b.getMeasurement(name, "Smallest", " Largest", " Average", units, precision, info...)
+ defer b.mu.Unlock()
+ measurement.Results = append(measurement.Results, value)
+}
+
+func (b *benchmarker) getMeasurement(name string, smallestLabel string, largestLabel string, averageLabel string, units string, precision int, info ...interface{}) *types.SpecMeasurement {
+ measurement, ok := b.measurements[name]
+ if !ok {
+ var computedInfo interface{}
+ computedInfo = nil
+ if len(info) > 0 {
+ computedInfo = info[0]
+ }
+ measurement = &types.SpecMeasurement{
+ Name: name,
+ Info: computedInfo,
+ Order: b.orderCounter,
+ SmallestLabel: smallestLabel,
+ LargestLabel: largestLabel,
+ AverageLabel: averageLabel,
+ Units: units,
+ Precision: precision,
+ Results: make([]float64, 0),
+ }
+ b.measurements[name] = measurement
+ b.orderCounter++
+ }
+
+ return measurement
+}
+
+func (b *benchmarker) measurementsReport() map[string]*types.SpecMeasurement {
+ b.mu.Lock()
+ defer b.mu.Unlock()
+ for _, measurement := range b.measurements {
+ measurement.Smallest = math.MaxFloat64
+ measurement.Largest = -math.MaxFloat64
+ sum := float64(0)
+ sumOfSquares := float64(0)
+
+ for _, result := range measurement.Results {
+ if result > measurement.Largest {
+ measurement.Largest = result
+ }
+ if result < measurement.Smallest {
+ measurement.Smallest = result
+ }
+ sum += result
+ sumOfSquares += result * result
+ }
+
+ n := float64(len(measurement.Results))
+ measurement.Average = sum / n
+ measurement.StdDeviation = math.Sqrt(sumOfSquares/n - (sum/n)*(sum/n))
+ }
+
+ return b.measurements
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/interfaces.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/interfaces.go
new file mode 100644
index 000000000..8c3902d60
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/interfaces.go
@@ -0,0 +1,19 @@
+package leafnodes
+
+import (
+ "github.com/onsi/ginkgo/types"
+)
+
+type BasicNode interface {
+ Type() types.SpecComponentType
+ Run() (types.SpecState, types.SpecFailure)
+ CodeLocation() types.CodeLocation
+}
+
+type SubjectNode interface {
+ BasicNode
+
+ Text() string
+ Flag() types.FlagType
+ Samples() int
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/it_node.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/it_node.go
new file mode 100644
index 000000000..6eded7b76
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/it_node.go
@@ -0,0 +1,47 @@
+package leafnodes
+
+import (
+ "time"
+
+ "github.com/onsi/ginkgo/internal/failer"
+ "github.com/onsi/ginkgo/types"
+)
+
+type ItNode struct {
+ runner *runner
+
+ flag types.FlagType
+ text string
+}
+
+func NewItNode(text string, body interface{}, flag types.FlagType, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer, componentIndex int) *ItNode {
+ return &ItNode{
+ runner: newRunner(body, codeLocation, timeout, failer, types.SpecComponentTypeIt, componentIndex),
+ flag: flag,
+ text: text,
+ }
+}
+
+func (node *ItNode) Run() (outcome types.SpecState, failure types.SpecFailure) {
+ return node.runner.run()
+}
+
+func (node *ItNode) Type() types.SpecComponentType {
+ return types.SpecComponentTypeIt
+}
+
+func (node *ItNode) Text() string {
+ return node.text
+}
+
+func (node *ItNode) Flag() types.FlagType {
+ return node.flag
+}
+
+func (node *ItNode) CodeLocation() types.CodeLocation {
+ return node.runner.codeLocation
+}
+
+func (node *ItNode) Samples() int {
+ return 1
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/it_node_test.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/it_node_test.go
new file mode 100644
index 000000000..29fa0c6e2
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/it_node_test.go
@@ -0,0 +1,22 @@
+package leafnodes_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/internal/leafnodes"
+ . "github.com/onsi/gomega"
+
+ "github.com/onsi/ginkgo/internal/codelocation"
+ "github.com/onsi/ginkgo/types"
+)
+
+var _ = Describe("It Nodes", func() {
+ It("should report the correct type, text, flag, and code location", func() {
+ codeLocation := codelocation.New(0)
+ it := NewItNode("my it node", func() {}, types.FlagTypeFocused, codeLocation, 0, nil, 3)
+ Ω(it.Type()).Should(Equal(types.SpecComponentTypeIt))
+ Ω(it.Flag()).Should(Equal(types.FlagTypeFocused))
+ Ω(it.Text()).Should(Equal("my it node"))
+ Ω(it.CodeLocation()).Should(Equal(codeLocation))
+ Ω(it.Samples()).Should(Equal(1))
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/leaf_node_suite_test.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/leaf_node_suite_test.go
new file mode 100644
index 000000000..a7ba9e006
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/leaf_node_suite_test.go
@@ -0,0 +1,13 @@
+package leafnodes_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestLeafNode(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "LeafNode Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/measure_node.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/measure_node.go
new file mode 100644
index 000000000..3ab9a6d55
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/measure_node.go
@@ -0,0 +1,62 @@
+package leafnodes
+
+import (
+ "reflect"
+
+ "github.com/onsi/ginkgo/internal/failer"
+ "github.com/onsi/ginkgo/types"
+)
+
+type MeasureNode struct {
+ runner *runner
+
+ text string
+ flag types.FlagType
+ samples int
+ benchmarker *benchmarker
+}
+
+func NewMeasureNode(text string, body interface{}, flag types.FlagType, codeLocation types.CodeLocation, samples int, failer *failer.Failer, componentIndex int) *MeasureNode {
+ benchmarker := newBenchmarker()
+
+ wrappedBody := func() {
+ reflect.ValueOf(body).Call([]reflect.Value{reflect.ValueOf(benchmarker)})
+ }
+
+ return &MeasureNode{
+ runner: newRunner(wrappedBody, codeLocation, 0, failer, types.SpecComponentTypeMeasure, componentIndex),
+
+ text: text,
+ flag: flag,
+ samples: samples,
+ benchmarker: benchmarker,
+ }
+}
+
+func (node *MeasureNode) Run() (outcome types.SpecState, failure types.SpecFailure) {
+ return node.runner.run()
+}
+
+func (node *MeasureNode) MeasurementsReport() map[string]*types.SpecMeasurement {
+ return node.benchmarker.measurementsReport()
+}
+
+func (node *MeasureNode) Type() types.SpecComponentType {
+ return types.SpecComponentTypeMeasure
+}
+
+func (node *MeasureNode) Text() string {
+ return node.text
+}
+
+func (node *MeasureNode) Flag() types.FlagType {
+ return node.flag
+}
+
+func (node *MeasureNode) CodeLocation() types.CodeLocation {
+ return node.runner.codeLocation
+}
+
+func (node *MeasureNode) Samples() int {
+ return node.samples
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/measure_node_test.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/measure_node_test.go
new file mode 100644
index 000000000..1cd13336a
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/measure_node_test.go
@@ -0,0 +1,155 @@
+package leafnodes_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/internal/leafnodes"
+ . "github.com/onsi/gomega"
+
+ "time"
+
+ "github.com/onsi/ginkgo/internal/codelocation"
+ Failer "github.com/onsi/ginkgo/internal/failer"
+ "github.com/onsi/ginkgo/types"
+)
+
+var _ = Describe("Measure Nodes", func() {
+ It("should report the correct type, text, flag, and code location", func() {
+ codeLocation := codelocation.New(0)
+ measure := NewMeasureNode("my measure node", func(b Benchmarker) {}, types.FlagTypeFocused, codeLocation, 10, nil, 3)
+ Ω(measure.Type()).Should(Equal(types.SpecComponentTypeMeasure))
+ Ω(measure.Flag()).Should(Equal(types.FlagTypeFocused))
+ Ω(measure.Text()).Should(Equal("my measure node"))
+ Ω(measure.CodeLocation()).Should(Equal(codeLocation))
+ Ω(measure.Samples()).Should(Equal(10))
+ })
+
+ Describe("benchmarking", func() {
+ var measure *MeasureNode
+
+ Describe("Value", func() {
+ BeforeEach(func() {
+ measure = NewMeasureNode("the measurement", func(b Benchmarker) {
+ b.RecordValue("foo", 7, "info!")
+ b.RecordValue("foo", 2)
+ b.RecordValue("foo", 3)
+ b.RecordValue("bar", 0.3)
+ b.RecordValue("bar", 0.1)
+ b.RecordValue("bar", 0.5)
+ b.RecordValue("bar", 0.7)
+ }, types.FlagTypeFocused, codelocation.New(0), 1, Failer.New(), 3)
+ Ω(measure.Run()).Should(Equal(types.SpecStatePassed))
+ })
+
+ It("records passed in values and reports on them", func() {
+ report := measure.MeasurementsReport()
+ Ω(report).Should(HaveLen(2))
+ Ω(report["foo"].Name).Should(Equal("foo"))
+ Ω(report["foo"].Info).Should(Equal("info!"))
+ Ω(report["foo"].Order).Should(Equal(0))
+ Ω(report["foo"].SmallestLabel).Should(Equal("Smallest"))
+ Ω(report["foo"].LargestLabel).Should(Equal(" Largest"))
+ Ω(report["foo"].AverageLabel).Should(Equal(" Average"))
+ Ω(report["foo"].Units).Should(Equal(""))
+ Ω(report["foo"].Results).Should(Equal([]float64{7, 2, 3}))
+ Ω(report["foo"].Smallest).Should(BeNumerically("==", 2))
+ Ω(report["foo"].Largest).Should(BeNumerically("==", 7))
+ Ω(report["foo"].Average).Should(BeNumerically("==", 4))
+ Ω(report["foo"].StdDeviation).Should(BeNumerically("~", 2.16, 0.01))
+
+ Ω(report["bar"].Name).Should(Equal("bar"))
+ Ω(report["bar"].Info).Should(BeNil())
+ Ω(report["bar"].SmallestLabel).Should(Equal("Smallest"))
+ Ω(report["bar"].Order).Should(Equal(1))
+ Ω(report["bar"].LargestLabel).Should(Equal(" Largest"))
+ Ω(report["bar"].AverageLabel).Should(Equal(" Average"))
+ Ω(report["bar"].Units).Should(Equal(""))
+ Ω(report["bar"].Results).Should(Equal([]float64{0.3, 0.1, 0.5, 0.7}))
+ Ω(report["bar"].Smallest).Should(BeNumerically("==", 0.1))
+ Ω(report["bar"].Largest).Should(BeNumerically("==", 0.7))
+ Ω(report["bar"].Average).Should(BeNumerically("==", 0.4))
+ Ω(report["bar"].StdDeviation).Should(BeNumerically("~", 0.22, 0.01))
+ })
+ })
+
+ Describe("Value with precision", func() {
+ BeforeEach(func() {
+ measure = NewMeasureNode("the measurement", func(b Benchmarker) {
+ b.RecordValueWithPrecision("foo", 7, "ms", 7, "info!")
+ b.RecordValueWithPrecision("foo", 2, "ms", 6)
+ b.RecordValueWithPrecision("foo", 3, "ms", 5)
+ b.RecordValueWithPrecision("bar", 0.3, "ns", 4)
+ b.RecordValueWithPrecision("bar", 0.1, "ns", 3)
+ b.RecordValueWithPrecision("bar", 0.5, "ns", 2)
+ b.RecordValueWithPrecision("bar", 0.7, "ns", 1)
+ }, types.FlagTypeFocused, codelocation.New(0), 1, Failer.New(), 3)
+ Ω(measure.Run()).Should(Equal(types.SpecStatePassed))
+ })
+
+ It("records passed in values and reports on them", func() {
+ report := measure.MeasurementsReport()
+ Ω(report).Should(HaveLen(2))
+ Ω(report["foo"].Name).Should(Equal("foo"))
+ Ω(report["foo"].Info).Should(Equal("info!"))
+ Ω(report["foo"].Order).Should(Equal(0))
+ Ω(report["foo"].SmallestLabel).Should(Equal("Smallest"))
+ Ω(report["foo"].LargestLabel).Should(Equal(" Largest"))
+ Ω(report["foo"].AverageLabel).Should(Equal(" Average"))
+ Ω(report["foo"].Units).Should(Equal("ms"))
+ Ω(report["foo"].Results).Should(Equal([]float64{7, 2, 3}))
+ Ω(report["foo"].Smallest).Should(BeNumerically("==", 2))
+ Ω(report["foo"].Largest).Should(BeNumerically("==", 7))
+ Ω(report["foo"].Average).Should(BeNumerically("==", 4))
+ Ω(report["foo"].StdDeviation).Should(BeNumerically("~", 2.16, 0.01))
+
+ Ω(report["bar"].Name).Should(Equal("bar"))
+ Ω(report["bar"].Info).Should(BeNil())
+ Ω(report["bar"].SmallestLabel).Should(Equal("Smallest"))
+ Ω(report["bar"].Order).Should(Equal(1))
+ Ω(report["bar"].LargestLabel).Should(Equal(" Largest"))
+ Ω(report["bar"].AverageLabel).Should(Equal(" Average"))
+ Ω(report["bar"].Units).Should(Equal("ns"))
+ Ω(report["bar"].Results).Should(Equal([]float64{0.3, 0.1, 0.5, 0.7}))
+ Ω(report["bar"].Smallest).Should(BeNumerically("==", 0.1))
+ Ω(report["bar"].Largest).Should(BeNumerically("==", 0.7))
+ Ω(report["bar"].Average).Should(BeNumerically("==", 0.4))
+ Ω(report["bar"].StdDeviation).Should(BeNumerically("~", 0.22, 0.01))
+ })
+ })
+
+ Describe("Time", func() {
+ BeforeEach(func() {
+ measure = NewMeasureNode("the measurement", func(b Benchmarker) {
+ b.Time("foo", func() {
+ time.Sleep(200 * time.Millisecond)
+ }, "info!")
+ b.Time("foo", func() {
+ time.Sleep(300 * time.Millisecond)
+ })
+ b.Time("foo", func() {
+ time.Sleep(250 * time.Millisecond)
+ })
+ }, types.FlagTypeFocused, codelocation.New(0), 1, Failer.New(), 3)
+ Ω(measure.Run()).Should(Equal(types.SpecStatePassed))
+ })
+
+ It("records passed in values and reports on them", func() {
+ report := measure.MeasurementsReport()
+ Ω(report).Should(HaveLen(1))
+ Ω(report["foo"].Name).Should(Equal("foo"))
+ Ω(report["foo"].Info).Should(Equal("info!"))
+ Ω(report["foo"].SmallestLabel).Should(Equal("Fastest Time"))
+ Ω(report["foo"].LargestLabel).Should(Equal("Slowest Time"))
+ Ω(report["foo"].AverageLabel).Should(Equal("Average Time"))
+ Ω(report["foo"].Units).Should(Equal("s"))
+ Ω(report["foo"].Results).Should(HaveLen(3))
+ Ω(report["foo"].Results[0]).Should(BeNumerically("~", 0.2, 0.06))
+ Ω(report["foo"].Results[1]).Should(BeNumerically("~", 0.3, 0.06))
+ Ω(report["foo"].Results[2]).Should(BeNumerically("~", 0.25, 0.06))
+ Ω(report["foo"].Smallest).Should(BeNumerically("~", 0.2, 0.06))
+ Ω(report["foo"].Largest).Should(BeNumerically("~", 0.3, 0.06))
+ Ω(report["foo"].Average).Should(BeNumerically("~", 0.25, 0.06))
+ Ω(report["foo"].StdDeviation).Should(BeNumerically("~", 0.07, 0.04))
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go
new file mode 100644
index 000000000..16cb66c3e
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/runner.go
@@ -0,0 +1,117 @@
+package leafnodes
+
+import (
+ "fmt"
+ "reflect"
+ "time"
+
+ "github.com/onsi/ginkgo/internal/codelocation"
+ "github.com/onsi/ginkgo/internal/failer"
+ "github.com/onsi/ginkgo/types"
+)
+
+type runner struct {
+ isAsync bool
+ asyncFunc func(chan<- interface{})
+ syncFunc func()
+ codeLocation types.CodeLocation
+ timeoutThreshold time.Duration
+ nodeType types.SpecComponentType
+ componentIndex int
+ failer *failer.Failer
+}
+
+func newRunner(body interface{}, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer, nodeType types.SpecComponentType, componentIndex int) *runner {
+ bodyType := reflect.TypeOf(body)
+ if bodyType.Kind() != reflect.Func {
+ panic(fmt.Sprintf("Expected a function but got something else at %v", codeLocation))
+ }
+
+ runner := &runner{
+ codeLocation: codeLocation,
+ timeoutThreshold: timeout,
+ failer: failer,
+ nodeType: nodeType,
+ componentIndex: componentIndex,
+ }
+
+ switch bodyType.NumIn() {
+ case 0:
+ runner.syncFunc = body.(func())
+ return runner
+ case 1:
+ if !(bodyType.In(0).Kind() == reflect.Chan && bodyType.In(0).Elem().Kind() == reflect.Interface) {
+ panic(fmt.Sprintf("Must pass a Done channel to function at %v", codeLocation))
+ }
+
+ wrappedBody := func(done chan<- interface{}) {
+ bodyValue := reflect.ValueOf(body)
+ bodyValue.Call([]reflect.Value{reflect.ValueOf(done)})
+ }
+
+ runner.isAsync = true
+ runner.asyncFunc = wrappedBody
+ return runner
+ }
+
+ panic(fmt.Sprintf("Too many arguments to function at %v", codeLocation))
+}
+
+func (r *runner) run() (outcome types.SpecState, failure types.SpecFailure) {
+ if r.isAsync {
+ return r.runAsync()
+ } else {
+ return r.runSync()
+ }
+}
+
+func (r *runner) runAsync() (outcome types.SpecState, failure types.SpecFailure) {
+ done := make(chan interface{}, 1)
+
+ go func() {
+ finished := false
+
+ defer func() {
+ if e := recover(); e != nil || !finished {
+ r.failer.Panic(codelocation.New(2), e)
+ select {
+ case <-done:
+ break
+ default:
+ close(done)
+ }
+ }
+ }()
+
+ r.asyncFunc(done)
+ finished = true
+ }()
+
+ // If this goroutine gets no CPU time before the select block,
+ // the <-done case may complete even if the test took longer than the timeoutThreshold.
+ // This can cause flaky behaviour, but we haven't seen it in the wild.
+ select {
+ case <-done:
+ case <-time.After(r.timeoutThreshold):
+ r.failer.Timeout(r.codeLocation)
+ }
+
+ failure, outcome = r.failer.Drain(r.nodeType, r.componentIndex, r.codeLocation)
+ return
+}
+func (r *runner) runSync() (outcome types.SpecState, failure types.SpecFailure) {
+ finished := false
+
+ defer func() {
+ if e := recover(); e != nil || !finished {
+ r.failer.Panic(codelocation.New(2), e)
+ }
+
+ failure, outcome = r.failer.Drain(r.nodeType, r.componentIndex, r.codeLocation)
+ }()
+
+ r.syncFunc()
+ finished = true
+
+ return
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/setup_nodes.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/setup_nodes.go
new file mode 100644
index 000000000..e3e9cb7c5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/setup_nodes.go
@@ -0,0 +1,48 @@
+package leafnodes
+
+import (
+ "time"
+
+ "github.com/onsi/ginkgo/internal/failer"
+ "github.com/onsi/ginkgo/types"
+)
+
+type SetupNode struct {
+ runner *runner
+}
+
+func (node *SetupNode) Run() (outcome types.SpecState, failure types.SpecFailure) {
+ return node.runner.run()
+}
+
+func (node *SetupNode) Type() types.SpecComponentType {
+ return node.runner.nodeType
+}
+
+func (node *SetupNode) CodeLocation() types.CodeLocation {
+ return node.runner.codeLocation
+}
+
+func NewBeforeEachNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer, componentIndex int) *SetupNode {
+ return &SetupNode{
+ runner: newRunner(body, codeLocation, timeout, failer, types.SpecComponentTypeBeforeEach, componentIndex),
+ }
+}
+
+func NewAfterEachNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer, componentIndex int) *SetupNode {
+ return &SetupNode{
+ runner: newRunner(body, codeLocation, timeout, failer, types.SpecComponentTypeAfterEach, componentIndex),
+ }
+}
+
+func NewJustBeforeEachNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer, componentIndex int) *SetupNode {
+ return &SetupNode{
+ runner: newRunner(body, codeLocation, timeout, failer, types.SpecComponentTypeJustBeforeEach, componentIndex),
+ }
+}
+
+func NewJustAfterEachNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer, componentIndex int) *SetupNode {
+ return &SetupNode{
+ runner: newRunner(body, codeLocation, timeout, failer, types.SpecComponentTypeJustAfterEach, componentIndex),
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/setup_nodes_test.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/setup_nodes_test.go
new file mode 100644
index 000000000..9810688cb
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/setup_nodes_test.go
@@ -0,0 +1,48 @@
+package leafnodes_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/types"
+ . "github.com/onsi/gomega"
+
+ . "github.com/onsi/ginkgo/internal/leafnodes"
+
+ "github.com/onsi/ginkgo/internal/codelocation"
+)
+
+var _ = Describe("Setup Nodes", func() {
+ Describe("BeforeEachNodes", func() {
+ It("should report the correct type and code location", func() {
+ codeLocation := codelocation.New(0)
+ beforeEach := NewBeforeEachNode(func() {}, codeLocation, 0, nil, 3)
+ Ω(beforeEach.Type()).Should(Equal(types.SpecComponentTypeBeforeEach))
+ Ω(beforeEach.CodeLocation()).Should(Equal(codeLocation))
+ })
+ })
+
+ Describe("AfterEachNodes", func() {
+ It("should report the correct type and code location", func() {
+ codeLocation := codelocation.New(0)
+ afterEach := NewAfterEachNode(func() {}, codeLocation, 0, nil, 3)
+ Ω(afterEach.Type()).Should(Equal(types.SpecComponentTypeAfterEach))
+ Ω(afterEach.CodeLocation()).Should(Equal(codeLocation))
+ })
+ })
+
+ Describe("JustBeforeEachNodes", func() {
+ It("should report the correct type and code location", func() {
+ codeLocation := codelocation.New(0)
+ justBeforeEach := NewJustBeforeEachNode(func() {}, codeLocation, 0, nil, 3)
+ Ω(justBeforeEach.Type()).Should(Equal(types.SpecComponentTypeJustBeforeEach))
+ Ω(justBeforeEach.CodeLocation()).Should(Equal(codeLocation))
+ })
+ })
+ Describe("JustAfterEachNodes", func() {
+ It("should report the correct type and code location", func() {
+ codeLocation := codelocation.New(0)
+ justAfterEach := NewJustAfterEachNode(func() {}, codeLocation, 0, nil, 3)
+ Ω(justAfterEach.Type()).Should(Equal(types.SpecComponentTypeJustAfterEach))
+ Ω(justAfterEach.CodeLocation()).Should(Equal(codeLocation))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/shared_runner_test.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/shared_runner_test.go
new file mode 100644
index 000000000..0897836cb
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/shared_runner_test.go
@@ -0,0 +1,353 @@
+package leafnodes_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/internal/leafnodes"
+ . "github.com/onsi/gomega"
+
+ "reflect"
+ "time"
+
+ "github.com/onsi/ginkgo/internal/codelocation"
+ Failer "github.com/onsi/ginkgo/internal/failer"
+ "github.com/onsi/ginkgo/types"
+)
+
+type runnable interface {
+ Run() (outcome types.SpecState, failure types.SpecFailure)
+ CodeLocation() types.CodeLocation
+}
+
+func SynchronousSharedRunnerBehaviors(build func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable, componentType types.SpecComponentType, componentIndex int) {
+ var (
+ outcome types.SpecState
+ failure types.SpecFailure
+
+ failer *Failer.Failer
+
+ componentCodeLocation types.CodeLocation
+ innerCodeLocation types.CodeLocation
+
+ didRun bool
+ )
+
+ BeforeEach(func() {
+ failer = Failer.New()
+ componentCodeLocation = codelocation.New(0)
+ innerCodeLocation = codelocation.New(0)
+
+ didRun = false
+ })
+
+ Describe("synchronous functions", func() {
+ Context("when the function passes", func() {
+ BeforeEach(func() {
+ outcome, failure = build(func() {
+ didRun = true
+ }, 0, failer, componentCodeLocation).Run()
+ })
+
+ It("should have a succesful outcome", func() {
+ Ω(didRun).Should(BeTrue())
+
+ Ω(outcome).Should(Equal(types.SpecStatePassed))
+ Ω(failure).Should(BeZero())
+ })
+ })
+
+ Context("when a failure occurs", func() {
+ BeforeEach(func() {
+ outcome, failure = build(func() {
+ didRun = true
+ failer.Fail("bam", innerCodeLocation)
+ panic("should not matter")
+ }, 0, failer, componentCodeLocation).Run()
+ })
+
+ It("should return the failure", func() {
+ Ω(didRun).Should(BeTrue())
+
+ Ω(outcome).Should(Equal(types.SpecStateFailed))
+ Ω(failure).Should(Equal(types.SpecFailure{
+ Message: "bam",
+ Location: innerCodeLocation,
+ ForwardedPanic: "",
+ ComponentIndex: componentIndex,
+ ComponentType: componentType,
+ ComponentCodeLocation: componentCodeLocation,
+ }))
+ })
+ })
+
+ Context("when a panic occurs", func() {
+ BeforeEach(func() {
+ outcome, failure = build(func() {
+ didRun = true
+ innerCodeLocation = codelocation.New(0)
+ panic("ack!")
+ }, 0, failer, componentCodeLocation).Run()
+ })
+
+ It("should return the panic", func() {
+ Ω(didRun).Should(BeTrue())
+
+ Ω(outcome).Should(Equal(types.SpecStatePanicked))
+ Ω(failure.ForwardedPanic).Should(Equal("ack!"))
+ })
+ })
+
+ Context("when a panic occurs with a nil value", func() {
+ BeforeEach(func() {
+ outcome, failure = build(func() {
+ didRun = true
+ innerCodeLocation = codelocation.New(0)
+ panic(nil)
+ }, 0, failer, componentCodeLocation).Run()
+ })
+
+ It("should return the nil-valued panic", func() {
+ Ω(didRun).Should(BeTrue())
+
+ Ω(outcome).Should(Equal(types.SpecStatePanicked))
+ Ω(failure.ForwardedPanic).Should(Equal("<nil>"))
+ })
+ })
+
+ })
+}
+
+func AsynchronousSharedRunnerBehaviors(build func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable, componentType types.SpecComponentType, componentIndex int) {
+ var (
+ outcome types.SpecState
+ failure types.SpecFailure
+
+ failer *Failer.Failer
+
+ componentCodeLocation types.CodeLocation
+ innerCodeLocation types.CodeLocation
+
+ didRun bool
+ )
+
+ BeforeEach(func() {
+ failer = Failer.New()
+ componentCodeLocation = codelocation.New(0)
+ innerCodeLocation = codelocation.New(0)
+
+ didRun = false
+ })
+
+ Describe("asynchronous functions", func() {
+ var timeoutDuration time.Duration
+
+ BeforeEach(func() {
+ timeoutDuration = time.Duration(1 * float64(time.Second))
+ })
+
+ Context("when running", func() {
+ It("should run the function as a goroutine, and block until it's done", func() {
+ proveAsync := make(chan bool)
+
+ build(func(done Done) {
+ didRun = true
+ proveAsync <- true
+ close(done)
+ }, timeoutDuration, failer, componentCodeLocation).Run()
+
+ Eventually(proveAsync).Should(Receive(Equal(true)))
+ })
+ })
+
+ Context("when the function passes", func() {
+ BeforeEach(func() {
+ outcome, failure = build(func(done Done) {
+ didRun = true
+ close(done)
+ }, timeoutDuration, failer, componentCodeLocation).Run()
+ })
+
+ It("should have a succesful outcome", func() {
+ Ω(didRun).Should(BeTrue())
+ Ω(outcome).Should(Equal(types.SpecStatePassed))
+ Ω(failure).Should(BeZero())
+ })
+ })
+
+ Context("when the function fails", func() {
+ BeforeEach(func() {
+ outcome, failure = build(func(done Done) {
+ didRun = true
+ failer.Fail("bam", innerCodeLocation)
+ time.Sleep(20 * time.Millisecond)
+ defer close(done)
+ panic("doesn't matter")
+ }, 10*time.Millisecond, failer, componentCodeLocation).Run()
+ })
+
+ It("should return the failure", func() {
+ Ω(didRun).Should(BeTrue())
+
+ Ω(outcome).Should(Equal(types.SpecStateFailed))
+ Ω(failure).Should(Equal(types.SpecFailure{
+ Message: "bam",
+ Location: innerCodeLocation,
+ ForwardedPanic: "",
+ ComponentIndex: componentIndex,
+ ComponentType: componentType,
+ ComponentCodeLocation: componentCodeLocation,
+ }))
+ })
+ })
+
+ Context("when the function doesn't close the done channel in time", func() {
+ var guard chan struct{}
+
+ BeforeEach(func() {
+ guard = make(chan struct{})
+ outcome, failure = build(func(done Done) {
+ didRun = true
+ close(guard)
+ }, 10*time.Millisecond, failer, componentCodeLocation).Run()
+ })
+
+ It("should return a timeout", func() {
+ <-guard
+ Ω(didRun).Should(BeTrue())
+
+ Ω(outcome).Should(Equal(types.SpecStateTimedOut))
+ Ω(failure).Should(Equal(types.SpecFailure{
+ Message: "Timed out",
+ Location: componentCodeLocation,
+ ForwardedPanic: "",
+ ComponentIndex: componentIndex,
+ ComponentType: componentType,
+ ComponentCodeLocation: componentCodeLocation,
+ }))
+ })
+ })
+
+ Context("when the function panics", func() {
+ BeforeEach(func() {
+ outcome, failure = build(func(done Done) {
+ didRun = true
+ innerCodeLocation = codelocation.New(0)
+ panic("ack!")
+ }, 100*time.Millisecond, failer, componentCodeLocation).Run()
+ })
+
+ It("should return the panic", func() {
+ Ω(didRun).Should(BeTrue())
+
+ Ω(outcome).Should(Equal(types.SpecStatePanicked))
+ Ω(failure.ForwardedPanic).Should(Equal("ack!"))
+ })
+ })
+
+ Context("when the function panics with a nil value", func() {
+ BeforeEach(func() {
+ outcome, failure = build(func(done Done) {
+ didRun = true
+ innerCodeLocation = codelocation.New(0)
+ panic(nil)
+ }, 100*time.Millisecond, failer, componentCodeLocation).Run()
+ })
+
+ It("should return the nil-valued panic", func() {
+ Ω(didRun).Should(BeTrue())
+
+ Ω(outcome).Should(Equal(types.SpecStatePanicked))
+ Ω(failure.ForwardedPanic).Should(Equal("<nil>"))
+ })
+ })
+ })
+}
+
+func InvalidSharedRunnerBehaviors(build func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable, componentType types.SpecComponentType) {
+ var (
+ failer *Failer.Failer
+ componentCodeLocation types.CodeLocation
+ )
+
+ BeforeEach(func() {
+ failer = Failer.New()
+ componentCodeLocation = codelocation.New(0)
+ })
+
+ Describe("invalid functions", func() {
+ Context("when passed something that's not a function", func() {
+ It("should panic", func() {
+ Ω(func() {
+ build("not a function", 0, failer, componentCodeLocation)
+ }).Should(Panic())
+ })
+ })
+
+ Context("when the function takes the wrong kind of argument", func() {
+ It("should panic", func() {
+ Ω(func() {
+ build(func(oops string) {}, 0, failer, componentCodeLocation)
+ }).Should(Panic())
+ })
+ })
+
+ Context("when the function takes more than one argument", func() {
+ It("should panic", func() {
+ Ω(func() {
+ build(func(done Done, oops string) {}, 0, failer, componentCodeLocation)
+ }).Should(Panic())
+ })
+ })
+ })
+}
+
+var _ = Describe("Shared RunnableNode behavior", func() {
+ Describe("It Nodes", func() {
+ build := func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable {
+ return NewItNode("", body, types.FlagTypeFocused, componentCodeLocation, timeout, failer, 3)
+ }
+
+ SynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeIt, 3)
+ AsynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeIt, 3)
+ InvalidSharedRunnerBehaviors(build, types.SpecComponentTypeIt)
+ })
+
+ Describe("Measure Nodes", func() {
+ build := func(body interface{}, _ time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable {
+ return NewMeasureNode("", func(Benchmarker) {
+ reflect.ValueOf(body).Call([]reflect.Value{})
+ }, types.FlagTypeFocused, componentCodeLocation, 10, failer, 3)
+ }
+
+ SynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeMeasure, 3)
+ })
+
+ Describe("BeforeEach Nodes", func() {
+ build := func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable {
+ return NewBeforeEachNode(body, componentCodeLocation, timeout, failer, 3)
+ }
+
+ SynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeBeforeEach, 3)
+ AsynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeBeforeEach, 3)
+ InvalidSharedRunnerBehaviors(build, types.SpecComponentTypeBeforeEach)
+ })
+
+ Describe("AfterEach Nodes", func() {
+ build := func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable {
+ return NewAfterEachNode(body, componentCodeLocation, timeout, failer, 3)
+ }
+
+ SynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeAfterEach, 3)
+ AsynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeAfterEach, 3)
+ InvalidSharedRunnerBehaviors(build, types.SpecComponentTypeAfterEach)
+ })
+
+ Describe("JustBeforeEach Nodes", func() {
+ build := func(body interface{}, timeout time.Duration, failer *Failer.Failer, componentCodeLocation types.CodeLocation) runnable {
+ return NewJustBeforeEachNode(body, componentCodeLocation, timeout, failer, 3)
+ }
+
+ SynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeJustBeforeEach, 3)
+ AsynchronousSharedRunnerBehaviors(build, types.SpecComponentTypeJustBeforeEach, 3)
+ InvalidSharedRunnerBehaviors(build, types.SpecComponentTypeJustBeforeEach)
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes.go
new file mode 100644
index 000000000..80f16ed78
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes.go
@@ -0,0 +1,55 @@
+package leafnodes
+
+import (
+ "time"
+
+ "github.com/onsi/ginkgo/internal/failer"
+ "github.com/onsi/ginkgo/types"
+)
+
+type SuiteNode interface {
+ Run(parallelNode int, parallelTotal int, syncHost string) bool
+ Passed() bool
+ Summary() *types.SetupSummary
+}
+
+type simpleSuiteNode struct {
+ runner *runner
+ outcome types.SpecState
+ failure types.SpecFailure
+ runTime time.Duration
+}
+
+func (node *simpleSuiteNode) Run(parallelNode int, parallelTotal int, syncHost string) bool {
+ t := time.Now()
+ node.outcome, node.failure = node.runner.run()
+ node.runTime = time.Since(t)
+
+ return node.outcome == types.SpecStatePassed
+}
+
+func (node *simpleSuiteNode) Passed() bool {
+ return node.outcome == types.SpecStatePassed
+}
+
+func (node *simpleSuiteNode) Summary() *types.SetupSummary {
+ return &types.SetupSummary{
+ ComponentType: node.runner.nodeType,
+ CodeLocation: node.runner.codeLocation,
+ State: node.outcome,
+ RunTime: node.runTime,
+ Failure: node.failure,
+ }
+}
+
+func NewBeforeSuiteNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer) SuiteNode {
+ return &simpleSuiteNode{
+ runner: newRunner(body, codeLocation, timeout, failer, types.SpecComponentTypeBeforeSuite, 0),
+ }
+}
+
+func NewAfterSuiteNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer) SuiteNode {
+ return &simpleSuiteNode{
+ runner: newRunner(body, codeLocation, timeout, failer, types.SpecComponentTypeAfterSuite, 0),
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes_test.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes_test.go
new file mode 100644
index 000000000..246b329fe
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes_test.go
@@ -0,0 +1,230 @@
+package leafnodes_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ . "github.com/onsi/ginkgo/internal/leafnodes"
+
+ "time"
+
+ "github.com/onsi/ginkgo/internal/codelocation"
+ Failer "github.com/onsi/ginkgo/internal/failer"
+ "github.com/onsi/ginkgo/types"
+)
+
+var _ = Describe("SuiteNodes", func() {
+ Describe("BeforeSuite nodes", func() {
+ var befSuite SuiteNode
+ var failer *Failer.Failer
+ var codeLocation types.CodeLocation
+ var innerCodeLocation types.CodeLocation
+ var outcome bool
+
+ BeforeEach(func() {
+ failer = Failer.New()
+ codeLocation = codelocation.New(0)
+ innerCodeLocation = codelocation.New(0)
+ })
+
+ Context("when the body passes", func() {
+ BeforeEach(func() {
+ befSuite = NewBeforeSuiteNode(func() {
+ time.Sleep(10 * time.Millisecond)
+ }, codeLocation, 0, failer)
+ outcome = befSuite.Run(0, 0, "")
+ })
+
+ It("should return true when run and report as passed", func() {
+ Ω(outcome).Should(BeTrue())
+ Ω(befSuite.Passed()).Should(BeTrue())
+ })
+
+ It("should have the correct summary", func() {
+ summary := befSuite.Summary()
+ Ω(summary.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
+ Ω(summary.CodeLocation).Should(Equal(codeLocation))
+ Ω(summary.State).Should(Equal(types.SpecStatePassed))
+ Ω(summary.RunTime).Should(BeNumerically(">=", 10*time.Millisecond))
+ Ω(summary.Failure).Should(BeZero())
+ })
+ })
+
+ Context("when the body fails", func() {
+ BeforeEach(func() {
+ befSuite = NewBeforeSuiteNode(func() {
+ failer.Fail("oops", innerCodeLocation)
+ }, codeLocation, 0, failer)
+ outcome = befSuite.Run(0, 0, "")
+ })
+
+ It("should return false when run and report as failed", func() {
+ Ω(outcome).Should(BeFalse())
+ Ω(befSuite.Passed()).Should(BeFalse())
+ })
+
+ It("should have the correct summary", func() {
+ summary := befSuite.Summary()
+ Ω(summary.State).Should(Equal(types.SpecStateFailed))
+ Ω(summary.Failure.Message).Should(Equal("oops"))
+ Ω(summary.Failure.Location).Should(Equal(innerCodeLocation))
+ Ω(summary.Failure.ForwardedPanic).Should(BeEmpty())
+ Ω(summary.Failure.ComponentIndex).Should(Equal(0))
+ Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
+ Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
+ })
+ })
+
+ Context("when the body times out", func() {
+ BeforeEach(func() {
+ befSuite = NewBeforeSuiteNode(func(done Done) {
+ }, codeLocation, time.Millisecond, failer)
+ outcome = befSuite.Run(0, 0, "")
+ })
+
+ It("should return false when run and report as failed", func() {
+ Ω(outcome).Should(BeFalse())
+ Ω(befSuite.Passed()).Should(BeFalse())
+ })
+
+ It("should have the correct summary", func() {
+ summary := befSuite.Summary()
+ Ω(summary.State).Should(Equal(types.SpecStateTimedOut))
+ Ω(summary.Failure.ForwardedPanic).Should(BeEmpty())
+ Ω(summary.Failure.ComponentIndex).Should(Equal(0))
+ Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
+ Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
+ })
+ })
+
+ Context("when the body panics", func() {
+ BeforeEach(func() {
+ befSuite = NewBeforeSuiteNode(func() {
+ panic("bam")
+ }, codeLocation, 0, failer)
+ outcome = befSuite.Run(0, 0, "")
+ })
+
+ It("should return false when run and report as failed", func() {
+ Ω(outcome).Should(BeFalse())
+ Ω(befSuite.Passed()).Should(BeFalse())
+ })
+
+ It("should have the correct summary", func() {
+ summary := befSuite.Summary()
+ Ω(summary.State).Should(Equal(types.SpecStatePanicked))
+ Ω(summary.Failure.ForwardedPanic).Should(Equal("bam"))
+ Ω(summary.Failure.ComponentIndex).Should(Equal(0))
+ Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
+ Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
+ })
+ })
+ })
+
+ Describe("AfterSuite nodes", func() {
+ var aftSuite SuiteNode
+ var failer *Failer.Failer
+ var codeLocation types.CodeLocation
+ var innerCodeLocation types.CodeLocation
+ var outcome bool
+
+ BeforeEach(func() {
+ failer = Failer.New()
+ codeLocation = codelocation.New(0)
+ innerCodeLocation = codelocation.New(0)
+ })
+
+ Context("when the body passes", func() {
+ BeforeEach(func() {
+ aftSuite = NewAfterSuiteNode(func() {
+ time.Sleep(10 * time.Millisecond)
+ }, codeLocation, 0, failer)
+ outcome = aftSuite.Run(0, 0, "")
+ })
+
+ It("should return true when run and report as passed", func() {
+ Ω(outcome).Should(BeTrue())
+ Ω(aftSuite.Passed()).Should(BeTrue())
+ })
+
+ It("should have the correct summary", func() {
+ summary := aftSuite.Summary()
+ Ω(summary.ComponentType).Should(Equal(types.SpecComponentTypeAfterSuite))
+ Ω(summary.CodeLocation).Should(Equal(codeLocation))
+ Ω(summary.State).Should(Equal(types.SpecStatePassed))
+ Ω(summary.RunTime).Should(BeNumerically(">=", 10*time.Millisecond))
+ Ω(summary.Failure).Should(BeZero())
+ })
+ })
+
+ Context("when the body fails", func() {
+ BeforeEach(func() {
+ aftSuite = NewAfterSuiteNode(func() {
+ failer.Fail("oops", innerCodeLocation)
+ }, codeLocation, 0, failer)
+ outcome = aftSuite.Run(0, 0, "")
+ })
+
+ It("should return false when run and report as failed", func() {
+ Ω(outcome).Should(BeFalse())
+ Ω(aftSuite.Passed()).Should(BeFalse())
+ })
+
+ It("should have the correct summary", func() {
+ summary := aftSuite.Summary()
+ Ω(summary.State).Should(Equal(types.SpecStateFailed))
+ Ω(summary.Failure.Message).Should(Equal("oops"))
+ Ω(summary.Failure.Location).Should(Equal(innerCodeLocation))
+ Ω(summary.Failure.ForwardedPanic).Should(BeEmpty())
+ Ω(summary.Failure.ComponentIndex).Should(Equal(0))
+ Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeAfterSuite))
+ Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
+ })
+ })
+
+ Context("when the body times out", func() {
+ BeforeEach(func() {
+ aftSuite = NewAfterSuiteNode(func(done Done) {
+ }, codeLocation, time.Millisecond, failer)
+ outcome = aftSuite.Run(0, 0, "")
+ })
+
+ It("should return false when run and report as failed", func() {
+ Ω(outcome).Should(BeFalse())
+ Ω(aftSuite.Passed()).Should(BeFalse())
+ })
+
+ It("should have the correct summary", func() {
+ summary := aftSuite.Summary()
+ Ω(summary.State).Should(Equal(types.SpecStateTimedOut))
+ Ω(summary.Failure.ForwardedPanic).Should(BeEmpty())
+ Ω(summary.Failure.ComponentIndex).Should(Equal(0))
+ Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeAfterSuite))
+ Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
+ })
+ })
+
+ Context("when the body panics", func() {
+ BeforeEach(func() {
+ aftSuite = NewAfterSuiteNode(func() {
+ panic("bam")
+ }, codeLocation, 0, failer)
+ outcome = aftSuite.Run(0, 0, "")
+ })
+
+ It("should return false when run and report as failed", func() {
+ Ω(outcome).Should(BeFalse())
+ Ω(aftSuite.Passed()).Should(BeFalse())
+ })
+
+ It("should have the correct summary", func() {
+ summary := aftSuite.Summary()
+ Ω(summary.State).Should(Equal(types.SpecStatePanicked))
+ Ω(summary.Failure.ForwardedPanic).Should(Equal("bam"))
+ Ω(summary.Failure.ComponentIndex).Should(Equal(0))
+ Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeAfterSuite))
+ Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_after_suite_node.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_after_suite_node.go
new file mode 100644
index 000000000..a721d0cf7
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_after_suite_node.go
@@ -0,0 +1,90 @@
+package leafnodes
+
+import (
+ "encoding/json"
+ "io/ioutil"
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo/internal/failer"
+ "github.com/onsi/ginkgo/types"
+)
+
+type synchronizedAfterSuiteNode struct {
+ runnerA *runner
+ runnerB *runner
+
+ outcome types.SpecState
+ failure types.SpecFailure
+ runTime time.Duration
+}
+
+func NewSynchronizedAfterSuiteNode(bodyA interface{}, bodyB interface{}, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer) SuiteNode {
+ return &synchronizedAfterSuiteNode{
+ runnerA: newRunner(bodyA, codeLocation, timeout, failer, types.SpecComponentTypeAfterSuite, 0),
+ runnerB: newRunner(bodyB, codeLocation, timeout, failer, types.SpecComponentTypeAfterSuite, 0),
+ }
+}
+
+func (node *synchronizedAfterSuiteNode) Run(parallelNode int, parallelTotal int, syncHost string) bool {
+ node.outcome, node.failure = node.runnerA.run()
+
+ if parallelNode == 1 {
+ if parallelTotal > 1 {
+ node.waitUntilOtherNodesAreDone(syncHost)
+ }
+
+ outcome, failure := node.runnerB.run()
+
+ if node.outcome == types.SpecStatePassed {
+ node.outcome, node.failure = outcome, failure
+ }
+ }
+
+ return node.outcome == types.SpecStatePassed
+}
+
+func (node *synchronizedAfterSuiteNode) Passed() bool {
+ return node.outcome == types.SpecStatePassed
+}
+
+func (node *synchronizedAfterSuiteNode) Summary() *types.SetupSummary {
+ return &types.SetupSummary{
+ ComponentType: node.runnerA.nodeType,
+ CodeLocation: node.runnerA.codeLocation,
+ State: node.outcome,
+ RunTime: node.runTime,
+ Failure: node.failure,
+ }
+}
+
+func (node *synchronizedAfterSuiteNode) waitUntilOtherNodesAreDone(syncHost string) {
+ for {
+ if node.canRun(syncHost) {
+ return
+ }
+
+ time.Sleep(50 * time.Millisecond)
+ }
+}
+
+func (node *synchronizedAfterSuiteNode) canRun(syncHost string) bool {
+ resp, err := http.Get(syncHost + "/RemoteAfterSuiteData")
+ if err != nil || resp.StatusCode != http.StatusOK {
+ return false
+ }
+
+ body, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ return false
+ }
+ resp.Body.Close()
+
+ afterSuiteData := types.RemoteAfterSuiteData{}
+ err = json.Unmarshal(body, &afterSuiteData)
+ if err != nil {
+ return false
+ }
+
+ return afterSuiteData.CanRun
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_after_suite_node_test.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_after_suite_node_test.go
new file mode 100644
index 000000000..edbdf6ae5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_after_suite_node_test.go
@@ -0,0 +1,199 @@
+package leafnodes_test
+
+import (
+ "sync"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/internal/leafnodes"
+ "github.com/onsi/ginkgo/types"
+ . "github.com/onsi/gomega"
+
+ "net/http"
+
+ "github.com/onsi/gomega/ghttp"
+
+ "time"
+
+ "github.com/onsi/ginkgo/internal/codelocation"
+ Failer "github.com/onsi/ginkgo/internal/failer"
+)
+
+var _ = Describe("SynchronizedAfterSuiteNode", func() {
+ var failer *Failer.Failer
+ var node SuiteNode
+ var codeLocation types.CodeLocation
+ var innerCodeLocation types.CodeLocation
+ var outcome bool
+ var server *ghttp.Server
+ var things []string
+ var lock *sync.Mutex
+
+ BeforeEach(func() {
+ things = []string{}
+ server = ghttp.NewServer()
+ codeLocation = codelocation.New(0)
+ innerCodeLocation = codelocation.New(0)
+ failer = Failer.New()
+ lock = &sync.Mutex{}
+ })
+
+ AfterEach(func() {
+ server.Close()
+ })
+
+ newNode := func(bodyA interface{}, bodyB interface{}) SuiteNode {
+ return NewSynchronizedAfterSuiteNode(bodyA, bodyB, codeLocation, time.Millisecond, failer)
+ }
+
+ ranThing := func(thing string) {
+ lock.Lock()
+ defer lock.Unlock()
+ things = append(things, thing)
+ }
+
+ thingsThatRan := func() []string {
+ lock.Lock()
+ defer lock.Unlock()
+ return things
+ }
+
+ Context("when not running in parallel", func() {
+ Context("when all is well", func() {
+ BeforeEach(func() {
+ node = newNode(func() {
+ ranThing("A")
+ }, func() {
+ ranThing("B")
+ })
+
+ outcome = node.Run(1, 1, server.URL())
+ })
+
+ It("should run A, then B", func() {
+ Ω(thingsThatRan()).Should(Equal([]string{"A", "B"}))
+ })
+
+ It("should report success", func() {
+ Ω(outcome).Should(BeTrue())
+ Ω(node.Passed()).Should(BeTrue())
+ Ω(node.Summary().State).Should(Equal(types.SpecStatePassed))
+ })
+ })
+
+ Context("when A fails", func() {
+ BeforeEach(func() {
+ node = newNode(func() {
+ ranThing("A")
+ failer.Fail("bam", innerCodeLocation)
+ }, func() {
+ ranThing("B")
+ })
+
+ outcome = node.Run(1, 1, server.URL())
+ })
+
+ It("should still run B", func() {
+ Ω(thingsThatRan()).Should(Equal([]string{"A", "B"}))
+ })
+
+ It("should report failure", func() {
+ Ω(outcome).Should(BeFalse())
+ Ω(node.Passed()).Should(BeFalse())
+ Ω(node.Summary().State).Should(Equal(types.SpecStateFailed))
+ })
+ })
+
+ Context("when B fails", func() {
+ BeforeEach(func() {
+ node = newNode(func() {
+ ranThing("A")
+ }, func() {
+ ranThing("B")
+ failer.Fail("bam", innerCodeLocation)
+ })
+
+ outcome = node.Run(1, 1, server.URL())
+ })
+
+ It("should run all the things", func() {
+ Ω(thingsThatRan()).Should(Equal([]string{"A", "B"}))
+ })
+
+ It("should report failure", func() {
+ Ω(outcome).Should(BeFalse())
+ Ω(node.Passed()).Should(BeFalse())
+ Ω(node.Summary().State).Should(Equal(types.SpecStateFailed))
+ })
+ })
+ })
+
+ Context("when running in parallel", func() {
+ Context("as the first node", func() {
+ BeforeEach(func() {
+ server.AppendHandlers(ghttp.CombineHandlers(
+ ghttp.VerifyRequest("GET", "/RemoteAfterSuiteData"),
+ func(writer http.ResponseWriter, request *http.Request) {
+ ranThing("Request1")
+ },
+ ghttp.RespondWithJSONEncoded(200, types.RemoteAfterSuiteData{CanRun: false}),
+ ), ghttp.CombineHandlers(
+ ghttp.VerifyRequest("GET", "/RemoteAfterSuiteData"),
+ func(writer http.ResponseWriter, request *http.Request) {
+ ranThing("Request2")
+ },
+ ghttp.RespondWithJSONEncoded(200, types.RemoteAfterSuiteData{CanRun: false}),
+ ), ghttp.CombineHandlers(
+ ghttp.VerifyRequest("GET", "/RemoteAfterSuiteData"),
+ func(writer http.ResponseWriter, request *http.Request) {
+ ranThing("Request3")
+ },
+ ghttp.RespondWithJSONEncoded(200, types.RemoteAfterSuiteData{CanRun: true}),
+ ))
+
+ node = newNode(func() {
+ ranThing("A")
+ }, func() {
+ ranThing("B")
+ })
+
+ outcome = node.Run(1, 3, server.URL())
+ })
+
+ It("should run A and, when the server says its time, run B", func() {
+ Ω(thingsThatRan()).Should(Equal([]string{"A", "Request1", "Request2", "Request3", "B"}))
+ })
+
+ It("should report success", func() {
+ Ω(outcome).Should(BeTrue())
+ Ω(node.Passed()).Should(BeTrue())
+ Ω(node.Summary().State).Should(Equal(types.SpecStatePassed))
+ })
+ })
+
+ Context("as any other node", func() {
+ BeforeEach(func() {
+ node = newNode(func() {
+ ranThing("A")
+ }, func() {
+ ranThing("B")
+ })
+
+ outcome = node.Run(2, 3, server.URL())
+ })
+
+ It("should run A, and not run B", func() {
+ Ω(thingsThatRan()).Should(Equal([]string{"A"}))
+ })
+
+ It("should not talk to the server", func() {
+ Ω(server.ReceivedRequests()).Should(BeEmpty())
+ })
+
+ It("should report success", func() {
+ Ω(outcome).Should(BeTrue())
+ Ω(node.Passed()).Should(BeTrue())
+ Ω(node.Summary().State).Should(Equal(types.SpecStatePassed))
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_before_suite_node.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_before_suite_node.go
new file mode 100644
index 000000000..d5c889319
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_before_suite_node.go
@@ -0,0 +1,181 @@
+package leafnodes
+
+import (
+ "bytes"
+ "encoding/json"
+ "io/ioutil"
+ "net/http"
+ "reflect"
+ "time"
+
+ "github.com/onsi/ginkgo/internal/failer"
+ "github.com/onsi/ginkgo/types"
+)
+
+type synchronizedBeforeSuiteNode struct {
+ runnerA *runner
+ runnerB *runner
+
+ data []byte
+
+ outcome types.SpecState
+ failure types.SpecFailure
+ runTime time.Duration
+}
+
+func NewSynchronizedBeforeSuiteNode(bodyA interface{}, bodyB interface{}, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer) SuiteNode {
+ node := &synchronizedBeforeSuiteNode{}
+
+ node.runnerA = newRunner(node.wrapA(bodyA), codeLocation, timeout, failer, types.SpecComponentTypeBeforeSuite, 0)
+ node.runnerB = newRunner(node.wrapB(bodyB), codeLocation, timeout, failer, types.SpecComponentTypeBeforeSuite, 0)
+
+ return node
+}
+
+func (node *synchronizedBeforeSuiteNode) Run(parallelNode int, parallelTotal int, syncHost string) bool {
+ t := time.Now()
+ defer func() {
+ node.runTime = time.Since(t)
+ }()
+
+ if parallelNode == 1 {
+ node.outcome, node.failure = node.runA(parallelTotal, syncHost)
+ } else {
+ node.outcome, node.failure = node.waitForA(syncHost)
+ }
+
+ if node.outcome != types.SpecStatePassed {
+ return false
+ }
+ node.outcome, node.failure = node.runnerB.run()
+
+ return node.outcome == types.SpecStatePassed
+}
+
+func (node *synchronizedBeforeSuiteNode) runA(parallelTotal int, syncHost string) (types.SpecState, types.SpecFailure) {
+ outcome, failure := node.runnerA.run()
+
+ if parallelTotal > 1 {
+ state := types.RemoteBeforeSuiteStatePassed
+ if outcome != types.SpecStatePassed {
+ state = types.RemoteBeforeSuiteStateFailed
+ }
+ json := (types.RemoteBeforeSuiteData{
+ Data: node.data,
+ State: state,
+ }).ToJSON()
+ http.Post(syncHost+"/BeforeSuiteState", "application/json", bytes.NewBuffer(json))
+ }
+
+ return outcome, failure
+}
+
+func (node *synchronizedBeforeSuiteNode) waitForA(syncHost string) (types.SpecState, types.SpecFailure) {
+ failure := func(message string) types.SpecFailure {
+ return types.SpecFailure{
+ Message: message,
+ Location: node.runnerA.codeLocation,
+ ComponentType: node.runnerA.nodeType,
+ ComponentIndex: node.runnerA.componentIndex,
+ ComponentCodeLocation: node.runnerA.codeLocation,
+ }
+ }
+ for {
+ resp, err := http.Get(syncHost + "/BeforeSuiteState")
+ if err != nil || resp.StatusCode != http.StatusOK {
+ return types.SpecStateFailed, failure("Failed to fetch BeforeSuite state")
+ }
+
+ body, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ return types.SpecStateFailed, failure("Failed to read BeforeSuite state")
+ }
+ resp.Body.Close()
+
+ beforeSuiteData := types.RemoteBeforeSuiteData{}
+ err = json.Unmarshal(body, &beforeSuiteData)
+ if err != nil {
+ return types.SpecStateFailed, failure("Failed to decode BeforeSuite state")
+ }
+
+ switch beforeSuiteData.State {
+ case types.RemoteBeforeSuiteStatePassed:
+ node.data = beforeSuiteData.Data
+ return types.SpecStatePassed, types.SpecFailure{}
+ case types.RemoteBeforeSuiteStateFailed:
+ return types.SpecStateFailed, failure("BeforeSuite on Node 1 failed")
+ case types.RemoteBeforeSuiteStateDisappeared:
+ return types.SpecStateFailed, failure("Node 1 disappeared before completing BeforeSuite")
+ }
+
+ time.Sleep(50 * time.Millisecond)
+ }
+}
+
+func (node *synchronizedBeforeSuiteNode) Passed() bool {
+ return node.outcome == types.SpecStatePassed
+}
+
+func (node *synchronizedBeforeSuiteNode) Summary() *types.SetupSummary {
+ return &types.SetupSummary{
+ ComponentType: node.runnerA.nodeType,
+ CodeLocation: node.runnerA.codeLocation,
+ State: node.outcome,
+ RunTime: node.runTime,
+ Failure: node.failure,
+ }
+}
+
+func (node *synchronizedBeforeSuiteNode) wrapA(bodyA interface{}) interface{} {
+ typeA := reflect.TypeOf(bodyA)
+ if typeA.Kind() != reflect.Func {
+ panic("SynchronizedBeforeSuite expects a function as its first argument")
+ }
+
+ takesNothing := typeA.NumIn() == 0
+ takesADoneChannel := typeA.NumIn() == 1 && typeA.In(0).Kind() == reflect.Chan && typeA.In(0).Elem().Kind() == reflect.Interface
+ returnsBytes := typeA.NumOut() == 1 && typeA.Out(0).Kind() == reflect.Slice && typeA.Out(0).Elem().Kind() == reflect.Uint8
+
+ if !((takesNothing || takesADoneChannel) && returnsBytes) {
+ panic("SynchronizedBeforeSuite's first argument should be a function that returns []byte and either takes no arguments or takes a Done channel.")
+ }
+
+ if takesADoneChannel {
+ return func(done chan<- interface{}) {
+ out := reflect.ValueOf(bodyA).Call([]reflect.Value{reflect.ValueOf(done)})
+ node.data = out[0].Interface().([]byte)
+ }
+ }
+
+ return func() {
+ out := reflect.ValueOf(bodyA).Call([]reflect.Value{})
+ node.data = out[0].Interface().([]byte)
+ }
+}
+
+func (node *synchronizedBeforeSuiteNode) wrapB(bodyB interface{}) interface{} {
+ typeB := reflect.TypeOf(bodyB)
+ if typeB.Kind() != reflect.Func {
+ panic("SynchronizedBeforeSuite expects a function as its second argument")
+ }
+
+ returnsNothing := typeB.NumOut() == 0
+ takesBytesOnly := typeB.NumIn() == 1 && typeB.In(0).Kind() == reflect.Slice && typeB.In(0).Elem().Kind() == reflect.Uint8
+ takesBytesAndDone := typeB.NumIn() == 2 &&
+ typeB.In(0).Kind() == reflect.Slice && typeB.In(0).Elem().Kind() == reflect.Uint8 &&
+ typeB.In(1).Kind() == reflect.Chan && typeB.In(1).Elem().Kind() == reflect.Interface
+
+ if !((takesBytesOnly || takesBytesAndDone) && returnsNothing) {
+ panic("SynchronizedBeforeSuite's second argument should be a function that returns nothing and either takes []byte or ([]byte, Done)")
+ }
+
+ if takesBytesAndDone {
+ return func(done chan<- interface{}) {
+ reflect.ValueOf(bodyB).Call([]reflect.Value{reflect.ValueOf(node.data), reflect.ValueOf(done)})
+ }
+ }
+
+ return func() {
+ reflect.ValueOf(bodyB).Call([]reflect.Value{reflect.ValueOf(node.data)})
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_before_suite_node_test.go b/vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_before_suite_node_test.go
new file mode 100644
index 000000000..46c3e276b
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_before_suite_node_test.go
@@ -0,0 +1,446 @@
+package leafnodes_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/internal/leafnodes"
+ . "github.com/onsi/gomega"
+
+ "net/http"
+
+ "github.com/onsi/gomega/ghttp"
+
+ "time"
+
+ "github.com/onsi/ginkgo/internal/codelocation"
+ Failer "github.com/onsi/ginkgo/internal/failer"
+ "github.com/onsi/ginkgo/types"
+)
+
+var _ = Describe("SynchronizedBeforeSuiteNode", func() {
+ var failer *Failer.Failer
+ var node SuiteNode
+ var codeLocation types.CodeLocation
+ var innerCodeLocation types.CodeLocation
+ var outcome bool
+ var server *ghttp.Server
+
+ BeforeEach(func() {
+ server = ghttp.NewServer()
+ codeLocation = codelocation.New(0)
+ innerCodeLocation = codelocation.New(0)
+ failer = Failer.New()
+ })
+
+ AfterEach(func() {
+ server.Close()
+ })
+
+ newNode := func(bodyA interface{}, bodyB interface{}) SuiteNode {
+ return NewSynchronizedBeforeSuiteNode(bodyA, bodyB, codeLocation, time.Millisecond, failer)
+ }
+
+ Describe("when not running in parallel", func() {
+ Context("when all is well", func() {
+ var data []byte
+ BeforeEach(func() {
+ data = nil
+
+ node = newNode(func() []byte {
+ return []byte("my data")
+ }, func(d []byte) {
+ data = d
+ })
+
+ outcome = node.Run(1, 1, server.URL())
+ })
+
+ It("should run A, then B passing the output from A to B", func() {
+ Ω(data).Should(Equal([]byte("my data")))
+ })
+
+ It("should report success", func() {
+ Ω(outcome).Should(BeTrue())
+ Ω(node.Passed()).Should(BeTrue())
+ Ω(node.Summary().State).Should(Equal(types.SpecStatePassed))
+ })
+ })
+
+ Context("when A fails", func() {
+ var ranB bool
+ BeforeEach(func() {
+ ranB = false
+ node = newNode(func() []byte {
+ failer.Fail("boom", innerCodeLocation)
+ return nil
+ }, func([]byte) {
+ ranB = true
+ })
+
+ outcome = node.Run(1, 1, server.URL())
+ })
+
+ It("should not run B", func() {
+ Ω(ranB).Should(BeFalse())
+ })
+
+ It("should report failure", func() {
+ Ω(outcome).Should(BeFalse())
+ Ω(node.Passed()).Should(BeFalse())
+ Ω(node.Summary().State).Should(Equal(types.SpecStateFailed))
+ })
+ })
+
+ Context("when B fails", func() {
+ BeforeEach(func() {
+ node = newNode(func() []byte {
+ return nil
+ }, func([]byte) {
+ failer.Fail("boom", innerCodeLocation)
+ })
+
+ outcome = node.Run(1, 1, server.URL())
+ })
+
+ It("should report failure", func() {
+ Ω(outcome).Should(BeFalse())
+ Ω(node.Passed()).Should(BeFalse())
+ Ω(node.Summary().State).Should(Equal(types.SpecStateFailed))
+ })
+ })
+
+ Context("when A times out", func() {
+ var ranB bool
+ BeforeEach(func() {
+ ranB = false
+ node = newNode(func(Done) []byte {
+ time.Sleep(time.Second)
+ return nil
+ }, func([]byte) {
+ ranB = true
+ })
+
+ outcome = node.Run(1, 1, server.URL())
+ })
+
+ It("should not run B", func() {
+ Ω(ranB).Should(BeFalse())
+ })
+
+ It("should report failure", func() {
+ Ω(outcome).Should(BeFalse())
+ Ω(node.Passed()).Should(BeFalse())
+ Ω(node.Summary().State).Should(Equal(types.SpecStateTimedOut))
+ })
+ })
+
+ Context("when B times out", func() {
+ BeforeEach(func() {
+ node = newNode(func() []byte {
+ return nil
+ }, func([]byte, Done) {
+ time.Sleep(time.Second)
+ })
+
+ outcome = node.Run(1, 1, server.URL())
+ })
+
+ It("should report failure", func() {
+ Ω(outcome).Should(BeFalse())
+ Ω(node.Passed()).Should(BeFalse())
+ Ω(node.Summary().State).Should(Equal(types.SpecStateTimedOut))
+ })
+ })
+ })
+
+ Describe("when running in parallel", func() {
+ var ranB bool
+ var parallelNode, parallelTotal int
+ BeforeEach(func() {
+ ranB = false
+ parallelNode, parallelTotal = 1, 3
+ })
+
+ Context("as the first node, it runs A", func() {
+ var expectedState types.RemoteBeforeSuiteData
+
+ BeforeEach(func() {
+ parallelNode, parallelTotal = 1, 3
+ })
+
+ JustBeforeEach(func() {
+ server.AppendHandlers(ghttp.CombineHandlers(
+ ghttp.VerifyRequest("POST", "/BeforeSuiteState"),
+ ghttp.VerifyJSONRepresenting(expectedState),
+ ))
+
+ outcome = node.Run(parallelNode, parallelTotal, server.URL())
+ })
+
+ Context("when A succeeds", func() {
+ BeforeEach(func() {
+ expectedState = types.RemoteBeforeSuiteData{Data: []byte("my data"), State: types.RemoteBeforeSuiteStatePassed}
+
+ node = newNode(func() []byte {
+ return []byte("my data")
+ }, func([]byte) {
+ ranB = true
+ })
+ })
+
+ It("should post about A succeeding", func() {
+ Ω(server.ReceivedRequests()).Should(HaveLen(1))
+ })
+
+ It("should run B", func() {
+ Ω(ranB).Should(BeTrue())
+ })
+
+ It("should report success", func() {
+ Ω(outcome).Should(BeTrue())
+ })
+ })
+
+ Context("when A fails", func() {
+ BeforeEach(func() {
+ expectedState = types.RemoteBeforeSuiteData{Data: nil, State: types.RemoteBeforeSuiteStateFailed}
+
+ node = newNode(func() []byte {
+ panic("BAM")
+ }, func([]byte) {
+ ranB = true
+ })
+ })
+
+ It("should post about A failing", func() {
+ Ω(server.ReceivedRequests()).Should(HaveLen(1))
+ })
+
+ It("should not run B", func() {
+ Ω(ranB).Should(BeFalse())
+ })
+
+ It("should report failure", func() {
+ Ω(outcome).Should(BeFalse())
+ })
+ })
+ })
+
+ Context("as the Nth node", func() {
+ var statusCode int
+ var response interface{}
+ var ranA bool
+ var bData []byte
+
+ BeforeEach(func() {
+ ranA = false
+ bData = nil
+
+ statusCode = http.StatusOK
+
+ server.AppendHandlers(ghttp.CombineHandlers(
+ ghttp.VerifyRequest("GET", "/BeforeSuiteState"),
+ ghttp.RespondWith(http.StatusOK, string((types.RemoteBeforeSuiteData{Data: nil, State: types.RemoteBeforeSuiteStatePending}).ToJSON())),
+ ), ghttp.CombineHandlers(
+ ghttp.VerifyRequest("GET", "/BeforeSuiteState"),
+ ghttp.RespondWith(http.StatusOK, string((types.RemoteBeforeSuiteData{Data: nil, State: types.RemoteBeforeSuiteStatePending}).ToJSON())),
+ ), ghttp.CombineHandlers(
+ ghttp.VerifyRequest("GET", "/BeforeSuiteState"),
+ ghttp.RespondWithJSONEncodedPtr(&statusCode, &response),
+ ))
+
+ node = newNode(func() []byte {
+ ranA = true
+ return nil
+ }, func(data []byte) {
+ bData = data
+ })
+
+ parallelNode, parallelTotal = 2, 3
+ })
+
+ Context("when A on node1 succeeds", func() {
+ BeforeEach(func() {
+ response = types.RemoteBeforeSuiteData{Data: []byte("my data"), State: types.RemoteBeforeSuiteStatePassed}
+ outcome = node.Run(parallelNode, parallelTotal, server.URL())
+ })
+
+ It("should not run A", func() {
+ Ω(ranA).Should(BeFalse())
+ })
+
+ It("should poll for A", func() {
+ Ω(server.ReceivedRequests()).Should(HaveLen(3))
+ })
+
+ It("should run B when the polling succeeds", func() {
+ Ω(bData).Should(Equal([]byte("my data")))
+ })
+
+ It("should succeed", func() {
+ Ω(outcome).Should(BeTrue())
+ Ω(node.Passed()).Should(BeTrue())
+ })
+ })
+
+ Context("when A on node1 fails", func() {
+ BeforeEach(func() {
+ response = types.RemoteBeforeSuiteData{Data: []byte("my data"), State: types.RemoteBeforeSuiteStateFailed}
+ outcome = node.Run(parallelNode, parallelTotal, server.URL())
+ })
+
+ It("should not run A", func() {
+ Ω(ranA).Should(BeFalse())
+ })
+
+ It("should poll for A", func() {
+ Ω(server.ReceivedRequests()).Should(HaveLen(3))
+ })
+
+ It("should not run B", func() {
+ Ω(bData).Should(BeNil())
+ })
+
+ It("should fail", func() {
+ Ω(outcome).Should(BeFalse())
+ Ω(node.Passed()).Should(BeFalse())
+
+ summary := node.Summary()
+ Ω(summary.State).Should(Equal(types.SpecStateFailed))
+ Ω(summary.Failure.Message).Should(Equal("BeforeSuite on Node 1 failed"))
+ Ω(summary.Failure.Location).Should(Equal(codeLocation))
+ Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
+ Ω(summary.Failure.ComponentIndex).Should(Equal(0))
+ Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
+ })
+ })
+
+ Context("when node1 disappears", func() {
+ BeforeEach(func() {
+ response = types.RemoteBeforeSuiteData{Data: []byte("my data"), State: types.RemoteBeforeSuiteStateDisappeared}
+ outcome = node.Run(parallelNode, parallelTotal, server.URL())
+ })
+
+ It("should not run A", func() {
+ Ω(ranA).Should(BeFalse())
+ })
+
+ It("should poll for A", func() {
+ Ω(server.ReceivedRequests()).Should(HaveLen(3))
+ })
+
+ It("should not run B", func() {
+ Ω(bData).Should(BeNil())
+ })
+
+ It("should fail", func() {
+ Ω(outcome).Should(BeFalse())
+ Ω(node.Passed()).Should(BeFalse())
+
+ summary := node.Summary()
+ Ω(summary.State).Should(Equal(types.SpecStateFailed))
+ Ω(summary.Failure.Message).Should(Equal("Node 1 disappeared before completing BeforeSuite"))
+ Ω(summary.Failure.Location).Should(Equal(codeLocation))
+ Ω(summary.Failure.ComponentType).Should(Equal(types.SpecComponentTypeBeforeSuite))
+ Ω(summary.Failure.ComponentIndex).Should(Equal(0))
+ Ω(summary.Failure.ComponentCodeLocation).Should(Equal(codeLocation))
+ })
+ })
+ })
+ })
+
+ Describe("construction", func() {
+ Describe("the first function", func() {
+ Context("when the first function returns a byte array", func() {
+ Context("and takes nothing", func() {
+ It("should be fine", func() {
+ Ω(func() {
+ newNode(func() []byte { return nil }, func([]byte) {})
+ }).ShouldNot(Panic())
+ })
+ })
+
+ Context("and takes a done function", func() {
+ It("should be fine", func() {
+ Ω(func() {
+ newNode(func(Done) []byte { return nil }, func([]byte) {})
+ }).ShouldNot(Panic())
+ })
+ })
+
+ Context("and takes more than one thing", func() {
+ It("should panic", func() {
+ Ω(func() {
+ newNode(func(Done, Done) []byte { return nil }, func([]byte) {})
+ }).Should(Panic())
+ })
+ })
+
+ Context("and takes something else", func() {
+ It("should panic", func() {
+ Ω(func() {
+ newNode(func(bool) []byte { return nil }, func([]byte) {})
+ }).Should(Panic())
+ })
+ })
+ })
+
+ Context("when the first function does not return a byte array", func() {
+ It("should panic", func() {
+ Ω(func() {
+ newNode(func() {}, func([]byte) {})
+ }).Should(Panic())
+
+ Ω(func() {
+ newNode(func() []int { return nil }, func([]byte) {})
+ }).Should(Panic())
+ })
+ })
+ })
+
+ Describe("the second function", func() {
+ Context("when the second function takes a byte array", func() {
+ It("should be fine", func() {
+ Ω(func() {
+ newNode(func() []byte { return nil }, func([]byte) {})
+ }).ShouldNot(Panic())
+ })
+ })
+
+ Context("when it also takes a done channel", func() {
+ It("should be fine", func() {
+ Ω(func() {
+ newNode(func() []byte { return nil }, func([]byte, Done) {})
+ }).ShouldNot(Panic())
+ })
+ })
+
+ Context("if it takes anything else", func() {
+ It("should panic", func() {
+ Ω(func() {
+ newNode(func() []byte { return nil }, func([]byte, chan bool) {})
+ }).Should(Panic())
+
+ Ω(func() {
+ newNode(func() []byte { return nil }, func(string) {})
+ }).Should(Panic())
+ })
+ })
+
+ Context("if it takes nothing at all", func() {
+ It("should panic", func() {
+ Ω(func() {
+ newNode(func() []byte { return nil }, func() {})
+ }).Should(Panic())
+ })
+ })
+
+ Context("if it returns something", func() {
+ It("should panic", func() {
+ Ω(func() {
+ newNode(func() []byte { return nil }, func([]byte) []byte { return nil })
+ }).Should(Panic())
+ })
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/aggregator.go b/vendor/github.com/onsi/ginkgo/internal/remote/aggregator.go
new file mode 100644
index 000000000..6b54afe01
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/remote/aggregator.go
@@ -0,0 +1,249 @@
+/*
+
+Aggregator is a reporter used by the Ginkgo CLI to aggregate and present parallel test output
+coherently as tests complete. You shouldn't need to use this in your code. To run tests in parallel:
+
+ ginkgo -nodes=N
+
+where N is the number of nodes you desire.
+*/
+package remote
+
+import (
+ "time"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/reporters/stenographer"
+ "github.com/onsi/ginkgo/types"
+)
+
+type configAndSuite struct {
+ config config.GinkgoConfigType
+ summary *types.SuiteSummary
+}
+
+type Aggregator struct {
+ nodeCount int
+ config config.DefaultReporterConfigType
+ stenographer stenographer.Stenographer
+ result chan bool
+
+ suiteBeginnings chan configAndSuite
+ aggregatedSuiteBeginnings []configAndSuite
+
+ beforeSuites chan *types.SetupSummary
+ aggregatedBeforeSuites []*types.SetupSummary
+
+ afterSuites chan *types.SetupSummary
+ aggregatedAfterSuites []*types.SetupSummary
+
+ specCompletions chan *types.SpecSummary
+ completedSpecs []*types.SpecSummary
+
+ suiteEndings chan *types.SuiteSummary
+ aggregatedSuiteEndings []*types.SuiteSummary
+ specs []*types.SpecSummary
+
+ startTime time.Time
+}
+
+func NewAggregator(nodeCount int, result chan bool, config config.DefaultReporterConfigType, stenographer stenographer.Stenographer) *Aggregator {
+ aggregator := &Aggregator{
+ nodeCount: nodeCount,
+ result: result,
+ config: config,
+ stenographer: stenographer,
+
+ suiteBeginnings: make(chan configAndSuite, 0),
+ beforeSuites: make(chan *types.SetupSummary, 0),
+ afterSuites: make(chan *types.SetupSummary, 0),
+ specCompletions: make(chan *types.SpecSummary, 0),
+ suiteEndings: make(chan *types.SuiteSummary, 0),
+ }
+
+ go aggregator.mux()
+
+ return aggregator
+}
+
+func (aggregator *Aggregator) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) {
+ aggregator.suiteBeginnings <- configAndSuite{config, summary}
+}
+
+func (aggregator *Aggregator) BeforeSuiteDidRun(setupSummary *types.SetupSummary) {
+ aggregator.beforeSuites <- setupSummary
+}
+
+func (aggregator *Aggregator) AfterSuiteDidRun(setupSummary *types.SetupSummary) {
+ aggregator.afterSuites <- setupSummary
+}
+
+func (aggregator *Aggregator) SpecWillRun(specSummary *types.SpecSummary) {
+ //noop
+}
+
+func (aggregator *Aggregator) SpecDidComplete(specSummary *types.SpecSummary) {
+ aggregator.specCompletions <- specSummary
+}
+
+func (aggregator *Aggregator) SpecSuiteDidEnd(summary *types.SuiteSummary) {
+ aggregator.suiteEndings <- summary
+}
+
+func (aggregator *Aggregator) mux() {
+loop:
+ for {
+ select {
+ case configAndSuite := <-aggregator.suiteBeginnings:
+ aggregator.registerSuiteBeginning(configAndSuite)
+ case setupSummary := <-aggregator.beforeSuites:
+ aggregator.registerBeforeSuite(setupSummary)
+ case setupSummary := <-aggregator.afterSuites:
+ aggregator.registerAfterSuite(setupSummary)
+ case specSummary := <-aggregator.specCompletions:
+ aggregator.registerSpecCompletion(specSummary)
+ case suite := <-aggregator.suiteEndings:
+ finished, passed := aggregator.registerSuiteEnding(suite)
+ if finished {
+ aggregator.result <- passed
+ break loop
+ }
+ }
+ }
+}
+
+func (aggregator *Aggregator) registerSuiteBeginning(configAndSuite configAndSuite) {
+ aggregator.aggregatedSuiteBeginnings = append(aggregator.aggregatedSuiteBeginnings, configAndSuite)
+
+ if len(aggregator.aggregatedSuiteBeginnings) == 1 {
+ aggregator.startTime = time.Now()
+ }
+
+ if len(aggregator.aggregatedSuiteBeginnings) != aggregator.nodeCount {
+ return
+ }
+
+ aggregator.stenographer.AnnounceSuite(configAndSuite.summary.SuiteDescription, configAndSuite.config.RandomSeed, configAndSuite.config.RandomizeAllSpecs, aggregator.config.Succinct)
+
+ totalNumberOfSpecs := 0
+ if len(aggregator.aggregatedSuiteBeginnings) > 0 {
+ totalNumberOfSpecs = configAndSuite.summary.NumberOfSpecsBeforeParallelization
+ }
+
+ aggregator.stenographer.AnnounceTotalNumberOfSpecs(totalNumberOfSpecs, aggregator.config.Succinct)
+ aggregator.stenographer.AnnounceAggregatedParallelRun(aggregator.nodeCount, aggregator.config.Succinct)
+ aggregator.flushCompletedSpecs()
+}
+
+func (aggregator *Aggregator) registerBeforeSuite(setupSummary *types.SetupSummary) {
+ aggregator.aggregatedBeforeSuites = append(aggregator.aggregatedBeforeSuites, setupSummary)
+ aggregator.flushCompletedSpecs()
+}
+
+func (aggregator *Aggregator) registerAfterSuite(setupSummary *types.SetupSummary) {
+ aggregator.aggregatedAfterSuites = append(aggregator.aggregatedAfterSuites, setupSummary)
+ aggregator.flushCompletedSpecs()
+}
+
+func (aggregator *Aggregator) registerSpecCompletion(specSummary *types.SpecSummary) {
+ aggregator.completedSpecs = append(aggregator.completedSpecs, specSummary)
+ aggregator.specs = append(aggregator.specs, specSummary)
+ aggregator.flushCompletedSpecs()
+}
+
+func (aggregator *Aggregator) flushCompletedSpecs() {
+ if len(aggregator.aggregatedSuiteBeginnings) != aggregator.nodeCount {
+ return
+ }
+
+ for _, setupSummary := range aggregator.aggregatedBeforeSuites {
+ aggregator.announceBeforeSuite(setupSummary)
+ }
+
+ for _, specSummary := range aggregator.completedSpecs {
+ aggregator.announceSpec(specSummary)
+ }
+
+ for _, setupSummary := range aggregator.aggregatedAfterSuites {
+ aggregator.announceAfterSuite(setupSummary)
+ }
+
+ aggregator.aggregatedBeforeSuites = []*types.SetupSummary{}
+ aggregator.completedSpecs = []*types.SpecSummary{}
+ aggregator.aggregatedAfterSuites = []*types.SetupSummary{}
+}
+
+func (aggregator *Aggregator) announceBeforeSuite(setupSummary *types.SetupSummary) {
+ aggregator.stenographer.AnnounceCapturedOutput(setupSummary.CapturedOutput)
+ if setupSummary.State != types.SpecStatePassed {
+ aggregator.stenographer.AnnounceBeforeSuiteFailure(setupSummary, aggregator.config.Succinct, aggregator.config.FullTrace)
+ }
+}
+
+func (aggregator *Aggregator) announceAfterSuite(setupSummary *types.SetupSummary) {
+ aggregator.stenographer.AnnounceCapturedOutput(setupSummary.CapturedOutput)
+ if setupSummary.State != types.SpecStatePassed {
+ aggregator.stenographer.AnnounceAfterSuiteFailure(setupSummary, aggregator.config.Succinct, aggregator.config.FullTrace)
+ }
+}
+
+func (aggregator *Aggregator) announceSpec(specSummary *types.SpecSummary) {
+ if aggregator.config.Verbose && specSummary.State != types.SpecStatePending && specSummary.State != types.SpecStateSkipped {
+ aggregator.stenographer.AnnounceSpecWillRun(specSummary)
+ }
+
+ aggregator.stenographer.AnnounceCapturedOutput(specSummary.CapturedOutput)
+
+ switch specSummary.State {
+ case types.SpecStatePassed:
+ if specSummary.IsMeasurement {
+ aggregator.stenographer.AnnounceSuccesfulMeasurement(specSummary, aggregator.config.Succinct)
+ } else if specSummary.RunTime.Seconds() >= aggregator.config.SlowSpecThreshold {
+ aggregator.stenographer.AnnounceSuccesfulSlowSpec(specSummary, aggregator.config.Succinct)
+ } else {
+ aggregator.stenographer.AnnounceSuccesfulSpec(specSummary)
+ }
+
+ case types.SpecStatePending:
+ aggregator.stenographer.AnnouncePendingSpec(specSummary, aggregator.config.NoisyPendings && !aggregator.config.Succinct)
+ case types.SpecStateSkipped:
+ aggregator.stenographer.AnnounceSkippedSpec(specSummary, aggregator.config.Succinct || !aggregator.config.NoisySkippings, aggregator.config.FullTrace)
+ case types.SpecStateTimedOut:
+ aggregator.stenographer.AnnounceSpecTimedOut(specSummary, aggregator.config.Succinct, aggregator.config.FullTrace)
+ case types.SpecStatePanicked:
+ aggregator.stenographer.AnnounceSpecPanicked(specSummary, aggregator.config.Succinct, aggregator.config.FullTrace)
+ case types.SpecStateFailed:
+ aggregator.stenographer.AnnounceSpecFailed(specSummary, aggregator.config.Succinct, aggregator.config.FullTrace)
+ }
+}
+
+func (aggregator *Aggregator) registerSuiteEnding(suite *types.SuiteSummary) (finished bool, passed bool) {
+ aggregator.aggregatedSuiteEndings = append(aggregator.aggregatedSuiteEndings, suite)
+ if len(aggregator.aggregatedSuiteEndings) < aggregator.nodeCount {
+ return false, false
+ }
+
+ aggregatedSuiteSummary := &types.SuiteSummary{}
+ aggregatedSuiteSummary.SuiteSucceeded = true
+
+ for _, suiteSummary := range aggregator.aggregatedSuiteEndings {
+ if suiteSummary.SuiteSucceeded == false {
+ aggregatedSuiteSummary.SuiteSucceeded = false
+ }
+
+ aggregatedSuiteSummary.NumberOfSpecsThatWillBeRun += suiteSummary.NumberOfSpecsThatWillBeRun
+ aggregatedSuiteSummary.NumberOfTotalSpecs += suiteSummary.NumberOfTotalSpecs
+ aggregatedSuiteSummary.NumberOfPassedSpecs += suiteSummary.NumberOfPassedSpecs
+ aggregatedSuiteSummary.NumberOfFailedSpecs += suiteSummary.NumberOfFailedSpecs
+ aggregatedSuiteSummary.NumberOfPendingSpecs += suiteSummary.NumberOfPendingSpecs
+ aggregatedSuiteSummary.NumberOfSkippedSpecs += suiteSummary.NumberOfSkippedSpecs
+ aggregatedSuiteSummary.NumberOfFlakedSpecs += suiteSummary.NumberOfFlakedSpecs
+ }
+
+ aggregatedSuiteSummary.RunTime = time.Since(aggregator.startTime)
+
+ aggregator.stenographer.SummarizeFailures(aggregator.specs)
+ aggregator.stenographer.AnnounceSpecRunCompletion(aggregatedSuiteSummary, aggregator.config.Succinct)
+
+ return true, aggregatedSuiteSummary.SuiteSucceeded
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/aggregator_test.go b/vendor/github.com/onsi/ginkgo/internal/remote/aggregator_test.go
new file mode 100644
index 000000000..aedf93927
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/remote/aggregator_test.go
@@ -0,0 +1,315 @@
+package remote_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "time"
+
+ "github.com/onsi/ginkgo/config"
+ . "github.com/onsi/ginkgo/internal/remote"
+ st "github.com/onsi/ginkgo/reporters/stenographer"
+ "github.com/onsi/ginkgo/types"
+)
+
+var _ = Describe("Aggregator", func() {
+ var (
+ aggregator *Aggregator
+ reporterConfig config.DefaultReporterConfigType
+ stenographer *st.FakeStenographer
+ result chan bool
+
+ ginkgoConfig1 config.GinkgoConfigType
+ ginkgoConfig2 config.GinkgoConfigType
+
+ suiteSummary1 *types.SuiteSummary
+ suiteSummary2 *types.SuiteSummary
+
+ beforeSummary *types.SetupSummary
+ afterSummary *types.SetupSummary
+ specSummary *types.SpecSummary
+
+ suiteDescription string
+ )
+
+ BeforeEach(func() {
+ reporterConfig = config.DefaultReporterConfigType{
+ NoColor: false,
+ SlowSpecThreshold: 0.1,
+ NoisyPendings: true,
+ Succinct: false,
+ Verbose: true,
+ }
+ stenographer = st.NewFakeStenographer()
+ result = make(chan bool, 1)
+ aggregator = NewAggregator(2, result, reporterConfig, stenographer)
+
+ //
+ // now set up some fixture data
+ //
+
+ ginkgoConfig1 = config.GinkgoConfigType{
+ RandomSeed: 1138,
+ RandomizeAllSpecs: true,
+ ParallelNode: 1,
+ ParallelTotal: 2,
+ }
+
+ ginkgoConfig2 = config.GinkgoConfigType{
+ RandomSeed: 1138,
+ RandomizeAllSpecs: true,
+ ParallelNode: 2,
+ ParallelTotal: 2,
+ }
+
+ suiteDescription = "My Parallel Suite"
+
+ suiteSummary1 = &types.SuiteSummary{
+ SuiteDescription: suiteDescription,
+
+ NumberOfSpecsBeforeParallelization: 30,
+ NumberOfTotalSpecs: 17,
+ NumberOfSpecsThatWillBeRun: 15,
+ NumberOfPendingSpecs: 1,
+ NumberOfSkippedSpecs: 1,
+ }
+
+ suiteSummary2 = &types.SuiteSummary{
+ SuiteDescription: suiteDescription,
+
+ NumberOfSpecsBeforeParallelization: 30,
+ NumberOfTotalSpecs: 13,
+ NumberOfSpecsThatWillBeRun: 8,
+ NumberOfPendingSpecs: 2,
+ NumberOfSkippedSpecs: 3,
+ }
+
+ beforeSummary = &types.SetupSummary{
+ State: types.SpecStatePassed,
+ CapturedOutput: "BeforeSuiteOutput",
+ }
+
+ afterSummary = &types.SetupSummary{
+ State: types.SpecStatePassed,
+ CapturedOutput: "AfterSuiteOutput",
+ }
+
+ specSummary = &types.SpecSummary{
+ State: types.SpecStatePassed,
+ CapturedOutput: "SpecOutput",
+ }
+ })
+
+ call := func(method string, args ...interface{}) st.FakeStenographerCall {
+ return st.NewFakeStenographerCall(method, args...)
+ }
+
+ beginSuite := func() {
+ stenographer.Reset()
+ aggregator.SpecSuiteWillBegin(ginkgoConfig2, suiteSummary2)
+ aggregator.SpecSuiteWillBegin(ginkgoConfig1, suiteSummary1)
+ Eventually(func() interface{} {
+ return len(stenographer.Calls())
+ }).Should(BeNumerically(">=", 3))
+ }
+
+ Describe("Announcing the beginning of the suite", func() {
+ Context("When one of the parallel-suites starts", func() {
+ BeforeEach(func() {
+ aggregator.SpecSuiteWillBegin(ginkgoConfig2, suiteSummary2)
+ })
+
+ It("should be silent", func() {
+ Consistently(func() interface{} { return stenographer.Calls() }).Should(BeEmpty())
+ })
+ })
+
+ Context("once all of the parallel-suites have started", func() {
+ BeforeEach(func() {
+ aggregator.SpecSuiteWillBegin(ginkgoConfig2, suiteSummary2)
+ aggregator.SpecSuiteWillBegin(ginkgoConfig1, suiteSummary1)
+ Eventually(func() interface{} {
+ return stenographer.Calls()
+ }).Should(HaveLen(3))
+ })
+
+ It("should announce the beginning of the suite", func() {
+ Ω(stenographer.Calls()).Should(HaveLen(3))
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuite", suiteDescription, ginkgoConfig1.RandomSeed, true, false)))
+ Ω(stenographer.Calls()[1]).Should(Equal(call("AnnounceTotalNumberOfSpecs", 30, false)))
+ Ω(stenographer.Calls()[2]).Should(Equal(call("AnnounceAggregatedParallelRun", 2, false)))
+ })
+ })
+ })
+
+ Describe("Announcing specs and before suites", func() {
+ Context("when the parallel-suites have not all started", func() {
+ BeforeEach(func() {
+ aggregator.BeforeSuiteDidRun(beforeSummary)
+ aggregator.AfterSuiteDidRun(afterSummary)
+ aggregator.SpecDidComplete(specSummary)
+ })
+
+ It("should not announce any specs", func() {
+ Consistently(func() interface{} { return stenographer.Calls() }).Should(BeEmpty())
+ })
+
+ Context("when the parallel-suites subsequently start", func() {
+ BeforeEach(func() {
+ beginSuite()
+ })
+
+ It("should announce the specs, the before suites and the after suites", func() {
+ Eventually(func() interface{} {
+ return stenographer.Calls()
+ }).Should(ContainElement(call("AnnounceSuccesfulSpec", specSummary)))
+
+ Ω(stenographer.Calls()).Should(ContainElement(call("AnnounceCapturedOutput", beforeSummary.CapturedOutput)))
+ Ω(stenographer.Calls()).Should(ContainElement(call("AnnounceCapturedOutput", afterSummary.CapturedOutput)))
+ })
+ })
+ })
+
+ Context("When the parallel-suites have all started", func() {
+ BeforeEach(func() {
+ beginSuite()
+ stenographer.Reset()
+ })
+
+ Context("When a spec completes", func() {
+ BeforeEach(func() {
+ aggregator.BeforeSuiteDidRun(beforeSummary)
+ aggregator.SpecDidComplete(specSummary)
+ aggregator.AfterSuiteDidRun(afterSummary)
+ Eventually(func() interface{} {
+ return stenographer.Calls()
+ }).Should(HaveLen(5))
+ })
+
+ It("should announce the captured output of the BeforeSuite", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceCapturedOutput", beforeSummary.CapturedOutput)))
+ })
+
+ It("should announce that the spec will run (when in verbose mode)", func() {
+ Ω(stenographer.Calls()[1]).Should(Equal(call("AnnounceSpecWillRun", specSummary)))
+ })
+
+ It("should announce the captured stdout of the spec", func() {
+ Ω(stenographer.Calls()[2]).Should(Equal(call("AnnounceCapturedOutput", specSummary.CapturedOutput)))
+ })
+
+ It("should announce completion", func() {
+ Ω(stenographer.Calls()[3]).Should(Equal(call("AnnounceSuccesfulSpec", specSummary)))
+ })
+
+ It("should announce the captured output of the AfterSuite", func() {
+ Ω(stenographer.Calls()[4]).Should(Equal(call("AnnounceCapturedOutput", afterSummary.CapturedOutput)))
+ })
+ })
+ })
+ })
+
+ Describe("Announcing the end of the suite", func() {
+ BeforeEach(func() {
+ beginSuite()
+ stenographer.Reset()
+ })
+
+ Context("When one of the parallel-suites ends", func() {
+ BeforeEach(func() {
+ aggregator.SpecSuiteDidEnd(suiteSummary2)
+ })
+
+ It("should be silent", func() {
+ Consistently(func() interface{} { return stenographer.Calls() }).Should(BeEmpty())
+ })
+
+ It("should not notify the channel", func() {
+ Ω(result).Should(BeEmpty())
+ })
+ })
+
+ Context("once all of the parallel-suites end", func() {
+ BeforeEach(func() {
+ time.Sleep(200 * time.Millisecond)
+
+ suiteSummary1.SuiteSucceeded = true
+ suiteSummary1.NumberOfPassedSpecs = 15
+ suiteSummary1.NumberOfFailedSpecs = 0
+ suiteSummary1.NumberOfFlakedSpecs = 3
+ suiteSummary2.SuiteSucceeded = false
+ suiteSummary2.NumberOfPassedSpecs = 5
+ suiteSummary2.NumberOfFailedSpecs = 3
+ suiteSummary2.NumberOfFlakedSpecs = 4
+
+ aggregator.SpecSuiteDidEnd(suiteSummary2)
+ aggregator.SpecSuiteDidEnd(suiteSummary1)
+ Eventually(func() interface{} {
+ return stenographer.Calls()
+ }).Should(HaveLen(2))
+ })
+
+ It("should announce the end of the suite", func() {
+ compositeSummary := stenographer.Calls()[1].Args[0].(*types.SuiteSummary)
+
+ Ω(compositeSummary.SuiteSucceeded).Should(BeFalse())
+ Ω(compositeSummary.NumberOfSpecsThatWillBeRun).Should(Equal(23))
+ Ω(compositeSummary.NumberOfTotalSpecs).Should(Equal(30))
+ Ω(compositeSummary.NumberOfPassedSpecs).Should(Equal(20))
+ Ω(compositeSummary.NumberOfFailedSpecs).Should(Equal(3))
+ Ω(compositeSummary.NumberOfPendingSpecs).Should(Equal(3))
+ Ω(compositeSummary.NumberOfSkippedSpecs).Should(Equal(4))
+ Ω(compositeSummary.NumberOfFlakedSpecs).Should(Equal(7))
+ Ω(compositeSummary.RunTime.Seconds()).Should(BeNumerically(">", 0.2))
+ })
+ })
+
+ Context("when all the parallel-suites pass", func() {
+ BeforeEach(func() {
+ suiteSummary1.SuiteSucceeded = true
+ suiteSummary2.SuiteSucceeded = true
+
+ aggregator.SpecSuiteDidEnd(suiteSummary2)
+ aggregator.SpecSuiteDidEnd(suiteSummary1)
+ Eventually(func() interface{} {
+ return stenographer.Calls()
+ }).Should(HaveLen(2))
+ })
+
+ It("should report success", func() {
+ compositeSummary := stenographer.Calls()[1].Args[0].(*types.SuiteSummary)
+
+ Ω(compositeSummary.SuiteSucceeded).Should(BeTrue())
+ })
+
+ It("should notify the channel that it succeded", func(done Done) {
+ Ω(<-result).Should(BeTrue())
+ close(done)
+ })
+ })
+
+ Context("when one of the parallel-suites fails", func() {
+ BeforeEach(func() {
+ suiteSummary1.SuiteSucceeded = true
+ suiteSummary2.SuiteSucceeded = false
+
+ aggregator.SpecSuiteDidEnd(suiteSummary2)
+ aggregator.SpecSuiteDidEnd(suiteSummary1)
+ Eventually(func() interface{} {
+ return stenographer.Calls()
+ }).Should(HaveLen(2))
+ })
+
+ It("should report failure", func() {
+ compositeSummary := stenographer.Calls()[1].Args[0].(*types.SuiteSummary)
+
+ Ω(compositeSummary.SuiteSucceeded).Should(BeFalse())
+ })
+
+ It("should notify the channel that it failed", func(done Done) {
+ Ω(<-result).Should(BeFalse())
+ close(done)
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/fake_output_interceptor_test.go b/vendor/github.com/onsi/ginkgo/internal/remote/fake_output_interceptor_test.go
new file mode 100644
index 000000000..ef54862ea
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/remote/fake_output_interceptor_test.go
@@ -0,0 +1,22 @@
+package remote_test
+
+import "os"
+
+type fakeOutputInterceptor struct {
+ DidStartInterceptingOutput bool
+ DidStopInterceptingOutput bool
+ InterceptedOutput string
+}
+
+func (interceptor *fakeOutputInterceptor) StartInterceptingOutput() error {
+ interceptor.DidStartInterceptingOutput = true
+ return nil
+}
+
+func (interceptor *fakeOutputInterceptor) StopInterceptingAndReturnOutput() (string, error) {
+ interceptor.DidStopInterceptingOutput = true
+ return interceptor.InterceptedOutput, nil
+}
+
+func (interceptor *fakeOutputInterceptor) StreamTo(*os.File) {
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/fake_poster_test.go b/vendor/github.com/onsi/ginkgo/internal/remote/fake_poster_test.go
new file mode 100644
index 000000000..3543c59c6
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/remote/fake_poster_test.go
@@ -0,0 +1,33 @@
+package remote_test
+
+import (
+ "io"
+ "io/ioutil"
+ "net/http"
+)
+
+type post struct {
+ url string
+ bodyType string
+ bodyContent []byte
+}
+
+type fakePoster struct {
+ posts []post
+}
+
+func newFakePoster() *fakePoster {
+ return &fakePoster{
+ posts: make([]post, 0),
+ }
+}
+
+func (poster *fakePoster) Post(url string, bodyType string, body io.Reader) (resp *http.Response, err error) {
+ bodyContent, _ := ioutil.ReadAll(body)
+ poster.posts = append(poster.posts, post{
+ url: url,
+ bodyType: bodyType,
+ bodyContent: bodyContent,
+ })
+ return nil, nil
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/forwarding_reporter.go b/vendor/github.com/onsi/ginkgo/internal/remote/forwarding_reporter.go
new file mode 100644
index 000000000..284bc62e5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/remote/forwarding_reporter.go
@@ -0,0 +1,147 @@
+package remote
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+ "os"
+
+ "github.com/onsi/ginkgo/internal/writer"
+ "github.com/onsi/ginkgo/reporters"
+ "github.com/onsi/ginkgo/reporters/stenographer"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/types"
+)
+
+//An interface to net/http's client to allow the injection of fakes under test
+type Poster interface {
+ Post(url string, bodyType string, body io.Reader) (resp *http.Response, err error)
+}
+
+/*
+The ForwardingReporter is a Ginkgo reporter that forwards information to
+a Ginkgo remote server.
+
+When streaming parallel test output, this repoter is automatically installed by Ginkgo.
+
+This is accomplished by passing in the GINKGO_REMOTE_REPORTING_SERVER environment variable to `go test`, the Ginkgo test runner
+detects this environment variable (which should contain the host of the server) and automatically installs a ForwardingReporter
+in place of Ginkgo's DefaultReporter.
+*/
+
+type ForwardingReporter struct {
+ serverHost string
+ poster Poster
+ outputInterceptor OutputInterceptor
+ debugMode bool
+ debugFile *os.File
+ nestedReporter *reporters.DefaultReporter
+}
+
+func NewForwardingReporter(config config.DefaultReporterConfigType, serverHost string, poster Poster, outputInterceptor OutputInterceptor, ginkgoWriter *writer.Writer, debugFile string) *ForwardingReporter {
+ reporter := &ForwardingReporter{
+ serverHost: serverHost,
+ poster: poster,
+ outputInterceptor: outputInterceptor,
+ }
+
+ if debugFile != "" {
+ var err error
+ reporter.debugMode = true
+ reporter.debugFile, err = os.Create(debugFile)
+ if err != nil {
+ fmt.Println(err.Error())
+ os.Exit(1)
+ }
+
+ if !config.Verbose {
+ //if verbose is true then the GinkgoWriter emits to stdout. Don't _also_ redirect GinkgoWriter output as that will result in duplication.
+ ginkgoWriter.AndRedirectTo(reporter.debugFile)
+ }
+ outputInterceptor.StreamTo(reporter.debugFile) //This is not working
+
+ stenographer := stenographer.New(false, true, reporter.debugFile)
+ config.Succinct = false
+ config.Verbose = true
+ config.FullTrace = true
+ reporter.nestedReporter = reporters.NewDefaultReporter(config, stenographer)
+ }
+
+ return reporter
+}
+
+func (reporter *ForwardingReporter) post(path string, data interface{}) {
+ encoded, _ := json.Marshal(data)
+ buffer := bytes.NewBuffer(encoded)
+ reporter.poster.Post(reporter.serverHost+path, "application/json", buffer)
+}
+
+func (reporter *ForwardingReporter) SpecSuiteWillBegin(conf config.GinkgoConfigType, summary *types.SuiteSummary) {
+ data := struct {
+ Config config.GinkgoConfigType `json:"config"`
+ Summary *types.SuiteSummary `json:"suite-summary"`
+ }{
+ conf,
+ summary,
+ }
+
+ reporter.outputInterceptor.StartInterceptingOutput()
+ if reporter.debugMode {
+ reporter.nestedReporter.SpecSuiteWillBegin(conf, summary)
+ reporter.debugFile.Sync()
+ }
+ reporter.post("/SpecSuiteWillBegin", data)
+}
+
+func (reporter *ForwardingReporter) BeforeSuiteDidRun(setupSummary *types.SetupSummary) {
+ output, _ := reporter.outputInterceptor.StopInterceptingAndReturnOutput()
+ reporter.outputInterceptor.StartInterceptingOutput()
+ setupSummary.CapturedOutput = output
+ if reporter.debugMode {
+ reporter.nestedReporter.BeforeSuiteDidRun(setupSummary)
+ reporter.debugFile.Sync()
+ }
+ reporter.post("/BeforeSuiteDidRun", setupSummary)
+}
+
+func (reporter *ForwardingReporter) SpecWillRun(specSummary *types.SpecSummary) {
+ if reporter.debugMode {
+ reporter.nestedReporter.SpecWillRun(specSummary)
+ reporter.debugFile.Sync()
+ }
+ reporter.post("/SpecWillRun", specSummary)
+}
+
+func (reporter *ForwardingReporter) SpecDidComplete(specSummary *types.SpecSummary) {
+ output, _ := reporter.outputInterceptor.StopInterceptingAndReturnOutput()
+ reporter.outputInterceptor.StartInterceptingOutput()
+ specSummary.CapturedOutput = output
+ if reporter.debugMode {
+ reporter.nestedReporter.SpecDidComplete(specSummary)
+ reporter.debugFile.Sync()
+ }
+ reporter.post("/SpecDidComplete", specSummary)
+}
+
+func (reporter *ForwardingReporter) AfterSuiteDidRun(setupSummary *types.SetupSummary) {
+ output, _ := reporter.outputInterceptor.StopInterceptingAndReturnOutput()
+ reporter.outputInterceptor.StartInterceptingOutput()
+ setupSummary.CapturedOutput = output
+ if reporter.debugMode {
+ reporter.nestedReporter.AfterSuiteDidRun(setupSummary)
+ reporter.debugFile.Sync()
+ }
+ reporter.post("/AfterSuiteDidRun", setupSummary)
+}
+
+func (reporter *ForwardingReporter) SpecSuiteDidEnd(summary *types.SuiteSummary) {
+ reporter.outputInterceptor.StopInterceptingAndReturnOutput()
+ if reporter.debugMode {
+ reporter.nestedReporter.SpecSuiteDidEnd(summary)
+ reporter.debugFile.Sync()
+ }
+ reporter.post("/SpecSuiteDidEnd", summary)
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/forwarding_reporter_test.go b/vendor/github.com/onsi/ginkgo/internal/remote/forwarding_reporter_test.go
new file mode 100644
index 000000000..0d7e4769c
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/remote/forwarding_reporter_test.go
@@ -0,0 +1,181 @@
+package remote_test
+
+import (
+ "encoding/json"
+
+ . "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/config"
+ . "github.com/onsi/ginkgo/internal/remote"
+ "github.com/onsi/ginkgo/types"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("ForwardingReporter", func() {
+ var (
+ reporter *ForwardingReporter
+ interceptor *fakeOutputInterceptor
+ poster *fakePoster
+ suiteSummary *types.SuiteSummary
+ specSummary *types.SpecSummary
+ setupSummary *types.SetupSummary
+ serverHost string
+ )
+
+ BeforeEach(func() {
+ serverHost = "http://127.0.0.1:7788"
+
+ poster = newFakePoster()
+
+ interceptor = &fakeOutputInterceptor{
+ InterceptedOutput: "The intercepted output!",
+ }
+
+ reporter = NewForwardingReporter(config.DefaultReporterConfigType{}, serverHost, poster, interceptor, nil, "")
+
+ suiteSummary = &types.SuiteSummary{
+ SuiteDescription: "My Test Suite",
+ }
+
+ setupSummary = &types.SetupSummary{
+ State: types.SpecStatePassed,
+ }
+
+ specSummary = &types.SpecSummary{
+ ComponentTexts: []string{"My", "Spec"},
+ State: types.SpecStatePassed,
+ }
+ })
+
+ Context("When a suite begins", func() {
+ BeforeEach(func() {
+ reporter.SpecSuiteWillBegin(config.GinkgoConfig, suiteSummary)
+ })
+
+ It("should start intercepting output", func() {
+ Ω(interceptor.DidStartInterceptingOutput).Should(BeTrue())
+ })
+
+ It("should POST the SuiteSummary and Ginkgo Config to the Ginkgo server", func() {
+ Ω(poster.posts).Should(HaveLen(1))
+ Ω(poster.posts[0].url).Should(Equal("http://127.0.0.1:7788/SpecSuiteWillBegin"))
+ Ω(poster.posts[0].bodyType).Should(Equal("application/json"))
+
+ var sentData struct {
+ SentConfig config.GinkgoConfigType `json:"config"`
+ SentSuiteSummary *types.SuiteSummary `json:"suite-summary"`
+ }
+
+ err := json.Unmarshal(poster.posts[0].bodyContent, &sentData)
+ Ω(err).ShouldNot(HaveOccurred())
+
+ Ω(sentData.SentConfig).Should(Equal(config.GinkgoConfig))
+ Ω(sentData.SentSuiteSummary).Should(Equal(suiteSummary))
+ })
+ })
+
+ Context("when a BeforeSuite completes", func() {
+ BeforeEach(func() {
+ reporter.BeforeSuiteDidRun(setupSummary)
+ })
+
+ It("should stop, then start intercepting output", func() {
+ Ω(interceptor.DidStopInterceptingOutput).Should(BeTrue())
+ Ω(interceptor.DidStartInterceptingOutput).Should(BeTrue())
+ })
+
+ It("should POST the SetupSummary to the Ginkgo server", func() {
+ Ω(poster.posts).Should(HaveLen(1))
+ Ω(poster.posts[0].url).Should(Equal("http://127.0.0.1:7788/BeforeSuiteDidRun"))
+ Ω(poster.posts[0].bodyType).Should(Equal("application/json"))
+
+ var summary *types.SetupSummary
+ err := json.Unmarshal(poster.posts[0].bodyContent, &summary)
+ Ω(err).ShouldNot(HaveOccurred())
+ setupSummary.CapturedOutput = interceptor.InterceptedOutput
+ Ω(summary).Should(Equal(setupSummary))
+ })
+ })
+
+ Context("when an AfterSuite completes", func() {
+ BeforeEach(func() {
+ reporter.AfterSuiteDidRun(setupSummary)
+ })
+
+ It("should stop, then start intercepting output", func() {
+ Ω(interceptor.DidStopInterceptingOutput).Should(BeTrue())
+ Ω(interceptor.DidStartInterceptingOutput).Should(BeTrue())
+ })
+
+ It("should POST the SetupSummary to the Ginkgo server", func() {
+ Ω(poster.posts).Should(HaveLen(1))
+ Ω(poster.posts[0].url).Should(Equal("http://127.0.0.1:7788/AfterSuiteDidRun"))
+ Ω(poster.posts[0].bodyType).Should(Equal("application/json"))
+
+ var summary *types.SetupSummary
+ err := json.Unmarshal(poster.posts[0].bodyContent, &summary)
+ Ω(err).ShouldNot(HaveOccurred())
+ setupSummary.CapturedOutput = interceptor.InterceptedOutput
+ Ω(summary).Should(Equal(setupSummary))
+ })
+ })
+
+ Context("When a spec will run", func() {
+ BeforeEach(func() {
+ reporter.SpecWillRun(specSummary)
+ })
+
+ It("should POST the SpecSummary to the Ginkgo server", func() {
+ Ω(poster.posts).Should(HaveLen(1))
+ Ω(poster.posts[0].url).Should(Equal("http://127.0.0.1:7788/SpecWillRun"))
+ Ω(poster.posts[0].bodyType).Should(Equal("application/json"))
+
+ var summary *types.SpecSummary
+ err := json.Unmarshal(poster.posts[0].bodyContent, &summary)
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(summary).Should(Equal(specSummary))
+ })
+
+ Context("When a spec completes", func() {
+ BeforeEach(func() {
+ specSummary.State = types.SpecStatePanicked
+ reporter.SpecDidComplete(specSummary)
+ })
+
+ It("should POST the SpecSummary to the Ginkgo server and include any intercepted output", func() {
+ Ω(poster.posts).Should(HaveLen(2))
+ Ω(poster.posts[1].url).Should(Equal("http://127.0.0.1:7788/SpecDidComplete"))
+ Ω(poster.posts[1].bodyType).Should(Equal("application/json"))
+
+ var summary *types.SpecSummary
+ err := json.Unmarshal(poster.posts[1].bodyContent, &summary)
+ Ω(err).ShouldNot(HaveOccurred())
+ specSummary.CapturedOutput = interceptor.InterceptedOutput
+ Ω(summary).Should(Equal(specSummary))
+ })
+
+ It("should stop, then start intercepting output", func() {
+ Ω(interceptor.DidStopInterceptingOutput).Should(BeTrue())
+ Ω(interceptor.DidStartInterceptingOutput).Should(BeTrue())
+ })
+ })
+ })
+
+ Context("When a suite ends", func() {
+ BeforeEach(func() {
+ reporter.SpecSuiteDidEnd(suiteSummary)
+ })
+
+ It("should POST the SuiteSummary to the Ginkgo server", func() {
+ Ω(poster.posts).Should(HaveLen(1))
+ Ω(poster.posts[0].url).Should(Equal("http://127.0.0.1:7788/SpecSuiteDidEnd"))
+ Ω(poster.posts[0].bodyType).Should(Equal("application/json"))
+
+ var summary *types.SuiteSummary
+
+ err := json.Unmarshal(poster.posts[0].bodyContent, &summary)
+ Ω(err).ShouldNot(HaveOccurred())
+
+ Ω(summary).Should(Equal(suiteSummary))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/output_interceptor.go b/vendor/github.com/onsi/ginkgo/internal/remote/output_interceptor.go
new file mode 100644
index 000000000..5154abe87
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/remote/output_interceptor.go
@@ -0,0 +1,13 @@
+package remote
+
+import "os"
+
+/*
+The OutputInterceptor is used by the ForwardingReporter to
+intercept and capture all stdin and stderr output during a test run.
+*/
+type OutputInterceptor interface {
+ StartInterceptingOutput() error
+ StopInterceptingAndReturnOutput() (string, error)
+ StreamTo(*os.File)
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/output_interceptor_unix.go b/vendor/github.com/onsi/ginkgo/internal/remote/output_interceptor_unix.go
new file mode 100644
index 000000000..ab6622a29
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/remote/output_interceptor_unix.go
@@ -0,0 +1,83 @@
+// +build freebsd openbsd netbsd dragonfly darwin linux solaris
+
+package remote
+
+import (
+ "errors"
+ "io/ioutil"
+ "os"
+
+ "github.com/hpcloud/tail"
+)
+
+func NewOutputInterceptor() OutputInterceptor {
+ return &outputInterceptor{}
+}
+
+type outputInterceptor struct {
+ redirectFile *os.File
+ streamTarget *os.File
+ intercepting bool
+ tailer *tail.Tail
+ doneTailing chan bool
+}
+
+func (interceptor *outputInterceptor) StartInterceptingOutput() error {
+ if interceptor.intercepting {
+ return errors.New("Already intercepting output!")
+ }
+ interceptor.intercepting = true
+
+ var err error
+
+ interceptor.redirectFile, err = ioutil.TempFile("", "ginkgo-output")
+ if err != nil {
+ return err
+ }
+
+ // Call a function in ./syscall_dup_*.go
+ // If building for everything other than linux_arm64,
+ // use a "normal" syscall.Dup2(oldfd, newfd) call. If building for linux_arm64 (which doesn't have syscall.Dup2)
+ // call syscall.Dup3(oldfd, newfd, 0). They are nearly identical, see: http://linux.die.net/man/2/dup3
+ syscallDup(int(interceptor.redirectFile.Fd()), 1)
+ syscallDup(int(interceptor.redirectFile.Fd()), 2)
+
+ if interceptor.streamTarget != nil {
+ interceptor.tailer, _ = tail.TailFile(interceptor.redirectFile.Name(), tail.Config{Follow: true})
+ interceptor.doneTailing = make(chan bool)
+
+ go func() {
+ for line := range interceptor.tailer.Lines {
+ interceptor.streamTarget.Write([]byte(line.Text + "\n"))
+ }
+ close(interceptor.doneTailing)
+ }()
+ }
+
+ return nil
+}
+
+func (interceptor *outputInterceptor) StopInterceptingAndReturnOutput() (string, error) {
+ if !interceptor.intercepting {
+ return "", errors.New("Not intercepting output!")
+ }
+
+ interceptor.redirectFile.Close()
+ output, err := ioutil.ReadFile(interceptor.redirectFile.Name())
+ os.Remove(interceptor.redirectFile.Name())
+
+ interceptor.intercepting = false
+
+ if interceptor.streamTarget != nil {
+ interceptor.tailer.Stop()
+ interceptor.tailer.Cleanup()
+ <-interceptor.doneTailing
+ interceptor.streamTarget.Sync()
+ }
+
+ return string(output), err
+}
+
+func (interceptor *outputInterceptor) StreamTo(out *os.File) {
+ interceptor.streamTarget = out
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/output_interceptor_win.go b/vendor/github.com/onsi/ginkgo/internal/remote/output_interceptor_win.go
new file mode 100644
index 000000000..40c790336
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/remote/output_interceptor_win.go
@@ -0,0 +1,36 @@
+// +build windows
+
+package remote
+
+import (
+ "errors"
+ "os"
+)
+
+func NewOutputInterceptor() OutputInterceptor {
+ return &outputInterceptor{}
+}
+
+type outputInterceptor struct {
+ intercepting bool
+}
+
+func (interceptor *outputInterceptor) StartInterceptingOutput() error {
+ if interceptor.intercepting {
+ return errors.New("Already intercepting output!")
+ }
+ interceptor.intercepting = true
+
+ // not working on windows...
+
+ return nil
+}
+
+func (interceptor *outputInterceptor) StopInterceptingAndReturnOutput() (string, error) {
+ // not working on windows...
+ interceptor.intercepting = false
+
+ return "", nil
+}
+
+func (interceptor *outputInterceptor) StreamTo(*os.File) {}
diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/remote_suite_test.go b/vendor/github.com/onsi/ginkgo/internal/remote/remote_suite_test.go
new file mode 100644
index 000000000..e6b4e9f32
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/remote/remote_suite_test.go
@@ -0,0 +1,13 @@
+package remote_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestRemote(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Remote Spec Forwarding Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/server.go b/vendor/github.com/onsi/ginkgo/internal/remote/server.go
new file mode 100644
index 000000000..367c54daf
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/remote/server.go
@@ -0,0 +1,224 @@
+/*
+
+The remote package provides the pieces to allow Ginkgo test suites to report to remote listeners.
+This is used, primarily, to enable streaming parallel test output but has, in principal, broader applications (e.g. streaming test output to a browser).
+
+*/
+
+package remote
+
+import (
+ "encoding/json"
+ "io/ioutil"
+ "net"
+ "net/http"
+ "sync"
+
+ "github.com/onsi/ginkgo/internal/spec_iterator"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/reporters"
+ "github.com/onsi/ginkgo/types"
+)
+
+/*
+Server spins up on an automatically selected port and listens for communication from the forwarding reporter.
+It then forwards that communication to attached reporters.
+*/
+type Server struct {
+ listener net.Listener
+ reporters []reporters.Reporter
+ alives []func() bool
+ lock *sync.Mutex
+ beforeSuiteData types.RemoteBeforeSuiteData
+ parallelTotal int
+ counter int
+}
+
+//Create a new server, automatically selecting a port
+func NewServer(parallelTotal int) (*Server, error) {
+ listener, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ return nil, err
+ }
+ return &Server{
+ listener: listener,
+ lock: &sync.Mutex{},
+ alives: make([]func() bool, parallelTotal),
+ beforeSuiteData: types.RemoteBeforeSuiteData{Data: nil, State: types.RemoteBeforeSuiteStatePending},
+ parallelTotal: parallelTotal,
+ }, nil
+}
+
+//Start the server. You don't need to `go s.Start()`, just `s.Start()`
+func (server *Server) Start() {
+ httpServer := &http.Server{}
+ mux := http.NewServeMux()
+ httpServer.Handler = mux
+
+ //streaming endpoints
+ mux.HandleFunc("/SpecSuiteWillBegin", server.specSuiteWillBegin)
+ mux.HandleFunc("/BeforeSuiteDidRun", server.beforeSuiteDidRun)
+ mux.HandleFunc("/AfterSuiteDidRun", server.afterSuiteDidRun)
+ mux.HandleFunc("/SpecWillRun", server.specWillRun)
+ mux.HandleFunc("/SpecDidComplete", server.specDidComplete)
+ mux.HandleFunc("/SpecSuiteDidEnd", server.specSuiteDidEnd)
+
+ //synchronization endpoints
+ mux.HandleFunc("/BeforeSuiteState", server.handleBeforeSuiteState)
+ mux.HandleFunc("/RemoteAfterSuiteData", server.handleRemoteAfterSuiteData)
+ mux.HandleFunc("/counter", server.handleCounter)
+ mux.HandleFunc("/has-counter", server.handleHasCounter) //for backward compatibility
+
+ go httpServer.Serve(server.listener)
+}
+
+//Stop the server
+func (server *Server) Close() {
+ server.listener.Close()
+}
+
+//The address the server can be reached it. Pass this into the `ForwardingReporter`.
+func (server *Server) Address() string {
+ return "http://" + server.listener.Addr().String()
+}
+
+//
+// Streaming Endpoints
+//
+
+//The server will forward all received messages to Ginkgo reporters registered with `RegisterReporters`
+func (server *Server) readAll(request *http.Request) []byte {
+ defer request.Body.Close()
+ body, _ := ioutil.ReadAll(request.Body)
+ return body
+}
+
+func (server *Server) RegisterReporters(reporters ...reporters.Reporter) {
+ server.reporters = reporters
+}
+
+func (server *Server) specSuiteWillBegin(writer http.ResponseWriter, request *http.Request) {
+ body := server.readAll(request)
+
+ var data struct {
+ Config config.GinkgoConfigType `json:"config"`
+ Summary *types.SuiteSummary `json:"suite-summary"`
+ }
+
+ json.Unmarshal(body, &data)
+
+ for _, reporter := range server.reporters {
+ reporter.SpecSuiteWillBegin(data.Config, data.Summary)
+ }
+}
+
+func (server *Server) beforeSuiteDidRun(writer http.ResponseWriter, request *http.Request) {
+ body := server.readAll(request)
+ var setupSummary *types.SetupSummary
+ json.Unmarshal(body, &setupSummary)
+
+ for _, reporter := range server.reporters {
+ reporter.BeforeSuiteDidRun(setupSummary)
+ }
+}
+
+func (server *Server) afterSuiteDidRun(writer http.ResponseWriter, request *http.Request) {
+ body := server.readAll(request)
+ var setupSummary *types.SetupSummary
+ json.Unmarshal(body, &setupSummary)
+
+ for _, reporter := range server.reporters {
+ reporter.AfterSuiteDidRun(setupSummary)
+ }
+}
+
+func (server *Server) specWillRun(writer http.ResponseWriter, request *http.Request) {
+ body := server.readAll(request)
+ var specSummary *types.SpecSummary
+ json.Unmarshal(body, &specSummary)
+
+ for _, reporter := range server.reporters {
+ reporter.SpecWillRun(specSummary)
+ }
+}
+
+func (server *Server) specDidComplete(writer http.ResponseWriter, request *http.Request) {
+ body := server.readAll(request)
+ var specSummary *types.SpecSummary
+ json.Unmarshal(body, &specSummary)
+
+ for _, reporter := range server.reporters {
+ reporter.SpecDidComplete(specSummary)
+ }
+}
+
+func (server *Server) specSuiteDidEnd(writer http.ResponseWriter, request *http.Request) {
+ body := server.readAll(request)
+ var suiteSummary *types.SuiteSummary
+ json.Unmarshal(body, &suiteSummary)
+
+ for _, reporter := range server.reporters {
+ reporter.SpecSuiteDidEnd(suiteSummary)
+ }
+}
+
+//
+// Synchronization Endpoints
+//
+
+func (server *Server) RegisterAlive(node int, alive func() bool) {
+ server.lock.Lock()
+ defer server.lock.Unlock()
+ server.alives[node-1] = alive
+}
+
+func (server *Server) nodeIsAlive(node int) bool {
+ server.lock.Lock()
+ defer server.lock.Unlock()
+ alive := server.alives[node-1]
+ if alive == nil {
+ return true
+ }
+ return alive()
+}
+
+func (server *Server) handleBeforeSuiteState(writer http.ResponseWriter, request *http.Request) {
+ if request.Method == "POST" {
+ dec := json.NewDecoder(request.Body)
+ dec.Decode(&(server.beforeSuiteData))
+ } else {
+ beforeSuiteData := server.beforeSuiteData
+ if beforeSuiteData.State == types.RemoteBeforeSuiteStatePending && !server.nodeIsAlive(1) {
+ beforeSuiteData.State = types.RemoteBeforeSuiteStateDisappeared
+ }
+ enc := json.NewEncoder(writer)
+ enc.Encode(beforeSuiteData)
+ }
+}
+
+func (server *Server) handleRemoteAfterSuiteData(writer http.ResponseWriter, request *http.Request) {
+ afterSuiteData := types.RemoteAfterSuiteData{
+ CanRun: true,
+ }
+ for i := 2; i <= server.parallelTotal; i++ {
+ afterSuiteData.CanRun = afterSuiteData.CanRun && !server.nodeIsAlive(i)
+ }
+
+ enc := json.NewEncoder(writer)
+ enc.Encode(afterSuiteData)
+}
+
+func (server *Server) handleCounter(writer http.ResponseWriter, request *http.Request) {
+ c := spec_iterator.Counter{}
+ server.lock.Lock()
+ c.Index = server.counter
+ server.counter = server.counter + 1
+ server.lock.Unlock()
+
+ json.NewEncoder(writer).Encode(c)
+}
+
+func (server *Server) handleHasCounter(writer http.ResponseWriter, request *http.Request) {
+ writer.Write([]byte(""))
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/server_test.go b/vendor/github.com/onsi/ginkgo/internal/remote/server_test.go
new file mode 100644
index 000000000..36bd00355
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/remote/server_test.go
@@ -0,0 +1,269 @@
+package remote_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/internal/remote"
+ . "github.com/onsi/gomega"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/reporters"
+ "github.com/onsi/ginkgo/types"
+
+ "bytes"
+ "encoding/json"
+ "net/http"
+)
+
+var _ = Describe("Server", func() {
+ var (
+ server *Server
+ )
+
+ BeforeEach(func() {
+ var err error
+ server, err = NewServer(3)
+ Ω(err).ShouldNot(HaveOccurred())
+
+ server.Start()
+ })
+
+ AfterEach(func() {
+ server.Close()
+ })
+
+ Describe("Streaming endpoints", func() {
+ var (
+ reporterA, reporterB *reporters.FakeReporter
+ forwardingReporter *ForwardingReporter
+
+ suiteSummary *types.SuiteSummary
+ setupSummary *types.SetupSummary
+ specSummary *types.SpecSummary
+ )
+
+ BeforeEach(func() {
+ reporterA = reporters.NewFakeReporter()
+ reporterB = reporters.NewFakeReporter()
+
+ server.RegisterReporters(reporterA, reporterB)
+
+ forwardingReporter = NewForwardingReporter(config.DefaultReporterConfigType{}, server.Address(), &http.Client{}, &fakeOutputInterceptor{}, nil, "")
+
+ suiteSummary = &types.SuiteSummary{
+ SuiteDescription: "My Test Suite",
+ }
+
+ setupSummary = &types.SetupSummary{
+ State: types.SpecStatePassed,
+ }
+
+ specSummary = &types.SpecSummary{
+ ComponentTexts: []string{"My", "Spec"},
+ State: types.SpecStatePassed,
+ }
+ })
+
+ It("should make its address available", func() {
+ Ω(server.Address()).Should(MatchRegexp(`http://127.0.0.1:\d{2,}`))
+ })
+
+ Describe("/SpecSuiteWillBegin", func() {
+ It("should decode and forward the Ginkgo config and suite summary", func(done Done) {
+ forwardingReporter.SpecSuiteWillBegin(config.GinkgoConfig, suiteSummary)
+ Ω(reporterA.Config).Should(Equal(config.GinkgoConfig))
+ Ω(reporterB.Config).Should(Equal(config.GinkgoConfig))
+ Ω(reporterA.BeginSummary).Should(Equal(suiteSummary))
+ Ω(reporterB.BeginSummary).Should(Equal(suiteSummary))
+ close(done)
+ })
+ })
+
+ Describe("/BeforeSuiteDidRun", func() {
+ It("should decode and forward the setup summary", func() {
+ forwardingReporter.BeforeSuiteDidRun(setupSummary)
+ Ω(reporterA.BeforeSuiteSummary).Should(Equal(setupSummary))
+ Ω(reporterB.BeforeSuiteSummary).Should(Equal(setupSummary))
+ })
+ })
+
+ Describe("/AfterSuiteDidRun", func() {
+ It("should decode and forward the setup summary", func() {
+ forwardingReporter.AfterSuiteDidRun(setupSummary)
+ Ω(reporterA.AfterSuiteSummary).Should(Equal(setupSummary))
+ Ω(reporterB.AfterSuiteSummary).Should(Equal(setupSummary))
+ })
+ })
+
+ Describe("/SpecWillRun", func() {
+ It("should decode and forward the spec summary", func(done Done) {
+ forwardingReporter.SpecWillRun(specSummary)
+ Ω(reporterA.SpecWillRunSummaries[0]).Should(Equal(specSummary))
+ Ω(reporterB.SpecWillRunSummaries[0]).Should(Equal(specSummary))
+ close(done)
+ })
+ })
+
+ Describe("/SpecDidComplete", func() {
+ It("should decode and forward the spec summary", func(done Done) {
+ forwardingReporter.SpecDidComplete(specSummary)
+ Ω(reporterA.SpecSummaries[0]).Should(Equal(specSummary))
+ Ω(reporterB.SpecSummaries[0]).Should(Equal(specSummary))
+ close(done)
+ })
+ })
+
+ Describe("/SpecSuiteDidEnd", func() {
+ It("should decode and forward the suite summary", func(done Done) {
+ forwardingReporter.SpecSuiteDidEnd(suiteSummary)
+ Ω(reporterA.EndSummary).Should(Equal(suiteSummary))
+ Ω(reporterB.EndSummary).Should(Equal(suiteSummary))
+ close(done)
+ })
+ })
+ })
+
+ Describe("Synchronization endpoints", func() {
+ Describe("GETting and POSTing BeforeSuiteState", func() {
+ getBeforeSuite := func() types.RemoteBeforeSuiteData {
+ resp, err := http.Get(server.Address() + "/BeforeSuiteState")
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(resp.StatusCode).Should(Equal(http.StatusOK))
+
+ r := types.RemoteBeforeSuiteData{}
+ decoder := json.NewDecoder(resp.Body)
+ err = decoder.Decode(&r)
+ Ω(err).ShouldNot(HaveOccurred())
+
+ return r
+ }
+
+ postBeforeSuite := func(r types.RemoteBeforeSuiteData) {
+ resp, err := http.Post(server.Address()+"/BeforeSuiteState", "application/json", bytes.NewReader(r.ToJSON()))
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(resp.StatusCode).Should(Equal(http.StatusOK))
+ }
+
+ Context("when the first node's Alive has not been registered yet", func() {
+ It("should return pending", func() {
+ state := getBeforeSuite()
+ Ω(state).Should(Equal(types.RemoteBeforeSuiteData{Data: nil, State: types.RemoteBeforeSuiteStatePending}))
+
+ state = getBeforeSuite()
+ Ω(state).Should(Equal(types.RemoteBeforeSuiteData{Data: nil, State: types.RemoteBeforeSuiteStatePending}))
+ })
+ })
+
+ Context("when the first node is Alive but has not responded yet", func() {
+ BeforeEach(func() {
+ server.RegisterAlive(1, func() bool {
+ return true
+ })
+ })
+
+ It("should return pending", func() {
+ state := getBeforeSuite()
+ Ω(state).Should(Equal(types.RemoteBeforeSuiteData{Data: nil, State: types.RemoteBeforeSuiteStatePending}))
+
+ state = getBeforeSuite()
+ Ω(state).Should(Equal(types.RemoteBeforeSuiteData{Data: nil, State: types.RemoteBeforeSuiteStatePending}))
+ })
+ })
+
+ Context("when the first node has responded", func() {
+ var state types.RemoteBeforeSuiteData
+ BeforeEach(func() {
+ server.RegisterAlive(1, func() bool {
+ return false
+ })
+
+ state = types.RemoteBeforeSuiteData{
+ Data: []byte("my data"),
+ State: types.RemoteBeforeSuiteStatePassed,
+ }
+ postBeforeSuite(state)
+ })
+
+ It("should return the passed in state", func() {
+ returnedState := getBeforeSuite()
+ Ω(returnedState).Should(Equal(state))
+ })
+ })
+
+ Context("when the first node is no longer Alive and has not responded yet", func() {
+ BeforeEach(func() {
+ server.RegisterAlive(1, func() bool {
+ return false
+ })
+ })
+
+ It("should return disappeared", func() {
+ state := getBeforeSuite()
+ Ω(state).Should(Equal(types.RemoteBeforeSuiteData{Data: nil, State: types.RemoteBeforeSuiteStateDisappeared}))
+
+ state = getBeforeSuite()
+ Ω(state).Should(Equal(types.RemoteBeforeSuiteData{Data: nil, State: types.RemoteBeforeSuiteStateDisappeared}))
+ })
+ })
+ })
+
+ Describe("GETting RemoteAfterSuiteData", func() {
+ getRemoteAfterSuiteData := func() bool {
+ resp, err := http.Get(server.Address() + "/RemoteAfterSuiteData")
+ Ω(err).ShouldNot(HaveOccurred())
+ Ω(resp.StatusCode).Should(Equal(http.StatusOK))
+
+ a := types.RemoteAfterSuiteData{}
+ decoder := json.NewDecoder(resp.Body)
+ err = decoder.Decode(&a)
+ Ω(err).ShouldNot(HaveOccurred())
+
+ return a.CanRun
+ }
+
+ Context("when there are unregistered nodes", func() {
+ BeforeEach(func() {
+ server.RegisterAlive(2, func() bool {
+ return false
+ })
+ })
+
+ It("should return false", func() {
+ Ω(getRemoteAfterSuiteData()).Should(BeFalse())
+ })
+ })
+
+ Context("when all none-node-1 nodes are still running", func() {
+ BeforeEach(func() {
+ server.RegisterAlive(2, func() bool {
+ return true
+ })
+
+ server.RegisterAlive(3, func() bool {
+ return false
+ })
+ })
+
+ It("should return false", func() {
+ Ω(getRemoteAfterSuiteData()).Should(BeFalse())
+ })
+ })
+
+ Context("when all none-1 nodes are done", func() {
+ BeforeEach(func() {
+ server.RegisterAlive(2, func() bool {
+ return false
+ })
+
+ server.RegisterAlive(3, func() bool {
+ return false
+ })
+ })
+
+ It("should return true", func() {
+ Ω(getRemoteAfterSuiteData()).Should(BeTrue())
+ })
+
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_linux_arm64.go b/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_linux_arm64.go
new file mode 100644
index 000000000..9550d37b3
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_linux_arm64.go
@@ -0,0 +1,11 @@
+// +build linux,arm64
+
+package remote
+
+import "syscall"
+
+// linux_arm64 doesn't have syscall.Dup2 which ginkgo uses, so
+// use the nearly identical syscall.Dup3 instead
+func syscallDup(oldfd int, newfd int) (err error) {
+ return syscall.Dup3(oldfd, newfd, 0)
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_solaris.go b/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_solaris.go
new file mode 100644
index 000000000..75ef7fb78
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_solaris.go
@@ -0,0 +1,9 @@
+// +build solaris
+
+package remote
+
+import "golang.org/x/sys/unix"
+
+func syscallDup(oldfd int, newfd int) (err error) {
+ return unix.Dup2(oldfd, newfd)
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_unix.go b/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_unix.go
new file mode 100644
index 000000000..ef6255960
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_unix.go
@@ -0,0 +1,11 @@
+// +build !linux !arm64
+// +build !windows
+// +build !solaris
+
+package remote
+
+import "syscall"
+
+func syscallDup(oldfd int, newfd int) (err error) {
+ return syscall.Dup2(oldfd, newfd)
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/spec/spec.go b/vendor/github.com/onsi/ginkgo/internal/spec/spec.go
new file mode 100644
index 000000000..7fd68ee8e
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/spec/spec.go
@@ -0,0 +1,247 @@
+package spec
+
+import (
+ "fmt"
+ "io"
+ "time"
+
+ "sync"
+
+ "github.com/onsi/ginkgo/internal/containernode"
+ "github.com/onsi/ginkgo/internal/leafnodes"
+ "github.com/onsi/ginkgo/types"
+)
+
+type Spec struct {
+ subject leafnodes.SubjectNode
+ focused bool
+ announceProgress bool
+
+ containers []*containernode.ContainerNode
+
+ state types.SpecState
+ runTime time.Duration
+ startTime time.Time
+ failure types.SpecFailure
+ previousFailures bool
+
+ stateMutex *sync.Mutex
+}
+
+func New(subject leafnodes.SubjectNode, containers []*containernode.ContainerNode, announceProgress bool) *Spec {
+ spec := &Spec{
+ subject: subject,
+ containers: containers,
+ focused: subject.Flag() == types.FlagTypeFocused,
+ announceProgress: announceProgress,
+ stateMutex: &sync.Mutex{},
+ }
+
+ spec.processFlag(subject.Flag())
+ for i := len(containers) - 1; i >= 0; i-- {
+ spec.processFlag(containers[i].Flag())
+ }
+
+ return spec
+}
+
+func (spec *Spec) processFlag(flag types.FlagType) {
+ if flag == types.FlagTypeFocused {
+ spec.focused = true
+ } else if flag == types.FlagTypePending {
+ spec.setState(types.SpecStatePending)
+ }
+}
+
+func (spec *Spec) Skip() {
+ spec.setState(types.SpecStateSkipped)
+}
+
+func (spec *Spec) Failed() bool {
+ return spec.getState() == types.SpecStateFailed || spec.getState() == types.SpecStatePanicked || spec.getState() == types.SpecStateTimedOut
+}
+
+func (spec *Spec) Passed() bool {
+ return spec.getState() == types.SpecStatePassed
+}
+
+func (spec *Spec) Flaked() bool {
+ return spec.getState() == types.SpecStatePassed && spec.previousFailures
+}
+
+func (spec *Spec) Pending() bool {
+ return spec.getState() == types.SpecStatePending
+}
+
+func (spec *Spec) Skipped() bool {
+ return spec.getState() == types.SpecStateSkipped
+}
+
+func (spec *Spec) Focused() bool {
+ return spec.focused
+}
+
+func (spec *Spec) IsMeasurement() bool {
+ return spec.subject.Type() == types.SpecComponentTypeMeasure
+}
+
+func (spec *Spec) Summary(suiteID string) *types.SpecSummary {
+ componentTexts := make([]string, len(spec.containers)+1)
+ componentCodeLocations := make([]types.CodeLocation, len(spec.containers)+1)
+
+ for i, container := range spec.containers {
+ componentTexts[i] = container.Text()
+ componentCodeLocations[i] = container.CodeLocation()
+ }
+
+ componentTexts[len(spec.containers)] = spec.subject.Text()
+ componentCodeLocations[len(spec.containers)] = spec.subject.CodeLocation()
+
+ runTime := spec.runTime
+ if runTime == 0 && !spec.startTime.IsZero() {
+ runTime = time.Since(spec.startTime)
+ }
+
+ return &types.SpecSummary{
+ IsMeasurement: spec.IsMeasurement(),
+ NumberOfSamples: spec.subject.Samples(),
+ ComponentTexts: componentTexts,
+ ComponentCodeLocations: componentCodeLocations,
+ State: spec.getState(),
+ RunTime: runTime,
+ Failure: spec.failure,
+ Measurements: spec.measurementsReport(),
+ SuiteID: suiteID,
+ }
+}
+
+func (spec *Spec) ConcatenatedString() string {
+ s := ""
+ for _, container := range spec.containers {
+ s += container.Text() + " "
+ }
+
+ return s + spec.subject.Text()
+}
+
+func (spec *Spec) Run(writer io.Writer) {
+ if spec.getState() == types.SpecStateFailed {
+ spec.previousFailures = true
+ }
+
+ spec.startTime = time.Now()
+ defer func() {
+ spec.runTime = time.Since(spec.startTime)
+ }()
+
+ for sample := 0; sample < spec.subject.Samples(); sample++ {
+ spec.runSample(sample, writer)
+
+ if spec.getState() != types.SpecStatePassed {
+ return
+ }
+ }
+}
+
+func (spec *Spec) getState() types.SpecState {
+ spec.stateMutex.Lock()
+ defer spec.stateMutex.Unlock()
+ return spec.state
+}
+
+func (spec *Spec) setState(state types.SpecState) {
+ spec.stateMutex.Lock()
+ defer spec.stateMutex.Unlock()
+ spec.state = state
+}
+
+func (spec *Spec) runSample(sample int, writer io.Writer) {
+ spec.setState(types.SpecStatePassed)
+ spec.failure = types.SpecFailure{}
+ innerMostContainerIndexToUnwind := -1
+
+ defer func() {
+ for i := innerMostContainerIndexToUnwind; i >= 0; i-- {
+ container := spec.containers[i]
+ for _, justAfterEach := range container.SetupNodesOfType(types.SpecComponentTypeJustAfterEach) {
+ spec.announceSetupNode(writer, "JustAfterEach", container, justAfterEach)
+ justAfterEachState, justAfterEachFailure := justAfterEach.Run()
+ if justAfterEachState != types.SpecStatePassed && spec.state == types.SpecStatePassed {
+ spec.state = justAfterEachState
+ spec.failure = justAfterEachFailure
+ }
+ }
+ }
+
+ for i := innerMostContainerIndexToUnwind; i >= 0; i-- {
+ container := spec.containers[i]
+ for _, afterEach := range container.SetupNodesOfType(types.SpecComponentTypeAfterEach) {
+ spec.announceSetupNode(writer, "AfterEach", container, afterEach)
+ afterEachState, afterEachFailure := afterEach.Run()
+ if afterEachState != types.SpecStatePassed && spec.getState() == types.SpecStatePassed {
+ spec.setState(afterEachState)
+ spec.failure = afterEachFailure
+ }
+ }
+ }
+ }()
+
+ for i, container := range spec.containers {
+ innerMostContainerIndexToUnwind = i
+ for _, beforeEach := range container.SetupNodesOfType(types.SpecComponentTypeBeforeEach) {
+ spec.announceSetupNode(writer, "BeforeEach", container, beforeEach)
+ s, f := beforeEach.Run()
+ spec.failure = f
+ spec.setState(s)
+ if spec.getState() != types.SpecStatePassed {
+ return
+ }
+ }
+ }
+
+ for _, container := range spec.containers {
+ for _, justBeforeEach := range container.SetupNodesOfType(types.SpecComponentTypeJustBeforeEach) {
+ spec.announceSetupNode(writer, "JustBeforeEach", container, justBeforeEach)
+ s, f := justBeforeEach.Run()
+ spec.failure = f
+ spec.setState(s)
+ if spec.getState() != types.SpecStatePassed {
+ return
+ }
+ }
+ }
+
+ spec.announceSubject(writer, spec.subject)
+ s, f := spec.subject.Run()
+ spec.failure = f
+ spec.setState(s)
+}
+
+func (spec *Spec) announceSetupNode(writer io.Writer, nodeType string, container *containernode.ContainerNode, setupNode leafnodes.BasicNode) {
+ if spec.announceProgress {
+ s := fmt.Sprintf("[%s] %s\n %s\n", nodeType, container.Text(), setupNode.CodeLocation().String())
+ writer.Write([]byte(s))
+ }
+}
+
+func (spec *Spec) announceSubject(writer io.Writer, subject leafnodes.SubjectNode) {
+ if spec.announceProgress {
+ nodeType := ""
+ switch subject.Type() {
+ case types.SpecComponentTypeIt:
+ nodeType = "It"
+ case types.SpecComponentTypeMeasure:
+ nodeType = "Measure"
+ }
+ s := fmt.Sprintf("[%s] %s\n %s\n", nodeType, subject.Text(), subject.CodeLocation().String())
+ writer.Write([]byte(s))
+ }
+}
+
+func (spec *Spec) measurementsReport() map[string]*types.SpecMeasurement {
+ if !spec.IsMeasurement() || spec.Failed() {
+ return map[string]*types.SpecMeasurement{}
+ }
+
+ return spec.subject.(*leafnodes.MeasureNode).MeasurementsReport()
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/spec/spec_suite_test.go b/vendor/github.com/onsi/ginkgo/internal/spec/spec_suite_test.go
new file mode 100644
index 000000000..8681a7206
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/spec/spec_suite_test.go
@@ -0,0 +1,13 @@
+package spec_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestSpec(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Spec Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/spec/spec_test.go b/vendor/github.com/onsi/ginkgo/internal/spec/spec_test.go
new file mode 100644
index 000000000..b4a2c9c79
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/spec/spec_test.go
@@ -0,0 +1,739 @@
+package spec_test
+
+import (
+ "time"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gbytes"
+
+ . "github.com/onsi/ginkgo/internal/spec"
+
+ "github.com/onsi/ginkgo/internal/codelocation"
+ "github.com/onsi/ginkgo/internal/containernode"
+ Failer "github.com/onsi/ginkgo/internal/failer"
+ "github.com/onsi/ginkgo/internal/leafnodes"
+ "github.com/onsi/ginkgo/types"
+)
+
+var noneFlag = types.FlagTypeNone
+var focusedFlag = types.FlagTypeFocused
+var pendingFlag = types.FlagTypePending
+
+var _ = Describe("Spec", func() {
+ var (
+ failer *Failer.Failer
+ codeLocation types.CodeLocation
+ nodesThatRan []string
+ spec *Spec
+ buffer *gbytes.Buffer
+ )
+
+ newBody := func(text string, fail bool) func() {
+ return func() {
+ nodesThatRan = append(nodesThatRan, text)
+ if fail {
+ failer.Fail(text, codeLocation)
+ }
+ }
+ }
+
+ newIt := func(text string, flag types.FlagType, fail bool) *leafnodes.ItNode {
+ return leafnodes.NewItNode(text, newBody(text, fail), flag, codeLocation, 0, failer, 0)
+ }
+
+ newItWithBody := func(text string, body interface{}) *leafnodes.ItNode {
+ return leafnodes.NewItNode(text, body, noneFlag, codeLocation, 0, failer, 0)
+ }
+
+ newMeasure := func(text string, flag types.FlagType, fail bool, samples int) *leafnodes.MeasureNode {
+ return leafnodes.NewMeasureNode(text, func(Benchmarker) {
+ nodesThatRan = append(nodesThatRan, text)
+ if fail {
+ failer.Fail(text, codeLocation)
+ }
+ }, flag, codeLocation, samples, failer, 0)
+ }
+
+ newBef := func(text string, fail bool) leafnodes.BasicNode {
+ return leafnodes.NewBeforeEachNode(newBody(text, fail), codeLocation, 0, failer, 0)
+ }
+
+ newAft := func(text string, fail bool) leafnodes.BasicNode {
+ return leafnodes.NewAfterEachNode(newBody(text, fail), codeLocation, 0, failer, 0)
+ }
+
+ newJusBef := func(text string, fail bool) leafnodes.BasicNode {
+ return leafnodes.NewJustBeforeEachNode(newBody(text, fail), codeLocation, 0, failer, 0)
+ }
+
+ newJusAft := func(text string, fail bool) leafnodes.BasicNode {
+ return leafnodes.NewJustAfterEachNode(newBody(text, fail), codeLocation, 0, failer, 0)
+ }
+
+ newContainer := func(text string, flag types.FlagType, setupNodes ...leafnodes.BasicNode) *containernode.ContainerNode {
+ c := containernode.New(text, flag, codeLocation)
+ for _, node := range setupNodes {
+ c.PushSetupNode(node)
+ }
+ return c
+ }
+
+ containers := func(containers ...*containernode.ContainerNode) []*containernode.ContainerNode {
+ return containers
+ }
+
+ BeforeEach(func() {
+ buffer = gbytes.NewBuffer()
+ failer = Failer.New()
+ codeLocation = codelocation.New(0)
+ nodesThatRan = []string{}
+ })
+
+ Describe("marking specs focused and pending", func() {
+ It("should satisfy various caes", func() {
+ cases := []struct {
+ ContainerFlags []types.FlagType
+ SubjectFlag types.FlagType
+ Pending bool
+ Focused bool
+ }{
+ {[]types.FlagType{}, noneFlag, false, false},
+ {[]types.FlagType{}, focusedFlag, false, true},
+ {[]types.FlagType{}, pendingFlag, true, false},
+ {[]types.FlagType{noneFlag}, noneFlag, false, false},
+ {[]types.FlagType{focusedFlag}, noneFlag, false, true},
+ {[]types.FlagType{pendingFlag}, noneFlag, true, false},
+ {[]types.FlagType{noneFlag}, focusedFlag, false, true},
+ {[]types.FlagType{focusedFlag}, focusedFlag, false, true},
+ {[]types.FlagType{pendingFlag}, focusedFlag, true, true},
+ {[]types.FlagType{noneFlag}, pendingFlag, true, false},
+ {[]types.FlagType{focusedFlag}, pendingFlag, true, true},
+ {[]types.FlagType{pendingFlag}, pendingFlag, true, false},
+ {[]types.FlagType{focusedFlag, noneFlag}, noneFlag, false, true},
+ {[]types.FlagType{noneFlag, focusedFlag}, noneFlag, false, true},
+ {[]types.FlagType{pendingFlag, noneFlag}, noneFlag, true, false},
+ {[]types.FlagType{noneFlag, pendingFlag}, noneFlag, true, false},
+ {[]types.FlagType{focusedFlag, pendingFlag}, noneFlag, true, true},
+ }
+
+ for i, c := range cases {
+ subject := newIt("it node", c.SubjectFlag, false)
+ containers := []*containernode.ContainerNode{}
+ for _, flag := range c.ContainerFlags {
+ containers = append(containers, newContainer("container", flag))
+ }
+
+ spec := New(subject, containers, false)
+ Ω(spec.Pending()).Should(Equal(c.Pending), "Case %d: %#v", i, c)
+ Ω(spec.Focused()).Should(Equal(c.Focused), "Case %d: %#v", i, c)
+
+ if c.Pending {
+ Ω(spec.Summary("").State).Should(Equal(types.SpecStatePending))
+ }
+ }
+ })
+ })
+
+ Describe("Skip", func() {
+ It("should be skipped", func() {
+ spec := New(newIt("it node", noneFlag, false), containers(newContainer("container", noneFlag)), false)
+ Ω(spec.Skipped()).Should(BeFalse())
+ spec.Skip()
+ Ω(spec.Skipped()).Should(BeTrue())
+ Ω(spec.Summary("").State).Should(Equal(types.SpecStateSkipped))
+ })
+ })
+
+ Describe("IsMeasurement", func() {
+ It("should be true if the subject is a measurement node", func() {
+ spec := New(newIt("it node", noneFlag, false), containers(newContainer("container", noneFlag)), false)
+ Ω(spec.IsMeasurement()).Should(BeFalse())
+ Ω(spec.Summary("").IsMeasurement).Should(BeFalse())
+ Ω(spec.Summary("").NumberOfSamples).Should(Equal(1))
+
+ spec = New(newMeasure("measure node", noneFlag, false, 10), containers(newContainer("container", noneFlag)), false)
+ Ω(spec.IsMeasurement()).Should(BeTrue())
+ Ω(spec.Summary("").IsMeasurement).Should(BeTrue())
+ Ω(spec.Summary("").NumberOfSamples).Should(Equal(10))
+ })
+ })
+
+ Describe("Passed", func() {
+ It("should pass when the subject passed", func() {
+ spec := New(newIt("it node", noneFlag, false), containers(), false)
+ spec.Run(buffer)
+
+ Ω(spec.Passed()).Should(BeTrue())
+ Ω(spec.Failed()).Should(BeFalse())
+ Ω(spec.Summary("").State).Should(Equal(types.SpecStatePassed))
+ Ω(spec.Summary("").Failure).Should(BeZero())
+ })
+ })
+
+ Describe("Flaked", func() {
+ It("should work if Run is called twice and gets different results", func() {
+ i := 0
+ spec := New(newItWithBody("flaky it", func() {
+ i++
+ if i == 1 {
+ failer.Fail("oops", codeLocation)
+ }
+ }), containers(), false)
+ spec.Run(buffer)
+ Ω(spec.Passed()).Should(BeFalse())
+ Ω(spec.Failed()).Should(BeTrue())
+ Ω(spec.Flaked()).Should(BeFalse())
+ Ω(spec.Summary("").State).Should(Equal(types.SpecStateFailed))
+ Ω(spec.Summary("").Failure.Message).Should(Equal("oops"))
+ spec.Run(buffer)
+ Ω(spec.Passed()).Should(BeTrue())
+ Ω(spec.Failed()).Should(BeFalse())
+ Ω(spec.Flaked()).Should(BeTrue())
+ Ω(spec.Summary("").State).Should(Equal(types.SpecStatePassed))
+ })
+ })
+
+ Describe("Failed", func() {
+ It("should be failed if the failure was panic", func() {
+ spec := New(newItWithBody("panicky it", func() {
+ panic("bam")
+ }), containers(), false)
+ spec.Run(buffer)
+ Ω(spec.Passed()).Should(BeFalse())
+ Ω(spec.Failed()).Should(BeTrue())
+ Ω(spec.Summary("").State).Should(Equal(types.SpecStatePanicked))
+ Ω(spec.Summary("").Failure.Message).Should(Equal("Test Panicked"))
+ Ω(spec.Summary("").Failure.ForwardedPanic).Should(Equal("bam"))
+ })
+
+ It("should be failed if the failure was a timeout", func() {
+ spec := New(newItWithBody("sleepy it", func(done Done) {}), containers(), false)
+ spec.Run(buffer)
+ Ω(spec.Passed()).Should(BeFalse())
+ Ω(spec.Failed()).Should(BeTrue())
+ Ω(spec.Summary("").State).Should(Equal(types.SpecStateTimedOut))
+ Ω(spec.Summary("").Failure.Message).Should(Equal("Timed out"))
+ })
+
+ It("should be failed if the failure was... a failure", func() {
+ spec := New(newItWithBody("failing it", func() {
+ failer.Fail("bam", codeLocation)
+ }), containers(), false)
+ spec.Run(buffer)
+ Ω(spec.Passed()).Should(BeFalse())
+ Ω(spec.Failed()).Should(BeTrue())
+ Ω(spec.Summary("").State).Should(Equal(types.SpecStateFailed))
+ Ω(spec.Summary("").Failure.Message).Should(Equal("bam"))
+ })
+ })
+
+ Describe("Concatenated string", func() {
+ It("should concatenate the texts of the containers and the subject", func() {
+ spec := New(
+ newIt("it node", noneFlag, false),
+ containers(
+ newContainer("outer container", noneFlag),
+ newContainer("inner container", noneFlag),
+ ),
+ false,
+ )
+
+ Ω(spec.ConcatenatedString()).Should(Equal("outer container inner container it node"))
+ })
+ })
+
+ Describe("running it specs", func() {
+ Context("with just an it", func() {
+ Context("that succeeds", func() {
+ It("should run the it and report on its success", func() {
+ spec := New(newIt("it node", noneFlag, false), containers(), false)
+ spec.Run(buffer)
+ Ω(spec.Passed()).Should(BeTrue())
+ Ω(spec.Failed()).Should(BeFalse())
+ Ω(nodesThatRan).Should(Equal([]string{"it node"}))
+ })
+ })
+
+ Context("that fails", func() {
+ It("should run the it and report on its success", func() {
+ spec := New(newIt("it node", noneFlag, true), containers(), false)
+ spec.Run(buffer)
+ Ω(spec.Passed()).Should(BeFalse())
+ Ω(spec.Failed()).Should(BeTrue())
+ Ω(spec.Summary("").Failure.Message).Should(Equal("it node"))
+ Ω(nodesThatRan).Should(Equal([]string{"it node"}))
+ })
+ })
+ })
+
+ Context("with a full set of setup nodes", func() {
+ var failingNodes map[string]bool
+
+ BeforeEach(func() {
+ failingNodes = map[string]bool{}
+ })
+
+ JustBeforeEach(func() {
+ spec = New(
+ newIt("it node", noneFlag, failingNodes["it node"]),
+ containers(
+ newContainer("outer container", noneFlag,
+ newBef("outer bef A", failingNodes["outer bef A"]),
+ newBef("outer bef B", failingNodes["outer bef B"]),
+ newJusBef("outer jusbef A", failingNodes["outer jusbef A"]),
+ newJusBef("outer jusbef B", failingNodes["outer jusbef B"]),
+ newJusAft("outer jusaft A", failingNodes["outer jusaft A"]),
+ newJusAft("outer jusaft B", failingNodes["outer jusaft B"]),
+ newAft("outer aft A", failingNodes["outer aft A"]),
+ newAft("outer aft B", failingNodes["outer aft B"]),
+ ),
+ newContainer("inner container", noneFlag,
+ newBef("inner bef A", failingNodes["inner bef A"]),
+ newBef("inner bef B", failingNodes["inner bef B"]),
+ newJusBef("inner jusbef A", failingNodes["inner jusbef A"]),
+ newJusBef("inner jusbef B", failingNodes["inner jusbef B"]),
+ newJusAft("inner jusaft A", failingNodes["inner jusaft A"]),
+ newJusAft("inner jusaft B", failingNodes["inner jusaft B"]),
+ newAft("inner aft A", failingNodes["inner aft A"]),
+ newAft("inner aft B", failingNodes["inner aft B"]),
+ ),
+ ),
+ false,
+ )
+ spec.Run(buffer)
+ })
+
+ Context("that all pass", func() {
+ It("should walk through the nodes in the correct order", func() {
+ Ω(spec.Passed()).Should(BeTrue())
+ Ω(spec.Failed()).Should(BeFalse())
+ Ω(nodesThatRan).Should(Equal([]string{
+ "outer bef A",
+ "outer bef B",
+ "inner bef A",
+ "inner bef B",
+ "outer jusbef A",
+ "outer jusbef B",
+ "inner jusbef A",
+ "inner jusbef B",
+ "it node",
+ "inner jusaft A",
+ "inner jusaft B",
+ "outer jusaft A",
+ "outer jusaft B",
+ "inner aft A",
+ "inner aft B",
+ "outer aft A",
+ "outer aft B",
+ }))
+ })
+ })
+
+ Context("when the subject fails", func() {
+ BeforeEach(func() {
+ failingNodes["it node"] = true
+ })
+
+ It("should run the afters", func() {
+ Ω(spec.Passed()).Should(BeFalse())
+ Ω(spec.Failed()).Should(BeTrue())
+ Ω(nodesThatRan).Should(Equal([]string{
+ "outer bef A",
+ "outer bef B",
+ "inner bef A",
+ "inner bef B",
+ "outer jusbef A",
+ "outer jusbef B",
+ "inner jusbef A",
+ "inner jusbef B",
+ "it node",
+ "inner jusaft A",
+ "inner jusaft B",
+ "outer jusaft A",
+ "outer jusaft B",
+ "inner aft A",
+ "inner aft B",
+ "outer aft A",
+ "outer aft B",
+ }))
+ Ω(spec.Summary("").Failure.Message).Should(Equal("it node"))
+ })
+ })
+
+ Context("when an inner before fails", func() {
+ BeforeEach(func() {
+ failingNodes["inner bef A"] = true
+ })
+
+ It("should not run any other befores, but it should run the subsequent afters", func() {
+ Ω(spec.Passed()).Should(BeFalse())
+ Ω(spec.Failed()).Should(BeTrue())
+ Ω(nodesThatRan).Should(Equal([]string{
+ "outer bef A",
+ "outer bef B",
+ "inner bef A",
+ "inner jusaft A",
+ "inner jusaft B",
+ "outer jusaft A",
+ "outer jusaft B",
+ "inner aft A",
+ "inner aft B",
+ "outer aft A",
+ "outer aft B",
+ }))
+ Ω(spec.Summary("").Failure.Message).Should(Equal("inner bef A"))
+ })
+ })
+
+ Context("when an outer before fails", func() {
+ BeforeEach(func() {
+ failingNodes["outer bef B"] = true
+ })
+
+ It("should not run any other befores, but it should run the subsequent afters", func() {
+ Ω(spec.Passed()).Should(BeFalse())
+ Ω(spec.Failed()).Should(BeTrue())
+ Ω(nodesThatRan).Should(Equal([]string{
+ "outer bef A",
+ "outer bef B",
+ "outer jusaft A",
+ "outer jusaft B",
+ "outer aft A",
+ "outer aft B",
+ }))
+ Ω(spec.Summary("").Failure.Message).Should(Equal("outer bef B"))
+ })
+ })
+
+ Context("when an after fails", func() {
+ BeforeEach(func() {
+ failingNodes["inner aft B"] = true
+ })
+
+ It("should run all other afters, but mark the test as failed", func() {
+ Ω(spec.Passed()).Should(BeFalse())
+ Ω(spec.Failed()).Should(BeTrue())
+ Ω(nodesThatRan).Should(Equal([]string{
+ "outer bef A",
+ "outer bef B",
+ "inner bef A",
+ "inner bef B",
+ "outer jusbef A",
+ "outer jusbef B",
+ "inner jusbef A",
+ "inner jusbef B",
+ "it node",
+ "inner jusaft A",
+ "inner jusaft B",
+ "outer jusaft A",
+ "outer jusaft B",
+ "inner aft A",
+ "inner aft B",
+ "outer aft A",
+ "outer aft B",
+ }))
+ Ω(spec.Summary("").Failure.Message).Should(Equal("inner aft B"))
+ })
+ })
+
+ Context("when a just before each fails", func() {
+ BeforeEach(func() {
+ failingNodes["outer jusbef B"] = true
+ })
+
+ It("should run the afters, but not the subject", func() {
+ Ω(spec.Passed()).Should(BeFalse())
+ Ω(spec.Failed()).Should(BeTrue())
+ Ω(nodesThatRan).Should(Equal([]string{
+ "outer bef A",
+ "outer bef B",
+ "inner bef A",
+ "inner bef B",
+ "outer jusbef A",
+ "outer jusbef B",
+ "inner jusaft A",
+ "inner jusaft B",
+ "outer jusaft A",
+ "outer jusaft B",
+ "inner aft A",
+ "inner aft B",
+ "outer aft A",
+ "outer aft B",
+ }))
+ Ω(spec.Summary("").Failure.Message).Should(Equal("outer jusbef B"))
+ })
+ })
+
+ Context("when a just after each fails", func() {
+ BeforeEach(func() {
+ failingNodes["outer jusaft A"] = true
+ })
+
+ It("should run all other afters, but mark the test as failed", func() {
+ Ω(spec.Passed()).Should(BeFalse())
+ Ω(spec.Failed()).Should(BeTrue())
+ Ω(nodesThatRan).Should(Equal([]string{
+ "outer bef A",
+ "outer bef B",
+ "inner bef A",
+ "inner bef B",
+ "outer jusbef A",
+ "outer jusbef B",
+ "inner jusbef A",
+ "inner jusbef B",
+ "it node",
+ "inner jusaft A",
+ "inner jusaft B",
+ "outer jusaft A",
+ "outer jusaft B",
+ "inner aft A",
+ "inner aft B",
+ "outer aft A",
+ "outer aft B",
+ }))
+ Ω(spec.Summary("").Failure.Message).Should(Equal("outer jusaft A"))
+ })
+ })
+
+ Context("when an after fails after an earlier node has failed", func() {
+ BeforeEach(func() {
+ failingNodes["it node"] = true
+ failingNodes["inner aft B"] = true
+ })
+
+ It("should record the earlier failure", func() {
+ Ω(spec.Passed()).Should(BeFalse())
+ Ω(spec.Failed()).Should(BeTrue())
+ Ω(nodesThatRan).Should(Equal([]string{
+ "outer bef A",
+ "outer bef B",
+ "inner bef A",
+ "inner bef B",
+ "outer jusbef A",
+ "outer jusbef B",
+ "inner jusbef A",
+ "inner jusbef B",
+ "it node",
+ "inner jusaft A",
+ "inner jusaft B",
+ "outer jusaft A",
+ "outer jusaft B",
+ "inner aft A",
+ "inner aft B",
+ "outer aft A",
+ "outer aft B",
+ }))
+ Ω(spec.Summary("").Failure.Message).Should(Equal("it node"))
+ })
+ })
+ })
+ })
+
+ Describe("running measurement specs", func() {
+ Context("when the measurement succeeds", func() {
+ It("should run N samples", func() {
+ spec = New(
+ newMeasure("measure node", noneFlag, false, 3),
+ containers(
+ newContainer("container", noneFlag,
+ newBef("bef A", false),
+ newJusBef("jusbef A", false),
+ newJusAft("jusaft A", false),
+ newAft("aft A", false),
+ ),
+ ),
+ false,
+ )
+ spec.Run(buffer)
+
+ Ω(spec.Passed()).Should(BeTrue())
+ Ω(spec.Failed()).Should(BeFalse())
+ Ω(nodesThatRan).Should(Equal([]string{
+ "bef A",
+ "jusbef A",
+ "measure node",
+ "jusaft A",
+ "aft A",
+ "bef A",
+ "jusbef A",
+ "measure node",
+ "jusaft A",
+ "aft A",
+ "bef A",
+ "jusbef A",
+ "measure node",
+ "jusaft A",
+ "aft A",
+ }))
+ })
+ })
+
+ Context("when the measurement fails", func() {
+ It("should bail after the failure occurs", func() {
+ spec = New(
+ newMeasure("measure node", noneFlag, true, 3),
+ containers(
+ newContainer("container", noneFlag,
+ newBef("bef A", false),
+ newJusBef("jusbef A", false),
+ newJusAft("jusaft A", false),
+ newAft("aft A", false),
+ ),
+ ),
+ false,
+ )
+ spec.Run(buffer)
+
+ Ω(spec.Passed()).Should(BeFalse())
+ Ω(spec.Failed()).Should(BeTrue())
+ Ω(nodesThatRan).Should(Equal([]string{
+ "bef A",
+ "jusbef A",
+ "measure node",
+ "jusaft A",
+ "aft A",
+ }))
+ })
+ })
+ })
+
+ Describe("Summary", func() {
+ var (
+ subjectCodeLocation types.CodeLocation
+ outerContainerCodeLocation types.CodeLocation
+ innerContainerCodeLocation types.CodeLocation
+ summary *types.SpecSummary
+ )
+
+ BeforeEach(func() {
+ subjectCodeLocation = codelocation.New(0)
+ outerContainerCodeLocation = codelocation.New(0)
+ innerContainerCodeLocation = codelocation.New(0)
+
+ spec = New(
+ leafnodes.NewItNode("it node", func() {
+ time.Sleep(10 * time.Millisecond)
+ }, noneFlag, subjectCodeLocation, 0, failer, 0),
+ containers(
+ containernode.New("outer container", noneFlag, outerContainerCodeLocation),
+ containernode.New("inner container", noneFlag, innerContainerCodeLocation),
+ ),
+ false,
+ )
+
+ spec.Run(buffer)
+ Ω(spec.Passed()).Should(BeTrue())
+ summary = spec.Summary("suite id")
+ })
+
+ It("should have the suite id", func() {
+ Ω(summary.SuiteID).Should(Equal("suite id"))
+ })
+
+ It("should have the component texts and code locations", func() {
+ Ω(summary.ComponentTexts).Should(Equal([]string{"outer container", "inner container", "it node"}))
+ Ω(summary.ComponentCodeLocations).Should(Equal([]types.CodeLocation{outerContainerCodeLocation, innerContainerCodeLocation, subjectCodeLocation}))
+ })
+
+ It("should have a runtime", func() {
+ Ω(summary.RunTime).Should(BeNumerically(">=", 10*time.Millisecond))
+ })
+
+ It("should have a runtime which remains consistent after spec run", func() {
+ totalRunTime := summary.RunTime
+ Ω(totalRunTime).Should(BeNumerically(">=", 10*time.Millisecond))
+
+ Consistently(func() time.Duration { return spec.Summary("suite id").RunTime }).Should(Equal(totalRunTime))
+ })
+
+ It("should not be a measurement, or have a measurement summary", func() {
+ Ω(summary.IsMeasurement).Should(BeFalse())
+ Ω(summary.Measurements).Should(BeEmpty())
+ })
+ })
+
+ Describe("Summaries for measurements", func() {
+ var summary *types.SpecSummary
+
+ BeforeEach(func() {
+ spec = New(leafnodes.NewMeasureNode("measure node", func(b Benchmarker) {
+ b.RecordValue("a value", 7, "some info")
+ b.RecordValueWithPrecision("another value", 8, "ns", 5, "more info")
+ }, noneFlag, codeLocation, 4, failer, 0), containers(), false)
+ spec.Run(buffer)
+ Ω(spec.Passed()).Should(BeTrue())
+ summary = spec.Summary("suite id")
+ })
+
+ It("should include the number of samples", func() {
+ Ω(summary.NumberOfSamples).Should(Equal(4))
+ })
+
+ It("should be a measurement", func() {
+ Ω(summary.IsMeasurement).Should(BeTrue())
+ })
+
+ It("should have the measurements report", func() {
+ Ω(summary.Measurements).Should(HaveKey("a value"))
+ report := summary.Measurements["a value"]
+ Ω(report.Name).Should(Equal("a value"))
+ Ω(report.Info).Should(Equal("some info"))
+ Ω(report.Results).Should(Equal([]float64{7, 7, 7, 7}))
+
+ Ω(summary.Measurements).Should(HaveKey("another value"))
+ report = summary.Measurements["another value"]
+ Ω(report.Name).Should(Equal("another value"))
+ Ω(report.Info).Should(Equal("more info"))
+ Ω(report.Results).Should(Equal([]float64{8, 8, 8, 8}))
+ Ω(report.Units).Should(Equal("ns"))
+ Ω(report.Precision).Should(Equal(5))
+ })
+ })
+
+ Describe("When told to emit progress", func() {
+ It("should emit progress to the writer as it runs Befores, JustBefores, Afters, and Its", func() {
+ spec = New(
+ newIt("it node", noneFlag, false),
+ containers(
+ newContainer("outer container", noneFlag,
+ newBef("outer bef A", false),
+ newJusBef("outer jusbef A", false),
+ newJusAft("outer jusaft A", false),
+ newAft("outer aft A", false),
+ ),
+ newContainer("inner container", noneFlag,
+ newBef("inner bef A", false),
+ newJusBef("inner jusbef A", false),
+ newJusAft("inner jusaft A", false),
+ newAft("inner aft A", false),
+ ),
+ ),
+ true,
+ )
+ spec.Run(buffer)
+
+ Ω(buffer).Should(gbytes.Say(`\[BeforeEach\] outer container`))
+ Ω(buffer).Should(gbytes.Say(`\[BeforeEach\] inner container`))
+ Ω(buffer).Should(gbytes.Say(`\[JustBeforeEach\] outer container`))
+ Ω(buffer).Should(gbytes.Say(`\[JustBeforeEach\] inner container`))
+ Ω(buffer).Should(gbytes.Say(`\[It\] it node`))
+ Ω(buffer).Should(gbytes.Say(`\[JustAfterEach\] inner container`))
+ Ω(buffer).Should(gbytes.Say(`\[JustAfterEach\] outer container`))
+ Ω(buffer).Should(gbytes.Say(`\[AfterEach\] inner container`))
+ Ω(buffer).Should(gbytes.Say(`\[AfterEach\] outer container`))
+ })
+
+ It("should emit progress to the writer as it runs Befores, JustBefores, JustAfters, Afters, and Measures", func() {
+ spec = New(
+ newMeasure("measure node", noneFlag, false, 2),
+ containers(),
+ true,
+ )
+ spec.Run(buffer)
+
+ Ω(buffer).Should(gbytes.Say(`\[Measure\] measure node`))
+ Ω(buffer).Should(gbytes.Say(`\[Measure\] measure node`))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/spec/specs.go b/vendor/github.com/onsi/ginkgo/internal/spec/specs.go
new file mode 100644
index 000000000..006185ab5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/spec/specs.go
@@ -0,0 +1,123 @@
+package spec
+
+import (
+ "math/rand"
+ "regexp"
+ "sort"
+)
+
+type Specs struct {
+ specs []*Spec
+ hasProgrammaticFocus bool
+ RegexScansFilePath bool
+}
+
+func NewSpecs(specs []*Spec) *Specs {
+ return &Specs{
+ specs: specs,
+ }
+}
+
+func (e *Specs) Specs() []*Spec {
+ return e.specs
+}
+
+func (e *Specs) HasProgrammaticFocus() bool {
+ return e.hasProgrammaticFocus
+}
+
+func (e *Specs) Shuffle(r *rand.Rand) {
+ sort.Sort(e)
+ permutation := r.Perm(len(e.specs))
+ shuffledSpecs := make([]*Spec, len(e.specs))
+ for i, j := range permutation {
+ shuffledSpecs[i] = e.specs[j]
+ }
+ e.specs = shuffledSpecs
+}
+
+func (e *Specs) ApplyFocus(description string, focusString string, skipString string) {
+ if focusString == "" && skipString == "" {
+ e.applyProgrammaticFocus()
+ } else {
+ e.applyRegExpFocusAndSkip(description, focusString, skipString)
+ }
+}
+
+func (e *Specs) applyProgrammaticFocus() {
+ e.hasProgrammaticFocus = false
+ for _, spec := range e.specs {
+ if spec.Focused() && !spec.Pending() {
+ e.hasProgrammaticFocus = true
+ break
+ }
+ }
+
+ if e.hasProgrammaticFocus {
+ for _, spec := range e.specs {
+ if !spec.Focused() {
+ spec.Skip()
+ }
+ }
+ }
+}
+
+// toMatch returns a byte[] to be used by regex matchers. When adding new behaviours to the matching function,
+// this is the place which we append to.
+func (e *Specs) toMatch(description string, spec *Spec) []byte {
+ if e.RegexScansFilePath {
+ return []byte(
+ description + " " +
+ spec.ConcatenatedString() + " " +
+ spec.subject.CodeLocation().FileName)
+ } else {
+ return []byte(
+ description + " " +
+ spec.ConcatenatedString())
+ }
+}
+
+func (e *Specs) applyRegExpFocusAndSkip(description string, focusString string, skipString string) {
+ for _, spec := range e.specs {
+ matchesFocus := true
+ matchesSkip := false
+
+ toMatch := e.toMatch(description, spec)
+
+ if focusString != "" {
+ focusFilter := regexp.MustCompile(focusString)
+ matchesFocus = focusFilter.Match([]byte(toMatch))
+ }
+
+ if skipString != "" {
+ skipFilter := regexp.MustCompile(skipString)
+ matchesSkip = skipFilter.Match([]byte(toMatch))
+ }
+
+ if !matchesFocus || matchesSkip {
+ spec.Skip()
+ }
+ }
+}
+
+func (e *Specs) SkipMeasurements() {
+ for _, spec := range e.specs {
+ if spec.IsMeasurement() {
+ spec.Skip()
+ }
+ }
+}
+
+//sort.Interface
+
+func (e *Specs) Len() int {
+ return len(e.specs)
+}
+
+func (e *Specs) Less(i, j int) bool {
+ return e.specs[i].ConcatenatedString() < e.specs[j].ConcatenatedString()
+}
+
+func (e *Specs) Swap(i, j int) {
+ e.specs[i], e.specs[j] = e.specs[j], e.specs[i]
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/spec/specs_test.go b/vendor/github.com/onsi/ginkgo/internal/spec/specs_test.go
new file mode 100644
index 000000000..066fbbb3a
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/spec/specs_test.go
@@ -0,0 +1,287 @@
+package spec_test
+
+import (
+ "math/rand"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/internal/spec"
+ . "github.com/onsi/gomega"
+
+ "github.com/onsi/ginkgo/internal/codelocation"
+ "github.com/onsi/ginkgo/internal/containernode"
+ "github.com/onsi/ginkgo/internal/leafnodes"
+ "github.com/onsi/ginkgo/types"
+)
+
+var _ = Describe("Specs", func() {
+ var specs *Specs
+
+ newSpec := func(text string, flag types.FlagType) *Spec {
+ subject := leafnodes.NewItNode(text, func() {}, flag, codelocation.New(0), 0, nil, 0)
+ return New(subject, []*containernode.ContainerNode{}, false)
+ }
+
+ newMeasureSpec := func(text string, flag types.FlagType) *Spec {
+ subject := leafnodes.NewMeasureNode(text, func(Benchmarker) {}, flag, codelocation.New(0), 0, nil, 0)
+ return New(subject, []*containernode.ContainerNode{}, false)
+ }
+
+ newSpecs := func(args ...interface{}) *Specs {
+ specs := []*Spec{}
+ for index := 0; index < len(args)-1; index += 2 {
+ specs = append(specs, newSpec(args[index].(string), args[index+1].(types.FlagType)))
+ }
+ return NewSpecs(specs)
+ }
+
+ specTexts := func(specs *Specs) []string {
+ texts := []string{}
+ for _, spec := range specs.Specs() {
+ texts = append(texts, spec.ConcatenatedString())
+ }
+ return texts
+ }
+
+ willRunTexts := func(specs *Specs) []string {
+ texts := []string{}
+ for _, spec := range specs.Specs() {
+ if !(spec.Skipped() || spec.Pending()) {
+ texts = append(texts, spec.ConcatenatedString())
+ }
+ }
+ return texts
+ }
+
+ skippedTexts := func(specs *Specs) []string {
+ texts := []string{}
+ for _, spec := range specs.Specs() {
+ if spec.Skipped() {
+ texts = append(texts, spec.ConcatenatedString())
+ }
+ }
+ return texts
+ }
+
+ pendingTexts := func(specs *Specs) []string {
+ texts := []string{}
+ for _, spec := range specs.Specs() {
+ if spec.Pending() {
+ texts = append(texts, spec.ConcatenatedString())
+ }
+ }
+ return texts
+ }
+
+ Describe("Shuffling specs", func() {
+ It("should shuffle the specs using the passed in randomizer", func() {
+ specs17 := newSpecs("C", noneFlag, "A", noneFlag, "B", noneFlag)
+ specs17.Shuffle(rand.New(rand.NewSource(17)))
+ texts17 := specTexts(specs17)
+
+ specs17Again := newSpecs("C", noneFlag, "A", noneFlag, "B", noneFlag)
+ specs17Again.Shuffle(rand.New(rand.NewSource(17)))
+ texts17Again := specTexts(specs17Again)
+
+ specs15 := newSpecs("C", noneFlag, "A", noneFlag, "B", noneFlag)
+ specs15.Shuffle(rand.New(rand.NewSource(15)))
+ texts15 := specTexts(specs15)
+
+ specsUnshuffled := newSpecs("C", noneFlag, "A", noneFlag, "B", noneFlag)
+ textsUnshuffled := specTexts(specsUnshuffled)
+
+ Ω(textsUnshuffled).Should(Equal([]string{"C", "A", "B"}))
+
+ Ω(texts17).Should(Equal(texts17Again))
+ Ω(texts17).ShouldNot(Equal(texts15))
+ Ω(texts17).ShouldNot(Equal(textsUnshuffled))
+ Ω(texts15).ShouldNot(Equal(textsUnshuffled))
+
+ Ω(texts17).Should(HaveLen(3))
+ Ω(texts17).Should(ContainElement("A"))
+ Ω(texts17).Should(ContainElement("B"))
+ Ω(texts17).Should(ContainElement("C"))
+
+ Ω(texts15).Should(HaveLen(3))
+ Ω(texts15).Should(ContainElement("A"))
+ Ω(texts15).Should(ContainElement("B"))
+ Ω(texts15).Should(ContainElement("C"))
+ })
+ })
+
+ Describe("with no programmatic focus", func() {
+ BeforeEach(func() {
+ specs = newSpecs("A1", noneFlag, "A2", noneFlag, "B1", noneFlag, "B2", pendingFlag)
+ specs.ApplyFocus("", "", "")
+ })
+
+ It("should not report as having programmatic specs", func() {
+ Ω(specs.HasProgrammaticFocus()).Should(BeFalse())
+ })
+ })
+
+ Describe("Applying focus/skip", func() {
+ var description, focusString, skipString string
+
+ BeforeEach(func() {
+ description, focusString, skipString = "", "", ""
+ })
+
+ JustBeforeEach(func() {
+ specs = newSpecs("A1", focusedFlag, "A2", noneFlag, "B1", focusedFlag, "B2", pendingFlag)
+ specs.ApplyFocus(description, focusString, skipString)
+ })
+
+ Context("with neither a focus string nor a skip string", func() {
+ It("should apply the programmatic focus", func() {
+ Ω(willRunTexts(specs)).Should(Equal([]string{"A1", "B1"}))
+ Ω(skippedTexts(specs)).Should(Equal([]string{"A2", "B2"}))
+ Ω(pendingTexts(specs)).Should(BeEmpty())
+ })
+
+ It("should report as having programmatic specs", func() {
+ Ω(specs.HasProgrammaticFocus()).Should(BeTrue())
+ })
+ })
+
+ Context("with a focus regexp", func() {
+ BeforeEach(func() {
+ focusString = "A"
+ })
+
+ It("should override the programmatic focus", func() {
+ Ω(willRunTexts(specs)).Should(Equal([]string{"A1", "A2"}))
+ Ω(skippedTexts(specs)).Should(Equal([]string{"B1", "B2"}))
+ Ω(pendingTexts(specs)).Should(BeEmpty())
+ })
+
+ It("should not report as having programmatic specs", func() {
+ Ω(specs.HasProgrammaticFocus()).Should(BeFalse())
+ })
+ })
+
+ Context("with a focus regexp", func() {
+ BeforeEach(func() {
+ focusString = "B"
+ })
+
+ It("should not override any pendings", func() {
+ Ω(willRunTexts(specs)).Should(Equal([]string{"B1"}))
+ Ω(skippedTexts(specs)).Should(Equal([]string{"A1", "A2"}))
+ Ω(pendingTexts(specs)).Should(Equal([]string{"B2"}))
+ })
+ })
+
+ Context("with a description", func() {
+ BeforeEach(func() {
+ description = "C"
+ focusString = "C"
+ })
+
+ It("should include the description in the focus determination", func() {
+ Ω(willRunTexts(specs)).Should(Equal([]string{"A1", "A2", "B1"}))
+ Ω(skippedTexts(specs)).Should(BeEmpty())
+ Ω(pendingTexts(specs)).Should(Equal([]string{"B2"}))
+ })
+ })
+
+ Context("with a description", func() {
+ BeforeEach(func() {
+ description = "C"
+ skipString = "C"
+ })
+
+ It("should include the description in the focus determination", func() {
+ Ω(willRunTexts(specs)).Should(BeEmpty())
+ Ω(skippedTexts(specs)).Should(Equal([]string{"A1", "A2", "B1", "B2"}))
+ Ω(pendingTexts(specs)).Should(BeEmpty())
+ })
+ })
+
+ Context("with a skip regexp", func() {
+ BeforeEach(func() {
+ skipString = "A"
+ })
+
+ It("should override the programmatic focus", func() {
+ Ω(willRunTexts(specs)).Should(Equal([]string{"B1"}))
+ Ω(skippedTexts(specs)).Should(Equal([]string{"A1", "A2"}))
+ Ω(pendingTexts(specs)).Should(Equal([]string{"B2"}))
+ })
+
+ It("should not report as having programmatic specs", func() {
+ Ω(specs.HasProgrammaticFocus()).Should(BeFalse())
+ })
+ })
+
+ Context("with both a focus and a skip regexp", func() {
+ BeforeEach(func() {
+ focusString = "1"
+ skipString = "B"
+ })
+
+ It("should AND the two", func() {
+ Ω(willRunTexts(specs)).Should(Equal([]string{"A1"}))
+ Ω(skippedTexts(specs)).Should(Equal([]string{"A2", "B1", "B2"}))
+ Ω(pendingTexts(specs)).Should(BeEmpty())
+ })
+
+ It("should not report as having programmatic specs", func() {
+ Ω(specs.HasProgrammaticFocus()).Should(BeFalse())
+ })
+ })
+ })
+
+ Describe("With a focused spec within a pending context and a pending spec within a focused context", func() {
+ BeforeEach(func() {
+ pendingInFocused := New(
+ leafnodes.NewItNode("PendingInFocused", func() {}, pendingFlag, codelocation.New(0), 0, nil, 0),
+ []*containernode.ContainerNode{
+ containernode.New("", focusedFlag, codelocation.New(0)),
+ }, false)
+
+ focusedInPending := New(
+ leafnodes.NewItNode("FocusedInPending", func() {}, focusedFlag, codelocation.New(0), 0, nil, 0),
+ []*containernode.ContainerNode{
+ containernode.New("", pendingFlag, codelocation.New(0)),
+ }, false)
+
+ specs = NewSpecs([]*Spec{
+ newSpec("A", noneFlag),
+ newSpec("B", noneFlag),
+ pendingInFocused,
+ focusedInPending,
+ })
+ specs.ApplyFocus("", "", "")
+ })
+
+ It("should not have a programmatic focus and should run all tests", func() {
+ Ω(willRunTexts(specs)).Should(Equal([]string{"A", "B"}))
+ Ω(skippedTexts(specs)).Should(BeEmpty())
+ Ω(pendingTexts(specs)).Should(ConsistOf(ContainSubstring("PendingInFocused"), ContainSubstring("FocusedInPending")))
+ })
+ })
+
+ Describe("skipping measurements", func() {
+ BeforeEach(func() {
+ specs = NewSpecs([]*Spec{
+ newSpec("A", noneFlag),
+ newSpec("B", noneFlag),
+ newSpec("C", pendingFlag),
+ newMeasureSpec("measurementA", noneFlag),
+ newMeasureSpec("measurementB", pendingFlag),
+ })
+ })
+
+ It("should skip measurements", func() {
+ Ω(willRunTexts(specs)).Should(Equal([]string{"A", "B", "measurementA"}))
+ Ω(skippedTexts(specs)).Should(BeEmpty())
+ Ω(pendingTexts(specs)).Should(Equal([]string{"C", "measurementB"}))
+
+ specs.SkipMeasurements()
+
+ Ω(willRunTexts(specs)).Should(Equal([]string{"A", "B"}))
+ Ω(skippedTexts(specs)).Should(Equal([]string{"measurementA", "measurementB"}))
+ Ω(pendingTexts(specs)).Should(Equal([]string{"C"}))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/spec_iterator/index_computer.go b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/index_computer.go
new file mode 100644
index 000000000..82272554a
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/index_computer.go
@@ -0,0 +1,55 @@
+package spec_iterator
+
+func ParallelizedIndexRange(length int, parallelTotal int, parallelNode int) (startIndex int, count int) {
+ if length == 0 {
+ return 0, 0
+ }
+
+ // We have more nodes than tests. Trivial case.
+ if parallelTotal >= length {
+ if parallelNode > length {
+ return 0, 0
+ } else {
+ return parallelNode - 1, 1
+ }
+ }
+
+ // This is the minimum amount of tests that a node will be required to run
+ minTestsPerNode := length / parallelTotal
+
+ // This is the maximum amount of tests that a node will be required to run
+ // The algorithm guarantees that this would be equal to at least the minimum amount
+ // and at most one more
+ maxTestsPerNode := minTestsPerNode
+ if length%parallelTotal != 0 {
+ maxTestsPerNode++
+ }
+
+ // Number of nodes that will have to run the maximum amount of tests per node
+ numMaxLoadNodes := length % parallelTotal
+
+ // Number of nodes that precede the current node and will have to run the maximum amount of tests per node
+ var numPrecedingMaxLoadNodes int
+ if parallelNode > numMaxLoadNodes {
+ numPrecedingMaxLoadNodes = numMaxLoadNodes
+ } else {
+ numPrecedingMaxLoadNodes = parallelNode - 1
+ }
+
+ // Number of nodes that precede the current node and will have to run the minimum amount of tests per node
+ var numPrecedingMinLoadNodes int
+ if parallelNode <= numMaxLoadNodes {
+ numPrecedingMinLoadNodes = 0
+ } else {
+ numPrecedingMinLoadNodes = parallelNode - numMaxLoadNodes - 1
+ }
+
+ // Evaluate the test start index and number of tests to run
+ startIndex = numPrecedingMaxLoadNodes*maxTestsPerNode + numPrecedingMinLoadNodes*minTestsPerNode
+ if parallelNode > numMaxLoadNodes {
+ count = minTestsPerNode
+ } else {
+ count = maxTestsPerNode
+ }
+ return
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/spec_iterator/index_computer_test.go b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/index_computer_test.go
new file mode 100644
index 000000000..65da9837c
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/index_computer_test.go
@@ -0,0 +1,149 @@
+package spec_iterator_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/internal/spec_iterator"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("ParallelizedIndexRange", func() {
+ var startIndex, count int
+
+ It("should return the correct index range for 4 tests on 2 nodes", func() {
+ startIndex, count = ParallelizedIndexRange(4, 2, 1)
+ Ω(startIndex).Should(Equal(0))
+ Ω(count).Should(Equal(2))
+
+ startIndex, count = ParallelizedIndexRange(4, 2, 2)
+ Ω(startIndex).Should(Equal(2))
+ Ω(count).Should(Equal(2))
+ })
+
+ It("should return the correct index range for 5 tests on 2 nodes", func() {
+ startIndex, count = ParallelizedIndexRange(5, 2, 1)
+ Ω(startIndex).Should(Equal(0))
+ Ω(count).Should(Equal(3))
+
+ startIndex, count = ParallelizedIndexRange(5, 2, 2)
+ Ω(startIndex).Should(Equal(3))
+ Ω(count).Should(Equal(2))
+ })
+
+ It("should return the correct index range for 5 tests on 3 nodes", func() {
+ startIndex, count = ParallelizedIndexRange(5, 3, 1)
+ Ω(startIndex).Should(Equal(0))
+ Ω(count).Should(Equal(2))
+
+ startIndex, count = ParallelizedIndexRange(5, 3, 2)
+ Ω(startIndex).Should(Equal(2))
+ Ω(count).Should(Equal(2))
+
+ startIndex, count = ParallelizedIndexRange(5, 3, 3)
+ Ω(startIndex).Should(Equal(4))
+ Ω(count).Should(Equal(1))
+ })
+
+ It("should return the correct index range for 5 tests on 4 nodes", func() {
+ startIndex, count = ParallelizedIndexRange(5, 4, 1)
+ Ω(startIndex).Should(Equal(0))
+ Ω(count).Should(Equal(2))
+
+ startIndex, count = ParallelizedIndexRange(5, 4, 2)
+ Ω(startIndex).Should(Equal(2))
+ Ω(count).Should(Equal(1))
+
+ startIndex, count = ParallelizedIndexRange(5, 4, 3)
+ Ω(startIndex).Should(Equal(3))
+ Ω(count).Should(Equal(1))
+
+ startIndex, count = ParallelizedIndexRange(5, 4, 4)
+ Ω(startIndex).Should(Equal(4))
+ Ω(count).Should(Equal(1))
+ })
+
+ It("should return the correct index range for 5 tests on 5 nodes", func() {
+ startIndex, count = ParallelizedIndexRange(5, 5, 1)
+ Ω(startIndex).Should(Equal(0))
+ Ω(count).Should(Equal(1))
+
+ startIndex, count = ParallelizedIndexRange(5, 5, 2)
+ Ω(startIndex).Should(Equal(1))
+ Ω(count).Should(Equal(1))
+
+ startIndex, count = ParallelizedIndexRange(5, 5, 3)
+ Ω(startIndex).Should(Equal(2))
+ Ω(count).Should(Equal(1))
+
+ startIndex, count = ParallelizedIndexRange(5, 5, 4)
+ Ω(startIndex).Should(Equal(3))
+ Ω(count).Should(Equal(1))
+
+ startIndex, count = ParallelizedIndexRange(5, 5, 5)
+ Ω(startIndex).Should(Equal(4))
+ Ω(count).Should(Equal(1))
+ })
+
+ It("should return the correct index range for 5 tests on 6 nodes", func() {
+ startIndex, count = ParallelizedIndexRange(5, 6, 1)
+ Ω(startIndex).Should(Equal(0))
+ Ω(count).Should(Equal(1))
+
+ startIndex, count = ParallelizedIndexRange(5, 6, 2)
+ Ω(startIndex).Should(Equal(1))
+ Ω(count).Should(Equal(1))
+
+ startIndex, count = ParallelizedIndexRange(5, 6, 3)
+ Ω(startIndex).Should(Equal(2))
+ Ω(count).Should(Equal(1))
+
+ startIndex, count = ParallelizedIndexRange(5, 6, 4)
+ Ω(startIndex).Should(Equal(3))
+ Ω(count).Should(Equal(1))
+
+ startIndex, count = ParallelizedIndexRange(5, 6, 5)
+ Ω(startIndex).Should(Equal(4))
+ Ω(count).Should(Equal(1))
+
+ startIndex, count = ParallelizedIndexRange(5, 6, 6)
+ Ω(count).Should(Equal(0))
+ })
+
+ It("should return the correct index range for 5 tests on 7 nodes", func() {
+ startIndex, count = ParallelizedIndexRange(5, 7, 6)
+ Ω(count).Should(Equal(0))
+
+ startIndex, count = ParallelizedIndexRange(5, 7, 7)
+ Ω(count).Should(Equal(0))
+ })
+
+ It("should return the correct index range for 11 tests on 7 nodes", func() {
+ startIndex, count = ParallelizedIndexRange(11, 7, 1)
+ Ω(startIndex).Should(Equal(0))
+ Ω(count).Should(Equal(2))
+
+ startIndex, count = ParallelizedIndexRange(11, 7, 2)
+ Ω(startIndex).Should(Equal(2))
+ Ω(count).Should(Equal(2))
+
+ startIndex, count = ParallelizedIndexRange(11, 7, 3)
+ Ω(startIndex).Should(Equal(4))
+ Ω(count).Should(Equal(2))
+
+ startIndex, count = ParallelizedIndexRange(11, 7, 4)
+ Ω(startIndex).Should(Equal(6))
+ Ω(count).Should(Equal(2))
+
+ startIndex, count = ParallelizedIndexRange(11, 7, 5)
+ Ω(startIndex).Should(Equal(8))
+ Ω(count).Should(Equal(1))
+
+ startIndex, count = ParallelizedIndexRange(11, 7, 6)
+ Ω(startIndex).Should(Equal(9))
+ Ω(count).Should(Equal(1))
+
+ startIndex, count = ParallelizedIndexRange(11, 7, 7)
+ Ω(startIndex).Should(Equal(10))
+ Ω(count).Should(Equal(1))
+ })
+
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/spec_iterator/parallel_spec_iterator.go b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/parallel_spec_iterator.go
new file mode 100644
index 000000000..99f548bca
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/parallel_spec_iterator.go
@@ -0,0 +1,59 @@
+package spec_iterator
+
+import (
+ "encoding/json"
+ "fmt"
+ "net/http"
+
+ "github.com/onsi/ginkgo/internal/spec"
+)
+
+type ParallelIterator struct {
+ specs []*spec.Spec
+ host string
+ client *http.Client
+}
+
+func NewParallelIterator(specs []*spec.Spec, host string) *ParallelIterator {
+ return &ParallelIterator{
+ specs: specs,
+ host: host,
+ client: &http.Client{},
+ }
+}
+
+func (s *ParallelIterator) Next() (*spec.Spec, error) {
+ resp, err := s.client.Get(s.host + "/counter")
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+
+ if resp.StatusCode != http.StatusOK {
+ return nil, fmt.Errorf("unexpected status code %d", resp.StatusCode)
+ }
+
+ var counter Counter
+ err = json.NewDecoder(resp.Body).Decode(&counter)
+ if err != nil {
+ return nil, err
+ }
+
+ if counter.Index >= len(s.specs) {
+ return nil, ErrClosed
+ }
+
+ return s.specs[counter.Index], nil
+}
+
+func (s *ParallelIterator) NumberOfSpecsPriorToIteration() int {
+ return len(s.specs)
+}
+
+func (s *ParallelIterator) NumberOfSpecsToProcessIfKnown() (int, bool) {
+ return -1, false
+}
+
+func (s *ParallelIterator) NumberOfSpecsThatWillBeRunIfKnown() (int, bool) {
+ return -1, false
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/spec_iterator/parallel_spec_iterator_test.go b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/parallel_spec_iterator_test.go
new file mode 100644
index 000000000..c5a762fd5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/parallel_spec_iterator_test.go
@@ -0,0 +1,112 @@
+package spec_iterator_test
+
+import (
+ "net/http"
+
+ . "github.com/onsi/ginkgo/internal/spec_iterator"
+ "github.com/onsi/gomega/ghttp"
+
+ "github.com/onsi/ginkgo/internal/codelocation"
+ "github.com/onsi/ginkgo/internal/containernode"
+ "github.com/onsi/ginkgo/internal/leafnodes"
+ "github.com/onsi/ginkgo/internal/spec"
+ "github.com/onsi/ginkgo/types"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("ParallelSpecIterator", func() {
+ var specs []*spec.Spec
+ var iterator *ParallelIterator
+ var server *ghttp.Server
+
+ newSpec := func(text string, flag types.FlagType) *spec.Spec {
+ subject := leafnodes.NewItNode(text, func() {}, flag, codelocation.New(0), 0, nil, 0)
+ return spec.New(subject, []*containernode.ContainerNode{}, false)
+ }
+
+ BeforeEach(func() {
+ specs = []*spec.Spec{
+ newSpec("A", types.FlagTypePending),
+ newSpec("B", types.FlagTypeNone),
+ newSpec("C", types.FlagTypeNone),
+ newSpec("D", types.FlagTypeNone),
+ }
+ specs[3].Skip()
+
+ server = ghttp.NewServer()
+
+ iterator = NewParallelIterator(specs, "http://"+server.Addr())
+ })
+
+ AfterEach(func() {
+ server.Close()
+ })
+
+ It("should report the total number of specs", func() {
+ Ω(iterator.NumberOfSpecsPriorToIteration()).Should(Equal(4))
+ })
+
+ It("should not report the number to be processed", func() {
+ n, known := iterator.NumberOfSpecsToProcessIfKnown()
+ Ω(n).Should(Equal(-1))
+ Ω(known).Should(BeFalse())
+ })
+
+ It("should not report the number that will be run", func() {
+ n, known := iterator.NumberOfSpecsThatWillBeRunIfKnown()
+ Ω(n).Should(Equal(-1))
+ Ω(known).Should(BeFalse())
+ })
+
+ Describe("iterating", func() {
+ Describe("when the server returns well-formed responses", func() {
+ BeforeEach(func() {
+ server.AppendHandlers(
+ ghttp.RespondWithJSONEncoded(http.StatusOK, Counter{Index: 0}),
+ ghttp.RespondWithJSONEncoded(http.StatusOK, Counter{Index: 1}),
+ ghttp.RespondWithJSONEncoded(http.StatusOK, Counter{Index: 3}),
+ ghttp.RespondWithJSONEncoded(http.StatusOK, Counter{Index: 4}),
+ )
+ })
+
+ It("should return the specs in question", func() {
+ Ω(iterator.Next()).Should(Equal(specs[0]))
+ Ω(iterator.Next()).Should(Equal(specs[1]))
+ Ω(iterator.Next()).Should(Equal(specs[3]))
+ spec, err := iterator.Next()
+ Ω(spec).Should(BeNil())
+ Ω(err).Should(MatchError(ErrClosed))
+ })
+ })
+
+ Describe("when the server 404s", func() {
+ BeforeEach(func() {
+ server.AppendHandlers(
+ ghttp.RespondWith(http.StatusNotFound, ""),
+ )
+ })
+
+ It("should return an error", func() {
+ spec, err := iterator.Next()
+ Ω(spec).Should(BeNil())
+ Ω(err).Should(MatchError("unexpected status code 404"))
+ })
+ })
+
+ Describe("when the server returns gibberish", func() {
+ BeforeEach(func() {
+ server.AppendHandlers(
+ ghttp.RespondWith(http.StatusOK, "ß"),
+ )
+ })
+
+ It("should error", func() {
+ spec, err := iterator.Next()
+ Ω(spec).Should(BeNil())
+ Ω(err).ShouldNot(BeNil())
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/spec_iterator/serial_spec_iterator.go b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/serial_spec_iterator.go
new file mode 100644
index 000000000..a51c93b8b
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/serial_spec_iterator.go
@@ -0,0 +1,45 @@
+package spec_iterator
+
+import (
+ "github.com/onsi/ginkgo/internal/spec"
+)
+
+type SerialIterator struct {
+ specs []*spec.Spec
+ index int
+}
+
+func NewSerialIterator(specs []*spec.Spec) *SerialIterator {
+ return &SerialIterator{
+ specs: specs,
+ index: 0,
+ }
+}
+
+func (s *SerialIterator) Next() (*spec.Spec, error) {
+ if s.index >= len(s.specs) {
+ return nil, ErrClosed
+ }
+
+ spec := s.specs[s.index]
+ s.index += 1
+ return spec, nil
+}
+
+func (s *SerialIterator) NumberOfSpecsPriorToIteration() int {
+ return len(s.specs)
+}
+
+func (s *SerialIterator) NumberOfSpecsToProcessIfKnown() (int, bool) {
+ return len(s.specs), true
+}
+
+func (s *SerialIterator) NumberOfSpecsThatWillBeRunIfKnown() (int, bool) {
+ count := 0
+ for _, s := range s.specs {
+ if !s.Skipped() && !s.Pending() {
+ count += 1
+ }
+ }
+ return count, true
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/spec_iterator/serial_spec_iterator_test.go b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/serial_spec_iterator_test.go
new file mode 100644
index 000000000..dde4a344e
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/serial_spec_iterator_test.go
@@ -0,0 +1,64 @@
+package spec_iterator_test
+
+import (
+ . "github.com/onsi/ginkgo/internal/spec_iterator"
+
+ "github.com/onsi/ginkgo/internal/codelocation"
+ "github.com/onsi/ginkgo/internal/containernode"
+ "github.com/onsi/ginkgo/internal/leafnodes"
+ "github.com/onsi/ginkgo/internal/spec"
+ "github.com/onsi/ginkgo/types"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("SerialSpecIterator", func() {
+ var specs []*spec.Spec
+ var iterator *SerialIterator
+
+ newSpec := func(text string, flag types.FlagType) *spec.Spec {
+ subject := leafnodes.NewItNode(text, func() {}, flag, codelocation.New(0), 0, nil, 0)
+ return spec.New(subject, []*containernode.ContainerNode{}, false)
+ }
+
+ BeforeEach(func() {
+ specs = []*spec.Spec{
+ newSpec("A", types.FlagTypePending),
+ newSpec("B", types.FlagTypeNone),
+ newSpec("C", types.FlagTypeNone),
+ newSpec("D", types.FlagTypeNone),
+ }
+ specs[3].Skip()
+
+ iterator = NewSerialIterator(specs)
+ })
+
+ It("should report the total number of specs", func() {
+ Ω(iterator.NumberOfSpecsPriorToIteration()).Should(Equal(4))
+ })
+
+ It("should report the number to be processed", func() {
+ n, known := iterator.NumberOfSpecsToProcessIfKnown()
+ Ω(n).Should(Equal(4))
+ Ω(known).Should(BeTrue())
+ })
+
+ It("should report the number that will be run", func() {
+ n, known := iterator.NumberOfSpecsThatWillBeRunIfKnown()
+ Ω(n).Should(Equal(2))
+ Ω(known).Should(BeTrue())
+ })
+
+ Describe("iterating", func() {
+ It("should return the specs in order", func() {
+ Ω(iterator.Next()).Should(Equal(specs[0]))
+ Ω(iterator.Next()).Should(Equal(specs[1]))
+ Ω(iterator.Next()).Should(Equal(specs[2]))
+ Ω(iterator.Next()).Should(Equal(specs[3]))
+ spec, err := iterator.Next()
+ Ω(spec).Should(BeNil())
+ Ω(err).Should(MatchError(ErrClosed))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/spec_iterator/sharded_parallel_spec_iterator.go b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/sharded_parallel_spec_iterator.go
new file mode 100644
index 000000000..ad4a3ea3c
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/sharded_parallel_spec_iterator.go
@@ -0,0 +1,47 @@
+package spec_iterator
+
+import "github.com/onsi/ginkgo/internal/spec"
+
+type ShardedParallelIterator struct {
+ specs []*spec.Spec
+ index int
+ maxIndex int
+}
+
+func NewShardedParallelIterator(specs []*spec.Spec, total int, node int) *ShardedParallelIterator {
+ startIndex, count := ParallelizedIndexRange(len(specs), total, node)
+
+ return &ShardedParallelIterator{
+ specs: specs,
+ index: startIndex,
+ maxIndex: startIndex + count,
+ }
+}
+
+func (s *ShardedParallelIterator) Next() (*spec.Spec, error) {
+ if s.index >= s.maxIndex {
+ return nil, ErrClosed
+ }
+
+ spec := s.specs[s.index]
+ s.index += 1
+ return spec, nil
+}
+
+func (s *ShardedParallelIterator) NumberOfSpecsPriorToIteration() int {
+ return len(s.specs)
+}
+
+func (s *ShardedParallelIterator) NumberOfSpecsToProcessIfKnown() (int, bool) {
+ return s.maxIndex - s.index, true
+}
+
+func (s *ShardedParallelIterator) NumberOfSpecsThatWillBeRunIfKnown() (int, bool) {
+ count := 0
+ for i := s.index; i < s.maxIndex; i += 1 {
+ if !s.specs[i].Skipped() && !s.specs[i].Pending() {
+ count += 1
+ }
+ }
+ return count, true
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/spec_iterator/sharded_parallel_spec_iterator_test.go b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/sharded_parallel_spec_iterator_test.go
new file mode 100644
index 000000000..c3786e03a
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/sharded_parallel_spec_iterator_test.go
@@ -0,0 +1,62 @@
+package spec_iterator_test
+
+import (
+ . "github.com/onsi/ginkgo/internal/spec_iterator"
+
+ "github.com/onsi/ginkgo/internal/codelocation"
+ "github.com/onsi/ginkgo/internal/containernode"
+ "github.com/onsi/ginkgo/internal/leafnodes"
+ "github.com/onsi/ginkgo/internal/spec"
+ "github.com/onsi/ginkgo/types"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("ShardedParallelSpecIterator", func() {
+ var specs []*spec.Spec
+ var iterator *ShardedParallelIterator
+
+ newSpec := func(text string, flag types.FlagType) *spec.Spec {
+ subject := leafnodes.NewItNode(text, func() {}, flag, codelocation.New(0), 0, nil, 0)
+ return spec.New(subject, []*containernode.ContainerNode{}, false)
+ }
+
+ BeforeEach(func() {
+ specs = []*spec.Spec{
+ newSpec("A", types.FlagTypePending),
+ newSpec("B", types.FlagTypeNone),
+ newSpec("C", types.FlagTypeNone),
+ newSpec("D", types.FlagTypeNone),
+ }
+ specs[3].Skip()
+
+ iterator = NewShardedParallelIterator(specs, 2, 1)
+ })
+
+ It("should report the total number of specs", func() {
+ Ω(iterator.NumberOfSpecsPriorToIteration()).Should(Equal(4))
+ })
+
+ It("should report the number to be processed", func() {
+ n, known := iterator.NumberOfSpecsToProcessIfKnown()
+ Ω(n).Should(Equal(2))
+ Ω(known).Should(BeTrue())
+ })
+
+ It("should report the number that will be run", func() {
+ n, known := iterator.NumberOfSpecsThatWillBeRunIfKnown()
+ Ω(n).Should(Equal(1))
+ Ω(known).Should(BeTrue())
+ })
+
+ Describe("iterating", func() {
+ It("should return the specs in order", func() {
+ Ω(iterator.Next()).Should(Equal(specs[0]))
+ Ω(iterator.Next()).Should(Equal(specs[1]))
+ spec, err := iterator.Next()
+ Ω(spec).Should(BeNil())
+ Ω(err).Should(MatchError(ErrClosed))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/spec_iterator/spec_iterator.go b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/spec_iterator.go
new file mode 100644
index 000000000..74bffad64
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/spec_iterator.go
@@ -0,0 +1,20 @@
+package spec_iterator
+
+import (
+ "errors"
+
+ "github.com/onsi/ginkgo/internal/spec"
+)
+
+var ErrClosed = errors.New("no more specs to run")
+
+type SpecIterator interface {
+ Next() (*spec.Spec, error)
+ NumberOfSpecsPriorToIteration() int
+ NumberOfSpecsToProcessIfKnown() (int, bool)
+ NumberOfSpecsThatWillBeRunIfKnown() (int, bool)
+}
+
+type Counter struct {
+ Index int `json:"index"`
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/spec_iterator/spec_iterator_suite_test.go b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/spec_iterator_suite_test.go
new file mode 100644
index 000000000..5c08a77e3
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/spec_iterator/spec_iterator_suite_test.go
@@ -0,0 +1,13 @@
+package spec_iterator_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestSpecIterator(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "SpecIterator Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/specrunner/random_id.go b/vendor/github.com/onsi/ginkgo/internal/specrunner/random_id.go
new file mode 100644
index 000000000..a0b8b62d5
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/specrunner/random_id.go
@@ -0,0 +1,15 @@
+package specrunner
+
+import (
+ "crypto/rand"
+ "fmt"
+)
+
+func randomID() string {
+ b := make([]byte, 8)
+ _, err := rand.Read(b)
+ if err != nil {
+ return ""
+ }
+ return fmt.Sprintf("%x-%x-%x-%x", b[0:2], b[2:4], b[4:6], b[6:8])
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner.go b/vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner.go
new file mode 100644
index 000000000..2c683cb8b
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner.go
@@ -0,0 +1,411 @@
+package specrunner
+
+import (
+ "fmt"
+ "os"
+ "os/signal"
+ "sync"
+ "syscall"
+
+ "github.com/onsi/ginkgo/internal/spec_iterator"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/internal/leafnodes"
+ "github.com/onsi/ginkgo/internal/spec"
+ Writer "github.com/onsi/ginkgo/internal/writer"
+ "github.com/onsi/ginkgo/reporters"
+ "github.com/onsi/ginkgo/types"
+
+ "time"
+)
+
+type SpecRunner struct {
+ description string
+ beforeSuiteNode leafnodes.SuiteNode
+ iterator spec_iterator.SpecIterator
+ afterSuiteNode leafnodes.SuiteNode
+ reporters []reporters.Reporter
+ startTime time.Time
+ suiteID string
+ runningSpec *spec.Spec
+ writer Writer.WriterInterface
+ config config.GinkgoConfigType
+ interrupted bool
+ processedSpecs []*spec.Spec
+ lock *sync.Mutex
+}
+
+func New(description string, beforeSuiteNode leafnodes.SuiteNode, iterator spec_iterator.SpecIterator, afterSuiteNode leafnodes.SuiteNode, reporters []reporters.Reporter, writer Writer.WriterInterface, config config.GinkgoConfigType) *SpecRunner {
+ return &SpecRunner{
+ description: description,
+ beforeSuiteNode: beforeSuiteNode,
+ iterator: iterator,
+ afterSuiteNode: afterSuiteNode,
+ reporters: reporters,
+ writer: writer,
+ config: config,
+ suiteID: randomID(),
+ lock: &sync.Mutex{},
+ }
+}
+
+func (runner *SpecRunner) Run() bool {
+ if runner.config.DryRun {
+ runner.performDryRun()
+ return true
+ }
+
+ runner.reportSuiteWillBegin()
+ signalRegistered := make(chan struct{})
+ go runner.registerForInterrupts(signalRegistered)
+ <-signalRegistered
+
+ suitePassed := runner.runBeforeSuite()
+
+ if suitePassed {
+ suitePassed = runner.runSpecs()
+ }
+
+ runner.blockForeverIfInterrupted()
+
+ suitePassed = runner.runAfterSuite() && suitePassed
+
+ runner.reportSuiteDidEnd(suitePassed)
+
+ return suitePassed
+}
+
+func (runner *SpecRunner) performDryRun() {
+ runner.reportSuiteWillBegin()
+
+ if runner.beforeSuiteNode != nil {
+ summary := runner.beforeSuiteNode.Summary()
+ summary.State = types.SpecStatePassed
+ runner.reportBeforeSuite(summary)
+ }
+
+ for {
+ spec, err := runner.iterator.Next()
+ if err == spec_iterator.ErrClosed {
+ break
+ }
+ if err != nil {
+ fmt.Println("failed to iterate over tests:\n" + err.Error())
+ break
+ }
+
+ runner.processedSpecs = append(runner.processedSpecs, spec)
+
+ summary := spec.Summary(runner.suiteID)
+ runner.reportSpecWillRun(summary)
+ if summary.State == types.SpecStateInvalid {
+ summary.State = types.SpecStatePassed
+ }
+ runner.reportSpecDidComplete(summary, false)
+ }
+
+ if runner.afterSuiteNode != nil {
+ summary := runner.afterSuiteNode.Summary()
+ summary.State = types.SpecStatePassed
+ runner.reportAfterSuite(summary)
+ }
+
+ runner.reportSuiteDidEnd(true)
+}
+
+func (runner *SpecRunner) runBeforeSuite() bool {
+ if runner.beforeSuiteNode == nil || runner.wasInterrupted() {
+ return true
+ }
+
+ runner.writer.Truncate()
+ conf := runner.config
+ passed := runner.beforeSuiteNode.Run(conf.ParallelNode, conf.ParallelTotal, conf.SyncHost)
+ if !passed {
+ runner.writer.DumpOut()
+ }
+ runner.reportBeforeSuite(runner.beforeSuiteNode.Summary())
+ return passed
+}
+
+func (runner *SpecRunner) runAfterSuite() bool {
+ if runner.afterSuiteNode == nil {
+ return true
+ }
+
+ runner.writer.Truncate()
+ conf := runner.config
+ passed := runner.afterSuiteNode.Run(conf.ParallelNode, conf.ParallelTotal, conf.SyncHost)
+ if !passed {
+ runner.writer.DumpOut()
+ }
+ runner.reportAfterSuite(runner.afterSuiteNode.Summary())
+ return passed
+}
+
+func (runner *SpecRunner) runSpecs() bool {
+ suiteFailed := false
+ skipRemainingSpecs := false
+ for {
+ spec, err := runner.iterator.Next()
+ if err == spec_iterator.ErrClosed {
+ break
+ }
+ if err != nil {
+ fmt.Println("failed to iterate over tests:\n" + err.Error())
+ suiteFailed = true
+ break
+ }
+
+ runner.processedSpecs = append(runner.processedSpecs, spec)
+
+ if runner.wasInterrupted() {
+ break
+ }
+ if skipRemainingSpecs {
+ spec.Skip()
+ }
+
+ if !spec.Skipped() && !spec.Pending() {
+ if passed := runner.runSpec(spec); !passed {
+ suiteFailed = true
+ }
+ } else if spec.Pending() && runner.config.FailOnPending {
+ runner.reportSpecWillRun(spec.Summary(runner.suiteID))
+ suiteFailed = true
+ runner.reportSpecDidComplete(spec.Summary(runner.suiteID), spec.Failed())
+ } else {
+ runner.reportSpecWillRun(spec.Summary(runner.suiteID))
+ runner.reportSpecDidComplete(spec.Summary(runner.suiteID), spec.Failed())
+ }
+
+ if spec.Failed() && runner.config.FailFast {
+ skipRemainingSpecs = true
+ }
+ }
+
+ return !suiteFailed
+}
+
+func (runner *SpecRunner) runSpec(spec *spec.Spec) (passed bool) {
+ maxAttempts := 1
+ if runner.config.FlakeAttempts > 0 {
+ // uninitialized configs count as 1
+ maxAttempts = runner.config.FlakeAttempts
+ }
+
+ for i := 0; i < maxAttempts; i++ {
+ runner.reportSpecWillRun(spec.Summary(runner.suiteID))
+ runner.runningSpec = spec
+ spec.Run(runner.writer)
+ runner.runningSpec = nil
+ runner.reportSpecDidComplete(spec.Summary(runner.suiteID), spec.Failed())
+ if !spec.Failed() {
+ return true
+ }
+ }
+ return false
+}
+
+func (runner *SpecRunner) CurrentSpecSummary() (*types.SpecSummary, bool) {
+ if runner.runningSpec == nil {
+ return nil, false
+ }
+
+ return runner.runningSpec.Summary(runner.suiteID), true
+}
+
+func (runner *SpecRunner) registerForInterrupts(signalRegistered chan struct{}) {
+ c := make(chan os.Signal, 1)
+ signal.Notify(c, os.Interrupt, syscall.SIGTERM)
+ close(signalRegistered)
+
+ <-c
+ signal.Stop(c)
+ runner.markInterrupted()
+ go runner.registerForHardInterrupts()
+ runner.writer.DumpOutWithHeader(`
+Received interrupt. Emitting contents of GinkgoWriter...
+---------------------------------------------------------
+`)
+ if runner.afterSuiteNode != nil {
+ fmt.Fprint(os.Stderr, `
+---------------------------------------------------------
+Received interrupt. Running AfterSuite...
+^C again to terminate immediately
+`)
+ runner.runAfterSuite()
+ }
+ runner.reportSuiteDidEnd(false)
+ os.Exit(1)
+}
+
+func (runner *SpecRunner) registerForHardInterrupts() {
+ c := make(chan os.Signal, 1)
+ signal.Notify(c, os.Interrupt, syscall.SIGTERM)
+
+ <-c
+ fmt.Fprintln(os.Stderr, "\nReceived second interrupt. Shutting down.")
+ os.Exit(1)
+}
+
+func (runner *SpecRunner) blockForeverIfInterrupted() {
+ runner.lock.Lock()
+ interrupted := runner.interrupted
+ runner.lock.Unlock()
+
+ if interrupted {
+ select {}
+ }
+}
+
+func (runner *SpecRunner) markInterrupted() {
+ runner.lock.Lock()
+ defer runner.lock.Unlock()
+ runner.interrupted = true
+}
+
+func (runner *SpecRunner) wasInterrupted() bool {
+ runner.lock.Lock()
+ defer runner.lock.Unlock()
+ return runner.interrupted
+}
+
+func (runner *SpecRunner) reportSuiteWillBegin() {
+ runner.startTime = time.Now()
+ summary := runner.suiteWillBeginSummary()
+ for _, reporter := range runner.reporters {
+ reporter.SpecSuiteWillBegin(runner.config, summary)
+ }
+}
+
+func (runner *SpecRunner) reportBeforeSuite(summary *types.SetupSummary) {
+ for _, reporter := range runner.reporters {
+ reporter.BeforeSuiteDidRun(summary)
+ }
+}
+
+func (runner *SpecRunner) reportAfterSuite(summary *types.SetupSummary) {
+ for _, reporter := range runner.reporters {
+ reporter.AfterSuiteDidRun(summary)
+ }
+}
+
+func (runner *SpecRunner) reportSpecWillRun(summary *types.SpecSummary) {
+ runner.writer.Truncate()
+
+ for _, reporter := range runner.reporters {
+ reporter.SpecWillRun(summary)
+ }
+}
+
+func (runner *SpecRunner) reportSpecDidComplete(summary *types.SpecSummary, failed bool) {
+ if failed && len(summary.CapturedOutput) == 0 {
+ summary.CapturedOutput = string(runner.writer.Bytes())
+ }
+ for i := len(runner.reporters) - 1; i >= 1; i-- {
+ runner.reporters[i].SpecDidComplete(summary)
+ }
+
+ if failed {
+ runner.writer.DumpOut()
+ }
+
+ runner.reporters[0].SpecDidComplete(summary)
+}
+
+func (runner *SpecRunner) reportSuiteDidEnd(success bool) {
+ summary := runner.suiteDidEndSummary(success)
+ summary.RunTime = time.Since(runner.startTime)
+ for _, reporter := range runner.reporters {
+ reporter.SpecSuiteDidEnd(summary)
+ }
+}
+
+func (runner *SpecRunner) countSpecsThatRanSatisfying(filter func(ex *spec.Spec) bool) (count int) {
+ count = 0
+
+ for _, spec := range runner.processedSpecs {
+ if filter(spec) {
+ count++
+ }
+ }
+
+ return count
+}
+
+func (runner *SpecRunner) suiteDidEndSummary(success bool) *types.SuiteSummary {
+ numberOfSpecsThatWillBeRun := runner.countSpecsThatRanSatisfying(func(ex *spec.Spec) bool {
+ return !ex.Skipped() && !ex.Pending()
+ })
+
+ numberOfPendingSpecs := runner.countSpecsThatRanSatisfying(func(ex *spec.Spec) bool {
+ return ex.Pending()
+ })
+
+ numberOfSkippedSpecs := runner.countSpecsThatRanSatisfying(func(ex *spec.Spec) bool {
+ return ex.Skipped()
+ })
+
+ numberOfPassedSpecs := runner.countSpecsThatRanSatisfying(func(ex *spec.Spec) bool {
+ return ex.Passed()
+ })
+
+ numberOfFlakedSpecs := runner.countSpecsThatRanSatisfying(func(ex *spec.Spec) bool {
+ return ex.Flaked()
+ })
+
+ numberOfFailedSpecs := runner.countSpecsThatRanSatisfying(func(ex *spec.Spec) bool {
+ return ex.Failed()
+ })
+
+ if runner.beforeSuiteNode != nil && !runner.beforeSuiteNode.Passed() && !runner.config.DryRun {
+ var known bool
+ numberOfSpecsThatWillBeRun, known = runner.iterator.NumberOfSpecsThatWillBeRunIfKnown()
+ if !known {
+ numberOfSpecsThatWillBeRun = runner.iterator.NumberOfSpecsPriorToIteration()
+ }
+ numberOfFailedSpecs = numberOfSpecsThatWillBeRun
+ }
+
+ return &types.SuiteSummary{
+ SuiteDescription: runner.description,
+ SuiteSucceeded: success,
+ SuiteID: runner.suiteID,
+
+ NumberOfSpecsBeforeParallelization: runner.iterator.NumberOfSpecsPriorToIteration(),
+ NumberOfTotalSpecs: len(runner.processedSpecs),
+ NumberOfSpecsThatWillBeRun: numberOfSpecsThatWillBeRun,
+ NumberOfPendingSpecs: numberOfPendingSpecs,
+ NumberOfSkippedSpecs: numberOfSkippedSpecs,
+ NumberOfPassedSpecs: numberOfPassedSpecs,
+ NumberOfFailedSpecs: numberOfFailedSpecs,
+ NumberOfFlakedSpecs: numberOfFlakedSpecs,
+ }
+}
+
+func (runner *SpecRunner) suiteWillBeginSummary() *types.SuiteSummary {
+ numTotal, known := runner.iterator.NumberOfSpecsToProcessIfKnown()
+ if !known {
+ numTotal = -1
+ }
+
+ numToRun, known := runner.iterator.NumberOfSpecsThatWillBeRunIfKnown()
+ if !known {
+ numToRun = -1
+ }
+
+ return &types.SuiteSummary{
+ SuiteDescription: runner.description,
+ SuiteID: runner.suiteID,
+
+ NumberOfSpecsBeforeParallelization: runner.iterator.NumberOfSpecsPriorToIteration(),
+ NumberOfTotalSpecs: numTotal,
+ NumberOfSpecsThatWillBeRun: numToRun,
+ NumberOfPendingSpecs: -1,
+ NumberOfSkippedSpecs: -1,
+ NumberOfPassedSpecs: -1,
+ NumberOfFailedSpecs: -1,
+ NumberOfFlakedSpecs: -1,
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner_suite_test.go b/vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner_suite_test.go
new file mode 100644
index 000000000..c8388fb6f
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner_suite_test.go
@@ -0,0 +1,13 @@
+package specrunner_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestSpecRunner(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Spec Runner Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner_test.go b/vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner_test.go
new file mode 100644
index 000000000..a41437922
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/specrunner/spec_runner_test.go
@@ -0,0 +1,785 @@
+package specrunner_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/internal/spec_iterator"
+ . "github.com/onsi/ginkgo/internal/specrunner"
+ "github.com/onsi/ginkgo/types"
+ . "github.com/onsi/gomega"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/internal/codelocation"
+ "github.com/onsi/ginkgo/internal/containernode"
+ Failer "github.com/onsi/ginkgo/internal/failer"
+ "github.com/onsi/ginkgo/internal/leafnodes"
+ "github.com/onsi/ginkgo/internal/spec"
+ Writer "github.com/onsi/ginkgo/internal/writer"
+ "github.com/onsi/ginkgo/reporters"
+)
+
+var noneFlag = types.FlagTypeNone
+var pendingFlag = types.FlagTypePending
+
+var _ = Describe("Spec Runner", func() {
+ var (
+ reporter1 *reporters.FakeReporter
+ reporter2 *reporters.FakeReporter
+ failer *Failer.Failer
+ writer *Writer.FakeGinkgoWriter
+
+ thingsThatRan []string
+
+ runner *SpecRunner
+ )
+
+ newBefSuite := func(text string, fail bool) leafnodes.SuiteNode {
+ return leafnodes.NewBeforeSuiteNode(func() {
+ writer.AddEvent(text)
+ thingsThatRan = append(thingsThatRan, text)
+ if fail {
+ failer.Fail(text, codelocation.New(0))
+ }
+ }, codelocation.New(0), 0, failer)
+ }
+
+ newAftSuite := func(text string, fail bool) leafnodes.SuiteNode {
+ return leafnodes.NewAfterSuiteNode(func() {
+ writer.AddEvent(text)
+ thingsThatRan = append(thingsThatRan, text)
+ if fail {
+ failer.Fail(text, codelocation.New(0))
+ }
+ }, codelocation.New(0), 0, failer)
+ }
+
+ newSpec := func(text string, flag types.FlagType, fail bool) *spec.Spec {
+ subject := leafnodes.NewItNode(text, func() {
+ writer.AddEvent(text)
+ thingsThatRan = append(thingsThatRan, text)
+ if fail {
+ failer.Fail(text, codelocation.New(0))
+ }
+ }, flag, codelocation.New(0), 0, failer, 0)
+
+ return spec.New(subject, []*containernode.ContainerNode{}, false)
+ }
+
+ newFlakySpec := func(text string, flag types.FlagType, failures int) *spec.Spec {
+ runs := 0
+ subject := leafnodes.NewItNode(text, func() {
+ writer.AddEvent(text)
+ thingsThatRan = append(thingsThatRan, text)
+ runs++
+ if runs < failures {
+ failer.Fail(text, codelocation.New(0))
+ }
+ }, flag, codelocation.New(0), 0, failer, 0)
+
+ return spec.New(subject, []*containernode.ContainerNode{}, false)
+ }
+
+ newSpecWithBody := func(text string, body interface{}) *spec.Spec {
+ subject := leafnodes.NewItNode(text, body, noneFlag, codelocation.New(0), 0, failer, 0)
+
+ return spec.New(subject, []*containernode.ContainerNode{}, false)
+ }
+
+ newRunner := func(config config.GinkgoConfigType, beforeSuiteNode leafnodes.SuiteNode, afterSuiteNode leafnodes.SuiteNode, specs ...*spec.Spec) *SpecRunner {
+ iterator := spec_iterator.NewSerialIterator(specs)
+ return New("description", beforeSuiteNode, iterator, afterSuiteNode, []reporters.Reporter{reporter1, reporter2}, writer, config)
+ }
+
+ BeforeEach(func() {
+ reporter1 = reporters.NewFakeReporter()
+ reporter2 = reporters.NewFakeReporter()
+ writer = Writer.NewFake()
+ failer = Failer.New()
+
+ thingsThatRan = []string{}
+ })
+
+ Describe("Running and Reporting", func() {
+ var specA, pendingSpec, anotherPendingSpec, failedSpec, specB, skippedSpec *spec.Spec
+ var willRunCalls, didCompleteCalls []string
+ var conf config.GinkgoConfigType
+
+ JustBeforeEach(func() {
+ willRunCalls = []string{}
+ didCompleteCalls = []string{}
+ specA = newSpec("spec A", noneFlag, false)
+ pendingSpec = newSpec("pending spec", pendingFlag, false)
+ anotherPendingSpec = newSpec("another pending spec", pendingFlag, false)
+ failedSpec = newSpec("failed spec", noneFlag, true)
+ specB = newSpec("spec B", noneFlag, false)
+ skippedSpec = newSpec("skipped spec", noneFlag, false)
+ skippedSpec.Skip()
+
+ reporter1.SpecWillRunStub = func(specSummary *types.SpecSummary) {
+ willRunCalls = append(willRunCalls, "Reporter1")
+ }
+ reporter2.SpecWillRunStub = func(specSummary *types.SpecSummary) {
+ willRunCalls = append(willRunCalls, "Reporter2")
+ }
+
+ reporter1.SpecDidCompleteStub = func(specSummary *types.SpecSummary) {
+ didCompleteCalls = append(didCompleteCalls, "Reporter1")
+ }
+ reporter2.SpecDidCompleteStub = func(specSummary *types.SpecSummary) {
+ didCompleteCalls = append(didCompleteCalls, "Reporter2")
+ }
+
+ runner = newRunner(conf, newBefSuite("BefSuite", false), newAftSuite("AftSuite", false), specA, pendingSpec, anotherPendingSpec, failedSpec, specB, skippedSpec)
+ runner.Run()
+ })
+
+ BeforeEach(func() {
+ conf = config.GinkgoConfigType{RandomSeed: 17}
+ })
+
+ It("should skip skipped/pending tests", func() {
+ Ω(thingsThatRan).Should(Equal([]string{"BefSuite", "spec A", "failed spec", "spec B", "AftSuite"}))
+ })
+
+ It("should report to any attached reporters", func() {
+ Ω(reporter1.Config).Should(Equal(reporter2.Config))
+ Ω(reporter1.BeforeSuiteSummary).Should(Equal(reporter2.BeforeSuiteSummary))
+ Ω(reporter1.BeginSummary).Should(Equal(reporter2.BeginSummary))
+ Ω(reporter1.SpecWillRunSummaries).Should(Equal(reporter2.SpecWillRunSummaries))
+ Ω(reporter1.SpecSummaries).Should(Equal(reporter2.SpecSummaries))
+ Ω(reporter1.AfterSuiteSummary).Should(Equal(reporter2.AfterSuiteSummary))
+ Ω(reporter1.EndSummary).Should(Equal(reporter2.EndSummary))
+ })
+
+ It("should report that a spec did end in reverse order", func() {
+ Ω(willRunCalls[0:4]).Should(Equal([]string{"Reporter1", "Reporter2", "Reporter1", "Reporter2"}))
+ Ω(didCompleteCalls[0:4]).Should(Equal([]string{"Reporter2", "Reporter1", "Reporter2", "Reporter1"}))
+ })
+
+ It("should report the passed in config", func() {
+ Ω(reporter1.Config.RandomSeed).Should(BeNumerically("==", 17))
+ })
+
+ It("should report the beginning of the suite", func() {
+ Ω(reporter1.BeginSummary.SuiteDescription).Should(Equal("description"))
+ Ω(reporter1.BeginSummary.SuiteID).Should(MatchRegexp("[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}"))
+ Ω(reporter1.BeginSummary.NumberOfSpecsBeforeParallelization).Should(Equal(6))
+ Ω(reporter1.BeginSummary.NumberOfTotalSpecs).Should(Equal(6))
+ Ω(reporter1.BeginSummary.NumberOfSpecsThatWillBeRun).Should(Equal(3))
+ Ω(reporter1.BeginSummary.NumberOfPendingSpecs).Should(Equal(-1))
+ Ω(reporter1.BeginSummary.NumberOfSkippedSpecs).Should(Equal(-1))
+ })
+
+ It("should report the end of the suite", func() {
+ Ω(reporter1.EndSummary.SuiteDescription).Should(Equal("description"))
+ Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
+ Ω(reporter1.EndSummary.SuiteID).Should(MatchRegexp("[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}"))
+ Ω(reporter1.EndSummary.NumberOfSpecsBeforeParallelization).Should(Equal(6))
+ Ω(reporter1.EndSummary.NumberOfTotalSpecs).Should(Equal(6))
+ Ω(reporter1.EndSummary.NumberOfSpecsThatWillBeRun).Should(Equal(3))
+ Ω(reporter1.EndSummary.NumberOfPendingSpecs).Should(Equal(2))
+ Ω(reporter1.EndSummary.NumberOfSkippedSpecs).Should(Equal(1))
+ Ω(reporter1.EndSummary.NumberOfPassedSpecs).Should(Equal(2))
+ Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(1))
+ })
+
+ Context("when told to perform a dry run", func() {
+ BeforeEach(func() {
+ conf.DryRun = true
+ })
+
+ It("should report to the reporters", func() {
+ Ω(reporter1.Config).Should(Equal(reporter2.Config))
+ Ω(reporter1.BeforeSuiteSummary).Should(Equal(reporter2.BeforeSuiteSummary))
+ Ω(reporter1.BeginSummary).Should(Equal(reporter2.BeginSummary))
+ Ω(reporter1.SpecWillRunSummaries).Should(Equal(reporter2.SpecWillRunSummaries))
+ Ω(reporter1.SpecSummaries).Should(Equal(reporter2.SpecSummaries))
+ Ω(reporter1.AfterSuiteSummary).Should(Equal(reporter2.AfterSuiteSummary))
+ Ω(reporter1.EndSummary).Should(Equal(reporter2.EndSummary))
+ })
+
+ It("should not actually run anything", func() {
+ Ω(thingsThatRan).Should(BeEmpty())
+ })
+
+ It("report before and after suites as passed", func() {
+ Ω(reporter1.BeforeSuiteSummary.State).Should(Equal(types.SpecStatePassed))
+ Ω(reporter1.AfterSuiteSummary.State).Should(Equal(types.SpecStatePassed))
+ })
+
+ It("should report specs as passed", func() {
+ summaries := reporter1.SpecSummaries
+ Ω(summaries).Should(HaveLen(6))
+ Ω(summaries[0].ComponentTexts).Should(ContainElement("spec A"))
+ Ω(summaries[0].State).Should(Equal(types.SpecStatePassed))
+ Ω(summaries[1].ComponentTexts).Should(ContainElement("pending spec"))
+ Ω(summaries[1].State).Should(Equal(types.SpecStatePending))
+ Ω(summaries[2].ComponentTexts).Should(ContainElement("another pending spec"))
+ Ω(summaries[2].State).Should(Equal(types.SpecStatePending))
+ Ω(summaries[3].ComponentTexts).Should(ContainElement("failed spec"))
+ Ω(summaries[3].State).Should(Equal(types.SpecStatePassed))
+ Ω(summaries[4].ComponentTexts).Should(ContainElement("spec B"))
+ Ω(summaries[4].State).Should(Equal(types.SpecStatePassed))
+ Ω(summaries[5].ComponentTexts).Should(ContainElement("skipped spec"))
+ Ω(summaries[5].State).Should(Equal(types.SpecStateSkipped))
+ })
+
+ It("should report the end of the suite", func() {
+ Ω(reporter1.EndSummary.SuiteDescription).Should(Equal("description"))
+ Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeTrue())
+ Ω(reporter1.EndSummary.SuiteID).Should(MatchRegexp("[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}"))
+ Ω(reporter1.EndSummary.NumberOfSpecsBeforeParallelization).Should(Equal(6))
+ Ω(reporter1.EndSummary.NumberOfTotalSpecs).Should(Equal(6))
+ Ω(reporter1.EndSummary.NumberOfSpecsThatWillBeRun).Should(Equal(3))
+ Ω(reporter1.EndSummary.NumberOfPendingSpecs).Should(Equal(2))
+ Ω(reporter1.EndSummary.NumberOfSkippedSpecs).Should(Equal(1))
+ Ω(reporter1.EndSummary.NumberOfPassedSpecs).Should(Equal(0))
+ Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(0))
+ })
+
+ It("should not report a slow test", func() {
+ summaries := reporter1.SpecSummaries
+ for _, s := range summaries {
+ Expect(s.RunTime).To(BeZero())
+ }
+ })
+ })
+ })
+
+ Describe("reporting on specs", func() {
+ var proceed chan bool
+ var ready chan bool
+ var finished chan bool
+ BeforeEach(func() {
+ ready = make(chan bool)
+ proceed = make(chan bool)
+ finished = make(chan bool)
+ skippedSpec := newSpec("SKIP", noneFlag, false)
+ skippedSpec.Skip()
+
+ runner = newRunner(
+ config.GinkgoConfigType{},
+ newBefSuite("BefSuite", false),
+ newAftSuite("AftSuite", false),
+ skippedSpec,
+ newSpec("PENDING", pendingFlag, false),
+ newSpecWithBody("RUN", func() {
+ close(ready)
+ <-proceed
+ }),
+ )
+ go func() {
+ runner.Run()
+ close(finished)
+ }()
+ })
+
+ It("should report about pending/skipped specs", func() {
+ <-ready
+ Ω(reporter1.SpecWillRunSummaries).Should(HaveLen(3))
+
+ Ω(reporter1.SpecWillRunSummaries[0].ComponentTexts[0]).Should(Equal("SKIP"))
+ Ω(reporter1.SpecWillRunSummaries[1].ComponentTexts[0]).Should(Equal("PENDING"))
+ Ω(reporter1.SpecWillRunSummaries[2].ComponentTexts[0]).Should(Equal("RUN"))
+
+ Ω(reporter1.SpecSummaries[0].ComponentTexts[0]).Should(Equal("SKIP"))
+ Ω(reporter1.SpecSummaries[1].ComponentTexts[0]).Should(Equal("PENDING"))
+ Ω(reporter1.SpecSummaries).Should(HaveLen(2))
+
+ close(proceed)
+ <-finished
+
+ Ω(reporter1.SpecSummaries).Should(HaveLen(3))
+ Ω(reporter1.SpecSummaries[2].ComponentTexts[0]).Should(Equal("RUN"))
+ })
+ })
+
+ Describe("Running and Reporting when there's flakes", func() {
+ var specA, pendingSpec, flakySpec, failedSpec, specB, skippedSpec *spec.Spec
+ var willRunCalls, didCompleteCalls []string
+ var conf config.GinkgoConfigType
+ var failedSpecFlag = noneFlag
+
+ JustBeforeEach(func() {
+ willRunCalls = []string{}
+ didCompleteCalls = []string{}
+ specA = newSpec("spec A", noneFlag, false)
+ pendingSpec = newSpec("pending spec", pendingFlag, false)
+ flakySpec = newFlakySpec("flaky spec", noneFlag, 3)
+ failedSpec = newSpec("failed spec", failedSpecFlag, true)
+ specB = newSpec("spec B", noneFlag, false)
+ skippedSpec = newSpec("skipped spec", noneFlag, false)
+ skippedSpec.Skip()
+
+ reporter1.SpecWillRunStub = func(specSummary *types.SpecSummary) {
+ willRunCalls = append(willRunCalls, "Reporter1")
+ }
+ reporter2.SpecWillRunStub = func(specSummary *types.SpecSummary) {
+ willRunCalls = append(willRunCalls, "Reporter2")
+ }
+
+ reporter1.SpecDidCompleteStub = func(specSummary *types.SpecSummary) {
+ didCompleteCalls = append(didCompleteCalls, "Reporter1")
+ }
+ reporter2.SpecDidCompleteStub = func(specSummary *types.SpecSummary) {
+ didCompleteCalls = append(didCompleteCalls, "Reporter2")
+ }
+
+ runner = newRunner(conf, newBefSuite("BefSuite", false), newAftSuite("AftSuite", false), specA, pendingSpec, flakySpec, failedSpec, specB, skippedSpec)
+ runner.Run()
+ })
+
+ BeforeEach(func() {
+ failedSpecFlag = noneFlag
+ conf = config.GinkgoConfigType{
+ RandomSeed: 17,
+ FlakeAttempts: 5,
+ }
+ })
+
+ It("should skip skipped/pending tests", func() {
+ Ω(thingsThatRan).Should(Equal([]string{"BefSuite", "spec A", "flaky spec", "flaky spec", "flaky spec", "failed spec", "failed spec", "failed spec", "failed spec", "failed spec", "spec B", "AftSuite"}))
+ })
+
+ It("should report to any attached reporters", func() {
+ Ω(reporter1.Config).Should(Equal(reporter2.Config))
+ Ω(reporter1.BeforeSuiteSummary).Should(Equal(reporter2.BeforeSuiteSummary))
+ Ω(reporter1.BeginSummary).Should(Equal(reporter2.BeginSummary))
+ Ω(reporter1.SpecWillRunSummaries).Should(Equal(reporter2.SpecWillRunSummaries))
+ Ω(reporter1.SpecSummaries).Should(Equal(reporter2.SpecSummaries))
+ Ω(reporter1.AfterSuiteSummary).Should(Equal(reporter2.AfterSuiteSummary))
+ Ω(reporter1.EndSummary).Should(Equal(reporter2.EndSummary))
+ })
+
+ It("should report that a spec did end in reverse order", func() {
+ Ω(willRunCalls[0:4]).Should(Equal([]string{"Reporter1", "Reporter2", "Reporter1", "Reporter2"}))
+ Ω(didCompleteCalls[0:4]).Should(Equal([]string{"Reporter2", "Reporter1", "Reporter2", "Reporter1"}))
+ })
+
+ It("should report the passed in config", func() {
+ Ω(reporter1.Config.RandomSeed).Should(BeNumerically("==", 17))
+ })
+
+ It("should report the beginning of the suite", func() {
+ Ω(reporter1.BeginSummary.SuiteDescription).Should(Equal("description"))
+ Ω(reporter1.BeginSummary.SuiteID).Should(MatchRegexp("[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}"))
+ Ω(reporter1.BeginSummary.NumberOfSpecsBeforeParallelization).Should(Equal(6))
+ Ω(reporter1.BeginSummary.NumberOfTotalSpecs).Should(Equal(6))
+ Ω(reporter1.BeginSummary.NumberOfSpecsThatWillBeRun).Should(Equal(4))
+ Ω(reporter1.BeginSummary.NumberOfPendingSpecs).Should(Equal(-1))
+ Ω(reporter1.BeginSummary.NumberOfSkippedSpecs).Should(Equal(-1))
+ })
+
+ It("should report the end of the suite", func() {
+ Ω(reporter1.EndSummary.SuiteDescription).Should(Equal("description"))
+ Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
+ Ω(reporter1.EndSummary.SuiteID).Should(MatchRegexp("[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}"))
+ Ω(reporter1.EndSummary.NumberOfSpecsBeforeParallelization).Should(Equal(6))
+ Ω(reporter1.EndSummary.NumberOfTotalSpecs).Should(Equal(6))
+ Ω(reporter1.EndSummary.NumberOfSpecsThatWillBeRun).Should(Equal(4))
+ Ω(reporter1.EndSummary.NumberOfPendingSpecs).Should(Equal(1))
+ Ω(reporter1.EndSummary.NumberOfSkippedSpecs).Should(Equal(1))
+ Ω(reporter1.EndSummary.NumberOfPassedSpecs).Should(Equal(3))
+ Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(1))
+ Ω(reporter1.EndSummary.NumberOfFlakedSpecs).Should(Equal(1))
+ })
+
+ Context("when nothing fails", func() {
+ BeforeEach(func() {
+ failedSpecFlag = pendingFlag
+ })
+
+ It("the suite should pass even with flakes", func() {
+ Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeTrue())
+ Ω(reporter1.EndSummary.NumberOfFlakedSpecs).Should(Equal(1))
+ })
+ })
+
+ Context("when told to perform a dry run", func() {
+ BeforeEach(func() {
+ conf.DryRun = true
+ })
+
+ It("should report to the reporters", func() {
+ Ω(reporter1.Config).Should(Equal(reporter2.Config))
+ Ω(reporter1.BeforeSuiteSummary).Should(Equal(reporter2.BeforeSuiteSummary))
+ Ω(reporter1.BeginSummary).Should(Equal(reporter2.BeginSummary))
+ Ω(reporter1.SpecWillRunSummaries).Should(Equal(reporter2.SpecWillRunSummaries))
+ Ω(reporter1.SpecSummaries).Should(Equal(reporter2.SpecSummaries))
+ Ω(reporter1.AfterSuiteSummary).Should(Equal(reporter2.AfterSuiteSummary))
+ Ω(reporter1.EndSummary).Should(Equal(reporter2.EndSummary))
+ })
+
+ It("should not actually run anything", func() {
+ Ω(thingsThatRan).Should(BeEmpty())
+ })
+
+ It("report before and after suites as passed", func() {
+ Ω(reporter1.BeforeSuiteSummary.State).Should(Equal(types.SpecStatePassed))
+ Ω(reporter1.AfterSuiteSummary.State).Should(Equal(types.SpecStatePassed))
+ })
+
+ It("should report specs as passed", func() {
+ summaries := reporter1.SpecSummaries
+ Ω(summaries).Should(HaveLen(6))
+ Ω(summaries[0].ComponentTexts).Should(ContainElement("spec A"))
+ Ω(summaries[0].State).Should(Equal(types.SpecStatePassed))
+ Ω(summaries[1].ComponentTexts).Should(ContainElement("pending spec"))
+ Ω(summaries[1].State).Should(Equal(types.SpecStatePending))
+ Ω(summaries[2].ComponentTexts).Should(ContainElement("flaky spec"))
+ Ω(summaries[2].State).Should(Equal(types.SpecStatePassed))
+ Ω(summaries[3].ComponentTexts).Should(ContainElement("failed spec"))
+ Ω(summaries[3].State).Should(Equal(types.SpecStatePassed))
+ Ω(summaries[4].ComponentTexts).Should(ContainElement("spec B"))
+ Ω(summaries[4].State).Should(Equal(types.SpecStatePassed))
+ Ω(summaries[5].ComponentTexts).Should(ContainElement("skipped spec"))
+ Ω(summaries[5].State).Should(Equal(types.SpecStateSkipped))
+ })
+
+ It("should report the end of the suite", func() {
+ Ω(reporter1.EndSummary.SuiteDescription).Should(Equal("description"))
+ Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeTrue())
+ Ω(reporter1.EndSummary.SuiteID).Should(MatchRegexp("[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}"))
+ Ω(reporter1.EndSummary.NumberOfSpecsBeforeParallelization).Should(Equal(6))
+ Ω(reporter1.EndSummary.NumberOfTotalSpecs).Should(Equal(6))
+ Ω(reporter1.EndSummary.NumberOfSpecsThatWillBeRun).Should(Equal(4))
+ Ω(reporter1.EndSummary.NumberOfPendingSpecs).Should(Equal(1))
+ Ω(reporter1.EndSummary.NumberOfSkippedSpecs).Should(Equal(1))
+ Ω(reporter1.EndSummary.NumberOfPassedSpecs).Should(Equal(0))
+ Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(0))
+ })
+ })
+ })
+
+ Describe("Running BeforeSuite & AfterSuite", func() {
+ var success bool
+ var befSuite leafnodes.SuiteNode
+ var aftSuite leafnodes.SuiteNode
+ Context("with a nil BeforeSuite & AfterSuite", func() {
+ BeforeEach(func() {
+ runner = newRunner(
+ config.GinkgoConfigType{},
+ nil,
+ nil,
+ newSpec("A", noneFlag, false),
+ newSpec("B", noneFlag, false),
+ )
+ success = runner.Run()
+ })
+
+ It("should not report about the BeforeSuite", func() {
+ Ω(reporter1.BeforeSuiteSummary).Should(BeNil())
+ })
+
+ It("should not report about the AfterSuite", func() {
+ Ω(reporter1.AfterSuiteSummary).Should(BeNil())
+ })
+
+ It("should run the specs", func() {
+ Ω(thingsThatRan).Should(Equal([]string{"A", "B"}))
+ })
+ })
+
+ Context("when the BeforeSuite & AfterSuite pass", func() {
+ BeforeEach(func() {
+ befSuite = newBefSuite("BefSuite", false)
+ aftSuite = newBefSuite("AftSuite", false)
+ runner = newRunner(
+ config.GinkgoConfigType{},
+ befSuite,
+ aftSuite,
+ newSpec("A", noneFlag, false),
+ newSpec("B", noneFlag, false),
+ )
+ success = runner.Run()
+ })
+
+ It("should run the BeforeSuite, the AfterSuite and the specs", func() {
+ Ω(thingsThatRan).Should(Equal([]string{"BefSuite", "A", "B", "AftSuite"}))
+ })
+
+ It("should report about the BeforeSuite", func() {
+ Ω(reporter1.BeforeSuiteSummary).Should(Equal(befSuite.Summary()))
+ })
+
+ It("should report about the AfterSuite", func() {
+ Ω(reporter1.AfterSuiteSummary).Should(Equal(aftSuite.Summary()))
+ })
+
+ It("should report success", func() {
+ Ω(success).Should(BeTrue())
+ Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeTrue())
+ Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(0))
+ })
+
+ It("should not dump the writer", func() {
+ Ω(writer.EventStream).ShouldNot(ContainElement("DUMP"))
+ })
+ })
+
+ Context("when the BeforeSuite fails", func() {
+ BeforeEach(func() {
+ befSuite = newBefSuite("BefSuite", true)
+ aftSuite = newBefSuite("AftSuite", false)
+
+ skipped := newSpec("Skipped", noneFlag, false)
+ skipped.Skip()
+
+ runner = newRunner(
+ config.GinkgoConfigType{},
+ befSuite,
+ aftSuite,
+ newSpec("A", noneFlag, false),
+ newSpec("B", noneFlag, false),
+ newSpec("Pending", pendingFlag, false),
+ skipped,
+ )
+ success = runner.Run()
+ })
+
+ It("should not run the specs, but it should run the AfterSuite", func() {
+ Ω(thingsThatRan).Should(Equal([]string{"BefSuite", "AftSuite"}))
+ })
+
+ It("should report about the BeforeSuite", func() {
+ Ω(reporter1.BeforeSuiteSummary).Should(Equal(befSuite.Summary()))
+ })
+
+ It("should report about the AfterSuite", func() {
+ Ω(reporter1.AfterSuiteSummary).Should(Equal(aftSuite.Summary()))
+ })
+
+ It("should report failure", func() {
+ Ω(success).Should(BeFalse())
+ Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
+ Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(2))
+ Ω(reporter1.EndSummary.NumberOfSpecsThatWillBeRun).Should(Equal(2))
+ })
+
+ It("should dump the writer", func() {
+ Ω(writer.EventStream).Should(ContainElement("DUMP"))
+ })
+ })
+
+ Context("when some other test fails", func() {
+ BeforeEach(func() {
+ aftSuite = newBefSuite("AftSuite", false)
+
+ runner = newRunner(
+ config.GinkgoConfigType{},
+ nil,
+ aftSuite,
+ newSpec("A", noneFlag, true),
+ )
+ success = runner.Run()
+ })
+
+ It("should still run the AfterSuite", func() {
+ Ω(thingsThatRan).Should(Equal([]string{"A", "AftSuite"}))
+ })
+
+ It("should report about the AfterSuite", func() {
+ Ω(reporter1.AfterSuiteSummary).Should(Equal(aftSuite.Summary()))
+ })
+
+ It("should report failure", func() {
+ Ω(success).Should(BeFalse())
+ Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
+ Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(1))
+ Ω(reporter1.EndSummary.NumberOfSpecsThatWillBeRun).Should(Equal(1))
+ })
+ })
+
+ Context("when the AfterSuite fails", func() {
+ BeforeEach(func() {
+ befSuite = newBefSuite("BefSuite", false)
+ aftSuite = newBefSuite("AftSuite", true)
+ runner = newRunner(
+ config.GinkgoConfigType{},
+ befSuite,
+ aftSuite,
+ newSpec("A", noneFlag, false),
+ newSpec("B", noneFlag, false),
+ )
+ success = runner.Run()
+ })
+
+ It("should run everything", func() {
+ Ω(thingsThatRan).Should(Equal([]string{"BefSuite", "A", "B", "AftSuite"}))
+ })
+
+ It("should report about the BeforeSuite", func() {
+ Ω(reporter1.BeforeSuiteSummary).Should(Equal(befSuite.Summary()))
+ })
+
+ It("should report about the AfterSuite", func() {
+ Ω(reporter1.AfterSuiteSummary).Should(Equal(aftSuite.Summary()))
+ })
+
+ It("should report failure", func() {
+ Ω(success).Should(BeFalse())
+ Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
+ Ω(reporter1.EndSummary.NumberOfFailedSpecs).Should(Equal(0))
+ })
+
+ It("should dump the writer", func() {
+ Ω(writer.EventStream).Should(ContainElement("DUMP"))
+ })
+ })
+ })
+
+ Describe("When instructed to fail fast", func() {
+ BeforeEach(func() {
+ conf := config.GinkgoConfigType{
+ FailFast: true,
+ }
+ runner = newRunner(conf, nil, newAftSuite("after-suite", false), newSpec("passing", noneFlag, false), newSpec("failing", noneFlag, true), newSpec("dont-see", noneFlag, true), newSpec("dont-see", noneFlag, true))
+ })
+
+ It("should return false, report failure, and not run anything past the failing test", func() {
+ Ω(runner.Run()).Should(BeFalse())
+ Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
+ Ω(thingsThatRan).Should(Equal([]string{"passing", "failing", "after-suite"}))
+ })
+
+ It("should announce the subsequent specs as skipped", func() {
+ runner.Run()
+ Ω(reporter1.SpecSummaries).Should(HaveLen(4))
+ Ω(reporter1.SpecSummaries[2].State).Should(Equal(types.SpecStateSkipped))
+ Ω(reporter1.SpecSummaries[3].State).Should(Equal(types.SpecStateSkipped))
+ })
+
+ It("should mark all subsequent specs as skipped", func() {
+ runner.Run()
+ Ω(reporter1.EndSummary.NumberOfSkippedSpecs).Should(Equal(2))
+ })
+ })
+
+ Describe("Marking failure and success", func() {
+ Context("when all tests pass", func() {
+ BeforeEach(func() {
+ runner = newRunner(config.GinkgoConfigType{}, nil, nil, newSpec("passing", noneFlag, false), newSpec("pending", pendingFlag, false))
+ })
+
+ It("should return true and report success", func() {
+ Ω(runner.Run()).Should(BeTrue())
+ Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeTrue())
+ })
+ })
+
+ Context("when a test fails", func() {
+ BeforeEach(func() {
+ runner = newRunner(config.GinkgoConfigType{}, nil, nil, newSpec("failing", noneFlag, true), newSpec("pending", pendingFlag, false))
+ })
+
+ It("should return false and report failure", func() {
+ Ω(runner.Run()).Should(BeFalse())
+ Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
+ })
+ })
+
+ Context("when there is a pending test, but pendings count as failures", func() {
+ BeforeEach(func() {
+ runner = newRunner(config.GinkgoConfigType{FailOnPending: true}, nil, nil, newSpec("passing", noneFlag, false), newSpec("pending", pendingFlag, false))
+ })
+
+ It("should return false and report failure", func() {
+ Ω(runner.Run()).Should(BeFalse())
+ Ω(reporter1.EndSummary.SuiteSucceeded).Should(BeFalse())
+ })
+ })
+ })
+
+ Describe("Managing the writer", func() {
+ BeforeEach(func() {
+ runner = newRunner(
+ config.GinkgoConfigType{},
+ nil,
+ nil,
+ newSpec("A", noneFlag, false),
+ newSpec("B", noneFlag, true),
+ newSpec("C", noneFlag, false),
+ )
+ reporter1.SpecWillRunStub = func(specSummary *types.SpecSummary) {
+ writer.AddEvent("R1.WillRun")
+ }
+ reporter2.SpecWillRunStub = func(specSummary *types.SpecSummary) {
+ writer.AddEvent("R2.WillRun")
+ }
+ reporter1.SpecDidCompleteStub = func(specSummary *types.SpecSummary) {
+ writer.AddEvent("R1.DidComplete")
+ }
+ reporter2.SpecDidCompleteStub = func(specSummary *types.SpecSummary) {
+ writer.AddEvent("R2.DidComplete")
+ }
+ runner.Run()
+ })
+
+ It("should truncate between tests, but only dump if a test fails", func() {
+ Ω(writer.EventStream).Should(Equal([]string{
+ "TRUNCATE",
+ "R1.WillRun",
+ "R2.WillRun",
+ "A",
+ "R2.DidComplete",
+ "R1.DidComplete",
+ "TRUNCATE",
+ "R1.WillRun",
+ "R2.WillRun",
+ "B",
+ "BYTES",
+ "R2.DidComplete",
+ "DUMP",
+ "R1.DidComplete",
+ "TRUNCATE",
+ "R1.WillRun",
+ "R2.WillRun",
+ "C",
+ "R2.DidComplete",
+ "R1.DidComplete",
+ }))
+ })
+ })
+
+ Describe("CurrentSpecSummary", func() {
+ It("should return the spec summary for the currently running spec", func() {
+ var summary *types.SpecSummary
+ runner = newRunner(
+ config.GinkgoConfigType{},
+ nil,
+ nil,
+ newSpec("A", noneFlag, false),
+ newSpecWithBody("B", func() {
+ var ok bool
+ summary, ok = runner.CurrentSpecSummary()
+ Ω(ok).Should(BeTrue())
+ }),
+ newSpec("C", noneFlag, false),
+ )
+ runner.Run()
+
+ Ω(summary.ComponentTexts).Should(Equal([]string{"B"}))
+
+ summary, ok := runner.CurrentSpecSummary()
+ Ω(summary).Should(BeNil())
+ Ω(ok).Should(BeFalse())
+ })
+ })
+
+ Describe("generating a suite id", func() {
+ It("should generate an id randomly", func() {
+ runnerA := newRunner(config.GinkgoConfigType{}, nil, nil)
+ runnerA.Run()
+ IDA := reporter1.BeginSummary.SuiteID
+
+ runnerB := newRunner(config.GinkgoConfigType{}, nil, nil)
+ runnerB.Run()
+ IDB := reporter1.BeginSummary.SuiteID
+
+ IDRegexp := "[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}"
+ Ω(IDA).Should(MatchRegexp(IDRegexp))
+ Ω(IDB).Should(MatchRegexp(IDRegexp))
+
+ Ω(IDA).ShouldNot(Equal(IDB))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/suite/suite.go b/vendor/github.com/onsi/ginkgo/internal/suite/suite.go
new file mode 100644
index 000000000..3104bbc88
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/suite/suite.go
@@ -0,0 +1,190 @@
+package suite
+
+import (
+ "math/rand"
+ "net/http"
+ "time"
+
+ "github.com/onsi/ginkgo/internal/spec_iterator"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/internal/containernode"
+ "github.com/onsi/ginkgo/internal/failer"
+ "github.com/onsi/ginkgo/internal/leafnodes"
+ "github.com/onsi/ginkgo/internal/spec"
+ "github.com/onsi/ginkgo/internal/specrunner"
+ "github.com/onsi/ginkgo/internal/writer"
+ "github.com/onsi/ginkgo/reporters"
+ "github.com/onsi/ginkgo/types"
+)
+
+type ginkgoTestingT interface {
+ Fail()
+}
+
+type Suite struct {
+ topLevelContainer *containernode.ContainerNode
+ currentContainer *containernode.ContainerNode
+ containerIndex int
+ beforeSuiteNode leafnodes.SuiteNode
+ afterSuiteNode leafnodes.SuiteNode
+ runner *specrunner.SpecRunner
+ failer *failer.Failer
+ running bool
+}
+
+func New(failer *failer.Failer) *Suite {
+ topLevelContainer := containernode.New("[Top Level]", types.FlagTypeNone, types.CodeLocation{})
+
+ return &Suite{
+ topLevelContainer: topLevelContainer,
+ currentContainer: topLevelContainer,
+ failer: failer,
+ containerIndex: 1,
+ }
+}
+
+func (suite *Suite) Run(t ginkgoTestingT, description string, reporters []reporters.Reporter, writer writer.WriterInterface, config config.GinkgoConfigType) (bool, bool) {
+ if config.ParallelTotal < 1 {
+ panic("ginkgo.parallel.total must be >= 1")
+ }
+
+ if config.ParallelNode > config.ParallelTotal || config.ParallelNode < 1 {
+ panic("ginkgo.parallel.node is one-indexed and must be <= ginkgo.parallel.total")
+ }
+
+ r := rand.New(rand.NewSource(config.RandomSeed))
+ suite.topLevelContainer.Shuffle(r)
+ iterator, hasProgrammaticFocus := suite.generateSpecsIterator(description, config)
+ suite.runner = specrunner.New(description, suite.beforeSuiteNode, iterator, suite.afterSuiteNode, reporters, writer, config)
+
+ suite.running = true
+ success := suite.runner.Run()
+ if !success {
+ t.Fail()
+ }
+ return success, hasProgrammaticFocus
+}
+
+func (suite *Suite) generateSpecsIterator(description string, config config.GinkgoConfigType) (spec_iterator.SpecIterator, bool) {
+ specsSlice := []*spec.Spec{}
+ suite.topLevelContainer.BackPropagateProgrammaticFocus()
+ for _, collatedNodes := range suite.topLevelContainer.Collate() {
+ specsSlice = append(specsSlice, spec.New(collatedNodes.Subject, collatedNodes.Containers, config.EmitSpecProgress))
+ }
+
+ specs := spec.NewSpecs(specsSlice)
+ specs.RegexScansFilePath = config.RegexScansFilePath
+
+ if config.RandomizeAllSpecs {
+ specs.Shuffle(rand.New(rand.NewSource(config.RandomSeed)))
+ }
+
+ specs.ApplyFocus(description, config.FocusString, config.SkipString)
+
+ if config.SkipMeasurements {
+ specs.SkipMeasurements()
+ }
+
+ var iterator spec_iterator.SpecIterator
+
+ if config.ParallelTotal > 1 {
+ iterator = spec_iterator.NewParallelIterator(specs.Specs(), config.SyncHost)
+ resp, err := http.Get(config.SyncHost + "/has-counter")
+ if err != nil || resp.StatusCode != http.StatusOK {
+ iterator = spec_iterator.NewShardedParallelIterator(specs.Specs(), config.ParallelTotal, config.ParallelNode)
+ }
+ } else {
+ iterator = spec_iterator.NewSerialIterator(specs.Specs())
+ }
+
+ return iterator, specs.HasProgrammaticFocus()
+}
+
+func (suite *Suite) CurrentRunningSpecSummary() (*types.SpecSummary, bool) {
+ return suite.runner.CurrentSpecSummary()
+}
+
+func (suite *Suite) SetBeforeSuiteNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration) {
+ if suite.beforeSuiteNode != nil {
+ panic("You may only call BeforeSuite once!")
+ }
+ suite.beforeSuiteNode = leafnodes.NewBeforeSuiteNode(body, codeLocation, timeout, suite.failer)
+}
+
+func (suite *Suite) SetAfterSuiteNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration) {
+ if suite.afterSuiteNode != nil {
+ panic("You may only call AfterSuite once!")
+ }
+ suite.afterSuiteNode = leafnodes.NewAfterSuiteNode(body, codeLocation, timeout, suite.failer)
+}
+
+func (suite *Suite) SetSynchronizedBeforeSuiteNode(bodyA interface{}, bodyB interface{}, codeLocation types.CodeLocation, timeout time.Duration) {
+ if suite.beforeSuiteNode != nil {
+ panic("You may only call BeforeSuite once!")
+ }
+ suite.beforeSuiteNode = leafnodes.NewSynchronizedBeforeSuiteNode(bodyA, bodyB, codeLocation, timeout, suite.failer)
+}
+
+func (suite *Suite) SetSynchronizedAfterSuiteNode(bodyA interface{}, bodyB interface{}, codeLocation types.CodeLocation, timeout time.Duration) {
+ if suite.afterSuiteNode != nil {
+ panic("You may only call AfterSuite once!")
+ }
+ suite.afterSuiteNode = leafnodes.NewSynchronizedAfterSuiteNode(bodyA, bodyB, codeLocation, timeout, suite.failer)
+}
+
+func (suite *Suite) PushContainerNode(text string, body func(), flag types.FlagType, codeLocation types.CodeLocation) {
+ container := containernode.New(text, flag, codeLocation)
+ suite.currentContainer.PushContainerNode(container)
+
+ previousContainer := suite.currentContainer
+ suite.currentContainer = container
+ suite.containerIndex++
+
+ body()
+
+ suite.containerIndex--
+ suite.currentContainer = previousContainer
+}
+
+func (suite *Suite) PushItNode(text string, body interface{}, flag types.FlagType, codeLocation types.CodeLocation, timeout time.Duration) {
+ if suite.running {
+ suite.failer.Fail("You may only call It from within a Describe, Context or When", codeLocation)
+ }
+ suite.currentContainer.PushSubjectNode(leafnodes.NewItNode(text, body, flag, codeLocation, timeout, suite.failer, suite.containerIndex))
+}
+
+func (suite *Suite) PushMeasureNode(text string, body interface{}, flag types.FlagType, codeLocation types.CodeLocation, samples int) {
+ if suite.running {
+ suite.failer.Fail("You may only call Measure from within a Describe, Context or When", codeLocation)
+ }
+ suite.currentContainer.PushSubjectNode(leafnodes.NewMeasureNode(text, body, flag, codeLocation, samples, suite.failer, suite.containerIndex))
+}
+
+func (suite *Suite) PushBeforeEachNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration) {
+ if suite.running {
+ suite.failer.Fail("You may only call BeforeEach from within a Describe, Context or When", codeLocation)
+ }
+ suite.currentContainer.PushSetupNode(leafnodes.NewBeforeEachNode(body, codeLocation, timeout, suite.failer, suite.containerIndex))
+}
+
+func (suite *Suite) PushJustBeforeEachNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration) {
+ if suite.running {
+ suite.failer.Fail("You may only call JustBeforeEach from within a Describe, Context or When", codeLocation)
+ }
+ suite.currentContainer.PushSetupNode(leafnodes.NewJustBeforeEachNode(body, codeLocation, timeout, suite.failer, suite.containerIndex))
+}
+
+func (suite *Suite) PushJustAfterEachNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration) {
+ if suite.running {
+ suite.failer.Fail("You may only call JustAfterEach from within a Describe or Context", codeLocation)
+ }
+ suite.currentContainer.PushSetupNode(leafnodes.NewJustAfterEachNode(body, codeLocation, timeout, suite.failer, suite.containerIndex))
+}
+
+func (suite *Suite) PushAfterEachNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration) {
+ if suite.running {
+ suite.failer.Fail("You may only call AfterEach from within a Describe, Context or When", codeLocation)
+ }
+ suite.currentContainer.PushSetupNode(leafnodes.NewAfterEachNode(body, codeLocation, timeout, suite.failer, suite.containerIndex))
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/suite/suite_suite_test.go b/vendor/github.com/onsi/ginkgo/internal/suite/suite_suite_test.go
new file mode 100644
index 000000000..06fe1d12a
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/suite/suite_suite_test.go
@@ -0,0 +1,35 @@
+package suite_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func Test(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Suite")
+}
+
+var numBeforeSuiteRuns = 0
+var numAfterSuiteRuns = 0
+
+var _ = BeforeSuite(func() {
+ numBeforeSuiteRuns++
+})
+
+var _ = AfterSuite(func() {
+ numAfterSuiteRuns++
+ Ω(numBeforeSuiteRuns).Should(Equal(1))
+ Ω(numAfterSuiteRuns).Should(Equal(1))
+})
+
+//Fakes
+type fakeTestingT struct {
+ didFail bool
+}
+
+func (fakeT *fakeTestingT) Fail() {
+ fakeT.didFail = true
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/suite/suite_test.go b/vendor/github.com/onsi/ginkgo/internal/suite/suite_test.go
new file mode 100644
index 000000000..fd2d11dc3
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/suite/suite_test.go
@@ -0,0 +1,385 @@
+package suite_test
+
+import (
+ "bytes"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/internal/suite"
+ . "github.com/onsi/gomega"
+
+ "math/rand"
+ "time"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/internal/codelocation"
+ Failer "github.com/onsi/ginkgo/internal/failer"
+ Writer "github.com/onsi/ginkgo/internal/writer"
+ "github.com/onsi/ginkgo/reporters"
+ "github.com/onsi/ginkgo/types"
+)
+
+var _ = Describe("Suite", func() {
+ var (
+ specSuite *Suite
+ fakeT *fakeTestingT
+ fakeR *reporters.FakeReporter
+ writer *Writer.FakeGinkgoWriter
+ failer *Failer.Failer
+ )
+
+ BeforeEach(func() {
+ writer = Writer.NewFake()
+ fakeT = &fakeTestingT{}
+ fakeR = reporters.NewFakeReporter()
+ failer = Failer.New()
+ specSuite = New(failer)
+ })
+
+ Describe("running a suite", func() {
+ var (
+ runOrder []string
+ randomizeAllSpecs bool
+ randomSeed int64
+ focusString string
+ parallelNode int
+ parallelTotal int
+ runResult bool
+ hasProgrammaticFocus bool
+ )
+
+ var f = func(runText string) func() {
+ return func() {
+ runOrder = append(runOrder, runText)
+ }
+ }
+
+ BeforeEach(func() {
+ randomizeAllSpecs = false
+ randomSeed = 11
+ parallelNode = 1
+ parallelTotal = 1
+ focusString = ""
+
+ runOrder = make([]string, 0)
+ specSuite.SetBeforeSuiteNode(f("BeforeSuite"), codelocation.New(0), 0)
+ specSuite.PushBeforeEachNode(f("top BE"), codelocation.New(0), 0)
+ specSuite.PushJustBeforeEachNode(f("top JBE"), codelocation.New(0), 0)
+ specSuite.PushAfterEachNode(f("top AE"), codelocation.New(0), 0)
+
+ specSuite.PushContainerNode("container", func() {
+ specSuite.PushBeforeEachNode(f("BE"), codelocation.New(0), 0)
+ specSuite.PushJustBeforeEachNode(f("JBE"), codelocation.New(0), 0)
+ specSuite.PushAfterEachNode(f("AE"), codelocation.New(0), 0)
+ specSuite.PushItNode("it", f("IT"), types.FlagTypeNone, codelocation.New(0), 0)
+
+ specSuite.PushContainerNode("inner container", func() {
+ specSuite.PushItNode("inner it", f("inner IT"), types.FlagTypeNone, codelocation.New(0), 0)
+ }, types.FlagTypeNone, codelocation.New(0))
+ }, types.FlagTypeNone, codelocation.New(0))
+
+ specSuite.PushContainerNode("container 2", func() {
+ specSuite.PushBeforeEachNode(f("BE 2"), codelocation.New(0), 0)
+ specSuite.PushItNode("it 2", f("IT 2"), types.FlagTypeNone, codelocation.New(0), 0)
+ }, types.FlagTypeNone, codelocation.New(0))
+
+ specSuite.PushItNode("top level it", f("top IT"), types.FlagTypeNone, codelocation.New(0), 0)
+
+ specSuite.SetAfterSuiteNode(f("AfterSuite"), codelocation.New(0), 0)
+ })
+
+ JustBeforeEach(func() {
+ runResult, hasProgrammaticFocus = specSuite.Run(fakeT, "suite description", []reporters.Reporter{fakeR}, writer, config.GinkgoConfigType{
+ RandomSeed: randomSeed,
+ RandomizeAllSpecs: randomizeAllSpecs,
+ FocusString: focusString,
+ ParallelNode: parallelNode,
+ ParallelTotal: parallelTotal,
+ })
+ })
+
+ It("provides the config and suite description to the reporter", func() {
+ Ω(fakeR.Config.RandomSeed).Should(Equal(int64(randomSeed)))
+ Ω(fakeR.Config.RandomizeAllSpecs).Should(Equal(randomizeAllSpecs))
+ Ω(fakeR.BeginSummary.SuiteDescription).Should(Equal("suite description"))
+ })
+
+ It("reports that the BeforeSuite node ran", func() {
+ Ω(fakeR.BeforeSuiteSummary).ShouldNot(BeNil())
+ })
+
+ It("reports that the AfterSuite node ran", func() {
+ Ω(fakeR.AfterSuiteSummary).ShouldNot(BeNil())
+ })
+
+ It("provides information about the current test", func() {
+ description := CurrentGinkgoTestDescription()
+ Ω(description.ComponentTexts).Should(Equal([]string{"Suite", "running a suite", "provides information about the current test"}))
+ Ω(description.FullTestText).Should(Equal("Suite running a suite provides information about the current test"))
+ Ω(description.TestText).Should(Equal("provides information about the current test"))
+ Ω(description.IsMeasurement).Should(BeFalse())
+ Ω(description.FileName).Should(ContainSubstring("suite_test.go"))
+ Ω(description.LineNumber).Should(BeNumerically(">", 50))
+ Ω(description.LineNumber).Should(BeNumerically("<", 150))
+ Ω(description.Failed).Should(BeFalse())
+ Ω(description.Duration).Should(BeNumerically(">", 0))
+ })
+
+ Measure("should run measurements", func(b Benchmarker) {
+ r := rand.New(rand.NewSource(time.Now().UnixNano()))
+
+ runtime := b.Time("sleeping", func() {
+ sleepTime := time.Duration(r.Float64() * 0.01 * float64(time.Second))
+ time.Sleep(sleepTime)
+ })
+ Ω(runtime.Seconds()).Should(BeNumerically("<=", 1))
+ Ω(runtime.Seconds()).Should(BeNumerically(">=", 0))
+
+ randomValue := r.Float64() * 10.0
+ b.RecordValue("random value", randomValue)
+ Ω(randomValue).Should(BeNumerically("<=", 10.0))
+ Ω(randomValue).Should(BeNumerically(">=", 0.0))
+
+ b.RecordValueWithPrecision("specific value", 123.4567, "ms", 2)
+ b.RecordValueWithPrecision("specific value", 234.5678, "ms", 2)
+ }, 10)
+
+ It("creates a node hierarchy, converts it to a spec collection, and runs it", func() {
+ Ω(runOrder).Should(Equal([]string{
+ "BeforeSuite",
+ "top BE", "BE", "top JBE", "JBE", "IT", "AE", "top AE",
+ "top BE", "BE", "top JBE", "JBE", "inner IT", "AE", "top AE",
+ "top BE", "BE 2", "top JBE", "IT 2", "top AE",
+ "top BE", "top JBE", "top IT", "top AE",
+ "AfterSuite",
+ }))
+ })
+ Context("when in an AfterEach block", func() {
+ AfterEach(func() {
+ description := CurrentGinkgoTestDescription()
+ Ω(description.IsMeasurement).Should(BeFalse())
+ Ω(description.FileName).Should(ContainSubstring("suite_test.go"))
+ Ω(description.Failed).Should(BeFalse())
+ Ω(description.Duration).Should(BeNumerically(">", 0))
+ })
+
+ It("still provides information about the current test", func() {
+ Ω(true).To(BeTrue())
+ })
+ })
+
+ Context("when told to randomize all specs", func() {
+ BeforeEach(func() {
+ randomizeAllSpecs = true
+ })
+
+ It("does", func() {
+ Ω(runOrder).Should(Equal([]string{
+ "BeforeSuite",
+ "top BE", "top JBE", "top IT", "top AE",
+ "top BE", "BE", "top JBE", "JBE", "inner IT", "AE", "top AE",
+ "top BE", "BE", "top JBE", "JBE", "IT", "AE", "top AE",
+ "top BE", "BE 2", "top JBE", "IT 2", "top AE",
+ "AfterSuite",
+ }))
+ })
+ })
+
+ Context("when provided with a filter", func() {
+ BeforeEach(func() {
+ focusString = `inner|\d`
+ })
+
+ It("converts the filter to a regular expression and uses it to filter the running specs", func() {
+ Ω(runOrder).Should(Equal([]string{
+ "BeforeSuite",
+ "top BE", "BE", "top JBE", "JBE", "inner IT", "AE", "top AE",
+ "top BE", "BE 2", "top JBE", "IT 2", "top AE",
+ "AfterSuite",
+ }))
+ })
+
+ It("should not report a programmatic focus", func() {
+ Ω(hasProgrammaticFocus).Should(BeFalse())
+ })
+ })
+
+ Context("with a programatically focused spec", func() {
+ BeforeEach(func() {
+ specSuite.PushItNode("focused it", f("focused it"), types.FlagTypeFocused, codelocation.New(0), 0)
+
+ specSuite.PushContainerNode("focused container", func() {
+ specSuite.PushItNode("inner focused it", f("inner focused it"), types.FlagTypeFocused, codelocation.New(0), 0)
+ specSuite.PushItNode("inner unfocused it", f("inner unfocused it"), types.FlagTypeNone, codelocation.New(0), 0)
+ }, types.FlagTypeFocused, codelocation.New(0))
+
+ })
+
+ It("should only run the focused test, applying backpropagation to favor most deeply focused leaf nodes", func() {
+ Ω(runOrder).Should(Equal([]string{
+ "BeforeSuite",
+ "top BE", "top JBE", "focused it", "top AE",
+ "top BE", "top JBE", "inner focused it", "top AE",
+ "AfterSuite",
+ }))
+ })
+
+ It("should report a programmatic focus", func() {
+ Ω(hasProgrammaticFocus).Should(BeTrue())
+ })
+ })
+
+ Context("when the specs pass", func() {
+ It("doesn't report a failure", func() {
+ Ω(fakeT.didFail).Should(BeFalse())
+ })
+
+ It("should return true", func() {
+ Ω(runResult).Should(BeTrue())
+ })
+ })
+
+ Context("when a spec fails", func() {
+ var location types.CodeLocation
+ BeforeEach(func() {
+ specSuite.PushItNode("top level it", func() {
+ location = codelocation.New(0)
+ failer.Fail("oops!", location)
+ }, types.FlagTypeNone, codelocation.New(0), 0)
+ })
+
+ It("should return false", func() {
+ Ω(runResult).Should(BeFalse())
+ })
+
+ It("reports a failure", func() {
+ Ω(fakeT.didFail).Should(BeTrue())
+ })
+
+ It("generates the correct failure data", func() {
+ Ω(fakeR.SpecSummaries[0].Failure.Message).Should(Equal("oops!"))
+ Ω(fakeR.SpecSummaries[0].Failure.Location).Should(Equal(location))
+ })
+ })
+
+ Context("when runnable nodes are nested within other runnable nodes", func() {
+ Context("when an It is nested", func() {
+ BeforeEach(func() {
+ specSuite.PushItNode("top level it", func() {
+ specSuite.PushItNode("nested it", f("oops"), types.FlagTypeNone, codelocation.New(0), 0)
+ }, types.FlagTypeNone, codelocation.New(0), 0)
+ })
+
+ It("should fail", func() {
+ Ω(fakeT.didFail).Should(BeTrue())
+ })
+ })
+
+ Context("when a Measure is nested", func() {
+ BeforeEach(func() {
+ specSuite.PushItNode("top level it", func() {
+ specSuite.PushMeasureNode("nested measure", func(Benchmarker) {}, types.FlagTypeNone, codelocation.New(0), 10)
+ }, types.FlagTypeNone, codelocation.New(0), 0)
+ })
+
+ It("should fail", func() {
+ Ω(fakeT.didFail).Should(BeTrue())
+ })
+ })
+
+ Context("when a BeforeEach is nested", func() {
+ BeforeEach(func() {
+ specSuite.PushItNode("top level it", func() {
+ specSuite.PushBeforeEachNode(f("nested bef"), codelocation.New(0), 0)
+ }, types.FlagTypeNone, codelocation.New(0), 0)
+ })
+
+ It("should fail", func() {
+ Ω(fakeT.didFail).Should(BeTrue())
+ })
+ })
+
+ Context("when a JustBeforeEach is nested", func() {
+ BeforeEach(func() {
+ specSuite.PushItNode("top level it", func() {
+ specSuite.PushJustBeforeEachNode(f("nested jbef"), codelocation.New(0), 0)
+ }, types.FlagTypeNone, codelocation.New(0), 0)
+ })
+
+ It("should fail", func() {
+ Ω(fakeT.didFail).Should(BeTrue())
+ })
+ })
+
+ Context("when a AfterEach is nested", func() {
+ BeforeEach(func() {
+ specSuite.PushItNode("top level it", func() {
+ specSuite.PushAfterEachNode(f("nested aft"), codelocation.New(0), 0)
+ }, types.FlagTypeNone, codelocation.New(0), 0)
+ })
+
+ It("should fail", func() {
+ Ω(fakeT.didFail).Should(BeTrue())
+ })
+ })
+ })
+ })
+
+ Describe("BeforeSuite", func() {
+ Context("when setting BeforeSuite more than once", func() {
+ It("should panic", func() {
+ specSuite.SetBeforeSuiteNode(func() {}, codelocation.New(0), 0)
+
+ Ω(func() {
+ specSuite.SetBeforeSuiteNode(func() {}, codelocation.New(0), 0)
+ }).Should(Panic())
+
+ })
+ })
+ })
+
+ Describe("AfterSuite", func() {
+ Context("when setting AfterSuite more than once", func() {
+ It("should panic", func() {
+ specSuite.SetAfterSuiteNode(func() {}, codelocation.New(0), 0)
+
+ Ω(func() {
+ specSuite.SetAfterSuiteNode(func() {}, codelocation.New(0), 0)
+ }).Should(Panic())
+ })
+ })
+ })
+
+ Describe("By", func() {
+ It("writes to the GinkgoWriter", func() {
+ originalGinkgoWriter := GinkgoWriter
+ buffer := &bytes.Buffer{}
+
+ GinkgoWriter = buffer
+ By("Saying Hello GinkgoWriter")
+ GinkgoWriter = originalGinkgoWriter
+
+ Ω(buffer.String()).Should(ContainSubstring("STEP"))
+ Ω(buffer.String()).Should(ContainSubstring(": Saying Hello GinkgoWriter\n"))
+ })
+
+ It("calls the passed-in callback if present", func() {
+ a := 0
+ By("calling the callback", func() {
+ a = 1
+ })
+ Ω(a).Should(Equal(1))
+ })
+
+ It("panics if there is more than one callback", func() {
+ Ω(func() {
+ By("registering more than one callback", func() {}, func() {})
+ }).Should(Panic())
+ })
+ })
+
+ Describe("GinkgoRandomSeed", func() {
+ It("returns the current config's random seed", func() {
+ Ω(GinkgoRandomSeed()).Should(Equal(config.GinkgoConfig.RandomSeed))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/internal/testingtproxy/testing_t_proxy.go b/vendor/github.com/onsi/ginkgo/internal/testingtproxy/testing_t_proxy.go
new file mode 100644
index 000000000..090445d08
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/testingtproxy/testing_t_proxy.go
@@ -0,0 +1,76 @@
+package testingtproxy
+
+import (
+ "fmt"
+ "io"
+)
+
+type failFunc func(message string, callerSkip ...int)
+
+func New(writer io.Writer, fail failFunc, offset int) *ginkgoTestingTProxy {
+ return &ginkgoTestingTProxy{
+ fail: fail,
+ offset: offset,
+ writer: writer,
+ }
+}
+
+type ginkgoTestingTProxy struct {
+ fail failFunc
+ offset int
+ writer io.Writer
+}
+
+func (t *ginkgoTestingTProxy) Error(args ...interface{}) {
+ t.fail(fmt.Sprintln(args...), t.offset)
+}
+
+func (t *ginkgoTestingTProxy) Errorf(format string, args ...interface{}) {
+ t.fail(fmt.Sprintf(format, args...), t.offset)
+}
+
+func (t *ginkgoTestingTProxy) Fail() {
+ t.fail("failed", t.offset)
+}
+
+func (t *ginkgoTestingTProxy) FailNow() {
+ t.fail("failed", t.offset)
+}
+
+func (t *ginkgoTestingTProxy) Fatal(args ...interface{}) {
+ t.fail(fmt.Sprintln(args...), t.offset)
+}
+
+func (t *ginkgoTestingTProxy) Fatalf(format string, args ...interface{}) {
+ t.fail(fmt.Sprintf(format, args...), t.offset)
+}
+
+func (t *ginkgoTestingTProxy) Log(args ...interface{}) {
+ fmt.Fprintln(t.writer, args...)
+}
+
+func (t *ginkgoTestingTProxy) Logf(format string, args ...interface{}) {
+ t.Log(fmt.Sprintf(format, args...))
+}
+
+func (t *ginkgoTestingTProxy) Failed() bool {
+ return false
+}
+
+func (t *ginkgoTestingTProxy) Parallel() {
+}
+
+func (t *ginkgoTestingTProxy) Skip(args ...interface{}) {
+ fmt.Println(args...)
+}
+
+func (t *ginkgoTestingTProxy) Skipf(format string, args ...interface{}) {
+ t.Skip(fmt.Sprintf(format, args...))
+}
+
+func (t *ginkgoTestingTProxy) SkipNow() {
+}
+
+func (t *ginkgoTestingTProxy) Skipped() bool {
+ return false
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/writer/fake_writer.go b/vendor/github.com/onsi/ginkgo/internal/writer/fake_writer.go
new file mode 100644
index 000000000..6739c3f60
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/writer/fake_writer.go
@@ -0,0 +1,36 @@
+package writer
+
+type FakeGinkgoWriter struct {
+ EventStream []string
+}
+
+func NewFake() *FakeGinkgoWriter {
+ return &FakeGinkgoWriter{
+ EventStream: []string{},
+ }
+}
+
+func (writer *FakeGinkgoWriter) AddEvent(event string) {
+ writer.EventStream = append(writer.EventStream, event)
+}
+
+func (writer *FakeGinkgoWriter) Truncate() {
+ writer.EventStream = append(writer.EventStream, "TRUNCATE")
+}
+
+func (writer *FakeGinkgoWriter) DumpOut() {
+ writer.EventStream = append(writer.EventStream, "DUMP")
+}
+
+func (writer *FakeGinkgoWriter) DumpOutWithHeader(header string) {
+ writer.EventStream = append(writer.EventStream, "DUMP_WITH_HEADER: "+header)
+}
+
+func (writer *FakeGinkgoWriter) Bytes() []byte {
+ writer.EventStream = append(writer.EventStream, "BYTES")
+ return nil
+}
+
+func (writer *FakeGinkgoWriter) Write(data []byte) (n int, err error) {
+ return 0, nil
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/writer/writer.go b/vendor/github.com/onsi/ginkgo/internal/writer/writer.go
new file mode 100644
index 000000000..98eca3bdd
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/writer/writer.go
@@ -0,0 +1,89 @@
+package writer
+
+import (
+ "bytes"
+ "io"
+ "sync"
+)
+
+type WriterInterface interface {
+ io.Writer
+
+ Truncate()
+ DumpOut()
+ DumpOutWithHeader(header string)
+ Bytes() []byte
+}
+
+type Writer struct {
+ buffer *bytes.Buffer
+ outWriter io.Writer
+ lock *sync.Mutex
+ stream bool
+ redirector io.Writer
+}
+
+func New(outWriter io.Writer) *Writer {
+ return &Writer{
+ buffer: &bytes.Buffer{},
+ lock: &sync.Mutex{},
+ outWriter: outWriter,
+ stream: true,
+ }
+}
+
+func (w *Writer) AndRedirectTo(writer io.Writer) {
+ w.redirector = writer
+}
+
+func (w *Writer) SetStream(stream bool) {
+ w.lock.Lock()
+ defer w.lock.Unlock()
+ w.stream = stream
+}
+
+func (w *Writer) Write(b []byte) (n int, err error) {
+ w.lock.Lock()
+ defer w.lock.Unlock()
+
+ n, err = w.buffer.Write(b)
+ if w.redirector != nil {
+ w.redirector.Write(b)
+ }
+ if w.stream {
+ return w.outWriter.Write(b)
+ }
+ return n, err
+}
+
+func (w *Writer) Truncate() {
+ w.lock.Lock()
+ defer w.lock.Unlock()
+ w.buffer.Reset()
+}
+
+func (w *Writer) DumpOut() {
+ w.lock.Lock()
+ defer w.lock.Unlock()
+ if !w.stream {
+ w.buffer.WriteTo(w.outWriter)
+ }
+}
+
+func (w *Writer) Bytes() []byte {
+ w.lock.Lock()
+ defer w.lock.Unlock()
+ b := w.buffer.Bytes()
+ copied := make([]byte, len(b))
+ copy(copied, b)
+ return copied
+}
+
+func (w *Writer) DumpOutWithHeader(header string) {
+ w.lock.Lock()
+ defer w.lock.Unlock()
+ if !w.stream && w.buffer.Len() > 0 {
+ w.outWriter.Write([]byte(header))
+ w.buffer.WriteTo(w.outWriter)
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/writer/writer_suite_test.go b/vendor/github.com/onsi/ginkgo/internal/writer/writer_suite_test.go
new file mode 100644
index 000000000..e20657791
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/writer/writer_suite_test.go
@@ -0,0 +1,13 @@
+package writer_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestWriter(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Writer Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/internal/writer/writer_test.go b/vendor/github.com/onsi/ginkgo/internal/writer/writer_test.go
new file mode 100644
index 000000000..3e1d17c6d
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/internal/writer/writer_test.go
@@ -0,0 +1,75 @@
+package writer_test
+
+import (
+ "github.com/onsi/gomega/gbytes"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/ginkgo/internal/writer"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Writer", func() {
+ var writer *Writer
+ var out *gbytes.Buffer
+
+ BeforeEach(func() {
+ out = gbytes.NewBuffer()
+ writer = New(out)
+ })
+
+ It("should stream directly to the outbuffer by default", func() {
+ writer.Write([]byte("foo"))
+ Ω(out).Should(gbytes.Say("foo"))
+ })
+
+ It("should not emit the header when asked to DumpOutWitHeader", func() {
+ writer.Write([]byte("foo"))
+ writer.DumpOutWithHeader("my header")
+ Ω(out).ShouldNot(gbytes.Say("my header"))
+ Ω(out).Should(gbytes.Say("foo"))
+ })
+
+ Context("when told not to stream", func() {
+ BeforeEach(func() {
+ writer.SetStream(false)
+ })
+
+ It("should only write to the buffer when told to DumpOut", func() {
+ writer.Write([]byte("foo"))
+ Ω(out).ShouldNot(gbytes.Say("foo"))
+ writer.DumpOut()
+ Ω(out).Should(gbytes.Say("foo"))
+ })
+
+ It("should truncate the internal buffer when told to truncate", func() {
+ writer.Write([]byte("foo"))
+ writer.Truncate()
+ writer.DumpOut()
+ Ω(out).ShouldNot(gbytes.Say("foo"))
+
+ writer.Write([]byte("bar"))
+ writer.DumpOut()
+ Ω(out).Should(gbytes.Say("bar"))
+ })
+
+ Describe("emitting a header", func() {
+ Context("when the buffer has content", func() {
+ It("should emit the header followed by the content", func() {
+ writer.Write([]byte("foo"))
+ writer.DumpOutWithHeader("my header")
+
+ Ω(out).Should(gbytes.Say("my header"))
+ Ω(out).Should(gbytes.Say("foo"))
+ })
+ })
+
+ Context("when the buffer has no content", func() {
+ It("should not emit the header", func() {
+ writer.DumpOutWithHeader("my header")
+
+ Ω(out).ShouldNot(gbytes.Say("my header"))
+ })
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/reporters/default_reporter.go b/vendor/github.com/onsi/ginkgo/reporters/default_reporter.go
new file mode 100644
index 000000000..ac58dd5f7
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/default_reporter.go
@@ -0,0 +1,84 @@
+/*
+Ginkgo's Default Reporter
+
+A number of command line flags are available to tweak Ginkgo's default output.
+
+These are documented [here](http://onsi.github.io/ginkgo/#running_tests)
+*/
+package reporters
+
+import (
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/reporters/stenographer"
+ "github.com/onsi/ginkgo/types"
+)
+
+type DefaultReporter struct {
+ config config.DefaultReporterConfigType
+ stenographer stenographer.Stenographer
+ specSummaries []*types.SpecSummary
+}
+
+func NewDefaultReporter(config config.DefaultReporterConfigType, stenographer stenographer.Stenographer) *DefaultReporter {
+ return &DefaultReporter{
+ config: config,
+ stenographer: stenographer,
+ }
+}
+
+func (reporter *DefaultReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) {
+ reporter.stenographer.AnnounceSuite(summary.SuiteDescription, config.RandomSeed, config.RandomizeAllSpecs, reporter.config.Succinct)
+ if config.ParallelTotal > 1 {
+ reporter.stenographer.AnnounceParallelRun(config.ParallelNode, config.ParallelTotal, reporter.config.Succinct)
+ } else {
+ reporter.stenographer.AnnounceNumberOfSpecs(summary.NumberOfSpecsThatWillBeRun, summary.NumberOfTotalSpecs, reporter.config.Succinct)
+ }
+}
+
+func (reporter *DefaultReporter) BeforeSuiteDidRun(setupSummary *types.SetupSummary) {
+ if setupSummary.State != types.SpecStatePassed {
+ reporter.stenographer.AnnounceBeforeSuiteFailure(setupSummary, reporter.config.Succinct, reporter.config.FullTrace)
+ }
+}
+
+func (reporter *DefaultReporter) AfterSuiteDidRun(setupSummary *types.SetupSummary) {
+ if setupSummary.State != types.SpecStatePassed {
+ reporter.stenographer.AnnounceAfterSuiteFailure(setupSummary, reporter.config.Succinct, reporter.config.FullTrace)
+ }
+}
+
+func (reporter *DefaultReporter) SpecWillRun(specSummary *types.SpecSummary) {
+ if reporter.config.Verbose && !reporter.config.Succinct && specSummary.State != types.SpecStatePending && specSummary.State != types.SpecStateSkipped {
+ reporter.stenographer.AnnounceSpecWillRun(specSummary)
+ }
+}
+
+func (reporter *DefaultReporter) SpecDidComplete(specSummary *types.SpecSummary) {
+ switch specSummary.State {
+ case types.SpecStatePassed:
+ if specSummary.IsMeasurement {
+ reporter.stenographer.AnnounceSuccesfulMeasurement(specSummary, reporter.config.Succinct)
+ } else if specSummary.RunTime.Seconds() >= reporter.config.SlowSpecThreshold {
+ reporter.stenographer.AnnounceSuccesfulSlowSpec(specSummary, reporter.config.Succinct)
+ } else {
+ reporter.stenographer.AnnounceSuccesfulSpec(specSummary)
+ }
+ case types.SpecStatePending:
+ reporter.stenographer.AnnouncePendingSpec(specSummary, reporter.config.NoisyPendings && !reporter.config.Succinct)
+ case types.SpecStateSkipped:
+ reporter.stenographer.AnnounceSkippedSpec(specSummary, reporter.config.Succinct || !reporter.config.NoisySkippings, reporter.config.FullTrace)
+ case types.SpecStateTimedOut:
+ reporter.stenographer.AnnounceSpecTimedOut(specSummary, reporter.config.Succinct, reporter.config.FullTrace)
+ case types.SpecStatePanicked:
+ reporter.stenographer.AnnounceSpecPanicked(specSummary, reporter.config.Succinct, reporter.config.FullTrace)
+ case types.SpecStateFailed:
+ reporter.stenographer.AnnounceSpecFailed(specSummary, reporter.config.Succinct, reporter.config.FullTrace)
+ }
+
+ reporter.specSummaries = append(reporter.specSummaries, specSummary)
+}
+
+func (reporter *DefaultReporter) SpecSuiteDidEnd(summary *types.SuiteSummary) {
+ reporter.stenographer.SummarizeFailures(reporter.specSummaries)
+ reporter.stenographer.AnnounceSpecRunCompletion(summary, reporter.config.Succinct)
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/default_reporter_test.go b/vendor/github.com/onsi/ginkgo/reporters/default_reporter_test.go
new file mode 100644
index 000000000..2dcf276d3
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/default_reporter_test.go
@@ -0,0 +1,433 @@
+package reporters_test
+
+import (
+ "time"
+
+ . "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/reporters"
+ st "github.com/onsi/ginkgo/reporters/stenographer"
+ "github.com/onsi/ginkgo/types"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("DefaultReporter", func() {
+ var (
+ reporter *reporters.DefaultReporter
+ reporterConfig config.DefaultReporterConfigType
+ stenographer *st.FakeStenographer
+
+ ginkgoConfig config.GinkgoConfigType
+ suite *types.SuiteSummary
+ spec *types.SpecSummary
+ )
+
+ BeforeEach(func() {
+ stenographer = st.NewFakeStenographer()
+ reporterConfig = config.DefaultReporterConfigType{
+ NoColor: false,
+ SlowSpecThreshold: 0.1,
+ NoisyPendings: false,
+ NoisySkippings: false,
+ Verbose: true,
+ FullTrace: true,
+ }
+
+ reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
+ })
+
+ call := func(method string, args ...interface{}) st.FakeStenographerCall {
+ return st.NewFakeStenographerCall(method, args...)
+ }
+
+ Describe("SpecSuiteWillBegin", func() {
+ BeforeEach(func() {
+ suite = &types.SuiteSummary{
+ SuiteDescription: "A Sweet Suite",
+ NumberOfTotalSpecs: 10,
+ NumberOfSpecsThatWillBeRun: 8,
+ }
+
+ ginkgoConfig = config.GinkgoConfigType{
+ RandomSeed: 1138,
+ RandomizeAllSpecs: true,
+ }
+ })
+
+ Context("when a serial (non-parallel) suite begins", func() {
+ BeforeEach(func() {
+ ginkgoConfig.ParallelTotal = 1
+
+ reporter.SpecSuiteWillBegin(ginkgoConfig, suite)
+ })
+
+ It("should announce the suite, then announce the number of specs", func() {
+ Ω(stenographer.Calls()).Should(HaveLen(2))
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuite", "A Sweet Suite", ginkgoConfig.RandomSeed, true, false)))
+ Ω(stenographer.Calls()[1]).Should(Equal(call("AnnounceNumberOfSpecs", 8, 10, false)))
+ })
+ })
+
+ Context("when a parallel suite begins", func() {
+ BeforeEach(func() {
+ ginkgoConfig.ParallelTotal = 2
+ ginkgoConfig.ParallelNode = 1
+ suite.NumberOfSpecsBeforeParallelization = 20
+
+ reporter.SpecSuiteWillBegin(ginkgoConfig, suite)
+ })
+
+ It("should announce the suite, announce that it's a parallel run, then announce the number of specs", func() {
+ Ω(stenographer.Calls()).Should(HaveLen(2))
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuite", "A Sweet Suite", ginkgoConfig.RandomSeed, true, false)))
+ Ω(stenographer.Calls()[1]).Should(Equal(call("AnnounceParallelRun", 1, 2, false)))
+ })
+ })
+ })
+
+ Describe("BeforeSuiteDidRun", func() {
+ Context("when the BeforeSuite passes", func() {
+ It("should announce nothing", func() {
+ reporter.BeforeSuiteDidRun(&types.SetupSummary{
+ State: types.SpecStatePassed,
+ })
+
+ Ω(stenographer.Calls()).Should(BeEmpty())
+ })
+ })
+
+ Context("when the BeforeSuite fails", func() {
+ It("should announce the failure", func() {
+ summary := &types.SetupSummary{
+ State: types.SpecStateFailed,
+ }
+ reporter.BeforeSuiteDidRun(summary)
+
+ Ω(stenographer.Calls()).Should(HaveLen(1))
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceBeforeSuiteFailure", summary, false, true)))
+ })
+ })
+ })
+
+ Describe("AfterSuiteDidRun", func() {
+ Context("when the AfterSuite passes", func() {
+ It("should announce nothing", func() {
+ reporter.AfterSuiteDidRun(&types.SetupSummary{
+ State: types.SpecStatePassed,
+ })
+
+ Ω(stenographer.Calls()).Should(BeEmpty())
+ })
+ })
+
+ Context("when the AfterSuite fails", func() {
+ It("should announce the failure", func() {
+ summary := &types.SetupSummary{
+ State: types.SpecStateFailed,
+ }
+ reporter.AfterSuiteDidRun(summary)
+
+ Ω(stenographer.Calls()).Should(HaveLen(1))
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceAfterSuiteFailure", summary, false, true)))
+ })
+ })
+ })
+
+ Describe("SpecWillRun", func() {
+ Context("When running in verbose mode", func() {
+ Context("and the spec will run", func() {
+ BeforeEach(func() {
+ spec = &types.SpecSummary{}
+ reporter.SpecWillRun(spec)
+ })
+
+ It("should announce that the spec will run", func() {
+ Ω(stenographer.Calls()).Should(HaveLen(1))
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecWillRun", spec)))
+ })
+ })
+
+ Context("and the spec will not run", func() {
+ Context("because it is pending", func() {
+ BeforeEach(func() {
+ spec = &types.SpecSummary{
+ State: types.SpecStatePending,
+ }
+ reporter.SpecWillRun(spec)
+ })
+
+ It("should announce nothing", func() {
+ Ω(stenographer.Calls()).Should(BeEmpty())
+ })
+ })
+
+ Context("because it is skipped", func() {
+ BeforeEach(func() {
+ spec = &types.SpecSummary{
+ State: types.SpecStateSkipped,
+ }
+ reporter.SpecWillRun(spec)
+ })
+
+ It("should announce nothing", func() {
+ Ω(stenographer.Calls()).Should(BeEmpty())
+ })
+ })
+ })
+ })
+
+ Context("When running in verbose & succinct mode", func() {
+ BeforeEach(func() {
+ reporterConfig.Succinct = true
+ reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
+ spec = &types.SpecSummary{}
+ reporter.SpecWillRun(spec)
+ })
+
+ It("should announce nothing", func() {
+ Ω(stenographer.Calls()).Should(BeEmpty())
+ })
+ })
+
+ Context("When not running in verbose mode", func() {
+ BeforeEach(func() {
+ reporterConfig.Verbose = false
+ reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
+ spec = &types.SpecSummary{}
+ reporter.SpecWillRun(spec)
+ })
+
+ It("should announce nothing", func() {
+ Ω(stenographer.Calls()).Should(BeEmpty())
+ })
+ })
+ })
+
+ Describe("SpecDidComplete", func() {
+ JustBeforeEach(func() {
+ reporter.SpecDidComplete(spec)
+ })
+
+ BeforeEach(func() {
+ spec = &types.SpecSummary{}
+ })
+
+ Context("When the spec passed", func() {
+ BeforeEach(func() {
+ spec.State = types.SpecStatePassed
+ })
+
+ Context("When the spec was a measurement", func() {
+ BeforeEach(func() {
+ spec.IsMeasurement = true
+ })
+
+ It("should announce the measurement", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulMeasurement", spec, false)))
+ })
+ })
+
+ Context("When the spec is slow", func() {
+ BeforeEach(func() {
+ spec.RunTime = time.Second
+ })
+
+ It("should announce that it was slow", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSlowSpec", spec, false)))
+ })
+ })
+
+ Context("Otherwise", func() {
+ It("should announce the succesful spec", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSpec", spec)))
+ })
+ })
+ })
+
+ Context("When the spec is pending", func() {
+ BeforeEach(func() {
+ spec.State = types.SpecStatePending
+ })
+
+ It("should announce the pending spec, succinctly", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnouncePendingSpec", spec, false)))
+ })
+ })
+
+ Context("When the spec is skipped", func() {
+ BeforeEach(func() {
+ spec.State = types.SpecStateSkipped
+ })
+
+ It("should announce the skipped spec, succinctly", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSkippedSpec", spec, true, true)))
+ })
+ })
+
+ Context("When the spec timed out", func() {
+ BeforeEach(func() {
+ spec.State = types.SpecStateTimedOut
+ })
+
+ It("should announce the timedout spec", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecTimedOut", spec, false, true)))
+ })
+ })
+
+ Context("When the spec panicked", func() {
+ BeforeEach(func() {
+ spec.State = types.SpecStatePanicked
+ })
+
+ It("should announce the panicked spec", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecPanicked", spec, false, true)))
+ })
+ })
+
+ Context("When the spec failed", func() {
+ BeforeEach(func() {
+ spec.State = types.SpecStateFailed
+ })
+
+ It("should announce the failed spec", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecFailed", spec, false, true)))
+ })
+ })
+
+ Context("in noisy pendings mode", func() {
+ BeforeEach(func() {
+ reporterConfig.Succinct = false
+ reporterConfig.NoisyPendings = true
+ reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
+ })
+
+ Context("When the spec is pending", func() {
+ BeforeEach(func() {
+ spec.State = types.SpecStatePending
+ })
+
+ It("should announce the pending spec, noisily", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnouncePendingSpec", spec, true)))
+ })
+ })
+ })
+
+ Context("in noisy skippings mode", func() {
+ BeforeEach(func() {
+ reporterConfig.Succinct = false
+ reporterConfig.NoisySkippings = true
+ reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
+ })
+
+ Context("When the spec is skipped", func() {
+ BeforeEach(func() {
+ spec.State = types.SpecStateSkipped
+ })
+
+ It("should announce the skipped spec, noisily", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSkippedSpec", spec, false, true)))
+ })
+ })
+ })
+
+ Context("in succinct mode", func() {
+ BeforeEach(func() {
+ reporterConfig.Succinct = true
+ reporter = reporters.NewDefaultReporter(reporterConfig, stenographer)
+ })
+
+ Context("When the spec passed", func() {
+ BeforeEach(func() {
+ spec.State = types.SpecStatePassed
+ })
+
+ Context("When the spec was a measurement", func() {
+ BeforeEach(func() {
+ spec.IsMeasurement = true
+ })
+
+ It("should announce the measurement", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulMeasurement", spec, true)))
+ })
+ })
+
+ Context("When the spec is slow", func() {
+ BeforeEach(func() {
+ spec.RunTime = time.Second
+ })
+
+ It("should announce that it was slow", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSlowSpec", spec, true)))
+ })
+ })
+
+ Context("Otherwise", func() {
+ It("should announce the succesful spec", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSuccesfulSpec", spec)))
+ })
+ })
+ })
+
+ Context("When the spec is pending", func() {
+ BeforeEach(func() {
+ spec.State = types.SpecStatePending
+ })
+
+ It("should announce the pending spec, succinctly", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnouncePendingSpec", spec, false)))
+ })
+ })
+
+ Context("When the spec is skipped", func() {
+ BeforeEach(func() {
+ spec.State = types.SpecStateSkipped
+ })
+
+ It("should announce the skipped spec", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSkippedSpec", spec, true, true)))
+ })
+ })
+
+ Context("When the spec timed out", func() {
+ BeforeEach(func() {
+ spec.State = types.SpecStateTimedOut
+ })
+
+ It("should announce the timedout spec", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecTimedOut", spec, true, true)))
+ })
+ })
+
+ Context("When the spec panicked", func() {
+ BeforeEach(func() {
+ spec.State = types.SpecStatePanicked
+ })
+
+ It("should announce the panicked spec", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecPanicked", spec, true, true)))
+ })
+ })
+
+ Context("When the spec failed", func() {
+ BeforeEach(func() {
+ spec.State = types.SpecStateFailed
+ })
+
+ It("should announce the failed spec", func() {
+ Ω(stenographer.Calls()[0]).Should(Equal(call("AnnounceSpecFailed", spec, true, true)))
+ })
+ })
+ })
+ })
+
+ Describe("SpecSuiteDidEnd", func() {
+ BeforeEach(func() {
+ suite = &types.SuiteSummary{}
+ reporter.SpecSuiteDidEnd(suite)
+ })
+
+ It("should announce the spec run's completion", func() {
+ Ω(stenographer.Calls()[1]).Should(Equal(call("AnnounceSpecRunCompletion", suite, false)))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/ginkgo/reporters/fake_reporter.go b/vendor/github.com/onsi/ginkgo/reporters/fake_reporter.go
new file mode 100644
index 000000000..27db47949
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/fake_reporter.go
@@ -0,0 +1,59 @@
+package reporters
+
+import (
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/types"
+)
+
+//FakeReporter is useful for testing purposes
+type FakeReporter struct {
+ Config config.GinkgoConfigType
+
+ BeginSummary *types.SuiteSummary
+ BeforeSuiteSummary *types.SetupSummary
+ SpecWillRunSummaries []*types.SpecSummary
+ SpecSummaries []*types.SpecSummary
+ AfterSuiteSummary *types.SetupSummary
+ EndSummary *types.SuiteSummary
+
+ SpecWillRunStub func(specSummary *types.SpecSummary)
+ SpecDidCompleteStub func(specSummary *types.SpecSummary)
+}
+
+func NewFakeReporter() *FakeReporter {
+ return &FakeReporter{
+ SpecWillRunSummaries: make([]*types.SpecSummary, 0),
+ SpecSummaries: make([]*types.SpecSummary, 0),
+ }
+}
+
+func (fakeR *FakeReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) {
+ fakeR.Config = config
+ fakeR.BeginSummary = summary
+}
+
+func (fakeR *FakeReporter) BeforeSuiteDidRun(setupSummary *types.SetupSummary) {
+ fakeR.BeforeSuiteSummary = setupSummary
+}
+
+func (fakeR *FakeReporter) SpecWillRun(specSummary *types.SpecSummary) {
+ if fakeR.SpecWillRunStub != nil {
+ fakeR.SpecWillRunStub(specSummary)
+ }
+ fakeR.SpecWillRunSummaries = append(fakeR.SpecWillRunSummaries, specSummary)
+}
+
+func (fakeR *FakeReporter) SpecDidComplete(specSummary *types.SpecSummary) {
+ if fakeR.SpecDidCompleteStub != nil {
+ fakeR.SpecDidCompleteStub(specSummary)
+ }
+ fakeR.SpecSummaries = append(fakeR.SpecSummaries, specSummary)
+}
+
+func (fakeR *FakeReporter) AfterSuiteDidRun(setupSummary *types.SetupSummary) {
+ fakeR.AfterSuiteSummary = setupSummary
+}
+
+func (fakeR *FakeReporter) SpecSuiteDidEnd(summary *types.SuiteSummary) {
+ fakeR.EndSummary = summary
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/junit_reporter.go b/vendor/github.com/onsi/ginkgo/reporters/junit_reporter.go
new file mode 100644
index 000000000..2c9f3c792
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/junit_reporter.go
@@ -0,0 +1,152 @@
+/*
+
+JUnit XML Reporter for Ginkgo
+
+For usage instructions: http://onsi.github.io/ginkgo/#generating_junit_xml_output
+
+*/
+
+package reporters
+
+import (
+ "encoding/xml"
+ "fmt"
+ "math"
+ "os"
+ "strings"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/types"
+)
+
+type JUnitTestSuite struct {
+ XMLName xml.Name `xml:"testsuite"`
+ TestCases []JUnitTestCase `xml:"testcase"`
+ Name string `xml:"name,attr"`
+ Tests int `xml:"tests,attr"`
+ Failures int `xml:"failures,attr"`
+ Errors int `xml:"errors,attr"`
+ Time float64 `xml:"time,attr"`
+}
+
+type JUnitTestCase struct {
+ Name string `xml:"name,attr"`
+ ClassName string `xml:"classname,attr"`
+ FailureMessage *JUnitFailureMessage `xml:"failure,omitempty"`
+ Skipped *JUnitSkipped `xml:"skipped,omitempty"`
+ Time float64 `xml:"time,attr"`
+ SystemOut string `xml:"system-out,omitempty"`
+}
+
+type JUnitFailureMessage struct {
+ Type string `xml:"type,attr"`
+ Message string `xml:",chardata"`
+}
+
+type JUnitSkipped struct {
+ XMLName xml.Name `xml:"skipped"`
+}
+
+type JUnitReporter struct {
+ suite JUnitTestSuite
+ filename string
+ testSuiteName string
+}
+
+//NewJUnitReporter creates a new JUnit XML reporter. The XML will be stored in the passed in filename.
+func NewJUnitReporter(filename string) *JUnitReporter {
+ return &JUnitReporter{
+ filename: filename,
+ }
+}
+
+func (reporter *JUnitReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) {
+ reporter.suite = JUnitTestSuite{
+ Name: summary.SuiteDescription,
+ TestCases: []JUnitTestCase{},
+ }
+ reporter.testSuiteName = summary.SuiteDescription
+}
+
+func (reporter *JUnitReporter) SpecWillRun(specSummary *types.SpecSummary) {
+}
+
+func (reporter *JUnitReporter) BeforeSuiteDidRun(setupSummary *types.SetupSummary) {
+ reporter.handleSetupSummary("BeforeSuite", setupSummary)
+}
+
+func (reporter *JUnitReporter) AfterSuiteDidRun(setupSummary *types.SetupSummary) {
+ reporter.handleSetupSummary("AfterSuite", setupSummary)
+}
+
+func failureMessage(failure types.SpecFailure) string {
+ return fmt.Sprintf("%s\n%s\n%s", failure.ComponentCodeLocation.String(), failure.Message, failure.Location.String())
+}
+
+func (reporter *JUnitReporter) handleSetupSummary(name string, setupSummary *types.SetupSummary) {
+ if setupSummary.State != types.SpecStatePassed {
+ testCase := JUnitTestCase{
+ Name: name,
+ ClassName: reporter.testSuiteName,
+ }
+
+ testCase.FailureMessage = &JUnitFailureMessage{
+ Type: reporter.failureTypeForState(setupSummary.State),
+ Message: failureMessage(setupSummary.Failure),
+ }
+ testCase.SystemOut = setupSummary.CapturedOutput
+ testCase.Time = setupSummary.RunTime.Seconds()
+ reporter.suite.TestCases = append(reporter.suite.TestCases, testCase)
+ }
+}
+
+func (reporter *JUnitReporter) SpecDidComplete(specSummary *types.SpecSummary) {
+ testCase := JUnitTestCase{
+ Name: strings.Join(specSummary.ComponentTexts[1:], " "),
+ ClassName: reporter.testSuiteName,
+ }
+ if specSummary.State == types.SpecStateFailed || specSummary.State == types.SpecStateTimedOut || specSummary.State == types.SpecStatePanicked {
+ testCase.FailureMessage = &JUnitFailureMessage{
+ Type: reporter.failureTypeForState(specSummary.State),
+ Message: failureMessage(specSummary.Failure),
+ }
+ testCase.SystemOut = specSummary.CapturedOutput
+ }
+ if specSummary.State == types.SpecStateSkipped || specSummary.State == types.SpecStatePending {
+ testCase.Skipped = &JUnitSkipped{}
+ }
+ testCase.Time = specSummary.RunTime.Seconds()
+ reporter.suite.TestCases = append(reporter.suite.TestCases, testCase)
+}
+
+func (reporter *JUnitReporter) SpecSuiteDidEnd(summary *types.SuiteSummary) {
+ reporter.suite.Tests = summary.NumberOfSpecsThatWillBeRun
+ reporter.suite.Time = math.Trunc(summary.RunTime.Seconds()*1000) / 1000
+ reporter.suite.Failures = summary.NumberOfFailedSpecs
+ reporter.suite.Errors = 0
+ file, err := os.Create(reporter.filename)
+ if err != nil {
+ fmt.Printf("Failed to create JUnit report file: %s\n\t%s", reporter.filename, err.Error())
+ }
+ defer file.Close()
+ file.WriteString(xml.Header)
+ encoder := xml.NewEncoder(file)
+ encoder.Indent(" ", " ")
+ err = encoder.Encode(reporter.suite)
+ if err != nil {
+ fmt.Printf("Failed to generate JUnit report\n\t%s", err.Error())
+ }
+}
+
+func (reporter *JUnitReporter) failureTypeForState(state types.SpecState) string {
+ switch state {
+ case types.SpecStateFailed:
+ return "Failure"
+ case types.SpecStateTimedOut:
+ return "Timeout"
+ case types.SpecStatePanicked:
+ return "Panic"
+ default:
+ return ""
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/junit_reporter_test.go b/vendor/github.com/onsi/ginkgo/reporters/junit_reporter_test.go
new file mode 100644
index 000000000..9b75dc006
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/junit_reporter_test.go
@@ -0,0 +1,258 @@
+package reporters_test
+
+import (
+ "encoding/xml"
+ "io/ioutil"
+ "os"
+ "time"
+
+ . "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/internal/codelocation"
+ "github.com/onsi/ginkgo/reporters"
+ "github.com/onsi/ginkgo/types"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("JUnit Reporter", func() {
+ var (
+ outputFile string
+ reporter Reporter
+ )
+ testSuiteTime := 12456999 * time.Microsecond
+ reportedSuiteTime := 12.456
+
+ readOutputFile := func() reporters.JUnitTestSuite {
+ bytes, err := ioutil.ReadFile(outputFile)
+ Ω(err).ShouldNot(HaveOccurred())
+ var suite reporters.JUnitTestSuite
+ err = xml.Unmarshal(bytes, &suite)
+ Ω(err).ShouldNot(HaveOccurred())
+ return suite
+ }
+
+ BeforeEach(func() {
+ f, err := ioutil.TempFile("", "output")
+ Ω(err).ShouldNot(HaveOccurred())
+ f.Close()
+ outputFile = f.Name()
+
+ reporter = reporters.NewJUnitReporter(outputFile)
+
+ reporter.SpecSuiteWillBegin(config.GinkgoConfigType{}, &types.SuiteSummary{
+ SuiteDescription: "My test suite",
+ NumberOfSpecsThatWillBeRun: 1,
+ })
+ })
+
+ AfterEach(func() {
+ os.RemoveAll(outputFile)
+ })
+
+ Describe("a passing test", func() {
+ BeforeEach(func() {
+ beforeSuite := &types.SetupSummary{
+ State: types.SpecStatePassed,
+ }
+ reporter.BeforeSuiteDidRun(beforeSuite)
+
+ afterSuite := &types.SetupSummary{
+ State: types.SpecStatePassed,
+ }
+ reporter.AfterSuiteDidRun(afterSuite)
+
+ spec := &types.SpecSummary{
+ ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
+ State: types.SpecStatePassed,
+ RunTime: 5 * time.Second,
+ }
+ reporter.SpecWillRun(spec)
+ reporter.SpecDidComplete(spec)
+
+ reporter.SpecSuiteDidEnd(&types.SuiteSummary{
+ NumberOfSpecsThatWillBeRun: 1,
+ NumberOfFailedSpecs: 0,
+ RunTime: testSuiteTime,
+ })
+ })
+
+ It("should record the test as passing", func() {
+ output := readOutputFile()
+ Ω(output.Name).Should(Equal("My test suite"))
+ Ω(output.Tests).Should(Equal(1))
+ Ω(output.Failures).Should(Equal(0))
+ Ω(output.Time).Should(Equal(reportedSuiteTime))
+ Ω(output.Errors).Should(Equal(0))
+ Ω(output.TestCases).Should(HaveLen(1))
+ Ω(output.TestCases[0].Name).Should(Equal("A B C"))
+ Ω(output.TestCases[0].ClassName).Should(Equal("My test suite"))
+ Ω(output.TestCases[0].FailureMessage).Should(BeNil())
+ Ω(output.TestCases[0].Skipped).Should(BeNil())
+ Ω(output.TestCases[0].Time).Should(Equal(5.0))
+ })
+ })
+
+ Describe("when the BeforeSuite fails", func() {
+ var beforeSuite *types.SetupSummary
+
+ BeforeEach(func() {
+ beforeSuite = &types.SetupSummary{
+ State: types.SpecStateFailed,
+ RunTime: 3 * time.Second,
+ Failure: types.SpecFailure{
+ Message: "failed to setup",
+ ComponentCodeLocation: codelocation.New(0),
+ Location: codelocation.New(2),
+ },
+ }
+ reporter.BeforeSuiteDidRun(beforeSuite)
+
+ reporter.SpecSuiteDidEnd(&types.SuiteSummary{
+ NumberOfSpecsThatWillBeRun: 1,
+ NumberOfFailedSpecs: 1,
+ RunTime: testSuiteTime,
+ })
+ })
+
+ It("should record the test as having failed", func() {
+ output := readOutputFile()
+ Ω(output.Name).Should(Equal("My test suite"))
+ Ω(output.Tests).Should(Equal(1))
+ Ω(output.Failures).Should(Equal(1))
+ Ω(output.Time).Should(Equal(reportedSuiteTime))
+ Ω(output.Errors).Should(Equal(0))
+ Ω(output.TestCases[0].Name).Should(Equal("BeforeSuite"))
+ Ω(output.TestCases[0].Time).Should(Equal(3.0))
+ Ω(output.TestCases[0].ClassName).Should(Equal("My test suite"))
+ Ω(output.TestCases[0].FailureMessage.Type).Should(Equal("Failure"))
+ Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring("failed to setup"))
+ Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(beforeSuite.Failure.ComponentCodeLocation.String()))
+ Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(beforeSuite.Failure.Location.String()))
+ Ω(output.TestCases[0].Skipped).Should(BeNil())
+ })
+ })
+
+ Describe("when the AfterSuite fails", func() {
+ var afterSuite *types.SetupSummary
+
+ BeforeEach(func() {
+ afterSuite = &types.SetupSummary{
+ State: types.SpecStateFailed,
+ RunTime: 3 * time.Second,
+ Failure: types.SpecFailure{
+ Message: "failed to setup",
+ ComponentCodeLocation: codelocation.New(0),
+ Location: codelocation.New(2),
+ },
+ }
+ reporter.AfterSuiteDidRun(afterSuite)
+
+ reporter.SpecSuiteDidEnd(&types.SuiteSummary{
+ NumberOfSpecsThatWillBeRun: 1,
+ NumberOfFailedSpecs: 1,
+ RunTime: testSuiteTime,
+ })
+ })
+
+ It("should record the test as having failed", func() {
+ output := readOutputFile()
+ Ω(output.Name).Should(Equal("My test suite"))
+ Ω(output.Tests).Should(Equal(1))
+ Ω(output.Failures).Should(Equal(1))
+ Ω(output.Time).Should(Equal(reportedSuiteTime))
+ Ω(output.Errors).Should(Equal(0))
+ Ω(output.TestCases[0].Name).Should(Equal("AfterSuite"))
+ Ω(output.TestCases[0].Time).Should(Equal(3.0))
+ Ω(output.TestCases[0].ClassName).Should(Equal("My test suite"))
+ Ω(output.TestCases[0].FailureMessage.Type).Should(Equal("Failure"))
+ Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring("failed to setup"))
+ Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(afterSuite.Failure.ComponentCodeLocation.String()))
+ Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(afterSuite.Failure.Location.String()))
+ Ω(output.TestCases[0].Skipped).Should(BeNil())
+ })
+ })
+
+ specStateCases := []struct {
+ state types.SpecState
+ message string
+ }{
+ {types.SpecStateFailed, "Failure"},
+ {types.SpecStateTimedOut, "Timeout"},
+ {types.SpecStatePanicked, "Panic"},
+ }
+
+ for _, specStateCase := range specStateCases {
+ specStateCase := specStateCase
+ Describe("a failing test", func() {
+ var spec *types.SpecSummary
+ BeforeEach(func() {
+ spec = &types.SpecSummary{
+ ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
+ State: specStateCase.state,
+ RunTime: 5 * time.Second,
+ Failure: types.SpecFailure{
+ ComponentCodeLocation: codelocation.New(0),
+ Location: codelocation.New(2),
+ Message: "I failed",
+ },
+ }
+ reporter.SpecWillRun(spec)
+ reporter.SpecDidComplete(spec)
+
+ reporter.SpecSuiteDidEnd(&types.SuiteSummary{
+ NumberOfSpecsThatWillBeRun: 1,
+ NumberOfFailedSpecs: 1,
+ RunTime: testSuiteTime,
+ })
+ })
+
+ It("should record test as failing", func() {
+ output := readOutputFile()
+ Ω(output.Name).Should(Equal("My test suite"))
+ Ω(output.Tests).Should(Equal(1))
+ Ω(output.Failures).Should(Equal(1))
+ Ω(output.Time).Should(Equal(reportedSuiteTime))
+ Ω(output.Errors).Should(Equal(0))
+ Ω(output.TestCases[0].Name).Should(Equal("A B C"))
+ Ω(output.TestCases[0].ClassName).Should(Equal("My test suite"))
+ Ω(output.TestCases[0].FailureMessage.Type).Should(Equal(specStateCase.message))
+ Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring("I failed"))
+ Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(spec.Failure.ComponentCodeLocation.String()))
+ Ω(output.TestCases[0].FailureMessage.Message).Should(ContainSubstring(spec.Failure.Location.String()))
+ Ω(output.TestCases[0].Skipped).Should(BeNil())
+ })
+ })
+ }
+
+ for _, specStateCase := range []types.SpecState{types.SpecStatePending, types.SpecStateSkipped} {
+ specStateCase := specStateCase
+ Describe("a skipped test", func() {
+ var spec *types.SpecSummary
+ BeforeEach(func() {
+ spec = &types.SpecSummary{
+ ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
+ State: specStateCase,
+ RunTime: 5 * time.Second,
+ }
+ reporter.SpecWillRun(spec)
+ reporter.SpecDidComplete(spec)
+
+ reporter.SpecSuiteDidEnd(&types.SuiteSummary{
+ NumberOfSpecsThatWillBeRun: 1,
+ NumberOfFailedSpecs: 0,
+ RunTime: testSuiteTime,
+ })
+ })
+
+ It("should record test as failing", func() {
+ output := readOutputFile()
+ Ω(output.Tests).Should(Equal(1))
+ Ω(output.Failures).Should(Equal(0))
+ Ω(output.Time).Should(Equal(reportedSuiteTime))
+ Ω(output.Errors).Should(Equal(0))
+ Ω(output.TestCases[0].Name).Should(Equal("A B C"))
+ Ω(output.TestCases[0].Skipped).ShouldNot(BeNil())
+ })
+ })
+ }
+})
diff --git a/vendor/github.com/onsi/ginkgo/reporters/reporter.go b/vendor/github.com/onsi/ginkgo/reporters/reporter.go
new file mode 100644
index 000000000..348b9dfce
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/reporter.go
@@ -0,0 +1,15 @@
+package reporters
+
+import (
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/types"
+)
+
+type Reporter interface {
+ SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary)
+ BeforeSuiteDidRun(setupSummary *types.SetupSummary)
+ SpecWillRun(specSummary *types.SpecSummary)
+ SpecDidComplete(specSummary *types.SpecSummary)
+ AfterSuiteDidRun(setupSummary *types.SetupSummary)
+ SpecSuiteDidEnd(summary *types.SuiteSummary)
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/reporters_suite_test.go b/vendor/github.com/onsi/ginkgo/reporters/reporters_suite_test.go
new file mode 100644
index 000000000..cec5a4dbf
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/reporters_suite_test.go
@@ -0,0 +1,13 @@
+package reporters_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestReporters(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Reporters Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/console_logging.go b/vendor/github.com/onsi/ginkgo/reporters/stenographer/console_logging.go
new file mode 100644
index 000000000..45b8f8869
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/console_logging.go
@@ -0,0 +1,64 @@
+package stenographer
+
+import (
+ "fmt"
+ "strings"
+)
+
+func (s *consoleStenographer) colorize(colorCode string, format string, args ...interface{}) string {
+ var out string
+
+ if len(args) > 0 {
+ out = fmt.Sprintf(format, args...)
+ } else {
+ out = format
+ }
+
+ if s.color {
+ return fmt.Sprintf("%s%s%s", colorCode, out, defaultStyle)
+ } else {
+ return out
+ }
+}
+
+func (s *consoleStenographer) printBanner(text string, bannerCharacter string) {
+ fmt.Fprintln(s.w, text)
+ fmt.Fprintln(s.w, strings.Repeat(bannerCharacter, len(text)))
+}
+
+func (s *consoleStenographer) printNewLine() {
+ fmt.Fprintln(s.w, "")
+}
+
+func (s *consoleStenographer) printDelimiter() {
+ fmt.Fprintln(s.w, s.colorize(grayColor, "%s", strings.Repeat("-", 30)))
+}
+
+func (s *consoleStenographer) print(indentation int, format string, args ...interface{}) {
+ fmt.Fprint(s.w, s.indent(indentation, format, args...))
+}
+
+func (s *consoleStenographer) println(indentation int, format string, args ...interface{}) {
+ fmt.Fprintln(s.w, s.indent(indentation, format, args...))
+}
+
+func (s *consoleStenographer) indent(indentation int, format string, args ...interface{}) string {
+ var text string
+
+ if len(args) > 0 {
+ text = fmt.Sprintf(format, args...)
+ } else {
+ text = format
+ }
+
+ stringArray := strings.Split(text, "\n")
+ padding := ""
+ if indentation >= 0 {
+ padding = strings.Repeat(" ", indentation)
+ }
+ for i, s := range stringArray {
+ stringArray[i] = fmt.Sprintf("%s%s", padding, s)
+ }
+
+ return strings.Join(stringArray, "\n")
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/fake_stenographer.go b/vendor/github.com/onsi/ginkgo/reporters/stenographer/fake_stenographer.go
new file mode 100644
index 000000000..98854e7d9
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/fake_stenographer.go
@@ -0,0 +1,142 @@
+package stenographer
+
+import (
+ "sync"
+
+ "github.com/onsi/ginkgo/types"
+)
+
+func NewFakeStenographerCall(method string, args ...interface{}) FakeStenographerCall {
+ return FakeStenographerCall{
+ Method: method,
+ Args: args,
+ }
+}
+
+type FakeStenographer struct {
+ calls []FakeStenographerCall
+ lock *sync.Mutex
+}
+
+type FakeStenographerCall struct {
+ Method string
+ Args []interface{}
+}
+
+func NewFakeStenographer() *FakeStenographer {
+ stenographer := &FakeStenographer{
+ lock: &sync.Mutex{},
+ }
+ stenographer.Reset()
+ return stenographer
+}
+
+func (stenographer *FakeStenographer) Calls() []FakeStenographerCall {
+ stenographer.lock.Lock()
+ defer stenographer.lock.Unlock()
+
+ return stenographer.calls
+}
+
+func (stenographer *FakeStenographer) Reset() {
+ stenographer.lock.Lock()
+ defer stenographer.lock.Unlock()
+
+ stenographer.calls = make([]FakeStenographerCall, 0)
+}
+
+func (stenographer *FakeStenographer) CallsTo(method string) []FakeStenographerCall {
+ stenographer.lock.Lock()
+ defer stenographer.lock.Unlock()
+
+ results := make([]FakeStenographerCall, 0)
+ for _, call := range stenographer.calls {
+ if call.Method == method {
+ results = append(results, call)
+ }
+ }
+
+ return results
+}
+
+func (stenographer *FakeStenographer) registerCall(method string, args ...interface{}) {
+ stenographer.lock.Lock()
+ defer stenographer.lock.Unlock()
+
+ stenographer.calls = append(stenographer.calls, NewFakeStenographerCall(method, args...))
+}
+
+func (stenographer *FakeStenographer) AnnounceSuite(description string, randomSeed int64, randomizingAll bool, succinct bool) {
+ stenographer.registerCall("AnnounceSuite", description, randomSeed, randomizingAll, succinct)
+}
+
+func (stenographer *FakeStenographer) AnnounceAggregatedParallelRun(nodes int, succinct bool) {
+ stenographer.registerCall("AnnounceAggregatedParallelRun", nodes, succinct)
+}
+
+func (stenographer *FakeStenographer) AnnounceParallelRun(node int, nodes int, succinct bool) {
+ stenographer.registerCall("AnnounceParallelRun", node, nodes, succinct)
+}
+
+func (stenographer *FakeStenographer) AnnounceNumberOfSpecs(specsToRun int, total int, succinct bool) {
+ stenographer.registerCall("AnnounceNumberOfSpecs", specsToRun, total, succinct)
+}
+
+func (stenographer *FakeStenographer) AnnounceTotalNumberOfSpecs(total int, succinct bool) {
+ stenographer.registerCall("AnnounceTotalNumberOfSpecs", total, succinct)
+}
+
+func (stenographer *FakeStenographer) AnnounceSpecRunCompletion(summary *types.SuiteSummary, succinct bool) {
+ stenographer.registerCall("AnnounceSpecRunCompletion", summary, succinct)
+}
+
+func (stenographer *FakeStenographer) AnnounceSpecWillRun(spec *types.SpecSummary) {
+ stenographer.registerCall("AnnounceSpecWillRun", spec)
+}
+
+func (stenographer *FakeStenographer) AnnounceBeforeSuiteFailure(summary *types.SetupSummary, succinct bool, fullTrace bool) {
+ stenographer.registerCall("AnnounceBeforeSuiteFailure", summary, succinct, fullTrace)
+}
+
+func (stenographer *FakeStenographer) AnnounceAfterSuiteFailure(summary *types.SetupSummary, succinct bool, fullTrace bool) {
+ stenographer.registerCall("AnnounceAfterSuiteFailure", summary, succinct, fullTrace)
+}
+func (stenographer *FakeStenographer) AnnounceCapturedOutput(output string) {
+ stenographer.registerCall("AnnounceCapturedOutput", output)
+}
+
+func (stenographer *FakeStenographer) AnnounceSuccesfulSpec(spec *types.SpecSummary) {
+ stenographer.registerCall("AnnounceSuccesfulSpec", spec)
+}
+
+func (stenographer *FakeStenographer) AnnounceSuccesfulSlowSpec(spec *types.SpecSummary, succinct bool) {
+ stenographer.registerCall("AnnounceSuccesfulSlowSpec", spec, succinct)
+}
+
+func (stenographer *FakeStenographer) AnnounceSuccesfulMeasurement(spec *types.SpecSummary, succinct bool) {
+ stenographer.registerCall("AnnounceSuccesfulMeasurement", spec, succinct)
+}
+
+func (stenographer *FakeStenographer) AnnouncePendingSpec(spec *types.SpecSummary, noisy bool) {
+ stenographer.registerCall("AnnouncePendingSpec", spec, noisy)
+}
+
+func (stenographer *FakeStenographer) AnnounceSkippedSpec(spec *types.SpecSummary, succinct bool, fullTrace bool) {
+ stenographer.registerCall("AnnounceSkippedSpec", spec, succinct, fullTrace)
+}
+
+func (stenographer *FakeStenographer) AnnounceSpecTimedOut(spec *types.SpecSummary, succinct bool, fullTrace bool) {
+ stenographer.registerCall("AnnounceSpecTimedOut", spec, succinct, fullTrace)
+}
+
+func (stenographer *FakeStenographer) AnnounceSpecPanicked(spec *types.SpecSummary, succinct bool, fullTrace bool) {
+ stenographer.registerCall("AnnounceSpecPanicked", spec, succinct, fullTrace)
+}
+
+func (stenographer *FakeStenographer) AnnounceSpecFailed(spec *types.SpecSummary, succinct bool, fullTrace bool) {
+ stenographer.registerCall("AnnounceSpecFailed", spec, succinct, fullTrace)
+}
+
+func (stenographer *FakeStenographer) SummarizeFailures(summaries []*types.SpecSummary) {
+ stenographer.registerCall("SummarizeFailures", summaries)
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/stenographer.go b/vendor/github.com/onsi/ginkgo/reporters/stenographer/stenographer.go
new file mode 100644
index 000000000..601c74d66
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/stenographer.go
@@ -0,0 +1,572 @@
+/*
+The stenographer is used by Ginkgo's reporters to generate output.
+
+Move along, nothing to see here.
+*/
+
+package stenographer
+
+import (
+ "fmt"
+ "io"
+ "runtime"
+ "strings"
+
+ "github.com/onsi/ginkgo/types"
+)
+
+const defaultStyle = "\x1b[0m"
+const boldStyle = "\x1b[1m"
+const redColor = "\x1b[91m"
+const greenColor = "\x1b[32m"
+const yellowColor = "\x1b[33m"
+const cyanColor = "\x1b[36m"
+const grayColor = "\x1b[90m"
+const lightGrayColor = "\x1b[37m"
+
+type cursorStateType int
+
+const (
+ cursorStateTop cursorStateType = iota
+ cursorStateStreaming
+ cursorStateMidBlock
+ cursorStateEndBlock
+)
+
+type Stenographer interface {
+ AnnounceSuite(description string, randomSeed int64, randomizingAll bool, succinct bool)
+ AnnounceAggregatedParallelRun(nodes int, succinct bool)
+ AnnounceParallelRun(node int, nodes int, succinct bool)
+ AnnounceTotalNumberOfSpecs(total int, succinct bool)
+ AnnounceNumberOfSpecs(specsToRun int, total int, succinct bool)
+ AnnounceSpecRunCompletion(summary *types.SuiteSummary, succinct bool)
+
+ AnnounceSpecWillRun(spec *types.SpecSummary)
+ AnnounceBeforeSuiteFailure(summary *types.SetupSummary, succinct bool, fullTrace bool)
+ AnnounceAfterSuiteFailure(summary *types.SetupSummary, succinct bool, fullTrace bool)
+
+ AnnounceCapturedOutput(output string)
+
+ AnnounceSuccesfulSpec(spec *types.SpecSummary)
+ AnnounceSuccesfulSlowSpec(spec *types.SpecSummary, succinct bool)
+ AnnounceSuccesfulMeasurement(spec *types.SpecSummary, succinct bool)
+
+ AnnouncePendingSpec(spec *types.SpecSummary, noisy bool)
+ AnnounceSkippedSpec(spec *types.SpecSummary, succinct bool, fullTrace bool)
+
+ AnnounceSpecTimedOut(spec *types.SpecSummary, succinct bool, fullTrace bool)
+ AnnounceSpecPanicked(spec *types.SpecSummary, succinct bool, fullTrace bool)
+ AnnounceSpecFailed(spec *types.SpecSummary, succinct bool, fullTrace bool)
+
+ SummarizeFailures(summaries []*types.SpecSummary)
+}
+
+func New(color bool, enableFlakes bool, writer io.Writer) Stenographer {
+ denoter := "•"
+ if runtime.GOOS == "windows" {
+ denoter = "+"
+ }
+ return &consoleStenographer{
+ color: color,
+ denoter: denoter,
+ cursorState: cursorStateTop,
+ enableFlakes: enableFlakes,
+ w: writer,
+ }
+}
+
+type consoleStenographer struct {
+ color bool
+ denoter string
+ cursorState cursorStateType
+ enableFlakes bool
+ w io.Writer
+}
+
+var alternatingColors = []string{defaultStyle, grayColor}
+
+func (s *consoleStenographer) AnnounceSuite(description string, randomSeed int64, randomizingAll bool, succinct bool) {
+ if succinct {
+ s.print(0, "[%d] %s ", randomSeed, s.colorize(boldStyle, description))
+ return
+ }
+ s.printBanner(fmt.Sprintf("Running Suite: %s", description), "=")
+ s.print(0, "Random Seed: %s", s.colorize(boldStyle, "%d", randomSeed))
+ if randomizingAll {
+ s.print(0, " - Will randomize all specs")
+ }
+ s.printNewLine()
+}
+
+func (s *consoleStenographer) AnnounceParallelRun(node int, nodes int, succinct bool) {
+ if succinct {
+ s.print(0, "- node #%d ", node)
+ return
+ }
+ s.println(0,
+ "Parallel test node %s/%s.",
+ s.colorize(boldStyle, "%d", node),
+ s.colorize(boldStyle, "%d", nodes),
+ )
+ s.printNewLine()
+}
+
+func (s *consoleStenographer) AnnounceAggregatedParallelRun(nodes int, succinct bool) {
+ if succinct {
+ s.print(0, "- %d nodes ", nodes)
+ return
+ }
+ s.println(0,
+ "Running in parallel across %s nodes",
+ s.colorize(boldStyle, "%d", nodes),
+ )
+ s.printNewLine()
+}
+
+func (s *consoleStenographer) AnnounceNumberOfSpecs(specsToRun int, total int, succinct bool) {
+ if succinct {
+ s.print(0, "- %d/%d specs ", specsToRun, total)
+ s.stream()
+ return
+ }
+ s.println(0,
+ "Will run %s of %s specs",
+ s.colorize(boldStyle, "%d", specsToRun),
+ s.colorize(boldStyle, "%d", total),
+ )
+
+ s.printNewLine()
+}
+
+func (s *consoleStenographer) AnnounceTotalNumberOfSpecs(total int, succinct bool) {
+ if succinct {
+ s.print(0, "- %d specs ", total)
+ s.stream()
+ return
+ }
+ s.println(0,
+ "Will run %s specs",
+ s.colorize(boldStyle, "%d", total),
+ )
+
+ s.printNewLine()
+}
+
+func (s *consoleStenographer) AnnounceSpecRunCompletion(summary *types.SuiteSummary, succinct bool) {
+ if succinct && summary.SuiteSucceeded {
+ s.print(0, " %s %s ", s.colorize(greenColor, "SUCCESS!"), summary.RunTime)
+ return
+ }
+ s.printNewLine()
+ color := greenColor
+ if !summary.SuiteSucceeded {
+ color = redColor
+ }
+ s.println(0, s.colorize(boldStyle+color, "Ran %d of %d Specs in %.3f seconds", summary.NumberOfSpecsThatWillBeRun, summary.NumberOfTotalSpecs, summary.RunTime.Seconds()))
+
+ status := ""
+ if summary.SuiteSucceeded {
+ status = s.colorize(boldStyle+greenColor, "SUCCESS!")
+ } else {
+ status = s.colorize(boldStyle+redColor, "FAIL!")
+ }
+
+ flakes := ""
+ if s.enableFlakes {
+ flakes = " | " + s.colorize(yellowColor+boldStyle, "%d Flaked", summary.NumberOfFlakedSpecs)
+ }
+
+ s.print(0,
+ "%s -- %s | %s | %s | %s\n",
+ status,
+ s.colorize(greenColor+boldStyle, "%d Passed", summary.NumberOfPassedSpecs),
+ s.colorize(redColor+boldStyle, "%d Failed", summary.NumberOfFailedSpecs)+flakes,
+ s.colorize(yellowColor+boldStyle, "%d Pending", summary.NumberOfPendingSpecs),
+ s.colorize(cyanColor+boldStyle, "%d Skipped", summary.NumberOfSkippedSpecs),
+ )
+}
+
+func (s *consoleStenographer) AnnounceSpecWillRun(spec *types.SpecSummary) {
+ s.startBlock()
+ for i, text := range spec.ComponentTexts[1 : len(spec.ComponentTexts)-1] {
+ s.print(0, s.colorize(alternatingColors[i%2], text)+" ")
+ }
+
+ indentation := 0
+ if len(spec.ComponentTexts) > 2 {
+ indentation = 1
+ s.printNewLine()
+ }
+ index := len(spec.ComponentTexts) - 1
+ s.print(indentation, s.colorize(boldStyle, spec.ComponentTexts[index]))
+ s.printNewLine()
+ s.print(indentation, s.colorize(lightGrayColor, spec.ComponentCodeLocations[index].String()))
+ s.printNewLine()
+ s.midBlock()
+}
+
+func (s *consoleStenographer) AnnounceBeforeSuiteFailure(summary *types.SetupSummary, succinct bool, fullTrace bool) {
+ s.announceSetupFailure("BeforeSuite", summary, succinct, fullTrace)
+}
+
+func (s *consoleStenographer) AnnounceAfterSuiteFailure(summary *types.SetupSummary, succinct bool, fullTrace bool) {
+ s.announceSetupFailure("AfterSuite", summary, succinct, fullTrace)
+}
+
+func (s *consoleStenographer) announceSetupFailure(name string, summary *types.SetupSummary, succinct bool, fullTrace bool) {
+ s.startBlock()
+ var message string
+ switch summary.State {
+ case types.SpecStateFailed:
+ message = "Failure"
+ case types.SpecStatePanicked:
+ message = "Panic"
+ case types.SpecStateTimedOut:
+ message = "Timeout"
+ }
+
+ s.println(0, s.colorize(redColor+boldStyle, "%s [%.3f seconds]", message, summary.RunTime.Seconds()))
+
+ indentation := s.printCodeLocationBlock([]string{name}, []types.CodeLocation{summary.CodeLocation}, summary.ComponentType, 0, summary.State, true)
+
+ s.printNewLine()
+ s.printFailure(indentation, summary.State, summary.Failure, fullTrace)
+
+ s.endBlock()
+}
+
+func (s *consoleStenographer) AnnounceCapturedOutput(output string) {
+ if output == "" {
+ return
+ }
+
+ s.startBlock()
+ s.println(0, output)
+ s.midBlock()
+}
+
+func (s *consoleStenographer) AnnounceSuccesfulSpec(spec *types.SpecSummary) {
+ s.print(0, s.colorize(greenColor, s.denoter))
+ s.stream()
+}
+
+func (s *consoleStenographer) AnnounceSuccesfulSlowSpec(spec *types.SpecSummary, succinct bool) {
+ s.printBlockWithMessage(
+ s.colorize(greenColor, "%s [SLOW TEST:%.3f seconds]", s.denoter, spec.RunTime.Seconds()),
+ "",
+ spec,
+ succinct,
+ )
+}
+
+func (s *consoleStenographer) AnnounceSuccesfulMeasurement(spec *types.SpecSummary, succinct bool) {
+ s.printBlockWithMessage(
+ s.colorize(greenColor, "%s [MEASUREMENT]", s.denoter),
+ s.measurementReport(spec, succinct),
+ spec,
+ succinct,
+ )
+}
+
+func (s *consoleStenographer) AnnouncePendingSpec(spec *types.SpecSummary, noisy bool) {
+ if noisy {
+ s.printBlockWithMessage(
+ s.colorize(yellowColor, "P [PENDING]"),
+ "",
+ spec,
+ false,
+ )
+ } else {
+ s.print(0, s.colorize(yellowColor, "P"))
+ s.stream()
+ }
+}
+
+func (s *consoleStenographer) AnnounceSkippedSpec(spec *types.SpecSummary, succinct bool, fullTrace bool) {
+ // Skips at runtime will have a non-empty spec.Failure. All others should be succinct.
+ if succinct || spec.Failure == (types.SpecFailure{}) {
+ s.print(0, s.colorize(cyanColor, "S"))
+ s.stream()
+ } else {
+ s.startBlock()
+ s.println(0, s.colorize(cyanColor+boldStyle, "S [SKIPPING]%s [%.3f seconds]", s.failureContext(spec.Failure.ComponentType), spec.RunTime.Seconds()))
+
+ indentation := s.printCodeLocationBlock(spec.ComponentTexts, spec.ComponentCodeLocations, spec.Failure.ComponentType, spec.Failure.ComponentIndex, spec.State, succinct)
+
+ s.printNewLine()
+ s.printSkip(indentation, spec.Failure)
+ s.endBlock()
+ }
+}
+
+func (s *consoleStenographer) AnnounceSpecTimedOut(spec *types.SpecSummary, succinct bool, fullTrace bool) {
+ s.printSpecFailure(fmt.Sprintf("%s... Timeout", s.denoter), spec, succinct, fullTrace)
+}
+
+func (s *consoleStenographer) AnnounceSpecPanicked(spec *types.SpecSummary, succinct bool, fullTrace bool) {
+ s.printSpecFailure(fmt.Sprintf("%s! Panic", s.denoter), spec, succinct, fullTrace)
+}
+
+func (s *consoleStenographer) AnnounceSpecFailed(spec *types.SpecSummary, succinct bool, fullTrace bool) {
+ s.printSpecFailure(fmt.Sprintf("%s Failure", s.denoter), spec, succinct, fullTrace)
+}
+
+func (s *consoleStenographer) SummarizeFailures(summaries []*types.SpecSummary) {
+ failingSpecs := []*types.SpecSummary{}
+
+ for _, summary := range summaries {
+ if summary.HasFailureState() {
+ failingSpecs = append(failingSpecs, summary)
+ }
+ }
+
+ if len(failingSpecs) == 0 {
+ return
+ }
+
+ s.printNewLine()
+ s.printNewLine()
+ plural := "s"
+ if len(failingSpecs) == 1 {
+ plural = ""
+ }
+ s.println(0, s.colorize(redColor+boldStyle, "Summarizing %d Failure%s:", len(failingSpecs), plural))
+ for _, summary := range failingSpecs {
+ s.printNewLine()
+ if summary.HasFailureState() {
+ if summary.TimedOut() {
+ s.print(0, s.colorize(redColor+boldStyle, "[Timeout...] "))
+ } else if summary.Panicked() {
+ s.print(0, s.colorize(redColor+boldStyle, "[Panic!] "))
+ } else if summary.Failed() {
+ s.print(0, s.colorize(redColor+boldStyle, "[Fail] "))
+ }
+ s.printSpecContext(summary.ComponentTexts, summary.ComponentCodeLocations, summary.Failure.ComponentType, summary.Failure.ComponentIndex, summary.State, true)
+ s.printNewLine()
+ s.println(0, s.colorize(lightGrayColor, summary.Failure.Location.String()))
+ }
+ }
+}
+
+func (s *consoleStenographer) startBlock() {
+ if s.cursorState == cursorStateStreaming {
+ s.printNewLine()
+ s.printDelimiter()
+ } else if s.cursorState == cursorStateMidBlock {
+ s.printNewLine()
+ }
+}
+
+func (s *consoleStenographer) midBlock() {
+ s.cursorState = cursorStateMidBlock
+}
+
+func (s *consoleStenographer) endBlock() {
+ s.printDelimiter()
+ s.cursorState = cursorStateEndBlock
+}
+
+func (s *consoleStenographer) stream() {
+ s.cursorState = cursorStateStreaming
+}
+
+func (s *consoleStenographer) printBlockWithMessage(header string, message string, spec *types.SpecSummary, succinct bool) {
+ s.startBlock()
+ s.println(0, header)
+
+ indentation := s.printCodeLocationBlock(spec.ComponentTexts, spec.ComponentCodeLocations, types.SpecComponentTypeInvalid, 0, spec.State, succinct)
+
+ if message != "" {
+ s.printNewLine()
+ s.println(indentation, message)
+ }
+
+ s.endBlock()
+}
+
+func (s *consoleStenographer) printSpecFailure(message string, spec *types.SpecSummary, succinct bool, fullTrace bool) {
+ s.startBlock()
+ s.println(0, s.colorize(redColor+boldStyle, "%s%s [%.3f seconds]", message, s.failureContext(spec.Failure.ComponentType), spec.RunTime.Seconds()))
+
+ indentation := s.printCodeLocationBlock(spec.ComponentTexts, spec.ComponentCodeLocations, spec.Failure.ComponentType, spec.Failure.ComponentIndex, spec.State, succinct)
+
+ s.printNewLine()
+ s.printFailure(indentation, spec.State, spec.Failure, fullTrace)
+ s.endBlock()
+}
+
+func (s *consoleStenographer) failureContext(failedComponentType types.SpecComponentType) string {
+ switch failedComponentType {
+ case types.SpecComponentTypeBeforeSuite:
+ return " in Suite Setup (BeforeSuite)"
+ case types.SpecComponentTypeAfterSuite:
+ return " in Suite Teardown (AfterSuite)"
+ case types.SpecComponentTypeBeforeEach:
+ return " in Spec Setup (BeforeEach)"
+ case types.SpecComponentTypeJustBeforeEach:
+ return " in Spec Setup (JustBeforeEach)"
+ case types.SpecComponentTypeAfterEach:
+ return " in Spec Teardown (AfterEach)"
+ }
+
+ return ""
+}
+
+func (s *consoleStenographer) printSkip(indentation int, spec types.SpecFailure) {
+ s.println(indentation, s.colorize(cyanColor, spec.Message))
+ s.printNewLine()
+ s.println(indentation, spec.Location.String())
+}
+
+func (s *consoleStenographer) printFailure(indentation int, state types.SpecState, failure types.SpecFailure, fullTrace bool) {
+ if state == types.SpecStatePanicked {
+ s.println(indentation, s.colorize(redColor+boldStyle, failure.Message))
+ s.println(indentation, s.colorize(redColor, failure.ForwardedPanic))
+ s.println(indentation, failure.Location.String())
+ s.printNewLine()
+ s.println(indentation, s.colorize(redColor, "Full Stack Trace"))
+ s.println(indentation, failure.Location.FullStackTrace)
+ } else {
+ s.println(indentation, s.colorize(redColor, failure.Message))
+ s.printNewLine()
+ s.println(indentation, failure.Location.String())
+ if fullTrace {
+ s.printNewLine()
+ s.println(indentation, s.colorize(redColor, "Full Stack Trace"))
+ s.println(indentation, failure.Location.FullStackTrace)
+ }
+ }
+}
+
+func (s *consoleStenographer) printSpecContext(componentTexts []string, componentCodeLocations []types.CodeLocation, failedComponentType types.SpecComponentType, failedComponentIndex int, state types.SpecState, succinct bool) int {
+ startIndex := 1
+ indentation := 0
+
+ if len(componentTexts) == 1 {
+ startIndex = 0
+ }
+
+ for i := startIndex; i < len(componentTexts); i++ {
+ if (state.IsFailure() || state == types.SpecStateSkipped) && i == failedComponentIndex {
+ color := redColor
+ if state == types.SpecStateSkipped {
+ color = cyanColor
+ }
+ blockType := ""
+ switch failedComponentType {
+ case types.SpecComponentTypeBeforeSuite:
+ blockType = "BeforeSuite"
+ case types.SpecComponentTypeAfterSuite:
+ blockType = "AfterSuite"
+ case types.SpecComponentTypeBeforeEach:
+ blockType = "BeforeEach"
+ case types.SpecComponentTypeJustBeforeEach:
+ blockType = "JustBeforeEach"
+ case types.SpecComponentTypeAfterEach:
+ blockType = "AfterEach"
+ case types.SpecComponentTypeIt:
+ blockType = "It"
+ case types.SpecComponentTypeMeasure:
+ blockType = "Measurement"
+ }
+ if succinct {
+ s.print(0, s.colorize(color+boldStyle, "[%s] %s ", blockType, componentTexts[i]))
+ } else {
+ s.println(indentation, s.colorize(color+boldStyle, "%s [%s]", componentTexts[i], blockType))
+ s.println(indentation, s.colorize(grayColor, "%s", componentCodeLocations[i]))
+ }
+ } else {
+ if succinct {
+ s.print(0, s.colorize(alternatingColors[i%2], "%s ", componentTexts[i]))
+ } else {
+ s.println(indentation, componentTexts[i])
+ s.println(indentation, s.colorize(grayColor, "%s", componentCodeLocations[i]))
+ }
+ }
+ indentation++
+ }
+
+ return indentation
+}
+
+func (s *consoleStenographer) printCodeLocationBlock(componentTexts []string, componentCodeLocations []types.CodeLocation, failedComponentType types.SpecComponentType, failedComponentIndex int, state types.SpecState, succinct bool) int {
+ indentation := s.printSpecContext(componentTexts, componentCodeLocations, failedComponentType, failedComponentIndex, state, succinct)
+
+ if succinct {
+ if len(componentTexts) > 0 {
+ s.printNewLine()
+ s.print(0, s.colorize(lightGrayColor, "%s", componentCodeLocations[len(componentCodeLocations)-1]))
+ }
+ s.printNewLine()
+ indentation = 1
+ } else {
+ indentation--
+ }
+
+ return indentation
+}
+
+func (s *consoleStenographer) orderedMeasurementKeys(measurements map[string]*types.SpecMeasurement) []string {
+ orderedKeys := make([]string, len(measurements))
+ for key, measurement := range measurements {
+ orderedKeys[measurement.Order] = key
+ }
+ return orderedKeys
+}
+
+func (s *consoleStenographer) measurementReport(spec *types.SpecSummary, succinct bool) string {
+ if len(spec.Measurements) == 0 {
+ return "Found no measurements"
+ }
+
+ message := []string{}
+ orderedKeys := s.orderedMeasurementKeys(spec.Measurements)
+
+ if succinct {
+ message = append(message, fmt.Sprintf("%s samples:", s.colorize(boldStyle, "%d", spec.NumberOfSamples)))
+ for _, key := range orderedKeys {
+ measurement := spec.Measurements[key]
+ message = append(message, fmt.Sprintf(" %s - %s: %s%s, %s: %s%s ± %s%s, %s: %s%s",
+ s.colorize(boldStyle, "%s", measurement.Name),
+ measurement.SmallestLabel,
+ s.colorize(greenColor, measurement.PrecisionFmt(), measurement.Smallest),
+ measurement.Units,
+ measurement.AverageLabel,
+ s.colorize(cyanColor, measurement.PrecisionFmt(), measurement.Average),
+ measurement.Units,
+ s.colorize(cyanColor, measurement.PrecisionFmt(), measurement.StdDeviation),
+ measurement.Units,
+ measurement.LargestLabel,
+ s.colorize(redColor, measurement.PrecisionFmt(), measurement.Largest),
+ measurement.Units,
+ ))
+ }
+ } else {
+ message = append(message, fmt.Sprintf("Ran %s samples:", s.colorize(boldStyle, "%d", spec.NumberOfSamples)))
+ for _, key := range orderedKeys {
+ measurement := spec.Measurements[key]
+ info := ""
+ if measurement.Info != nil {
+ message = append(message, fmt.Sprintf("%v", measurement.Info))
+ }
+
+ message = append(message, fmt.Sprintf("%s:\n%s %s: %s%s\n %s: %s%s\n %s: %s%s ± %s%s",
+ s.colorize(boldStyle, "%s", measurement.Name),
+ info,
+ measurement.SmallestLabel,
+ s.colorize(greenColor, measurement.PrecisionFmt(), measurement.Smallest),
+ measurement.Units,
+ measurement.LargestLabel,
+ s.colorize(redColor, measurement.PrecisionFmt(), measurement.Largest),
+ measurement.Units,
+ measurement.AverageLabel,
+ s.colorize(cyanColor, measurement.PrecisionFmt(), measurement.Average),
+ measurement.Units,
+ s.colorize(cyanColor, measurement.PrecisionFmt(), measurement.StdDeviation),
+ measurement.Units,
+ ))
+ }
+ }
+
+ return strings.Join(message, "\n")
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/README.md b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/README.md
new file mode 100644
index 000000000..37de454f4
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/README.md
@@ -0,0 +1,6 @@
+## Colorize Windows
+
+These packages are used for colorize on Windows and contributed by mattn.jp@gmail.com
+
+ * go-colorable: <https://github.com/mattn/go-colorable>
+ * go-isatty: <https://github.com/mattn/go-isatty>
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/LICENSE b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/LICENSE
new file mode 100644
index 000000000..91b5cef30
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Yasuhiro Matsumoto
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/README.md b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/README.md
new file mode 100644
index 000000000..e84226a73
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/README.md
@@ -0,0 +1,43 @@
+# go-colorable
+
+Colorable writer for windows.
+
+For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.)
+This package is possible to handle escape sequence for ansi color on windows.
+
+## Too Bad!
+
+![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/bad.png)
+
+
+## So Good!
+
+![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/good.png)
+
+## Usage
+
+```go
+logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true})
+logrus.SetOutput(colorable.NewColorableStdout())
+
+logrus.Info("succeeded")
+logrus.Warn("not correct")
+logrus.Error("something error")
+logrus.Fatal("panic")
+```
+
+You can compile above code on non-windows OSs.
+
+## Installation
+
+```
+$ go get github.com/mattn/go-colorable
+```
+
+# License
+
+MIT
+
+# Author
+
+Yasuhiro Matsumoto (a.k.a mattn)
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/colorable_others.go b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/colorable_others.go
new file mode 100644
index 000000000..52d6653b3
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/colorable_others.go
@@ -0,0 +1,24 @@
+// +build !windows
+
+package colorable
+
+import (
+ "io"
+ "os"
+)
+
+func NewColorable(file *os.File) io.Writer {
+ if file == nil {
+ panic("nil passed instead of *os.File to NewColorable()")
+ }
+
+ return file
+}
+
+func NewColorableStdout() io.Writer {
+ return os.Stdout
+}
+
+func NewColorableStderr() io.Writer {
+ return os.Stderr
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/colorable_windows.go b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/colorable_windows.go
new file mode 100644
index 000000000..108800923
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/colorable_windows.go
@@ -0,0 +1,783 @@
+package colorable
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+ "math"
+ "os"
+ "strconv"
+ "strings"
+ "syscall"
+ "unsafe"
+
+ "github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty"
+)
+
+const (
+ foregroundBlue = 0x1
+ foregroundGreen = 0x2
+ foregroundRed = 0x4
+ foregroundIntensity = 0x8
+ foregroundMask = (foregroundRed | foregroundBlue | foregroundGreen | foregroundIntensity)
+ backgroundBlue = 0x10
+ backgroundGreen = 0x20
+ backgroundRed = 0x40
+ backgroundIntensity = 0x80
+ backgroundMask = (backgroundRed | backgroundBlue | backgroundGreen | backgroundIntensity)
+)
+
+type wchar uint16
+type short int16
+type dword uint32
+type word uint16
+
+type coord struct {
+ x short
+ y short
+}
+
+type smallRect struct {
+ left short
+ top short
+ right short
+ bottom short
+}
+
+type consoleScreenBufferInfo struct {
+ size coord
+ cursorPosition coord
+ attributes word
+ window smallRect
+ maximumWindowSize coord
+}
+
+var (
+ kernel32 = syscall.NewLazyDLL("kernel32.dll")
+ procGetConsoleScreenBufferInfo = kernel32.NewProc("GetConsoleScreenBufferInfo")
+ procSetConsoleTextAttribute = kernel32.NewProc("SetConsoleTextAttribute")
+ procSetConsoleCursorPosition = kernel32.NewProc("SetConsoleCursorPosition")
+ procFillConsoleOutputCharacter = kernel32.NewProc("FillConsoleOutputCharacterW")
+ procFillConsoleOutputAttribute = kernel32.NewProc("FillConsoleOutputAttribute")
+)
+
+type Writer struct {
+ out io.Writer
+ handle syscall.Handle
+ lastbuf bytes.Buffer
+ oldattr word
+}
+
+func NewColorable(file *os.File) io.Writer {
+ if file == nil {
+ panic("nil passed instead of *os.File to NewColorable()")
+ }
+
+ if isatty.IsTerminal(file.Fd()) {
+ var csbi consoleScreenBufferInfo
+ handle := syscall.Handle(file.Fd())
+ procGetConsoleScreenBufferInfo.Call(uintptr(handle), uintptr(unsafe.Pointer(&csbi)))
+ return &Writer{out: file, handle: handle, oldattr: csbi.attributes}
+ } else {
+ return file
+ }
+}
+
+func NewColorableStdout() io.Writer {
+ return NewColorable(os.Stdout)
+}
+
+func NewColorableStderr() io.Writer {
+ return NewColorable(os.Stderr)
+}
+
+var color256 = map[int]int{
+ 0: 0x000000,
+ 1: 0x800000,
+ 2: 0x008000,
+ 3: 0x808000,
+ 4: 0x000080,
+ 5: 0x800080,
+ 6: 0x008080,
+ 7: 0xc0c0c0,
+ 8: 0x808080,
+ 9: 0xff0000,
+ 10: 0x00ff00,
+ 11: 0xffff00,
+ 12: 0x0000ff,
+ 13: 0xff00ff,
+ 14: 0x00ffff,
+ 15: 0xffffff,
+ 16: 0x000000,
+ 17: 0x00005f,
+ 18: 0x000087,
+ 19: 0x0000af,
+ 20: 0x0000d7,
+ 21: 0x0000ff,
+ 22: 0x005f00,
+ 23: 0x005f5f,
+ 24: 0x005f87,
+ 25: 0x005faf,
+ 26: 0x005fd7,
+ 27: 0x005fff,
+ 28: 0x008700,
+ 29: 0x00875f,
+ 30: 0x008787,
+ 31: 0x0087af,
+ 32: 0x0087d7,
+ 33: 0x0087ff,
+ 34: 0x00af00,
+ 35: 0x00af5f,
+ 36: 0x00af87,
+ 37: 0x00afaf,
+ 38: 0x00afd7,
+ 39: 0x00afff,
+ 40: 0x00d700,
+ 41: 0x00d75f,
+ 42: 0x00d787,
+ 43: 0x00d7af,
+ 44: 0x00d7d7,
+ 45: 0x00d7ff,
+ 46: 0x00ff00,
+ 47: 0x00ff5f,
+ 48: 0x00ff87,
+ 49: 0x00ffaf,
+ 50: 0x00ffd7,
+ 51: 0x00ffff,
+ 52: 0x5f0000,
+ 53: 0x5f005f,
+ 54: 0x5f0087,
+ 55: 0x5f00af,
+ 56: 0x5f00d7,
+ 57: 0x5f00ff,
+ 58: 0x5f5f00,
+ 59: 0x5f5f5f,
+ 60: 0x5f5f87,
+ 61: 0x5f5faf,
+ 62: 0x5f5fd7,
+ 63: 0x5f5fff,
+ 64: 0x5f8700,
+ 65: 0x5f875f,
+ 66: 0x5f8787,
+ 67: 0x5f87af,
+ 68: 0x5f87d7,
+ 69: 0x5f87ff,
+ 70: 0x5faf00,
+ 71: 0x5faf5f,
+ 72: 0x5faf87,
+ 73: 0x5fafaf,
+ 74: 0x5fafd7,
+ 75: 0x5fafff,
+ 76: 0x5fd700,
+ 77: 0x5fd75f,
+ 78: 0x5fd787,
+ 79: 0x5fd7af,
+ 80: 0x5fd7d7,
+ 81: 0x5fd7ff,
+ 82: 0x5fff00,
+ 83: 0x5fff5f,
+ 84: 0x5fff87,
+ 85: 0x5fffaf,
+ 86: 0x5fffd7,
+ 87: 0x5fffff,
+ 88: 0x870000,
+ 89: 0x87005f,
+ 90: 0x870087,
+ 91: 0x8700af,
+ 92: 0x8700d7,
+ 93: 0x8700ff,
+ 94: 0x875f00,
+ 95: 0x875f5f,
+ 96: 0x875f87,
+ 97: 0x875faf,
+ 98: 0x875fd7,
+ 99: 0x875fff,
+ 100: 0x878700,
+ 101: 0x87875f,
+ 102: 0x878787,
+ 103: 0x8787af,
+ 104: 0x8787d7,
+ 105: 0x8787ff,
+ 106: 0x87af00,
+ 107: 0x87af5f,
+ 108: 0x87af87,
+ 109: 0x87afaf,
+ 110: 0x87afd7,
+ 111: 0x87afff,
+ 112: 0x87d700,
+ 113: 0x87d75f,
+ 114: 0x87d787,
+ 115: 0x87d7af,
+ 116: 0x87d7d7,
+ 117: 0x87d7ff,
+ 118: 0x87ff00,
+ 119: 0x87ff5f,
+ 120: 0x87ff87,
+ 121: 0x87ffaf,
+ 122: 0x87ffd7,
+ 123: 0x87ffff,
+ 124: 0xaf0000,
+ 125: 0xaf005f,
+ 126: 0xaf0087,
+ 127: 0xaf00af,
+ 128: 0xaf00d7,
+ 129: 0xaf00ff,
+ 130: 0xaf5f00,
+ 131: 0xaf5f5f,
+ 132: 0xaf5f87,
+ 133: 0xaf5faf,
+ 134: 0xaf5fd7,
+ 135: 0xaf5fff,
+ 136: 0xaf8700,
+ 137: 0xaf875f,
+ 138: 0xaf8787,
+ 139: 0xaf87af,
+ 140: 0xaf87d7,
+ 141: 0xaf87ff,
+ 142: 0xafaf00,
+ 143: 0xafaf5f,
+ 144: 0xafaf87,
+ 145: 0xafafaf,
+ 146: 0xafafd7,
+ 147: 0xafafff,
+ 148: 0xafd700,
+ 149: 0xafd75f,
+ 150: 0xafd787,
+ 151: 0xafd7af,
+ 152: 0xafd7d7,
+ 153: 0xafd7ff,
+ 154: 0xafff00,
+ 155: 0xafff5f,
+ 156: 0xafff87,
+ 157: 0xafffaf,
+ 158: 0xafffd7,
+ 159: 0xafffff,
+ 160: 0xd70000,
+ 161: 0xd7005f,
+ 162: 0xd70087,
+ 163: 0xd700af,
+ 164: 0xd700d7,
+ 165: 0xd700ff,
+ 166: 0xd75f00,
+ 167: 0xd75f5f,
+ 168: 0xd75f87,
+ 169: 0xd75faf,
+ 170: 0xd75fd7,
+ 171: 0xd75fff,
+ 172: 0xd78700,
+ 173: 0xd7875f,
+ 174: 0xd78787,
+ 175: 0xd787af,
+ 176: 0xd787d7,
+ 177: 0xd787ff,
+ 178: 0xd7af00,
+ 179: 0xd7af5f,
+ 180: 0xd7af87,
+ 181: 0xd7afaf,
+ 182: 0xd7afd7,
+ 183: 0xd7afff,
+ 184: 0xd7d700,
+ 185: 0xd7d75f,
+ 186: 0xd7d787,
+ 187: 0xd7d7af,
+ 188: 0xd7d7d7,
+ 189: 0xd7d7ff,
+ 190: 0xd7ff00,
+ 191: 0xd7ff5f,
+ 192: 0xd7ff87,
+ 193: 0xd7ffaf,
+ 194: 0xd7ffd7,
+ 195: 0xd7ffff,
+ 196: 0xff0000,
+ 197: 0xff005f,
+ 198: 0xff0087,
+ 199: 0xff00af,
+ 200: 0xff00d7,
+ 201: 0xff00ff,
+ 202: 0xff5f00,
+ 203: 0xff5f5f,
+ 204: 0xff5f87,
+ 205: 0xff5faf,
+ 206: 0xff5fd7,
+ 207: 0xff5fff,
+ 208: 0xff8700,
+ 209: 0xff875f,
+ 210: 0xff8787,
+ 211: 0xff87af,
+ 212: 0xff87d7,
+ 213: 0xff87ff,
+ 214: 0xffaf00,
+ 215: 0xffaf5f,
+ 216: 0xffaf87,
+ 217: 0xffafaf,
+ 218: 0xffafd7,
+ 219: 0xffafff,
+ 220: 0xffd700,
+ 221: 0xffd75f,
+ 222: 0xffd787,
+ 223: 0xffd7af,
+ 224: 0xffd7d7,
+ 225: 0xffd7ff,
+ 226: 0xffff00,
+ 227: 0xffff5f,
+ 228: 0xffff87,
+ 229: 0xffffaf,
+ 230: 0xffffd7,
+ 231: 0xffffff,
+ 232: 0x080808,
+ 233: 0x121212,
+ 234: 0x1c1c1c,
+ 235: 0x262626,
+ 236: 0x303030,
+ 237: 0x3a3a3a,
+ 238: 0x444444,
+ 239: 0x4e4e4e,
+ 240: 0x585858,
+ 241: 0x626262,
+ 242: 0x6c6c6c,
+ 243: 0x767676,
+ 244: 0x808080,
+ 245: 0x8a8a8a,
+ 246: 0x949494,
+ 247: 0x9e9e9e,
+ 248: 0xa8a8a8,
+ 249: 0xb2b2b2,
+ 250: 0xbcbcbc,
+ 251: 0xc6c6c6,
+ 252: 0xd0d0d0,
+ 253: 0xdadada,
+ 254: 0xe4e4e4,
+ 255: 0xeeeeee,
+}
+
+func (w *Writer) Write(data []byte) (n int, err error) {
+ var csbi consoleScreenBufferInfo
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
+
+ er := bytes.NewBuffer(data)
+loop:
+ for {
+ r1, _, err := procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
+ if r1 == 0 {
+ break loop
+ }
+
+ c1, _, err := er.ReadRune()
+ if err != nil {
+ break loop
+ }
+ if c1 != 0x1b {
+ fmt.Fprint(w.out, string(c1))
+ continue
+ }
+ c2, _, err := er.ReadRune()
+ if err != nil {
+ w.lastbuf.WriteRune(c1)
+ break loop
+ }
+ if c2 != 0x5b {
+ w.lastbuf.WriteRune(c1)
+ w.lastbuf.WriteRune(c2)
+ continue
+ }
+
+ var buf bytes.Buffer
+ var m rune
+ for {
+ c, _, err := er.ReadRune()
+ if err != nil {
+ w.lastbuf.WriteRune(c1)
+ w.lastbuf.WriteRune(c2)
+ w.lastbuf.Write(buf.Bytes())
+ break loop
+ }
+ if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' {
+ m = c
+ break
+ }
+ buf.Write([]byte(string(c)))
+ }
+
+ var csbi consoleScreenBufferInfo
+ switch m {
+ case 'A':
+ n, err = strconv.Atoi(buf.String())
+ if err != nil {
+ continue
+ }
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
+ csbi.cursorPosition.y -= short(n)
+ procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ case 'B':
+ n, err = strconv.Atoi(buf.String())
+ if err != nil {
+ continue
+ }
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
+ csbi.cursorPosition.y += short(n)
+ procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ case 'C':
+ n, err = strconv.Atoi(buf.String())
+ if err != nil {
+ continue
+ }
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
+ csbi.cursorPosition.x -= short(n)
+ procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ case 'D':
+ n, err = strconv.Atoi(buf.String())
+ if err != nil {
+ continue
+ }
+ if n, err = strconv.Atoi(buf.String()); err == nil {
+ var csbi consoleScreenBufferInfo
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
+ csbi.cursorPosition.x += short(n)
+ procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ }
+ case 'E':
+ n, err = strconv.Atoi(buf.String())
+ if err != nil {
+ continue
+ }
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
+ csbi.cursorPosition.x = 0
+ csbi.cursorPosition.y += short(n)
+ procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ case 'F':
+ n, err = strconv.Atoi(buf.String())
+ if err != nil {
+ continue
+ }
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
+ csbi.cursorPosition.x = 0
+ csbi.cursorPosition.y -= short(n)
+ procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ case 'G':
+ n, err = strconv.Atoi(buf.String())
+ if err != nil {
+ continue
+ }
+ procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
+ csbi.cursorPosition.x = short(n)
+ procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ case 'H':
+ token := strings.Split(buf.String(), ";")
+ if len(token) != 2 {
+ continue
+ }
+ n1, err := strconv.Atoi(token[0])
+ if err != nil {
+ continue
+ }
+ n2, err := strconv.Atoi(token[1])
+ if err != nil {
+ continue
+ }
+ csbi.cursorPosition.x = short(n2)
+ csbi.cursorPosition.x = short(n1)
+ procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
+ case 'J':
+ n, err := strconv.Atoi(buf.String())
+ if err != nil {
+ continue
+ }
+ var cursor coord
+ switch n {
+ case 0:
+ cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y}
+ case 1:
+ cursor = coord{x: csbi.window.left, y: csbi.window.top}
+ case 2:
+ cursor = coord{x: csbi.window.left, y: csbi.window.top}
+ }
+ var count, written dword
+ count = dword(csbi.size.x - csbi.cursorPosition.x + (csbi.size.y-csbi.cursorPosition.y)*csbi.size.x)
+ procFillConsoleOutputCharacter.Call(uintptr(w.handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
+ procFillConsoleOutputAttribute.Call(uintptr(w.handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
+ case 'K':
+ n, err := strconv.Atoi(buf.String())
+ if err != nil {
+ continue
+ }
+ var cursor coord
+ switch n {
+ case 0:
+ cursor = coord{x: csbi.cursorPosition.x, y: csbi.cursorPosition.y}
+ case 1:
+ cursor = coord{x: csbi.window.left, y: csbi.window.top + csbi.cursorPosition.y}
+ case 2:
+ cursor = coord{x: csbi.window.left, y: csbi.window.top + csbi.cursorPosition.y}
+ }
+ var count, written dword
+ count = dword(csbi.size.x - csbi.cursorPosition.x)
+ procFillConsoleOutputCharacter.Call(uintptr(w.handle), uintptr(' '), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
+ procFillConsoleOutputAttribute.Call(uintptr(w.handle), uintptr(csbi.attributes), uintptr(count), *(*uintptr)(unsafe.Pointer(&cursor)), uintptr(unsafe.Pointer(&written)))
+ case 'm':
+ attr := csbi.attributes
+ cs := buf.String()
+ if cs == "" {
+ procSetConsoleTextAttribute.Call(uintptr(w.handle), uintptr(w.oldattr))
+ continue
+ }
+ token := strings.Split(cs, ";")
+ for i := 0; i < len(token); i += 1 {
+ ns := token[i]
+ if n, err = strconv.Atoi(ns); err == nil {
+ switch {
+ case n == 0 || n == 100:
+ attr = w.oldattr
+ case 1 <= n && n <= 5:
+ attr |= foregroundIntensity
+ case n == 7:
+ attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4)
+ case 22 == n || n == 25 || n == 25:
+ attr |= foregroundIntensity
+ case n == 27:
+ attr = ((attr & foregroundMask) << 4) | ((attr & backgroundMask) >> 4)
+ case 30 <= n && n <= 37:
+ attr = (attr & backgroundMask)
+ if (n-30)&1 != 0 {
+ attr |= foregroundRed
+ }
+ if (n-30)&2 != 0 {
+ attr |= foregroundGreen
+ }
+ if (n-30)&4 != 0 {
+ attr |= foregroundBlue
+ }
+ case n == 38: // set foreground color.
+ if i < len(token)-2 && (token[i+1] == "5" || token[i+1] == "05") {
+ if n256, err := strconv.Atoi(token[i+2]); err == nil {
+ if n256foreAttr == nil {
+ n256setup()
+ }
+ attr &= backgroundMask
+ attr |= n256foreAttr[n256]
+ i += 2
+ }
+ } else {
+ attr = attr & (w.oldattr & backgroundMask)
+ }
+ case n == 39: // reset foreground color.
+ attr &= backgroundMask
+ attr |= w.oldattr & foregroundMask
+ case 40 <= n && n <= 47:
+ attr = (attr & foregroundMask)
+ if (n-40)&1 != 0 {
+ attr |= backgroundRed
+ }
+ if (n-40)&2 != 0 {
+ attr |= backgroundGreen
+ }
+ if (n-40)&4 != 0 {
+ attr |= backgroundBlue
+ }
+ case n == 48: // set background color.
+ if i < len(token)-2 && token[i+1] == "5" {
+ if n256, err := strconv.Atoi(token[i+2]); err == nil {
+ if n256backAttr == nil {
+ n256setup()
+ }
+ attr &= foregroundMask
+ attr |= n256backAttr[n256]
+ i += 2
+ }
+ } else {
+ attr = attr & (w.oldattr & foregroundMask)
+ }
+ case n == 49: // reset foreground color.
+ attr &= foregroundMask
+ attr |= w.oldattr & backgroundMask
+ case 90 <= n && n <= 97:
+ attr = (attr & backgroundMask)
+ attr |= foregroundIntensity
+ if (n-90)&1 != 0 {
+ attr |= foregroundRed
+ }
+ if (n-90)&2 != 0 {
+ attr |= foregroundGreen
+ }
+ if (n-90)&4 != 0 {
+ attr |= foregroundBlue
+ }
+ case 100 <= n && n <= 107:
+ attr = (attr & foregroundMask)
+ attr |= backgroundIntensity
+ if (n-100)&1 != 0 {
+ attr |= backgroundRed
+ }
+ if (n-100)&2 != 0 {
+ attr |= backgroundGreen
+ }
+ if (n-100)&4 != 0 {
+ attr |= backgroundBlue
+ }
+ }
+ procSetConsoleTextAttribute.Call(uintptr(w.handle), uintptr(attr))
+ }
+ }
+ }
+ }
+ return len(data) - w.lastbuf.Len(), nil
+}
+
+type consoleColor struct {
+ rgb int
+ red bool
+ green bool
+ blue bool
+ intensity bool
+}
+
+func (c consoleColor) foregroundAttr() (attr word) {
+ if c.red {
+ attr |= foregroundRed
+ }
+ if c.green {
+ attr |= foregroundGreen
+ }
+ if c.blue {
+ attr |= foregroundBlue
+ }
+ if c.intensity {
+ attr |= foregroundIntensity
+ }
+ return
+}
+
+func (c consoleColor) backgroundAttr() (attr word) {
+ if c.red {
+ attr |= backgroundRed
+ }
+ if c.green {
+ attr |= backgroundGreen
+ }
+ if c.blue {
+ attr |= backgroundBlue
+ }
+ if c.intensity {
+ attr |= backgroundIntensity
+ }
+ return
+}
+
+var color16 = []consoleColor{
+ consoleColor{0x000000, false, false, false, false},
+ consoleColor{0x000080, false, false, true, false},
+ consoleColor{0x008000, false, true, false, false},
+ consoleColor{0x008080, false, true, true, false},
+ consoleColor{0x800000, true, false, false, false},
+ consoleColor{0x800080, true, false, true, false},
+ consoleColor{0x808000, true, true, false, false},
+ consoleColor{0xc0c0c0, true, true, true, false},
+ consoleColor{0x808080, false, false, false, true},
+ consoleColor{0x0000ff, false, false, true, true},
+ consoleColor{0x00ff00, false, true, false, true},
+ consoleColor{0x00ffff, false, true, true, true},
+ consoleColor{0xff0000, true, false, false, true},
+ consoleColor{0xff00ff, true, false, true, true},
+ consoleColor{0xffff00, true, true, false, true},
+ consoleColor{0xffffff, true, true, true, true},
+}
+
+type hsv struct {
+ h, s, v float32
+}
+
+func (a hsv) dist(b hsv) float32 {
+ dh := a.h - b.h
+ switch {
+ case dh > 0.5:
+ dh = 1 - dh
+ case dh < -0.5:
+ dh = -1 - dh
+ }
+ ds := a.s - b.s
+ dv := a.v - b.v
+ return float32(math.Sqrt(float64(dh*dh + ds*ds + dv*dv)))
+}
+
+func toHSV(rgb int) hsv {
+ r, g, b := float32((rgb&0xFF0000)>>16)/256.0,
+ float32((rgb&0x00FF00)>>8)/256.0,
+ float32(rgb&0x0000FF)/256.0
+ min, max := minmax3f(r, g, b)
+ h := max - min
+ if h > 0 {
+ if max == r {
+ h = (g - b) / h
+ if h < 0 {
+ h += 6
+ }
+ } else if max == g {
+ h = 2 + (b-r)/h
+ } else {
+ h = 4 + (r-g)/h
+ }
+ }
+ h /= 6.0
+ s := max - min
+ if max != 0 {
+ s /= max
+ }
+ v := max
+ return hsv{h: h, s: s, v: v}
+}
+
+type hsvTable []hsv
+
+func toHSVTable(rgbTable []consoleColor) hsvTable {
+ t := make(hsvTable, len(rgbTable))
+ for i, c := range rgbTable {
+ t[i] = toHSV(c.rgb)
+ }
+ return t
+}
+
+func (t hsvTable) find(rgb int) consoleColor {
+ hsv := toHSV(rgb)
+ n := 7
+ l := float32(5.0)
+ for i, p := range t {
+ d := hsv.dist(p)
+ if d < l {
+ l, n = d, i
+ }
+ }
+ return color16[n]
+}
+
+func minmax3f(a, b, c float32) (min, max float32) {
+ if a < b {
+ if b < c {
+ return a, c
+ } else if a < c {
+ return a, b
+ } else {
+ return c, b
+ }
+ } else {
+ if a < c {
+ return b, c
+ } else if b < c {
+ return b, a
+ } else {
+ return c, a
+ }
+ }
+}
+
+var n256foreAttr []word
+var n256backAttr []word
+
+func n256setup() {
+ n256foreAttr = make([]word, 256)
+ n256backAttr = make([]word, 256)
+ t := toHSVTable(color16)
+ for i, rgb := range color256 {
+ c := t.find(rgb)
+ n256foreAttr[i] = c.foregroundAttr()
+ n256backAttr[i] = c.backgroundAttr()
+ }
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/noncolorable.go b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/noncolorable.go
new file mode 100644
index 000000000..fb976dbd8
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/noncolorable.go
@@ -0,0 +1,57 @@
+package colorable
+
+import (
+ "bytes"
+ "fmt"
+ "io"
+)
+
+type NonColorable struct {
+ out io.Writer
+ lastbuf bytes.Buffer
+}
+
+func NewNonColorable(w io.Writer) io.Writer {
+ return &NonColorable{out: w}
+}
+
+func (w *NonColorable) Write(data []byte) (n int, err error) {
+ er := bytes.NewBuffer(data)
+loop:
+ for {
+ c1, _, err := er.ReadRune()
+ if err != nil {
+ break loop
+ }
+ if c1 != 0x1b {
+ fmt.Fprint(w.out, string(c1))
+ continue
+ }
+ c2, _, err := er.ReadRune()
+ if err != nil {
+ w.lastbuf.WriteRune(c1)
+ break loop
+ }
+ if c2 != 0x5b {
+ w.lastbuf.WriteRune(c1)
+ w.lastbuf.WriteRune(c2)
+ continue
+ }
+
+ var buf bytes.Buffer
+ for {
+ c, _, err := er.ReadRune()
+ if err != nil {
+ w.lastbuf.WriteRune(c1)
+ w.lastbuf.WriteRune(c2)
+ w.lastbuf.Write(buf.Bytes())
+ break loop
+ }
+ if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' {
+ break
+ }
+ buf.Write([]byte(string(c)))
+ }
+ }
+ return len(data) - w.lastbuf.Len(), nil
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/LICENSE b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/LICENSE
new file mode 100644
index 000000000..65dc692b6
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/LICENSE
@@ -0,0 +1,9 @@
+Copyright (c) Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
+
+MIT License (Expat)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/README.md b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/README.md
new file mode 100644
index 000000000..74845de4a
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/README.md
@@ -0,0 +1,37 @@
+# go-isatty
+
+isatty for golang
+
+## Usage
+
+```go
+package main
+
+import (
+ "fmt"
+ "github.com/mattn/go-isatty"
+ "os"
+)
+
+func main() {
+ if isatty.IsTerminal(os.Stdout.Fd()) {
+ fmt.Println("Is Terminal")
+ } else {
+ fmt.Println("Is Not Terminal")
+ }
+}
+```
+
+## Installation
+
+```
+$ go get github.com/mattn/go-isatty
+```
+
+# License
+
+MIT
+
+# Author
+
+Yasuhiro Matsumoto (a.k.a mattn)
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/doc.go b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/doc.go
new file mode 100644
index 000000000..17d4f90eb
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/doc.go
@@ -0,0 +1,2 @@
+// Package isatty implements interface to isatty
+package isatty
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_appengine.go b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_appengine.go
new file mode 100644
index 000000000..83c588773
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_appengine.go
@@ -0,0 +1,9 @@
+// +build appengine
+
+package isatty
+
+// IsTerminal returns true if the file descriptor is terminal which
+// is always false on on appengine classic which is a sandboxed PaaS.
+func IsTerminal(fd uintptr) bool {
+ return false
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_bsd.go b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_bsd.go
new file mode 100644
index 000000000..98ffe86a4
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_bsd.go
@@ -0,0 +1,18 @@
+// +build darwin freebsd openbsd netbsd
+// +build !appengine
+
+package isatty
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+const ioctlReadTermios = syscall.TIOCGETA
+
+// IsTerminal return true if the file descriptor is terminal.
+func IsTerminal(fd uintptr) bool {
+ var termios syscall.Termios
+ _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
+ return err == 0
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_linux.go b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_linux.go
new file mode 100644
index 000000000..9d24bac1d
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_linux.go
@@ -0,0 +1,18 @@
+// +build linux
+// +build !appengine
+
+package isatty
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+const ioctlReadTermios = syscall.TCGETS
+
+// IsTerminal return true if the file descriptor is terminal.
+func IsTerminal(fd uintptr) bool {
+ var termios syscall.Termios
+ _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
+ return err == 0
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_solaris.go b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_solaris.go
new file mode 100644
index 000000000..1f0c6bf53
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_solaris.go
@@ -0,0 +1,16 @@
+// +build solaris
+// +build !appengine
+
+package isatty
+
+import (
+ "golang.org/x/sys/unix"
+)
+
+// IsTerminal returns true if the given file descriptor is a terminal.
+// see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c
+func IsTerminal(fd uintptr) bool {
+ var termio unix.Termio
+ err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio)
+ return err == nil
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_windows.go b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_windows.go
new file mode 100644
index 000000000..83c398b16
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/isatty_windows.go
@@ -0,0 +1,19 @@
+// +build windows
+// +build !appengine
+
+package isatty
+
+import (
+ "syscall"
+ "unsafe"
+)
+
+var kernel32 = syscall.NewLazyDLL("kernel32.dll")
+var procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
+
+// IsTerminal return true if the file descriptor is terminal.
+func IsTerminal(fd uintptr) bool {
+ var st uint32
+ r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0)
+ return r != 0 && e == 0
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/teamcity_reporter.go b/vendor/github.com/onsi/ginkgo/reporters/teamcity_reporter.go
new file mode 100644
index 000000000..36ee2a600
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/teamcity_reporter.go
@@ -0,0 +1,93 @@
+/*
+
+TeamCity Reporter for Ginkgo
+
+Makes use of TeamCity's support for Service Messages
+http://confluence.jetbrains.com/display/TCD7/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-ReportingTests
+*/
+
+package reporters
+
+import (
+ "fmt"
+ "io"
+ "strings"
+
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/types"
+)
+
+const (
+ messageId = "##teamcity"
+)
+
+type TeamCityReporter struct {
+ writer io.Writer
+ testSuiteName string
+}
+
+func NewTeamCityReporter(writer io.Writer) *TeamCityReporter {
+ return &TeamCityReporter{
+ writer: writer,
+ }
+}
+
+func (reporter *TeamCityReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) {
+ reporter.testSuiteName = escape(summary.SuiteDescription)
+ fmt.Fprintf(reporter.writer, "%s[testSuiteStarted name='%s']", messageId, reporter.testSuiteName)
+}
+
+func (reporter *TeamCityReporter) BeforeSuiteDidRun(setupSummary *types.SetupSummary) {
+ reporter.handleSetupSummary("BeforeSuite", setupSummary)
+}
+
+func (reporter *TeamCityReporter) AfterSuiteDidRun(setupSummary *types.SetupSummary) {
+ reporter.handleSetupSummary("AfterSuite", setupSummary)
+}
+
+func (reporter *TeamCityReporter) handleSetupSummary(name string, setupSummary *types.SetupSummary) {
+ if setupSummary.State != types.SpecStatePassed {
+ testName := escape(name)
+ fmt.Fprintf(reporter.writer, "%s[testStarted name='%s']", messageId, testName)
+ message := escape(setupSummary.Failure.ComponentCodeLocation.String())
+ details := escape(setupSummary.Failure.Message)
+ fmt.Fprintf(reporter.writer, "%s[testFailed name='%s' message='%s' details='%s']", messageId, testName, message, details)
+ durationInMilliseconds := setupSummary.RunTime.Seconds() * 1000
+ fmt.Fprintf(reporter.writer, "%s[testFinished name='%s' duration='%v']", messageId, testName, durationInMilliseconds)
+ }
+}
+
+func (reporter *TeamCityReporter) SpecWillRun(specSummary *types.SpecSummary) {
+ testName := escape(strings.Join(specSummary.ComponentTexts[1:], " "))
+ fmt.Fprintf(reporter.writer, "%s[testStarted name='%s']", messageId, testName)
+}
+
+func (reporter *TeamCityReporter) SpecDidComplete(specSummary *types.SpecSummary) {
+ testName := escape(strings.Join(specSummary.ComponentTexts[1:], " "))
+
+ if specSummary.State == types.SpecStateFailed || specSummary.State == types.SpecStateTimedOut || specSummary.State == types.SpecStatePanicked {
+ message := escape(specSummary.Failure.ComponentCodeLocation.String())
+ details := escape(specSummary.Failure.Message)
+ fmt.Fprintf(reporter.writer, "%s[testFailed name='%s' message='%s' details='%s']", messageId, testName, message, details)
+ }
+ if specSummary.State == types.SpecStateSkipped || specSummary.State == types.SpecStatePending {
+ fmt.Fprintf(reporter.writer, "%s[testIgnored name='%s']", messageId, testName)
+ }
+
+ durationInMilliseconds := specSummary.RunTime.Seconds() * 1000
+ fmt.Fprintf(reporter.writer, "%s[testFinished name='%s' duration='%v']", messageId, testName, durationInMilliseconds)
+}
+
+func (reporter *TeamCityReporter) SpecSuiteDidEnd(summary *types.SuiteSummary) {
+ fmt.Fprintf(reporter.writer, "%s[testSuiteFinished name='%s']", messageId, reporter.testSuiteName)
+}
+
+func escape(output string) string {
+ output = strings.Replace(output, "|", "||", -1)
+ output = strings.Replace(output, "'", "|'", -1)
+ output = strings.Replace(output, "\n", "|n", -1)
+ output = strings.Replace(output, "\r", "|r", -1)
+ output = strings.Replace(output, "[", "|[", -1)
+ output = strings.Replace(output, "]", "|]", -1)
+ return output
+}
diff --git a/vendor/github.com/onsi/ginkgo/reporters/teamcity_reporter_test.go b/vendor/github.com/onsi/ginkgo/reporters/teamcity_reporter_test.go
new file mode 100644
index 000000000..b45d5db01
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/reporters/teamcity_reporter_test.go
@@ -0,0 +1,214 @@
+package reporters_test
+
+import (
+ "bytes"
+ "fmt"
+ "time"
+
+ . "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/config"
+ "github.com/onsi/ginkgo/internal/codelocation"
+ "github.com/onsi/ginkgo/reporters"
+ "github.com/onsi/ginkgo/types"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("TeamCity Reporter", func() {
+ var (
+ buffer bytes.Buffer
+ reporter Reporter
+ )
+
+ BeforeEach(func() {
+ buffer.Truncate(0)
+ reporter = reporters.NewTeamCityReporter(&buffer)
+ reporter.SpecSuiteWillBegin(config.GinkgoConfigType{}, &types.SuiteSummary{
+ SuiteDescription: "Foo's test suite",
+ NumberOfSpecsThatWillBeRun: 1,
+ })
+ })
+
+ Describe("a passing test", func() {
+ BeforeEach(func() {
+ beforeSuite := &types.SetupSummary{
+ State: types.SpecStatePassed,
+ }
+ reporter.BeforeSuiteDidRun(beforeSuite)
+
+ afterSuite := &types.SetupSummary{
+ State: types.SpecStatePassed,
+ }
+ reporter.AfterSuiteDidRun(afterSuite)
+
+ spec := &types.SpecSummary{
+ ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
+ State: types.SpecStatePassed,
+ RunTime: 5 * time.Second,
+ }
+ reporter.SpecWillRun(spec)
+ reporter.SpecDidComplete(spec)
+
+ reporter.SpecSuiteDidEnd(&types.SuiteSummary{
+ NumberOfSpecsThatWillBeRun: 1,
+ NumberOfFailedSpecs: 0,
+ RunTime: 10 * time.Second,
+ })
+ })
+
+ It("should record the test as passing", func() {
+ actual := buffer.String()
+ expected :=
+ "##teamcity[testSuiteStarted name='Foo|'s test suite']" +
+ "##teamcity[testStarted name='A B C']" +
+ "##teamcity[testFinished name='A B C' duration='5000']" +
+ "##teamcity[testSuiteFinished name='Foo|'s test suite']"
+ Ω(actual).Should(Equal(expected))
+ })
+ })
+
+ Describe("when the BeforeSuite fails", func() {
+ var beforeSuite *types.SetupSummary
+
+ BeforeEach(func() {
+ beforeSuite = &types.SetupSummary{
+ State: types.SpecStateFailed,
+ RunTime: 3 * time.Second,
+ Failure: types.SpecFailure{
+ Message: "failed to setup\n",
+ ComponentCodeLocation: codelocation.New(0),
+ },
+ }
+ reporter.BeforeSuiteDidRun(beforeSuite)
+
+ reporter.SpecSuiteDidEnd(&types.SuiteSummary{
+ NumberOfSpecsThatWillBeRun: 1,
+ NumberOfFailedSpecs: 1,
+ RunTime: 10 * time.Second,
+ })
+ })
+
+ It("should record the test as having failed", func() {
+ actual := buffer.String()
+ expected := fmt.Sprintf(
+ "##teamcity[testSuiteStarted name='Foo|'s test suite']"+
+ "##teamcity[testStarted name='BeforeSuite']"+
+ "##teamcity[testFailed name='BeforeSuite' message='%s' details='failed to setup|n']"+
+ "##teamcity[testFinished name='BeforeSuite' duration='3000']"+
+ "##teamcity[testSuiteFinished name='Foo|'s test suite']", beforeSuite.Failure.ComponentCodeLocation.String(),
+ )
+ Ω(actual).Should(Equal(expected))
+ })
+ })
+
+ Describe("when the AfterSuite fails", func() {
+ var afterSuite *types.SetupSummary
+
+ BeforeEach(func() {
+ afterSuite = &types.SetupSummary{
+ State: types.SpecStateFailed,
+ RunTime: 3 * time.Second,
+ Failure: types.SpecFailure{
+ Message: "failed to setup\n",
+ ComponentCodeLocation: codelocation.New(0),
+ },
+ }
+ reporter.AfterSuiteDidRun(afterSuite)
+
+ reporter.SpecSuiteDidEnd(&types.SuiteSummary{
+ NumberOfSpecsThatWillBeRun: 1,
+ NumberOfFailedSpecs: 1,
+ RunTime: 10 * time.Second,
+ })
+ })
+
+ It("should record the test as having failed", func() {
+ actual := buffer.String()
+ expected := fmt.Sprintf(
+ "##teamcity[testSuiteStarted name='Foo|'s test suite']"+
+ "##teamcity[testStarted name='AfterSuite']"+
+ "##teamcity[testFailed name='AfterSuite' message='%s' details='failed to setup|n']"+
+ "##teamcity[testFinished name='AfterSuite' duration='3000']"+
+ "##teamcity[testSuiteFinished name='Foo|'s test suite']", afterSuite.Failure.ComponentCodeLocation.String(),
+ )
+ Ω(actual).Should(Equal(expected))
+ })
+ })
+ specStateCases := []struct {
+ state types.SpecState
+ message string
+ }{
+ {types.SpecStateFailed, "Failure"},
+ {types.SpecStateTimedOut, "Timeout"},
+ {types.SpecStatePanicked, "Panic"},
+ }
+
+ for _, specStateCase := range specStateCases {
+ specStateCase := specStateCase
+ Describe("a failing test", func() {
+ var spec *types.SpecSummary
+ BeforeEach(func() {
+ spec = &types.SpecSummary{
+ ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
+ State: specStateCase.state,
+ RunTime: 5 * time.Second,
+ Failure: types.SpecFailure{
+ ComponentCodeLocation: codelocation.New(0),
+ Message: "I failed",
+ },
+ }
+ reporter.SpecWillRun(spec)
+ reporter.SpecDidComplete(spec)
+
+ reporter.SpecSuiteDidEnd(&types.SuiteSummary{
+ NumberOfSpecsThatWillBeRun: 1,
+ NumberOfFailedSpecs: 1,
+ RunTime: 10 * time.Second,
+ })
+ })
+
+ It("should record test as failing", func() {
+ actual := buffer.String()
+ expected :=
+ fmt.Sprintf("##teamcity[testSuiteStarted name='Foo|'s test suite']"+
+ "##teamcity[testStarted name='A B C']"+
+ "##teamcity[testFailed name='A B C' message='%s' details='I failed']"+
+ "##teamcity[testFinished name='A B C' duration='5000']"+
+ "##teamcity[testSuiteFinished name='Foo|'s test suite']", spec.Failure.ComponentCodeLocation.String())
+ Ω(actual).Should(Equal(expected))
+ })
+ })
+ }
+
+ for _, specStateCase := range []types.SpecState{types.SpecStatePending, types.SpecStateSkipped} {
+ specStateCase := specStateCase
+ Describe("a skipped test", func() {
+ var spec *types.SpecSummary
+ BeforeEach(func() {
+ spec = &types.SpecSummary{
+ ComponentTexts: []string{"[Top Level]", "A", "B", "C"},
+ State: specStateCase,
+ RunTime: 5 * time.Second,
+ }
+ reporter.SpecWillRun(spec)
+ reporter.SpecDidComplete(spec)
+
+ reporter.SpecSuiteDidEnd(&types.SuiteSummary{
+ NumberOfSpecsThatWillBeRun: 1,
+ NumberOfFailedSpecs: 0,
+ RunTime: 10 * time.Second,
+ })
+ })
+
+ It("should record test as ignored", func() {
+ actual := buffer.String()
+ expected :=
+ "##teamcity[testSuiteStarted name='Foo|'s test suite']" +
+ "##teamcity[testStarted name='A B C']" +
+ "##teamcity[testIgnored name='A B C']" +
+ "##teamcity[testFinished name='A B C' duration='5000']" +
+ "##teamcity[testSuiteFinished name='Foo|'s test suite']"
+ Ω(actual).Should(Equal(expected))
+ })
+ })
+ }
+})
diff --git a/vendor/github.com/onsi/ginkgo/types/code_location.go b/vendor/github.com/onsi/ginkgo/types/code_location.go
new file mode 100644
index 000000000..935a89e13
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/types/code_location.go
@@ -0,0 +1,15 @@
+package types
+
+import (
+ "fmt"
+)
+
+type CodeLocation struct {
+ FileName string
+ LineNumber int
+ FullStackTrace string
+}
+
+func (codeLocation CodeLocation) String() string {
+ return fmt.Sprintf("%s:%d", codeLocation.FileName, codeLocation.LineNumber)
+}
diff --git a/vendor/github.com/onsi/ginkgo/types/synchronization.go b/vendor/github.com/onsi/ginkgo/types/synchronization.go
new file mode 100644
index 000000000..fdd6ed5bd
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/types/synchronization.go
@@ -0,0 +1,30 @@
+package types
+
+import (
+ "encoding/json"
+)
+
+type RemoteBeforeSuiteState int
+
+const (
+ RemoteBeforeSuiteStateInvalid RemoteBeforeSuiteState = iota
+
+ RemoteBeforeSuiteStatePending
+ RemoteBeforeSuiteStatePassed
+ RemoteBeforeSuiteStateFailed
+ RemoteBeforeSuiteStateDisappeared
+)
+
+type RemoteBeforeSuiteData struct {
+ Data []byte
+ State RemoteBeforeSuiteState
+}
+
+func (r RemoteBeforeSuiteData) ToJSON() []byte {
+ data, _ := json.Marshal(r)
+ return data
+}
+
+type RemoteAfterSuiteData struct {
+ CanRun bool
+}
diff --git a/vendor/github.com/onsi/ginkgo/types/types.go b/vendor/github.com/onsi/ginkgo/types/types.go
new file mode 100644
index 000000000..0e89521be
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/types/types.go
@@ -0,0 +1,174 @@
+package types
+
+import (
+ "strconv"
+ "time"
+)
+
+const GINKGO_FOCUS_EXIT_CODE = 197
+
+/*
+SuiteSummary represents the a summary of the test suite and is passed to both
+Reporter.SpecSuiteWillBegin
+Reporter.SpecSuiteDidEnd
+
+this is unfortunate as these two methods should receive different objects. When running in parallel
+each node does not deterministically know how many specs it will end up running.
+
+Unfortunately making such a change would break backward compatibility.
+
+Until Ginkgo 2.0 comes out we will continue to reuse this struct but populate unkown fields
+with -1.
+*/
+type SuiteSummary struct {
+ SuiteDescription string
+ SuiteSucceeded bool
+ SuiteID string
+
+ NumberOfSpecsBeforeParallelization int
+ NumberOfTotalSpecs int
+ NumberOfSpecsThatWillBeRun int
+ NumberOfPendingSpecs int
+ NumberOfSkippedSpecs int
+ NumberOfPassedSpecs int
+ NumberOfFailedSpecs int
+ // Flaked specs are those that failed initially, but then passed on a
+ // subsequent try.
+ NumberOfFlakedSpecs int
+ RunTime time.Duration
+}
+
+type SpecSummary struct {
+ ComponentTexts []string
+ ComponentCodeLocations []CodeLocation
+
+ State SpecState
+ RunTime time.Duration
+ Failure SpecFailure
+ IsMeasurement bool
+ NumberOfSamples int
+ Measurements map[string]*SpecMeasurement
+
+ CapturedOutput string
+ SuiteID string
+}
+
+func (s SpecSummary) HasFailureState() bool {
+ return s.State.IsFailure()
+}
+
+func (s SpecSummary) TimedOut() bool {
+ return s.State == SpecStateTimedOut
+}
+
+func (s SpecSummary) Panicked() bool {
+ return s.State == SpecStatePanicked
+}
+
+func (s SpecSummary) Failed() bool {
+ return s.State == SpecStateFailed
+}
+
+func (s SpecSummary) Passed() bool {
+ return s.State == SpecStatePassed
+}
+
+func (s SpecSummary) Skipped() bool {
+ return s.State == SpecStateSkipped
+}
+
+func (s SpecSummary) Pending() bool {
+ return s.State == SpecStatePending
+}
+
+type SetupSummary struct {
+ ComponentType SpecComponentType
+ CodeLocation CodeLocation
+
+ State SpecState
+ RunTime time.Duration
+ Failure SpecFailure
+
+ CapturedOutput string
+ SuiteID string
+}
+
+type SpecFailure struct {
+ Message string
+ Location CodeLocation
+ ForwardedPanic string
+
+ ComponentIndex int
+ ComponentType SpecComponentType
+ ComponentCodeLocation CodeLocation
+}
+
+type SpecMeasurement struct {
+ Name string
+ Info interface{}
+ Order int
+
+ Results []float64
+
+ Smallest float64
+ Largest float64
+ Average float64
+ StdDeviation float64
+
+ SmallestLabel string
+ LargestLabel string
+ AverageLabel string
+ Units string
+ Precision int
+}
+
+func (s SpecMeasurement) PrecisionFmt() string {
+ if s.Precision == 0 {
+ return "%f"
+ }
+
+ str := strconv.Itoa(s.Precision)
+
+ return "%." + str + "f"
+}
+
+type SpecState uint
+
+const (
+ SpecStateInvalid SpecState = iota
+
+ SpecStatePending
+ SpecStateSkipped
+ SpecStatePassed
+ SpecStateFailed
+ SpecStatePanicked
+ SpecStateTimedOut
+)
+
+func (state SpecState) IsFailure() bool {
+ return state == SpecStateTimedOut || state == SpecStatePanicked || state == SpecStateFailed
+}
+
+type SpecComponentType uint
+
+const (
+ SpecComponentTypeInvalid SpecComponentType = iota
+
+ SpecComponentTypeContainer
+ SpecComponentTypeBeforeSuite
+ SpecComponentTypeAfterSuite
+ SpecComponentTypeBeforeEach
+ SpecComponentTypeJustBeforeEach
+ SpecComponentTypeJustAfterEach
+ SpecComponentTypeAfterEach
+ SpecComponentTypeIt
+ SpecComponentTypeMeasure
+)
+
+type FlagType uint
+
+const (
+ FlagTypeNone FlagType = iota
+ FlagTypeFocused
+ FlagTypePending
+)
diff --git a/vendor/github.com/onsi/ginkgo/types/types_suite_test.go b/vendor/github.com/onsi/ginkgo/types/types_suite_test.go
new file mode 100644
index 000000000..b026169c1
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/types/types_suite_test.go
@@ -0,0 +1,13 @@
+package types_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestTypes(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Types Suite")
+}
diff --git a/vendor/github.com/onsi/ginkgo/types/types_test.go b/vendor/github.com/onsi/ginkgo/types/types_test.go
new file mode 100644
index 000000000..a0e161c88
--- /dev/null
+++ b/vendor/github.com/onsi/ginkgo/types/types_test.go
@@ -0,0 +1,99 @@
+package types_test
+
+import (
+ . "github.com/onsi/ginkgo/types"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var specStates = []SpecState{
+ SpecStatePassed,
+ SpecStateTimedOut,
+ SpecStatePanicked,
+ SpecStateFailed,
+ SpecStatePending,
+ SpecStateSkipped,
+}
+
+func verifySpecSummary(caller func(SpecSummary) bool, trueStates ...SpecState) {
+ summary := SpecSummary{}
+ trueStateLookup := map[SpecState]bool{}
+ for _, state := range trueStates {
+ trueStateLookup[state] = true
+ summary.State = state
+ Ω(caller(summary)).Should(BeTrue())
+ }
+
+ for _, state := range specStates {
+ if trueStateLookup[state] {
+ continue
+ }
+ summary.State = state
+ Ω(caller(summary)).Should(BeFalse())
+ }
+}
+
+var _ = Describe("Types", func() {
+ Describe("IsFailureState", func() {
+ It("knows when it is in a failure-like state", func() {
+ verifySpecSummary(func(summary SpecSummary) bool {
+ return summary.State.IsFailure()
+ }, SpecStateTimedOut, SpecStatePanicked, SpecStateFailed)
+ })
+ })
+
+ Describe("SpecSummary", func() {
+ It("knows when it is in a failure-like state", func() {
+ verifySpecSummary(func(summary SpecSummary) bool {
+ return summary.HasFailureState()
+ }, SpecStateTimedOut, SpecStatePanicked, SpecStateFailed)
+ })
+
+ It("knows when it passed", func() {
+ verifySpecSummary(func(summary SpecSummary) bool {
+ return summary.Passed()
+ }, SpecStatePassed)
+ })
+
+ It("knows when it has failed", func() {
+ verifySpecSummary(func(summary SpecSummary) bool {
+ return summary.Failed()
+ }, SpecStateFailed)
+ })
+
+ It("knows when it has panicked", func() {
+ verifySpecSummary(func(summary SpecSummary) bool {
+ return summary.Panicked()
+ }, SpecStatePanicked)
+ })
+
+ It("knows when it has timed out", func() {
+ verifySpecSummary(func(summary SpecSummary) bool {
+ return summary.TimedOut()
+ }, SpecStateTimedOut)
+ })
+
+ It("knows when it is pending", func() {
+ verifySpecSummary(func(summary SpecSummary) bool {
+ return summary.Pending()
+ }, SpecStatePending)
+ })
+
+ It("knows when it is skipped", func() {
+ verifySpecSummary(func(summary SpecSummary) bool {
+ return summary.Skipped()
+ }, SpecStateSkipped)
+ })
+ })
+
+ Describe("SpecMeasurement", func() {
+ It("knows how to format values when the precision is 0", func() {
+ Ω(SpecMeasurement{}.PrecisionFmt()).Should(Equal("%f"))
+ })
+
+ It("knows how to format the values when the precision is 3", func() {
+ Ω(SpecMeasurement{Precision: 3}.PrecisionFmt()).Should(Equal("%.3f"))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/.gitignore b/vendor/github.com/onsi/gomega/.gitignore
new file mode 100644
index 000000000..720c13cba
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/.gitignore
@@ -0,0 +1,5 @@
+.DS_Store
+*.test
+.
+.idea
+gomega.iml
diff --git a/vendor/github.com/onsi/gomega/.travis.yml b/vendor/github.com/onsi/gomega/.travis.yml
new file mode 100644
index 000000000..4d71367f6
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/.travis.yml
@@ -0,0 +1,23 @@
+language: go
+
+go:
+ - 1.6.x
+ - 1.7.x
+ - 1.8.x
+ - 1.9.x
+ - 1.10.x
+ - 1.11.x
+
+env:
+ - GO111MODULE=on
+
+install:
+ - go get -v ./...
+ - go build ./...
+ - go get github.com/onsi/ginkgo
+ - go install github.com/onsi/ginkgo/ginkgo
+
+script: |
+ $HOME/gopath/bin/ginkgo -p -r --randomizeAllSpecs --failOnPending --randomizeSuites --race &&
+ go vet &&
+ [ -z "`gofmt -l -e -s -w .`" ]
diff --git a/vendor/github.com/onsi/gomega/CHANGELOG.md b/vendor/github.com/onsi/gomega/CHANGELOG.md
new file mode 100644
index 000000000..9153294f7
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/CHANGELOG.md
@@ -0,0 +1,125 @@
+## 1.4.3
+
+### Fixes:
+
+- ensure file name and line numbers are correctly reported for XUnit [6fff58f]
+- Fixed matcher for content-type (#305) [69d9b43]
+
+## 1.4.2
+
+### Fixes:
+
+- Add go.mod and go.sum files to define the gomega go module [f3de367, a085d30]
+- Work around go vet issue with Go v1.11 (#300) [40dd6ad]
+- Better output when using with go XUnit-style tests, fixes #255 (#297) [29a4b97]
+- Fix MatchJSON fail to parse json.RawMessage (#298) [ae19f1b]
+- show threshold in failure message of BeNumericallyMatcher (#293) [4bbecc8]
+
+## 1.4.1
+
+### Fixes:
+
+- Update documentation formatting and examples (#289) [9be8410]
+- allow 'Receive' matcher to be used with concrete types (#286) [41673fd]
+- Fix data race in ghttp server (#283) [7ac6b01]
+- Travis badge should only show master [cc102ab]
+
+## 1.4.0
+
+### Features
+- Make string pretty diff user configurable (#273) [eb112ce, 649b44d]
+
+### Fixes
+- Use httputil.DumpRequest to pretty-print unhandled requests (#278) [a4ff0fc, b7d1a52]
+- fix typo floa32 > float32 (#272) [041ae3b, 6e33911]
+- Fix link to documentation on adding your own matchers (#270) [bb2c830, fcebc62]
+- Use setters and getters to avoid race condition (#262) [13057c3, a9c79f1]
+- Avoid sending a signal if the process is not alive (#259) [b8043e5, 4fc1762]
+- Improve message from AssignableToTypeOf when expected value is nil (#281) [9c1fb20]
+
+## 1.3.0
+
+Improvements:
+
+- The `Equal` matcher matches byte slices more performantly.
+- Improved how `MatchError` matches error strings.
+- `MatchXML` ignores the order of xml node attributes.
+- Improve support for XUnit style golang tests. ([#254](https://github.com/onsi/gomega/issues/254))
+
+Bug Fixes:
+
+- Diff generation now handles multi-byte sequences correctly.
+- Multiple goroutines can now call `gexec.Build` concurrently.
+
+## 1.2.0
+
+Improvements:
+
+- Added `BeSent` which attempts to send a value down a channel and fails if the attempt blocks. Can be paired with `Eventually` to safely send a value down a channel with a timeout.
+- `Ω`, `Expect`, `Eventually`, and `Consistently` now immediately `panic` if there is no registered fail handler. This is always a mistake that can hide failing tests.
+- `Receive()` no longer errors when passed a closed channel, it's perfectly fine to attempt to read from a closed channel so Ω(c).Should(Receive()) always fails and Ω(c).ShoudlNot(Receive()) always passes with a closed channel.
+- Added `HavePrefix` and `HaveSuffix` matchers.
+- `ghttp` can now handle concurrent requests.
+- Added `Succeed` which allows one to write `Ω(MyFunction()).Should(Succeed())`.
+- Improved `ghttp`'s behavior around failing assertions and panics:
+ - If a registered handler makes a failing assertion `ghttp` will return `500`.
+ - If a registered handler panics, `ghttp` will return `500` *and* fail the test. This is new behavior that may cause existing code to break. This code is almost certainly incorrect and creating a false positive.
+- `ghttp` servers can take an `io.Writer`. `ghttp` will write a line to the writer when each request arrives.
+- Added `WithTransform` matcher to allow munging input data before feeding into the relevant matcher
+- Added boolean `And`, `Or`, and `Not` matchers to allow creating composite matchers
+- Added `gbytes.TimeoutCloser`, `gbytes.TimeoutReader`, and `gbytes.TimeoutWriter` - these are convenience wrappers that timeout if the underlying Closer/Reader/Writer does not return within the alloted time.
+- Added `gbytes.BufferReader` - this constructs a `gbytes.Buffer` that asynchronously reads the passed-in `io.Reader` into its buffer.
+
+Bug Fixes:
+- gexec: `session.Wait` now uses `EventuallyWithOffset` to get the right line number in the failure.
+- `ContainElement` no longer bails if a passed-in matcher errors.
+
+## 1.0 (8/2/2014)
+
+No changes. Dropping "beta" from the version number.
+
+## 1.0.0-beta (7/8/2014)
+Breaking Changes:
+
+- Changed OmegaMatcher interface. Instead of having `Match` return failure messages, two new methods `FailureMessage` and `NegatedFailureMessage` are called instead.
+- Moved and renamed OmegaFailHandler to types.GomegaFailHandler and OmegaMatcher to types.GomegaMatcher. Any references to OmegaMatcher in any custom matchers will need to be changed to point to types.GomegaMatcher
+
+New Test-Support Features:
+
+- `ghttp`: supports testing http clients
+ - Provides a flexible fake http server
+ - Provides a collection of chainable http handlers that perform assertions.
+- `gbytes`: supports making ordered assertions against streams of data
+ - Provides a `gbytes.Buffer`
+ - Provides a `Say` matcher to perform ordered assertions against output data
+- `gexec`: supports testing external processes
+ - Provides support for building Go binaries
+ - Wraps and starts `exec.Cmd` commands
+ - Makes it easy to assert against stdout and stderr
+ - Makes it easy to send signals and wait for processes to exit
+ - Provides an `Exit` matcher to assert against exit code.
+
+DSL Changes:
+
+- `Eventually` and `Consistently` can accept `time.Duration` interval and polling inputs.
+- The default timeouts for `Eventually` and `Consistently` are now configurable.
+
+New Matchers:
+
+- `ConsistOf`: order-independent assertion against the elements of an array/slice or keys of a map.
+- `BeTemporally`: like `BeNumerically` but for `time.Time`
+- `HaveKeyWithValue`: asserts a map has a given key with the given value.
+
+Updated Matchers:
+
+- `Receive` matcher can take a matcher as an argument and passes only if the channel under test receives an objet that satisfies the passed-in matcher.
+- Matchers that implement `MatchMayChangeInTheFuture(actual interface{}) bool` can inform `Eventually` and/or `Consistently` when a match has no chance of changing status in the future. For example, `Receive` returns `false` when a channel is closed.
+
+Misc:
+
+- Start using semantic versioning
+- Start maintaining changelog
+
+Major refactor:
+
+- Pull out Gomega's internal to `internal`
diff --git a/vendor/github.com/onsi/gomega/CONTRIBUTING.md b/vendor/github.com/onsi/gomega/CONTRIBUTING.md
new file mode 100644
index 000000000..0d7a09928
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/CONTRIBUTING.md
@@ -0,0 +1,14 @@
+# Contributing to Gomega
+
+Your contributions to Gomega are essential for its long-term maintenance and improvement. To make a contribution:
+
+- Please **open an issue first** - describe what problem you are trying to solve and give the community a forum for input and feedback ahead of investing time in writing code!
+- Ensure adequate test coverage:
+ - Make sure to add appropriate unit tests
+ - Please run all tests locally (`ginkgo -r -p`) and make sure they go green before submitting the PR
+ - Please run following linter locally `go vet ./...` and make sure output does not contain any warnings
+- Update the documentation. In addition to standard `godoc` comments Gomega has extensive documentation on the `gh-pages` branch. If relevant, please submit a docs PR to that branch alongside your code PR.
+
+If you're a committer, check out RELEASING.md to learn how to cut a release.
+
+Thanks for supporting Gomega!
diff --git a/vendor/github.com/onsi/gomega/LICENSE b/vendor/github.com/onsi/gomega/LICENSE
new file mode 100644
index 000000000..9415ee72c
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2013-2014 Onsi Fakhouri
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/onsi/gomega/README.md b/vendor/github.com/onsi/gomega/README.md
new file mode 100644
index 000000000..76aa6b558
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/README.md
@@ -0,0 +1,21 @@
+![Gomega: Ginkgo's Preferred Matcher Library](http://onsi.github.io/gomega/images/gomega.png)
+
+[![Build Status](https://travis-ci.org/onsi/gomega.svg?branch=master)](https://travis-ci.org/onsi/gomega)
+
+Jump straight to the [docs](http://onsi.github.io/gomega/) to learn about Gomega, including a list of [all available matchers](http://onsi.github.io/gomega/#provided-matchers).
+
+If you have a question, comment, bug report, feature request, etc. please open a GitHub issue.
+
+## [Ginkgo](http://github.com/onsi/ginkgo): a BDD Testing Framework for Golang
+
+Learn more about Ginkgo [here](http://onsi.github.io/ginkgo/)
+
+## Community Matchers
+
+A collection of community matchers is available on the [wiki](https://github.com/onsi/gomega/wiki).
+
+## License
+
+Gomega is MIT-Licensed
+
+The `ConsistOf` matcher uses [goraph](https://github.com/amitkgupta/goraph) which is embedded in the source to simplify distribution. goraph has an MIT license.
diff --git a/vendor/github.com/onsi/gomega/RELEASING.md b/vendor/github.com/onsi/gomega/RELEASING.md
new file mode 100644
index 000000000..998d64ee7
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/RELEASING.md
@@ -0,0 +1,12 @@
+A Gomega release is a tagged sha and a GitHub release. To cut a release:
+
+1. Ensure CHANGELOG.md is up to date.
+ - Use `git log --pretty=format:'- %s [%h]' HEAD...vX.X.X` to list all the commits since the last release
+ - Categorize the changes into
+ - Breaking Changes (requires a major version)
+ - New Features (minor version)
+ - Fixes (fix version)
+ - Maintenance (which in general should not be mentioned in `CHANGELOG.md` as they have no user impact)
+2. Update GOMEGA_VERSION in `gomega_dsl.go`
+3. Push a commit with the version number as the commit message (e.g. `v1.3.0`)
+4. Create a new [GitHub release](https://help.github.com/articles/creating-releases/) with the version number as the tag (e.g. `v1.3.0`). List the key changes in the release notes.
diff --git a/vendor/github.com/onsi/gomega/format/format.go b/vendor/github.com/onsi/gomega/format/format.go
new file mode 100644
index 000000000..6559525f1
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/format/format.go
@@ -0,0 +1,382 @@
+/*
+Gomega's format package pretty-prints objects. It explores input objects recursively and generates formatted, indented output with type information.
+*/
+package format
+
+import (
+ "fmt"
+ "reflect"
+ "strconv"
+ "strings"
+ "time"
+)
+
+// Use MaxDepth to set the maximum recursion depth when printing deeply nested objects
+var MaxDepth = uint(10)
+
+/*
+By default, all objects (even those that implement fmt.Stringer and fmt.GoStringer) are recursively inspected to generate output.
+
+Set UseStringerRepresentation = true to use GoString (for fmt.GoStringers) or String (for fmt.Stringer) instead.
+
+Note that GoString and String don't always have all the information you need to understand why a test failed!
+*/
+var UseStringerRepresentation = false
+
+/*
+Print the content of context objects. By default it will be suppressed.
+
+Set PrintContextObjects = true to enable printing of the context internals.
+*/
+var PrintContextObjects = false
+
+// TruncatedDiff choose if we should display a truncated pretty diff or not
+var TruncatedDiff = true
+
+// Ctx interface defined here to keep backwards compatability with go < 1.7
+// It matches the context.Context interface
+type Ctx interface {
+ Deadline() (deadline time.Time, ok bool)
+ Done() <-chan struct{}
+ Err() error
+ Value(key interface{}) interface{}
+}
+
+var contextType = reflect.TypeOf((*Ctx)(nil)).Elem()
+var timeType = reflect.TypeOf(time.Time{})
+
+//The default indentation string emitted by the format package
+var Indent = " "
+
+var longFormThreshold = 20
+
+/*
+Generates a formatted matcher success/failure message of the form:
+
+ Expected
+ <pretty printed actual>
+ <message>
+ <pretty printed expected>
+
+If expected is omited, then the message looks like:
+
+ Expected
+ <pretty printed actual>
+ <message>
+*/
+func Message(actual interface{}, message string, expected ...interface{}) string {
+ if len(expected) == 0 {
+ return fmt.Sprintf("Expected\n%s\n%s", Object(actual, 1), message)
+ }
+ return fmt.Sprintf("Expected\n%s\n%s\n%s", Object(actual, 1), message, Object(expected[0], 1))
+}
+
+/*
+
+Generates a nicely formatted matcher success / failure message
+
+Much like Message(...), but it attempts to pretty print diffs in strings
+
+Expected
+ <string>: "...aaaaabaaaaa..."
+to equal |
+ <string>: "...aaaaazaaaaa..."
+
+*/
+
+func MessageWithDiff(actual, message, expected string) string {
+ if TruncatedDiff && len(actual) >= truncateThreshold && len(expected) >= truncateThreshold {
+ diffPoint := findFirstMismatch(actual, expected)
+ formattedActual := truncateAndFormat(actual, diffPoint)
+ formattedExpected := truncateAndFormat(expected, diffPoint)
+
+ spacesBeforeFormattedMismatch := findFirstMismatch(formattedActual, formattedExpected)
+
+ tabLength := 4
+ spaceFromMessageToActual := tabLength + len("<string>: ") - len(message)
+ padding := strings.Repeat(" ", spaceFromMessageToActual+spacesBeforeFormattedMismatch) + "|"
+ return Message(formattedActual, message+padding, formattedExpected)
+ }
+ return Message(actual, message, expected)
+}
+
+func truncateAndFormat(str string, index int) string {
+ leftPadding := `...`
+ rightPadding := `...`
+
+ start := index - charactersAroundMismatchToInclude
+ if start < 0 {
+ start = 0
+ leftPadding = ""
+ }
+
+ // slice index must include the mis-matched character
+ lengthOfMismatchedCharacter := 1
+ end := index + charactersAroundMismatchToInclude + lengthOfMismatchedCharacter
+ if end > len(str) {
+ end = len(str)
+ rightPadding = ""
+
+ }
+ return fmt.Sprintf("\"%s\"", leftPadding+str[start:end]+rightPadding)
+}
+
+func findFirstMismatch(a, b string) int {
+ aSlice := strings.Split(a, "")
+ bSlice := strings.Split(b, "")
+
+ for index, str := range aSlice {
+ if index > len(bSlice)-1 {
+ return index
+ }
+ if str != bSlice[index] {
+ return index
+ }
+ }
+
+ if len(b) > len(a) {
+ return len(a) + 1
+ }
+
+ return 0
+}
+
+const (
+ truncateThreshold = 50
+ charactersAroundMismatchToInclude = 5
+)
+
+/*
+Pretty prints the passed in object at the passed in indentation level.
+
+Object recurses into deeply nested objects emitting pretty-printed representations of their components.
+
+Modify format.MaxDepth to control how deep the recursion is allowed to go
+Set format.UseStringerRepresentation to true to return object.GoString() or object.String() when available instead of
+recursing into the object.
+
+Set PrintContextObjects to true to print the content of objects implementing context.Context
+*/
+func Object(object interface{}, indentation uint) string {
+ indent := strings.Repeat(Indent, int(indentation))
+ value := reflect.ValueOf(object)
+ return fmt.Sprintf("%s<%s>: %s", indent, formatType(object), formatValue(value, indentation))
+}
+
+/*
+IndentString takes a string and indents each line by the specified amount.
+*/
+func IndentString(s string, indentation uint) string {
+ components := strings.Split(s, "\n")
+ result := ""
+ indent := strings.Repeat(Indent, int(indentation))
+ for i, component := range components {
+ result += indent + component
+ if i < len(components)-1 {
+ result += "\n"
+ }
+ }
+
+ return result
+}
+
+func formatType(object interface{}) string {
+ t := reflect.TypeOf(object)
+ if t == nil {
+ return "nil"
+ }
+ switch t.Kind() {
+ case reflect.Chan:
+ v := reflect.ValueOf(object)
+ return fmt.Sprintf("%T | len:%d, cap:%d", object, v.Len(), v.Cap())
+ case reflect.Ptr:
+ return fmt.Sprintf("%T | %p", object, object)
+ case reflect.Slice:
+ v := reflect.ValueOf(object)
+ return fmt.Sprintf("%T | len:%d, cap:%d", object, v.Len(), v.Cap())
+ case reflect.Map:
+ v := reflect.ValueOf(object)
+ return fmt.Sprintf("%T | len:%d", object, v.Len())
+ default:
+ return fmt.Sprintf("%T", object)
+ }
+}
+
+func formatValue(value reflect.Value, indentation uint) string {
+ if indentation > MaxDepth {
+ return "..."
+ }
+
+ if isNilValue(value) {
+ return "nil"
+ }
+
+ if UseStringerRepresentation {
+ if value.CanInterface() {
+ obj := value.Interface()
+ switch x := obj.(type) {
+ case fmt.GoStringer:
+ return x.GoString()
+ case fmt.Stringer:
+ return x.String()
+ }
+ }
+ }
+
+ if !PrintContextObjects {
+ if value.Type().Implements(contextType) && indentation > 1 {
+ return "<suppressed context>"
+ }
+ }
+
+ switch value.Kind() {
+ case reflect.Bool:
+ return fmt.Sprintf("%v", value.Bool())
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return fmt.Sprintf("%v", value.Int())
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ return fmt.Sprintf("%v", value.Uint())
+ case reflect.Uintptr:
+ return fmt.Sprintf("0x%x", value.Uint())
+ case reflect.Float32, reflect.Float64:
+ return fmt.Sprintf("%v", value.Float())
+ case reflect.Complex64, reflect.Complex128:
+ return fmt.Sprintf("%v", value.Complex())
+ case reflect.Chan:
+ return fmt.Sprintf("0x%x", value.Pointer())
+ case reflect.Func:
+ return fmt.Sprintf("0x%x", value.Pointer())
+ case reflect.Ptr:
+ return formatValue(value.Elem(), indentation)
+ case reflect.Slice:
+ return formatSlice(value, indentation)
+ case reflect.String:
+ return formatString(value.String(), indentation)
+ case reflect.Array:
+ return formatSlice(value, indentation)
+ case reflect.Map:
+ return formatMap(value, indentation)
+ case reflect.Struct:
+ if value.Type() == timeType && value.CanInterface() {
+ t, _ := value.Interface().(time.Time)
+ return t.Format(time.RFC3339Nano)
+ }
+ return formatStruct(value, indentation)
+ case reflect.Interface:
+ return formatValue(value.Elem(), indentation)
+ default:
+ if value.CanInterface() {
+ return fmt.Sprintf("%#v", value.Interface())
+ }
+ return fmt.Sprintf("%#v", value)
+ }
+}
+
+func formatString(object interface{}, indentation uint) string {
+ if indentation == 1 {
+ s := fmt.Sprintf("%s", object)
+ components := strings.Split(s, "\n")
+ result := ""
+ for i, component := range components {
+ if i == 0 {
+ result += component
+ } else {
+ result += Indent + component
+ }
+ if i < len(components)-1 {
+ result += "\n"
+ }
+ }
+
+ return fmt.Sprintf("%s", result)
+ } else {
+ return fmt.Sprintf("%q", object)
+ }
+}
+
+func formatSlice(v reflect.Value, indentation uint) string {
+ if v.Kind() == reflect.Slice && v.Type().Elem().Kind() == reflect.Uint8 && isPrintableString(string(v.Bytes())) {
+ return formatString(v.Bytes(), indentation)
+ }
+
+ l := v.Len()
+ result := make([]string, l)
+ longest := 0
+ for i := 0; i < l; i++ {
+ result[i] = formatValue(v.Index(i), indentation+1)
+ if len(result[i]) > longest {
+ longest = len(result[i])
+ }
+ }
+
+ if longest > longFormThreshold {
+ indenter := strings.Repeat(Indent, int(indentation))
+ return fmt.Sprintf("[\n%s%s,\n%s]", indenter+Indent, strings.Join(result, ",\n"+indenter+Indent), indenter)
+ }
+ return fmt.Sprintf("[%s]", strings.Join(result, ", "))
+}
+
+func formatMap(v reflect.Value, indentation uint) string {
+ l := v.Len()
+ result := make([]string, l)
+
+ longest := 0
+ for i, key := range v.MapKeys() {
+ value := v.MapIndex(key)
+ result[i] = fmt.Sprintf("%s: %s", formatValue(key, indentation+1), formatValue(value, indentation+1))
+ if len(result[i]) > longest {
+ longest = len(result[i])
+ }
+ }
+
+ if longest > longFormThreshold {
+ indenter := strings.Repeat(Indent, int(indentation))
+ return fmt.Sprintf("{\n%s%s,\n%s}", indenter+Indent, strings.Join(result, ",\n"+indenter+Indent), indenter)
+ }
+ return fmt.Sprintf("{%s}", strings.Join(result, ", "))
+}
+
+func formatStruct(v reflect.Value, indentation uint) string {
+ t := v.Type()
+
+ l := v.NumField()
+ result := []string{}
+ longest := 0
+ for i := 0; i < l; i++ {
+ structField := t.Field(i)
+ fieldEntry := v.Field(i)
+ representation := fmt.Sprintf("%s: %s", structField.Name, formatValue(fieldEntry, indentation+1))
+ result = append(result, representation)
+ if len(representation) > longest {
+ longest = len(representation)
+ }
+ }
+ if longest > longFormThreshold {
+ indenter := strings.Repeat(Indent, int(indentation))
+ return fmt.Sprintf("{\n%s%s,\n%s}", indenter+Indent, strings.Join(result, ",\n"+indenter+Indent), indenter)
+ }
+ return fmt.Sprintf("{%s}", strings.Join(result, ", "))
+}
+
+func isNilValue(a reflect.Value) bool {
+ switch a.Kind() {
+ case reflect.Invalid:
+ return true
+ case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
+ return a.IsNil()
+ }
+
+ return false
+}
+
+/*
+Returns true when the string is entirely made of printable runes, false otherwise.
+*/
+func isPrintableString(str string) bool {
+ for _, runeValue := range str {
+ if !strconv.IsPrint(runeValue) {
+ return false
+ }
+ }
+ return true
+}
diff --git a/vendor/github.com/onsi/gomega/format/format_suite_test.go b/vendor/github.com/onsi/gomega/format/format_suite_test.go
new file mode 100644
index 000000000..8e65a9529
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/format/format_suite_test.go
@@ -0,0 +1,13 @@
+package format_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestFormat(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Format Suite")
+}
diff --git a/vendor/github.com/onsi/gomega/format/format_test.go b/vendor/github.com/onsi/gomega/format/format_test.go
new file mode 100644
index 000000000..9ea781379
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/format/format_test.go
@@ -0,0 +1,627 @@
+package format_test
+
+import (
+ "fmt"
+ "strings"
+ "time"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/format"
+ "github.com/onsi/gomega/types"
+)
+
+//recursive struct
+
+type StringAlias string
+type ByteAlias []byte
+type IntAlias int
+
+type AStruct struct {
+ Exported string
+}
+
+type SimpleStruct struct {
+ Name string
+ Enumeration int
+ Veritas bool
+ Data []byte
+ secret uint32
+}
+
+type ComplexStruct struct {
+ Strings []string
+ SimpleThings []*SimpleStruct
+ DataMaps map[int]ByteAlias
+}
+
+type SecretiveStruct struct {
+ boolValue bool
+ intValue int
+ uintValue uint
+ uintptrValue uintptr
+ floatValue float32
+ complexValue complex64
+ chanValue chan bool
+ funcValue func()
+ pointerValue *int
+ sliceValue []string
+ byteSliceValue []byte
+ stringValue string
+ arrValue [3]int
+ byteArrValue [3]byte
+ mapValue map[string]int
+ structValue AStruct
+ interfaceValue interface{}
+}
+
+type GoStringer struct {
+}
+
+func (g GoStringer) GoString() string {
+ return "go-string"
+}
+
+func (g GoStringer) String() string {
+ return "string"
+}
+
+type Stringer struct {
+}
+
+func (g Stringer) String() string {
+ return "string"
+}
+
+type ctx struct {
+}
+
+func (c *ctx) Deadline() (deadline time.Time, ok bool) {
+ return time.Time{}, false
+}
+
+func (c *ctx) Done() <-chan struct{} {
+ return nil
+}
+
+func (c *ctx) Err() error {
+ return nil
+}
+
+func (c *ctx) Value(key interface{}) interface{} {
+ return nil
+}
+
+var _ = Describe("Format", func() {
+ match := func(typeRepresentation string, valueRepresentation string, args ...interface{}) types.GomegaMatcher {
+ if len(args) > 0 {
+ valueRepresentation = fmt.Sprintf(valueRepresentation, args...)
+ }
+ return Equal(fmt.Sprintf("%s<%s>: %s", Indent, typeRepresentation, valueRepresentation))
+ }
+
+ matchRegexp := func(typeRepresentation string, valueRepresentation string, args ...interface{}) types.GomegaMatcher {
+ if len(args) > 0 {
+ valueRepresentation = fmt.Sprintf(valueRepresentation, args...)
+ }
+ return MatchRegexp(fmt.Sprintf("%s<%s>: %s", Indent, typeRepresentation, valueRepresentation))
+ }
+
+ hashMatchingRegexp := func(entries ...string) string {
+ entriesSwitch := "(" + strings.Join(entries, "|") + ")"
+ arr := make([]string, len(entries))
+ for i := range arr {
+ arr[i] = entriesSwitch
+ }
+ return "{" + strings.Join(arr, ", ") + "}"
+ }
+
+ Describe("Message", func() {
+ Context("with only an actual value", func() {
+ It("should print out an indented formatted representation of the value and the message", func() {
+ Expect(Message(3, "to be three.")).Should(Equal("Expected\n <int>: 3\nto be three."))
+ })
+ })
+
+ Context("with an actual and an expected value", func() {
+ It("should print out an indented formatted representatino of both values, and the message", func() {
+ Expect(Message(3, "to equal", 4)).Should(Equal("Expected\n <int>: 3\nto equal\n <int>: 4"))
+ })
+ })
+ })
+
+ Describe("MessageWithDiff", func() {
+ It("shows the exact point where two long strings differ", func() {
+ stringWithB := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+ stringWithZ := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+
+ Expect(MessageWithDiff(stringWithB, "to equal", stringWithZ)).Should(Equal(expectedLongStringFailureMessage))
+ })
+
+ It("truncates the start of long strings that differ only at their end", func() {
+ stringWithB := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab"
+ stringWithZ := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz"
+
+ Expect(MessageWithDiff(stringWithB, "to equal", stringWithZ)).Should(Equal(expectedTruncatedStartStringFailureMessage))
+ })
+
+ It("truncates the start of long strings that differ only in length", func() {
+ smallString := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+ largeString := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+
+ Expect(MessageWithDiff(largeString, "to equal", smallString)).Should(Equal(expectedTruncatedStartSizeFailureMessage))
+ Expect(MessageWithDiff(smallString, "to equal", largeString)).Should(Equal(expectedTruncatedStartSizeSwappedFailureMessage))
+ })
+
+ It("truncates the end of long strings that differ only at their start", func() {
+ stringWithB := "baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+ stringWithZ := "zaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+
+ Expect(MessageWithDiff(stringWithB, "to equal", stringWithZ)).Should(Equal(expectedTruncatedEndStringFailureMessage))
+ })
+
+ It("handles multi-byte sequences correctly", func() {
+ stringA := "• abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz1"
+ stringB := "• abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"
+
+ Expect(MessageWithDiff(stringA, "to equal", stringB)).Should(Equal(expectedTruncatedMultiByteFailureMessage))
+ })
+
+ Context("With truncated diff disabled", func() {
+ BeforeEach(func() {
+ TruncatedDiff = false
+ })
+
+ AfterEach(func() {
+ TruncatedDiff = true
+ })
+
+ It("should show the full diff", func() {
+ stringWithB := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+ stringWithZ := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+
+ Expect(MessageWithDiff(stringWithB, "to equal", stringWithZ)).Should(Equal(expectedFullFailureDiff))
+ })
+ })
+ })
+
+ Describe("IndentString", func() {
+ It("should indent the string", func() {
+ Expect(IndentString("foo\n bar\nbaz", 2)).Should(Equal(" foo\n bar\n baz"))
+ })
+ })
+
+ Describe("Object", func() {
+ Describe("formatting boolean values", func() {
+ It("should give the type and format values correctly", func() {
+ Expect(Object(true, 1)).Should(match("bool", "true"))
+ Expect(Object(false, 1)).Should(match("bool", "false"))
+ })
+ })
+
+ Describe("formatting numbers", func() {
+ It("should give the type and format values correctly", func() {
+ Expect(Object(int(3), 1)).Should(match("int", "3"))
+ Expect(Object(int8(3), 1)).Should(match("int8", "3"))
+ Expect(Object(int16(3), 1)).Should(match("int16", "3"))
+ Expect(Object(int32(3), 1)).Should(match("int32", "3"))
+ Expect(Object(int64(3), 1)).Should(match("int64", "3"))
+
+ Expect(Object(uint(3), 1)).Should(match("uint", "3"))
+ Expect(Object(uint8(3), 1)).Should(match("uint8", "3"))
+ Expect(Object(uint16(3), 1)).Should(match("uint16", "3"))
+ Expect(Object(uint32(3), 1)).Should(match("uint32", "3"))
+ Expect(Object(uint64(3), 1)).Should(match("uint64", "3"))
+ })
+
+ It("should handle uintptr differently", func() {
+ Expect(Object(uintptr(3), 1)).Should(match("uintptr", "0x3"))
+ })
+ })
+
+ Describe("formatting channels", func() {
+ It("should give the type and format values correctly", func() {
+ c := make(chan<- bool, 3)
+ c <- true
+ c <- false
+ Expect(Object(c, 1)).Should(match("chan<- bool | len:2, cap:3", "%v", c))
+ })
+ })
+
+ Describe("formatting strings", func() {
+ It("should give the type and format values correctly", func() {
+ s := "a\nb\nc"
+ Expect(Object(s, 1)).Should(match("string", `a
+ b
+ c`))
+ })
+ })
+
+ Describe("formatting []byte slices", func() {
+ Context("when the slice is made of printable bytes", func() {
+ It("should present it as string", func() {
+ b := []byte("a b c")
+ Expect(Object(b, 1)).Should(matchRegexp(`\[\]uint8 \| len:5, cap:\d+`, `a b c`))
+ })
+ })
+ Context("when the slice contains non-printable bytes", func() {
+ It("should present it as slice", func() {
+ b := []byte("a b c\n\x01\x02\x03\xff\x1bH")
+ Expect(Object(b, 1)).Should(matchRegexp(`\[\]uint8 \| len:12, cap:\d+`, `\[97, 32, 98, 32, 99, 10, 1, 2, 3, 255, 27, 72\]`))
+ })
+ })
+ })
+
+ Describe("formatting functions", func() {
+ It("should give the type and format values correctly", func() {
+ f := func(a string, b []int) ([]byte, error) {
+ return []byte("abc"), nil
+ }
+ Expect(Object(f, 1)).Should(match("func(string, []int) ([]uint8, error)", "%v", f))
+ })
+ })
+
+ Describe("formatting pointers", func() {
+ It("should give the type and dereference the value to format it correctly", func() {
+ a := 3
+ Expect(Object(&a, 1)).Should(match(fmt.Sprintf("*int | %p", &a), "3"))
+ })
+
+ Context("when there are pointers to pointers...", func() {
+ It("should recursively deference the pointer until it gets to a value", func() {
+ a := 3
+ var b *int
+ var c **int
+ var d ***int
+ b = &a
+ c = &b
+ d = &c
+
+ Expect(Object(d, 1)).Should(match(fmt.Sprintf("***int | %p", d), "3"))
+ })
+ })
+
+ Context("when the pointer points to nil", func() {
+ It("should say nil and not explode", func() {
+ var a *AStruct
+ Expect(Object(a, 1)).Should(match("*format_test.AStruct | 0x0", "nil"))
+ })
+ })
+ })
+
+ Describe("formatting arrays", func() {
+ It("should give the type and format values correctly", func() {
+ w := [3]string{"Jed Bartlet", "Toby Ziegler", "CJ Cregg"}
+ Expect(Object(w, 1)).Should(match("[3]string", `["Jed Bartlet", "Toby Ziegler", "CJ Cregg"]`))
+ })
+
+ Context("with byte arrays", func() {
+ It("should give the type and format values correctly", func() {
+ w := [3]byte{17, 28, 19}
+ Expect(Object(w, 1)).Should(match("[3]uint8", `[17, 28, 19]`))
+ })
+ })
+ })
+
+ Describe("formatting slices", func() {
+ It("should include the length and capacity in the type information", func() {
+ s := make([]bool, 3, 4)
+ Expect(Object(s, 1)).Should(match("[]bool | len:3, cap:4", "[false, false, false]"))
+ })
+
+ Context("when the slice contains long entries", func() {
+ It("should format the entries with newlines", func() {
+ w := []string{"Josiah Edward Bartlet", "Toby Ziegler", "CJ Cregg"}
+ expected := `[
+ "Josiah Edward Bartlet",
+ "Toby Ziegler",
+ "CJ Cregg",
+ ]`
+ Expect(Object(w, 1)).Should(match("[]string | len:3, cap:3", expected))
+ })
+ })
+ })
+
+ Describe("formatting maps", func() {
+ It("should include the length in the type information", func() {
+ m := make(map[int]bool, 5)
+ m[3] = true
+ m[4] = false
+ Expect(Object(m, 1)).Should(matchRegexp(`map\[int\]bool \| len:2`, hashMatchingRegexp("3: true", "4: false")))
+ })
+
+ Context("when the slice contains long entries", func() {
+ It("should format the entries with newlines", func() {
+ m := map[string][]byte{}
+ m["Josiah Edward Bartlet"] = []byte("Martin Sheen")
+ m["Toby Ziegler"] = []byte("Richard Schiff")
+ m["CJ Cregg"] = []byte("Allison Janney")
+ expected := `{
+ ("Josiah Edward Bartlet": "Martin Sheen"|"Toby Ziegler": "Richard Schiff"|"CJ Cregg": "Allison Janney"),
+ ("Josiah Edward Bartlet": "Martin Sheen"|"Toby Ziegler": "Richard Schiff"|"CJ Cregg": "Allison Janney"),
+ ("Josiah Edward Bartlet": "Martin Sheen"|"Toby Ziegler": "Richard Schiff"|"CJ Cregg": "Allison Janney"),
+ }`
+ Expect(Object(m, 1)).Should(matchRegexp(`map\[string\]\[\]uint8 \| len:3`, expected))
+ })
+ })
+ })
+
+ Describe("formatting structs", func() {
+ It("should include the struct name and the field names", func() {
+ s := SimpleStruct{
+ Name: "Oswald",
+ Enumeration: 17,
+ Veritas: true,
+ Data: []byte("datum"),
+ secret: 1983,
+ }
+
+ Expect(Object(s, 1)).Should(match("format_test.SimpleStruct", `{Name: "Oswald", Enumeration: 17, Veritas: true, Data: "datum", secret: 1983}`))
+ })
+
+ Context("when the struct contains long entries", func() {
+ It("should format the entries with new lines", func() {
+ s := &SimpleStruct{
+ Name: "Mithrandir Gandalf Greyhame",
+ Enumeration: 2021,
+ Veritas: true,
+ Data: []byte("wizard"),
+ secret: 3,
+ }
+
+ Expect(Object(s, 1)).Should(match(fmt.Sprintf("*format_test.SimpleStruct | %p", s), `{
+ Name: "Mithrandir Gandalf Greyhame",
+ Enumeration: 2021,
+ Veritas: true,
+ Data: "wizard",
+ secret: 3,
+ }`))
+ })
+ })
+ })
+
+ Describe("formatting nil values", func() {
+ It("should print out nil", func() {
+ Expect(Object(nil, 1)).Should(match("nil", "nil"))
+ var typedNil *AStruct
+ Expect(Object(typedNil, 1)).Should(match("*format_test.AStruct | 0x0", "nil"))
+ var c chan<- bool
+ Expect(Object(c, 1)).Should(match("chan<- bool | len:0, cap:0", "nil"))
+ var s []string
+ Expect(Object(s, 1)).Should(match("[]string | len:0, cap:0", "nil"))
+ var m map[string]bool
+ Expect(Object(m, 1)).Should(match("map[string]bool | len:0", "nil"))
+ })
+ })
+
+ Describe("formatting aliased types", func() {
+ It("should print out the correct alias type", func() {
+ Expect(Object(StringAlias("alias"), 1)).Should(match("format_test.StringAlias", `alias`))
+ Expect(Object(ByteAlias("alias"), 1)).Should(matchRegexp(`format_test\.ByteAlias \| len:5, cap:\d+`, `alias`))
+ Expect(Object(IntAlias(3), 1)).Should(match("format_test.IntAlias", "3"))
+ })
+ })
+
+ Describe("handling nested things", func() {
+ It("should produce a correctly nested representation", func() {
+ s := ComplexStruct{
+ Strings: []string{"lots", "of", "short", "strings"},
+ SimpleThings: []*SimpleStruct{
+ {"short", 7, true, []byte("succinct"), 17},
+ {"something longer", 427, true, []byte("designed to wrap around nicely"), 30},
+ },
+ DataMaps: map[int]ByteAlias{
+ 17: ByteAlias("some substantially longer chunks of data"),
+ 1138: ByteAlias("that should make things wrap"),
+ },
+ }
+ expected := `{
+ Strings: \["lots", "of", "short", "strings"\],
+ SimpleThings: \[
+ {Name: "short", Enumeration: 7, Veritas: true, Data: "succinct", secret: 17},
+ {
+ Name: "something longer",
+ Enumeration: 427,
+ Veritas: true,
+ Data: "designed to wrap around nicely",
+ secret: 30,
+ },
+ \],
+ DataMaps: {
+ (17: "some substantially longer chunks of data"|1138: "that should make things wrap"),
+ (17: "some substantially longer chunks of data"|1138: "that should make things wrap"),
+ },
+ }`
+ Expect(Object(s, 1)).Should(matchRegexp(`format_test\.ComplexStruct`, expected))
+ })
+ })
+
+ Describe("formatting times", func() {
+ It("should format time as RFC3339", func() {
+ t := time.Date(2016, 10, 31, 9, 57, 23, 12345, time.UTC)
+ Expect(Object(t, 1)).Should(match("time.Time", `2016-10-31T09:57:23.000012345Z`))
+ })
+ })
+ })
+
+ Describe("Handling unexported fields in structs", func() {
+ It("should handle all the various types correctly", func() {
+ a := int(5)
+ s := SecretiveStruct{
+ boolValue: true,
+ intValue: 3,
+ uintValue: 4,
+ uintptrValue: 5,
+ floatValue: 6.0,
+ complexValue: complex(5.0, 3.0),
+ chanValue: make(chan bool, 2),
+ funcValue: func() {},
+ pointerValue: &a,
+ sliceValue: []string{"string", "slice"},
+ byteSliceValue: []byte("bytes"),
+ stringValue: "a string",
+ arrValue: [3]int{11, 12, 13},
+ byteArrValue: [3]byte{17, 20, 32},
+ mapValue: map[string]int{"a key": 20, "b key": 30},
+ structValue: AStruct{"exported"},
+ interfaceValue: map[string]int{"a key": 17},
+ }
+
+ expected := fmt.Sprintf(`{
+ boolValue: true,
+ intValue: 3,
+ uintValue: 4,
+ uintptrValue: 0x5,
+ floatValue: 6,
+ complexValue: \(5\+3i\),
+ chanValue: %p,
+ funcValue: %p,
+ pointerValue: 5,
+ sliceValue: \["string", "slice"\],
+ byteSliceValue: "bytes",
+ stringValue: "a string",
+ arrValue: \[11, 12, 13\],
+ byteArrValue: \[17, 20, 32\],
+ mapValue: %s,
+ structValue: {Exported: "exported"},
+ interfaceValue: {"a key": 17},
+ }`, s.chanValue, s.funcValue, hashMatchingRegexp(`"a key": 20`, `"b key": 30`))
+
+ Expect(Object(s, 1)).Should(matchRegexp(`format_test\.SecretiveStruct`, expected))
+ })
+ })
+
+ Describe("Handling interfaces", func() {
+ It("should unpack the interface", func() {
+ outerHash := map[string]interface{}{}
+ innerHash := map[string]int{}
+
+ innerHash["inner"] = 3
+ outerHash["integer"] = 2
+ outerHash["map"] = innerHash
+
+ expected := hashMatchingRegexp(`"integer": 2`, `"map": {"inner": 3}`)
+ Expect(Object(outerHash, 1)).Should(matchRegexp(`map\[string\]interface {} \| len:2`, expected))
+ })
+ })
+
+ Describe("Handling recursive things", func() {
+ It("should not go crazy...", func() {
+ m := map[string]interface{}{}
+ m["integer"] = 2
+ m["map"] = m
+ Expect(Object(m, 1)).Should(ContainSubstring("..."))
+ })
+
+ It("really should not go crazy...", func() {
+ type complexKey struct {
+ Value map[interface{}]int
+ }
+
+ complexObject := complexKey{}
+ complexObject.Value = make(map[interface{}]int)
+
+ complexObject.Value[&complexObject] = 2
+ Expect(Object(complexObject, 1)).Should(ContainSubstring("..."))
+ })
+ })
+
+ Describe("When instructed to use the Stringer representation", func() {
+ BeforeEach(func() {
+ UseStringerRepresentation = true
+ })
+
+ AfterEach(func() {
+ UseStringerRepresentation = false
+ })
+
+ Context("when passed a GoStringer", func() {
+ It("should use what GoString() returns", func() {
+ Expect(Object(GoStringer{}, 1)).Should(ContainSubstring("<format_test.GoStringer>: go-string"))
+ })
+ })
+
+ Context("when passed a stringer", func() {
+ It("should use what String() returns", func() {
+ Expect(Object(Stringer{}, 1)).Should(ContainSubstring("<format_test.Stringer>: string"))
+ })
+ })
+ })
+
+ Describe("Printing a context.Context field", func() {
+
+ type structWithContext struct {
+ Context Ctx
+ Value string
+ }
+
+ context := ctx{}
+ objWithContext := structWithContext{Value: "some-value", Context: &context}
+
+ It("Suppresses the content by default", func() {
+ Expect(Object(objWithContext, 1)).Should(ContainSubstring("<suppressed context>"))
+ })
+
+ It("Doesn't supress the context if it's the object being printed", func() {
+ Expect(Object(context, 1)).ShouldNot(MatchRegexp("^.*<suppressed context>$"))
+ })
+
+ Context("PrintContextObjects is set", func() {
+ BeforeEach(func() {
+ PrintContextObjects = true
+ })
+
+ AfterEach(func() {
+ PrintContextObjects = false
+ })
+
+ It("Prints the context", func() {
+ Expect(Object(objWithContext, 1)).ShouldNot(ContainSubstring("<suppressed context>"))
+ })
+ })
+ })
+})
+
+var expectedLongStringFailureMessage = strings.TrimSpace(`
+Expected
+ <string>: "...aaaaabaaaaa..."
+to equal |
+ <string>: "...aaaaazaaaaa..."
+`)
+var expectedTruncatedEndStringFailureMessage = strings.TrimSpace(`
+Expected
+ <string>: "baaaaa..."
+to equal |
+ <string>: "zaaaaa..."
+`)
+var expectedTruncatedStartStringFailureMessage = strings.TrimSpace(`
+Expected
+ <string>: "...aaaaab"
+to equal |
+ <string>: "...aaaaaz"
+`)
+var expectedTruncatedStartSizeFailureMessage = strings.TrimSpace(`
+Expected
+ <string>: "...aaaaaa"
+to equal |
+ <string>: "...aaaaa"
+`)
+var expectedTruncatedStartSizeSwappedFailureMessage = strings.TrimSpace(`
+Expected
+ <string>: "...aaaa"
+to equal |
+ <string>: "...aaaaa"
+`)
+var expectedTruncatedMultiByteFailureMessage = strings.TrimSpace(`
+Expected
+ <string>: "...tuvwxyz1"
+to equal |
+ <string>: "...tuvwxyz"
+`)
+
+var expectedFullFailureDiff = strings.TrimSpace(`
+Expected
+ <string>: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+to equal
+ <string>: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+`)
diff --git a/vendor/github.com/onsi/gomega/gbytes/buffer.go b/vendor/github.com/onsi/gomega/gbytes/buffer.go
new file mode 100644
index 000000000..336086f4a
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gbytes/buffer.go
@@ -0,0 +1,245 @@
+/*
+Package gbytes provides a buffer that supports incrementally detecting input.
+
+You use gbytes.Buffer with the gbytes.Say matcher. When Say finds a match, it fastforwards the buffer's read cursor to the end of that match.
+
+Subsequent matches against the buffer will only operate against data that appears *after* the read cursor.
+
+The read cursor is an opaque implementation detail that you cannot access. You should use the Say matcher to sift through the buffer. You can always
+access the entire buffer's contents with Contents().
+
+*/
+package gbytes
+
+import (
+ "errors"
+ "fmt"
+ "io"
+ "regexp"
+ "sync"
+ "time"
+)
+
+/*
+gbytes.Buffer implements an io.Writer and can be used with the gbytes.Say matcher.
+
+You should only use a gbytes.Buffer in test code. It stores all writes in an in-memory buffer - behavior that is inappropriate for production code!
+*/
+type Buffer struct {
+ contents []byte
+ readCursor uint64
+ lock *sync.Mutex
+ detectCloser chan interface{}
+ closed bool
+}
+
+/*
+NewBuffer returns a new gbytes.Buffer
+*/
+func NewBuffer() *Buffer {
+ return &Buffer{
+ lock: &sync.Mutex{},
+ }
+}
+
+/*
+BufferWithBytes returns a new gbytes.Buffer seeded with the passed in bytes
+*/
+func BufferWithBytes(bytes []byte) *Buffer {
+ return &Buffer{
+ lock: &sync.Mutex{},
+ contents: bytes,
+ }
+}
+
+/*
+BufferReader returns a new gbytes.Buffer that wraps a reader. The reader's contents are read into
+the Buffer via io.Copy
+*/
+func BufferReader(reader io.Reader) *Buffer {
+ b := &Buffer{
+ lock: &sync.Mutex{},
+ }
+
+ go func() {
+ io.Copy(b, reader)
+ b.Close()
+ }()
+
+ return b
+}
+
+/*
+Write implements the io.Writer interface
+*/
+func (b *Buffer) Write(p []byte) (n int, err error) {
+ b.lock.Lock()
+ defer b.lock.Unlock()
+
+ if b.closed {
+ return 0, errors.New("attempt to write to closed buffer")
+ }
+
+ b.contents = append(b.contents, p...)
+ return len(p), nil
+}
+
+/*
+Read implements the io.Reader interface. It advances the
+cursor as it reads.
+
+Returns an error if called after Close.
+*/
+func (b *Buffer) Read(d []byte) (int, error) {
+ b.lock.Lock()
+ defer b.lock.Unlock()
+
+ if b.closed {
+ return 0, errors.New("attempt to read from closed buffer")
+ }
+
+ if uint64(len(b.contents)) <= b.readCursor {
+ return 0, io.EOF
+ }
+
+ n := copy(d, b.contents[b.readCursor:])
+ b.readCursor += uint64(n)
+
+ return n, nil
+}
+
+/*
+Close signifies that the buffer will no longer be written to
+*/
+func (b *Buffer) Close() error {
+ b.lock.Lock()
+ defer b.lock.Unlock()
+
+ b.closed = true
+
+ return nil
+}
+
+/*
+Closed returns true if the buffer has been closed
+*/
+func (b *Buffer) Closed() bool {
+ b.lock.Lock()
+ defer b.lock.Unlock()
+
+ return b.closed
+}
+
+/*
+Contents returns all data ever written to the buffer.
+*/
+func (b *Buffer) Contents() []byte {
+ b.lock.Lock()
+ defer b.lock.Unlock()
+
+ contents := make([]byte, len(b.contents))
+ copy(contents, b.contents)
+ return contents
+}
+
+/*
+Detect takes a regular expression and returns a channel.
+
+The channel will receive true the first time data matching the regular expression is written to the buffer.
+The channel is subsequently closed and the buffer's read-cursor is fast-forwarded to just after the matching region.
+
+You typically don't need to use Detect and should use the ghttp.Say matcher instead. Detect is useful, however, in cases where your code must
+be branch and handle different outputs written to the buffer.
+
+For example, consider a buffer hooked up to the stdout of a client library. You may (or may not, depending on state outside of your control) need to authenticate the client library.
+
+You could do something like:
+
+select {
+case <-buffer.Detect("You are not logged in"):
+ //log in
+case <-buffer.Detect("Success"):
+ //carry on
+case <-time.After(time.Second):
+ //welp
+}
+buffer.CancelDetects()
+
+You should always call CancelDetects after using Detect. This will close any channels that have not detected and clean up the goroutines that were spawned to support them.
+
+Finally, you can pass detect a format string followed by variadic arguments. This will construct the regexp using fmt.Sprintf.
+*/
+func (b *Buffer) Detect(desired string, args ...interface{}) chan bool {
+ formattedRegexp := desired
+ if len(args) > 0 {
+ formattedRegexp = fmt.Sprintf(desired, args...)
+ }
+ re := regexp.MustCompile(formattedRegexp)
+
+ b.lock.Lock()
+ defer b.lock.Unlock()
+
+ if b.detectCloser == nil {
+ b.detectCloser = make(chan interface{})
+ }
+
+ closer := b.detectCloser
+ response := make(chan bool)
+ go func() {
+ ticker := time.NewTicker(10 * time.Millisecond)
+ defer ticker.Stop()
+ defer close(response)
+ for {
+ select {
+ case <-ticker.C:
+ b.lock.Lock()
+ data, cursor := b.contents[b.readCursor:], b.readCursor
+ loc := re.FindIndex(data)
+ b.lock.Unlock()
+
+ if loc != nil {
+ response <- true
+ b.lock.Lock()
+ newCursorPosition := cursor + uint64(loc[1])
+ if newCursorPosition >= b.readCursor {
+ b.readCursor = newCursorPosition
+ }
+ b.lock.Unlock()
+ return
+ }
+ case <-closer:
+ return
+ }
+ }
+ }()
+
+ return response
+}
+
+/*
+CancelDetects cancels any pending detects and cleans up their goroutines. You should always call this when you're done with a set of Detect channels.
+*/
+func (b *Buffer) CancelDetects() {
+ b.lock.Lock()
+ defer b.lock.Unlock()
+
+ close(b.detectCloser)
+ b.detectCloser = nil
+}
+
+func (b *Buffer) didSay(re *regexp.Regexp) (bool, []byte) {
+ b.lock.Lock()
+ defer b.lock.Unlock()
+
+ unreadBytes := b.contents[b.readCursor:]
+ copyOfUnreadBytes := make([]byte, len(unreadBytes))
+ copy(copyOfUnreadBytes, unreadBytes)
+
+ loc := re.FindIndex(unreadBytes)
+
+ if loc != nil {
+ b.readCursor += uint64(loc[1])
+ return true, copyOfUnreadBytes
+ }
+ return false, copyOfUnreadBytes
+}
diff --git a/vendor/github.com/onsi/gomega/gbytes/buffer_test.go b/vendor/github.com/onsi/gomega/gbytes/buffer_test.go
new file mode 100644
index 000000000..9d4e8279d
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gbytes/buffer_test.go
@@ -0,0 +1,205 @@
+package gbytes_test
+
+import (
+ "io"
+ "time"
+
+ . "github.com/onsi/gomega/gbytes"
+
+ "bytes"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+type SlowReader struct {
+ R io.Reader
+ D time.Duration
+}
+
+func (s SlowReader) Read(p []byte) (int, error) {
+ time.Sleep(s.D)
+ return s.R.Read(p)
+}
+
+var _ = Describe("Buffer", func() {
+ var buffer *Buffer
+
+ BeforeEach(func() {
+ buffer = NewBuffer()
+ })
+
+ Describe("dumping the entire contents of the buffer", func() {
+ It("should return everything that's been written", func() {
+ buffer.Write([]byte("abc"))
+ buffer.Write([]byte("def"))
+ Expect(buffer.Contents()).Should(Equal([]byte("abcdef")))
+
+ Expect(buffer).Should(Say("bcd"))
+ Expect(buffer.Contents()).Should(Equal([]byte("abcdef")))
+ })
+ })
+
+ Describe("creating a buffer with bytes", func() {
+ It("should create the buffer with the cursor set to the beginning", func() {
+ buffer := BufferWithBytes([]byte("abcdef"))
+ Expect(buffer.Contents()).Should(Equal([]byte("abcdef")))
+ Expect(buffer).Should(Say("abc"))
+ Expect(buffer).ShouldNot(Say("abc"))
+ Expect(buffer).Should(Say("def"))
+ })
+ })
+
+ Describe("creating a buffer that wraps a reader", func() {
+ Context("for a well-behaved reader", func() {
+ It("should buffer the contents of the reader", func() {
+ reader := bytes.NewBuffer([]byte("abcdef"))
+ buffer := BufferReader(reader)
+ Eventually(buffer).Should(Say("abc"))
+ Expect(buffer).ShouldNot(Say("abc"))
+ Eventually(buffer).Should(Say("def"))
+ Eventually(buffer.Closed).Should(BeTrue())
+ })
+ })
+
+ Context("for a slow reader", func() {
+ It("should allow Eventually to time out", func() {
+ slowReader := SlowReader{
+ R: bytes.NewBuffer([]byte("abcdef")),
+ D: time.Second,
+ }
+ buffer := BufferReader(slowReader)
+ failures := InterceptGomegaFailures(func() {
+ Eventually(buffer, 100*time.Millisecond).Should(Say("abc"))
+ })
+ Expect(failures).ShouldNot(BeEmpty())
+
+ fastReader := SlowReader{
+ R: bytes.NewBuffer([]byte("abcdef")),
+ D: time.Millisecond,
+ }
+ buffer = BufferReader(fastReader)
+ Eventually(buffer, 100*time.Millisecond).Should(Say("abc"))
+ Eventually(buffer.Closed).Should(BeTrue())
+ })
+ })
+ })
+
+ Describe("reading from a buffer", func() {
+ It("should read the current contents of the buffer", func() {
+ buffer := BufferWithBytes([]byte("abcde"))
+
+ dest := make([]byte, 3)
+ n, err := buffer.Read(dest)
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(n).Should(Equal(3))
+ Expect(string(dest)).Should(Equal("abc"))
+
+ dest = make([]byte, 3)
+ n, err = buffer.Read(dest)
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(n).Should(Equal(2))
+ Expect(string(dest[:n])).Should(Equal("de"))
+
+ n, err = buffer.Read(dest)
+ Expect(err).Should(Equal(io.EOF))
+ Expect(n).Should(Equal(0))
+ })
+
+ Context("after the buffer has been closed", func() {
+ It("returns an error", func() {
+ buffer := BufferWithBytes([]byte("abcde"))
+
+ buffer.Close()
+
+ dest := make([]byte, 3)
+ n, err := buffer.Read(dest)
+ Expect(err).Should(HaveOccurred())
+ Expect(n).Should(Equal(0))
+ })
+ })
+ })
+
+ Describe("detecting regular expressions", func() {
+ It("should fire the appropriate channel when the passed in pattern matches, then close it", func(done Done) {
+ go func() {
+ time.Sleep(10 * time.Millisecond)
+ buffer.Write([]byte("abcde"))
+ }()
+
+ A := buffer.Detect("%s", "a.c")
+ B := buffer.Detect("def")
+
+ var gotIt bool
+ select {
+ case gotIt = <-A:
+ case <-B:
+ Fail("should not have gotten here")
+ }
+
+ Expect(gotIt).Should(BeTrue())
+ Eventually(A).Should(BeClosed())
+
+ buffer.Write([]byte("f"))
+ Eventually(B).Should(Receive())
+ Eventually(B).Should(BeClosed())
+
+ close(done)
+ })
+
+ It("should fast-forward the buffer upon detection", func(done Done) {
+ buffer.Write([]byte("abcde"))
+ <-buffer.Detect("abc")
+ Expect(buffer).ShouldNot(Say("abc"))
+ Expect(buffer).Should(Say("de"))
+ close(done)
+ })
+
+ It("should only fast-forward the buffer when the channel is read, and only if doing so would not rewind it", func(done Done) {
+ buffer.Write([]byte("abcde"))
+ A := buffer.Detect("abc")
+ time.Sleep(20 * time.Millisecond) //give the goroutine a chance to detect and write to the channel
+ Expect(buffer).Should(Say("abcd"))
+ <-A
+ Expect(buffer).ShouldNot(Say("d"))
+ Expect(buffer).Should(Say("e"))
+ Eventually(A).Should(BeClosed())
+ close(done)
+ })
+
+ It("should be possible to cancel a detection", func(done Done) {
+ A := buffer.Detect("abc")
+ B := buffer.Detect("def")
+ buffer.CancelDetects()
+ buffer.Write([]byte("abcdef"))
+ Eventually(A).Should(BeClosed())
+ Eventually(B).Should(BeClosed())
+
+ Expect(buffer).Should(Say("bcde"))
+ <-buffer.Detect("f")
+ close(done)
+ })
+ })
+
+ Describe("closing the buffer", func() {
+ It("should error when further write attempts are made", func() {
+ _, err := buffer.Write([]byte("abc"))
+ Expect(err).ShouldNot(HaveOccurred())
+
+ buffer.Close()
+
+ _, err = buffer.Write([]byte("def"))
+ Expect(err).Should(HaveOccurred())
+
+ Expect(buffer.Contents()).Should(Equal([]byte("abc")))
+ })
+
+ It("should be closed", func() {
+ Expect(buffer.Closed()).Should(BeFalse())
+
+ buffer.Close()
+
+ Expect(buffer.Closed()).Should(BeTrue())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/gbytes/gbuffer_suite_test.go b/vendor/github.com/onsi/gomega/gbytes/gbuffer_suite_test.go
new file mode 100644
index 000000000..3a7dc0612
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gbytes/gbuffer_suite_test.go
@@ -0,0 +1,13 @@
+package gbytes_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestGbytes(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Gbytes Suite")
+}
diff --git a/vendor/github.com/onsi/gomega/gbytes/io_wrappers.go b/vendor/github.com/onsi/gomega/gbytes/io_wrappers.go
new file mode 100644
index 000000000..3caed8769
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gbytes/io_wrappers.go
@@ -0,0 +1,85 @@
+package gbytes
+
+import (
+ "errors"
+ "io"
+ "time"
+)
+
+// ErrTimeout is returned by TimeoutCloser, TimeoutReader, and TimeoutWriter when the underlying Closer/Reader/Writer does not return within the specified timeout
+var ErrTimeout = errors.New("timeout occurred")
+
+// TimeoutCloser returns an io.Closer that wraps the passed-in io.Closer. If the underlying Closer fails to close within the alloted timeout ErrTimeout is returned.
+func TimeoutCloser(c io.Closer, timeout time.Duration) io.Closer {
+ return timeoutReaderWriterCloser{c: c, d: timeout}
+}
+
+// TimeoutReader returns an io.Reader that wraps the passed-in io.Reader. If the underlying Reader fails to read within the alloted timeout ErrTimeout is returned.
+func TimeoutReader(r io.Reader, timeout time.Duration) io.Reader {
+ return timeoutReaderWriterCloser{r: r, d: timeout}
+}
+
+// TimeoutWriter returns an io.Writer that wraps the passed-in io.Writer. If the underlying Writer fails to write within the alloted timeout ErrTimeout is returned.
+func TimeoutWriter(w io.Writer, timeout time.Duration) io.Writer {
+ return timeoutReaderWriterCloser{w: w, d: timeout}
+}
+
+type timeoutReaderWriterCloser struct {
+ c io.Closer
+ w io.Writer
+ r io.Reader
+ d time.Duration
+}
+
+func (t timeoutReaderWriterCloser) Close() error {
+ done := make(chan struct{})
+ var err error
+
+ go func() {
+ err = t.c.Close()
+ close(done)
+ }()
+
+ select {
+ case <-done:
+ return err
+ case <-time.After(t.d):
+ return ErrTimeout
+ }
+}
+
+func (t timeoutReaderWriterCloser) Read(p []byte) (int, error) {
+ done := make(chan struct{})
+ var n int
+ var err error
+
+ go func() {
+ n, err = t.r.Read(p)
+ close(done)
+ }()
+
+ select {
+ case <-done:
+ return n, err
+ case <-time.After(t.d):
+ return 0, ErrTimeout
+ }
+}
+
+func (t timeoutReaderWriterCloser) Write(p []byte) (int, error) {
+ done := make(chan struct{})
+ var n int
+ var err error
+
+ go func() {
+ n, err = t.w.Write(p)
+ close(done)
+ }()
+
+ select {
+ case <-done:
+ return n, err
+ case <-time.After(t.d):
+ return 0, ErrTimeout
+ }
+}
diff --git a/vendor/github.com/onsi/gomega/gbytes/io_wrappers_test.go b/vendor/github.com/onsi/gomega/gbytes/io_wrappers_test.go
new file mode 100644
index 000000000..3da973498
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gbytes/io_wrappers_test.go
@@ -0,0 +1,188 @@
+package gbytes_test
+
+import (
+ "fmt"
+ "io"
+ "time"
+
+ . "github.com/onsi/gomega/gbytes"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+type FakeCloser struct {
+ err error
+ duration time.Duration
+}
+
+func (f FakeCloser) Close() error {
+ time.Sleep(f.duration)
+ return f.err
+}
+
+type FakeReader struct {
+ err error
+ duration time.Duration
+}
+
+func (f FakeReader) Read(p []byte) (int, error) {
+ time.Sleep(f.duration)
+ if f.err != nil {
+ return 0, f.err
+ }
+
+ for i := 0; i < len(p); i++ {
+ p[i] = 'a'
+ }
+
+ return len(p), nil
+}
+
+type FakeWriter struct {
+ err error
+ duration time.Duration
+}
+
+func (f FakeWriter) Write(p []byte) (int, error) {
+ time.Sleep(f.duration)
+ if f.err != nil {
+ return 0, f.err
+ }
+
+ return len(p), nil
+}
+
+var _ = Describe("Io Wrappers", func() {
+ Describe("TimeoutCloser", func() {
+ var innerCloser io.Closer
+ var timeoutCloser io.Closer
+
+ JustBeforeEach(func() {
+ timeoutCloser = TimeoutCloser(innerCloser, 20*time.Millisecond)
+ })
+
+ Context("when the underlying Closer closes with no error", func() {
+ BeforeEach(func() {
+ innerCloser = FakeCloser{}
+ })
+
+ It("returns with no error", func() {
+ Expect(timeoutCloser.Close()).Should(Succeed())
+ })
+ })
+
+ Context("when the underlying Closer closes with an error", func() {
+ BeforeEach(func() {
+ innerCloser = FakeCloser{err: fmt.Errorf("boom")}
+ })
+
+ It("returns the error", func() {
+ Expect(timeoutCloser.Close()).Should(MatchError("boom"))
+ })
+ })
+
+ Context("when the underlying Closer hangs", func() {
+ BeforeEach(func() {
+ innerCloser = FakeCloser{
+ err: fmt.Errorf("boom"),
+ duration: time.Hour,
+ }
+ })
+
+ It("returns ErrTimeout", func() {
+ Expect(timeoutCloser.Close()).Should(MatchError(ErrTimeout))
+ })
+ })
+ })
+
+ Describe("TimeoutReader", func() {
+ var innerReader io.Reader
+ var timeoutReader io.Reader
+
+ JustBeforeEach(func() {
+ timeoutReader = TimeoutReader(innerReader, 20*time.Millisecond)
+ })
+
+ Context("when the underlying Reader returns no error", func() {
+ BeforeEach(func() {
+ innerReader = FakeReader{}
+ })
+
+ It("returns with no error", func() {
+ p := make([]byte, 5)
+ n, err := timeoutReader.Read(p)
+ Expect(n).Should(Equal(5))
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(p).Should(Equal([]byte("aaaaa")))
+ })
+ })
+
+ Context("when the underlying Reader returns an error", func() {
+ BeforeEach(func() {
+ innerReader = FakeReader{err: fmt.Errorf("boom")}
+ })
+
+ It("returns the error", func() {
+ p := make([]byte, 5)
+ _, err := timeoutReader.Read(p)
+ Expect(err).Should(MatchError("boom"))
+ })
+ })
+
+ Context("when the underlying Reader hangs", func() {
+ BeforeEach(func() {
+ innerReader = FakeReader{err: fmt.Errorf("boom"), duration: time.Hour}
+ })
+
+ It("returns ErrTimeout", func() {
+ p := make([]byte, 5)
+ _, err := timeoutReader.Read(p)
+ Expect(err).Should(MatchError(ErrTimeout))
+ })
+ })
+ })
+
+ Describe("TimeoutWriter", func() {
+ var innerWriter io.Writer
+ var timeoutWriter io.Writer
+
+ JustBeforeEach(func() {
+ timeoutWriter = TimeoutWriter(innerWriter, 20*time.Millisecond)
+ })
+
+ Context("when the underlying Writer returns no error", func() {
+ BeforeEach(func() {
+ innerWriter = FakeWriter{}
+ })
+
+ It("returns with no error", func() {
+ n, err := timeoutWriter.Write([]byte("aaaaa"))
+ Expect(n).Should(Equal(5))
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+ })
+
+ Context("when the underlying Writer returns an error", func() {
+ BeforeEach(func() {
+ innerWriter = FakeWriter{err: fmt.Errorf("boom")}
+ })
+
+ It("returns the error", func() {
+ _, err := timeoutWriter.Write([]byte("aaaaa"))
+ Expect(err).Should(MatchError("boom"))
+ })
+ })
+
+ Context("when the underlying Writer hangs", func() {
+ BeforeEach(func() {
+ innerWriter = FakeWriter{err: fmt.Errorf("boom"), duration: time.Hour}
+ })
+
+ It("returns ErrTimeout", func() {
+ _, err := timeoutWriter.Write([]byte("aaaaa"))
+ Expect(err).Should(MatchError(ErrTimeout))
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/gbytes/say_matcher.go b/vendor/github.com/onsi/gomega/gbytes/say_matcher.go
new file mode 100644
index 000000000..14317182b
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gbytes/say_matcher.go
@@ -0,0 +1,104 @@
+package gbytes
+
+import (
+ "fmt"
+ "regexp"
+
+ "github.com/onsi/gomega/format"
+)
+
+//Objects satisfying the BufferProvider can be used with the Say matcher.
+type BufferProvider interface {
+ Buffer() *Buffer
+}
+
+/*
+Say is a Gomega matcher that operates on gbytes.Buffers:
+
+ Expect(buffer).Should(Say("something"))
+
+will succeed if the unread portion of the buffer matches the regular expression "something".
+
+When Say succeeds, it fast forwards the gbytes.Buffer's read cursor to just after the succesful match.
+Thus, subsequent calls to Say will only match against the unread portion of the buffer
+
+Say pairs very well with Eventually. To assert that a buffer eventually receives data matching "[123]-star" within 3 seconds you can:
+
+ Eventually(buffer, 3).Should(Say("[123]-star"))
+
+Ditto with consistently. To assert that a buffer does not receive data matching "never-see-this" for 1 second you can:
+
+ Consistently(buffer, 1).ShouldNot(Say("never-see-this"))
+
+In addition to bytes.Buffers, Say can operate on objects that implement the gbytes.BufferProvider interface.
+In such cases, Say simply operates on the *gbytes.Buffer returned by Buffer()
+
+If the buffer is closed, the Say matcher will tell Eventually to abort.
+*/
+func Say(expected string, args ...interface{}) *sayMatcher {
+ if len(args) > 0 {
+ expected = fmt.Sprintf(expected, args...)
+ }
+ return &sayMatcher{
+ re: regexp.MustCompile(expected),
+ }
+}
+
+type sayMatcher struct {
+ re *regexp.Regexp
+ receivedSayings []byte
+}
+
+func (m *sayMatcher) buffer(actual interface{}) (*Buffer, bool) {
+ var buffer *Buffer
+
+ switch x := actual.(type) {
+ case *Buffer:
+ buffer = x
+ case BufferProvider:
+ buffer = x.Buffer()
+ default:
+ return nil, false
+ }
+
+ return buffer, true
+}
+
+func (m *sayMatcher) Match(actual interface{}) (success bool, err error) {
+ buffer, ok := m.buffer(actual)
+ if !ok {
+ return false, fmt.Errorf("Say must be passed a *gbytes.Buffer or BufferProvider. Got:\n%s", format.Object(actual, 1))
+ }
+
+ didSay, sayings := buffer.didSay(m.re)
+ m.receivedSayings = sayings
+
+ return didSay, nil
+}
+
+func (m *sayMatcher) FailureMessage(actual interface{}) (message string) {
+ return fmt.Sprintf(
+ "Got stuck at:\n%s\nWaiting for:\n%s",
+ format.IndentString(string(m.receivedSayings), 1),
+ format.IndentString(m.re.String(), 1),
+ )
+}
+
+func (m *sayMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return fmt.Sprintf(
+ "Saw:\n%s\nWhich matches the unexpected:\n%s",
+ format.IndentString(string(m.receivedSayings), 1),
+ format.IndentString(m.re.String(), 1),
+ )
+}
+
+func (m *sayMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
+ switch x := actual.(type) {
+ case *Buffer:
+ return !x.Closed()
+ case BufferProvider:
+ return !x.Buffer().Closed()
+ default:
+ return true
+ }
+}
diff --git a/vendor/github.com/onsi/gomega/gbytes/say_matcher_test.go b/vendor/github.com/onsi/gomega/gbytes/say_matcher_test.go
new file mode 100644
index 000000000..0055d4a1b
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gbytes/say_matcher_test.go
@@ -0,0 +1,169 @@
+package gbytes_test
+
+import (
+ "time"
+
+ . "github.com/onsi/gomega/gbytes"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+type speaker struct {
+ buffer *Buffer
+}
+
+func (s *speaker) Buffer() *Buffer {
+ return s.buffer
+}
+
+var _ = Describe("SayMatcher", func() {
+ var buffer *Buffer
+
+ BeforeEach(func() {
+ buffer = NewBuffer()
+ buffer.Write([]byte("abc"))
+ })
+
+ Context("when actual is not a gexec Buffer, or a BufferProvider", func() {
+ It("should error", func() {
+ failures := InterceptGomegaFailures(func() {
+ Expect("foo").Should(Say("foo"))
+ })
+ Expect(failures[0]).Should(ContainSubstring("*gbytes.Buffer"))
+ })
+ })
+
+ Context("when a match is found", func() {
+ It("should succeed", func() {
+ Expect(buffer).Should(Say("abc"))
+ })
+
+ It("should support printf-like formatting", func() {
+ Expect(buffer).Should(Say("a%sc", "b"))
+ })
+
+ It("should match literal %", func() {
+ buffer.Write([]byte("%"))
+ Expect(buffer).Should(Say("abc%"))
+ })
+
+ It("should use a regular expression", func() {
+ Expect(buffer).Should(Say("a.c"))
+ })
+
+ It("should fastforward the buffer", func() {
+ buffer.Write([]byte("def"))
+ Expect(buffer).Should(Say("abcd"))
+ Expect(buffer).Should(Say("ef"))
+ Expect(buffer).ShouldNot(Say("[a-z]"))
+ })
+ })
+
+ Context("when no match is found", func() {
+ It("should not error", func() {
+ Expect(buffer).ShouldNot(Say("def"))
+ })
+
+ Context("when the buffer is closed", func() {
+ BeforeEach(func() {
+ buffer.Close()
+ })
+
+ It("should abort an eventually", func() {
+ t := time.Now()
+ failures := InterceptGomegaFailures(func() {
+ Eventually(buffer).Should(Say("def"))
+ })
+ Eventually(buffer).ShouldNot(Say("def"))
+ Expect(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond))
+ Expect(failures).Should(HaveLen(1))
+
+ t = time.Now()
+ Eventually(buffer).Should(Say("abc"))
+ Expect(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond))
+ })
+
+ It("should abort a consistently", func() {
+ t := time.Now()
+ Consistently(buffer, 2.0).ShouldNot(Say("def"))
+ Expect(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond))
+ })
+
+ It("should not error with a synchronous matcher", func() {
+ Expect(buffer).ShouldNot(Say("def"))
+ Expect(buffer).Should(Say("abc"))
+ })
+ })
+ })
+
+ Context("when a positive match fails", func() {
+ It("should report where it got stuck", func() {
+ Expect(buffer).Should(Say("abc"))
+ buffer.Write([]byte("def"))
+ failures := InterceptGomegaFailures(func() {
+ Expect(buffer).Should(Say("abc"))
+ })
+ Expect(failures[0]).Should(ContainSubstring("Got stuck at:"))
+ Expect(failures[0]).Should(ContainSubstring("def"))
+ })
+ })
+
+ Context("when a negative match fails", func() {
+ It("should report where it got stuck", func() {
+ failures := InterceptGomegaFailures(func() {
+ Expect(buffer).ShouldNot(Say("abc"))
+ })
+ Expect(failures[0]).Should(ContainSubstring("Saw:"))
+ Expect(failures[0]).Should(ContainSubstring("Which matches the unexpected:"))
+ Expect(failures[0]).Should(ContainSubstring("abc"))
+ })
+ })
+
+ Context("when a match is not found", func() {
+ It("should not fastforward the buffer", func() {
+ Expect(buffer).ShouldNot(Say("def"))
+ Expect(buffer).Should(Say("abc"))
+ })
+ })
+
+ Context("a nice real-life example", func() {
+ It("should behave well", func() {
+ Expect(buffer).Should(Say("abc"))
+ go func() {
+ time.Sleep(10 * time.Millisecond)
+ buffer.Write([]byte("def"))
+ }()
+ Expect(buffer).ShouldNot(Say("def"))
+ Eventually(buffer).Should(Say("def"))
+ })
+ })
+
+ Context("when actual is a BufferProvider", func() {
+ It("should use actual's buffer", func() {
+ s := &speaker{
+ buffer: NewBuffer(),
+ }
+
+ Expect(s).ShouldNot(Say("abc"))
+
+ s.Buffer().Write([]byte("abc"))
+ Expect(s).Should(Say("abc"))
+ })
+
+ It("should abort an eventually", func() {
+ s := &speaker{
+ buffer: NewBuffer(),
+ }
+
+ s.buffer.Close()
+
+ t := time.Now()
+ failures := InterceptGomegaFailures(func() {
+ Eventually(s).Should(Say("def"))
+ })
+ Expect(failures).Should(HaveLen(1))
+ Expect(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/gexec/_fixture/firefly/main.go b/vendor/github.com/onsi/gomega/gexec/_fixture/firefly/main.go
new file mode 100644
index 000000000..16091c22b
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gexec/_fixture/firefly/main.go
@@ -0,0 +1,36 @@
+package main
+
+import (
+ "fmt"
+ "math/rand"
+ "os"
+ "strconv"
+ "time"
+)
+
+var outQuote = "We've done the impossible, and that makes us mighty."
+var errQuote = "Ah, curse your sudden but inevitable betrayal!"
+
+var randomQuotes = []string{
+ "Can we maybe vote on the whole murdering people issue?",
+ "I swear by my pretty floral bonnet, I will end you.",
+ "My work's illegal, but at least it's honest.",
+}
+
+func main() {
+ fmt.Fprintln(os.Stdout, outQuote)
+ fmt.Fprintln(os.Stderr, errQuote)
+
+ randomIndex := rand.New(rand.NewSource(time.Now().UnixNano())).Intn(len(randomQuotes))
+
+ time.Sleep(100 * time.Millisecond)
+
+ fmt.Fprintln(os.Stdout, randomQuotes[randomIndex])
+
+ if len(os.Args) == 2 {
+ exitCode, _ := strconv.Atoi(os.Args[1])
+ os.Exit(exitCode)
+ } else {
+ os.Exit(randomIndex)
+ }
+}
diff --git a/vendor/github.com/onsi/gomega/gexec/build.go b/vendor/github.com/onsi/gomega/gexec/build.go
new file mode 100644
index 000000000..869c1ead8
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gexec/build.go
@@ -0,0 +1,112 @@
+package gexec
+
+import (
+ "errors"
+ "fmt"
+ "go/build"
+ "io/ioutil"
+ "os"
+ "os/exec"
+ "path"
+ "path/filepath"
+ "runtime"
+ "strings"
+ "sync"
+)
+
+var (
+ mu sync.Mutex
+ tmpDir string
+)
+
+/*
+Build uses go build to compile the package at packagePath. The resulting binary is saved off in a temporary directory.
+A path pointing to this binary is returned.
+
+Build uses the $GOPATH set in your environment. If $GOPATH is not set and you are using Go 1.8+,
+it will use the default GOPATH instead. It passes the variadic args on to `go build`.
+*/
+func Build(packagePath string, args ...string) (compiledPath string, err error) {
+ return doBuild(build.Default.GOPATH, packagePath, nil, args...)
+}
+
+/*
+BuildWithEnvironment is identical to Build but allows you to specify env vars to be set at build time.
+*/
+func BuildWithEnvironment(packagePath string, env []string, args ...string) (compiledPath string, err error) {
+ return doBuild(build.Default.GOPATH, packagePath, env, args...)
+}
+
+/*
+BuildIn is identical to Build but allows you to specify a custom $GOPATH (the first argument).
+*/
+func BuildIn(gopath string, packagePath string, args ...string) (compiledPath string, err error) {
+ return doBuild(gopath, packagePath, nil, args...)
+}
+
+func replaceGoPath(environ []string, newGoPath string) []string {
+ newEnviron := []string{}
+ for _, v := range environ {
+ if !strings.HasPrefix(v, "GOPATH=") {
+ newEnviron = append(newEnviron, v)
+ }
+ }
+ return append(newEnviron, "GOPATH="+newGoPath)
+}
+
+func doBuild(gopath, packagePath string, env []string, args ...string) (compiledPath string, err error) {
+ tmpDir, err := temporaryDirectory()
+ if err != nil {
+ return "", err
+ }
+
+ if len(gopath) == 0 {
+ return "", errors.New("$GOPATH not provided when building " + packagePath)
+ }
+
+ executable := filepath.Join(tmpDir, path.Base(packagePath))
+ if runtime.GOOS == "windows" {
+ executable = executable + ".exe"
+ }
+
+ cmdArgs := append([]string{"build"}, args...)
+ cmdArgs = append(cmdArgs, "-o", executable, packagePath)
+
+ build := exec.Command("go", cmdArgs...)
+ build.Env = replaceGoPath(os.Environ(), gopath)
+ build.Env = append(build.Env, env...)
+
+ output, err := build.CombinedOutput()
+ if err != nil {
+ return "", fmt.Errorf("Failed to build %s:\n\nError:\n%s\n\nOutput:\n%s", packagePath, err, string(output))
+ }
+
+ return executable, nil
+}
+
+/*
+You should call CleanupBuildArtifacts before your test ends to clean up any temporary artifacts generated by
+gexec. In Ginkgo this is typically done in an AfterSuite callback.
+*/
+func CleanupBuildArtifacts() {
+ mu.Lock()
+ defer mu.Unlock()
+ if tmpDir != "" {
+ os.RemoveAll(tmpDir)
+ tmpDir = ""
+ }
+}
+
+func temporaryDirectory() (string, error) {
+ var err error
+ mu.Lock()
+ defer mu.Unlock()
+ if tmpDir == "" {
+ tmpDir, err = ioutil.TempDir("", "gexec_artifacts")
+ if err != nil {
+ return "", err
+ }
+ }
+
+ return ioutil.TempDir(tmpDir, "g")
+}
diff --git a/vendor/github.com/onsi/gomega/gexec/build_test.go b/vendor/github.com/onsi/gomega/gexec/build_test.go
new file mode 100644
index 000000000..295dac8bc
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gexec/build_test.go
@@ -0,0 +1,112 @@
+package gexec_test
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gexec"
+)
+
+var packagePath = "./_fixture/firefly"
+
+var _ = Describe(".Build", func() {
+ Context("when there have been previous calls to Build", func() {
+ BeforeEach(func() {
+ _, err := gexec.Build(packagePath)
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("compiles the specified package", func() {
+ compiledPath, err := gexec.Build(packagePath)
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(compiledPath).Should(BeAnExistingFile())
+ })
+
+ Context("and CleanupBuildArtifacts has been called", func() {
+ BeforeEach(func() {
+ gexec.CleanupBuildArtifacts()
+ })
+
+ It("compiles the specified package", func() {
+ var err error
+ fireflyPath, err = gexec.Build(packagePath)
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(fireflyPath).Should(BeAnExistingFile())
+ })
+ })
+ })
+})
+
+var _ = Describe(".BuildWithEnvironment", func() {
+ var err error
+ env := []string{
+ "GOOS=linux",
+ "GOARCH=amd64",
+ }
+
+ It("compiles the specified package with the specified env vars", func() {
+ compiledPath, err := gexec.BuildWithEnvironment(packagePath, env)
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(compiledPath).Should(BeAnExistingFile())
+ })
+
+ It("returns the environment to a good state", func() {
+ _, err = gexec.BuildWithEnvironment(packagePath, env)
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(os.Environ()).ShouldNot(ContainElement("GOOS=linux"))
+ })
+})
+
+var _ = Describe(".BuildIn", func() {
+ const (
+ target = "github.com/onsi/gomega/gexec/_fixture/firefly/"
+ )
+
+ var (
+ original string
+ gopath string
+ )
+
+ BeforeEach(func() {
+ var err error
+ original = os.Getenv("GOPATH")
+ gopath, err = ioutil.TempDir("", "")
+ Expect(err).NotTo(HaveOccurred())
+ copyFile(filepath.Join("_fixture", "firefly", "main.go"), filepath.Join(gopath, "src", target), "main.go")
+ Expect(os.Setenv("GOPATH", filepath.Join(os.TempDir(), "emptyFakeGopath"))).To(Succeed())
+ Expect(os.Environ()).To(ContainElement(fmt.Sprintf("GOPATH=%s", filepath.Join(os.TempDir(), "emptyFakeGopath"))))
+ })
+
+ AfterEach(func() {
+ if original == "" {
+ Expect(os.Unsetenv("GOPATH")).To(Succeed())
+ } else {
+ Expect(os.Setenv("GOPATH", original)).To(Succeed())
+ }
+ if gopath != "" {
+ os.RemoveAll(gopath)
+ }
+ })
+
+ It("appends the gopath env var", func() {
+ _, err := gexec.BuildIn(gopath, target)
+ Expect(err).NotTo(HaveOccurred())
+ })
+
+ It("resets GOPATH to its original value", func() {
+ _, err := gexec.BuildIn(gopath, target)
+ Expect(err).NotTo(HaveOccurred())
+ Expect(os.Getenv("GOPATH")).To(Equal(filepath.Join(os.TempDir(), "emptyFakeGopath")))
+ })
+})
+
+func copyFile(source, directory, basename string) {
+ Expect(os.MkdirAll(directory, 0755)).To(Succeed())
+ content, err := ioutil.ReadFile(source)
+ Expect(err).NotTo(HaveOccurred())
+ Expect(ioutil.WriteFile(filepath.Join(directory, basename), content, 0644)).To(Succeed())
+}
diff --git a/vendor/github.com/onsi/gomega/gexec/exit_matcher.go b/vendor/github.com/onsi/gomega/gexec/exit_matcher.go
new file mode 100644
index 000000000..98a354937
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gexec/exit_matcher.go
@@ -0,0 +1,86 @@
+package gexec
+
+import (
+ "fmt"
+
+ "github.com/onsi/gomega/format"
+)
+
+/*
+The Exit matcher operates on a session:
+
+ Expect(session).Should(Exit(<optional status code>))
+
+Exit passes if the session has already exited.
+
+If no status code is provided, then Exit will succeed if the session has exited regardless of exit code.
+Otherwise, Exit will only succeed if the process has exited with the provided status code.
+
+Note that the process must have already exited. To wait for a process to exit, use Eventually:
+
+ Eventually(session, 3).Should(Exit(0))
+*/
+func Exit(optionalExitCode ...int) *exitMatcher {
+ exitCode := -1
+ if len(optionalExitCode) > 0 {
+ exitCode = optionalExitCode[0]
+ }
+
+ return &exitMatcher{
+ exitCode: exitCode,
+ }
+}
+
+type exitMatcher struct {
+ exitCode int
+ didExit bool
+ actualExitCode int
+}
+
+type Exiter interface {
+ ExitCode() int
+}
+
+func (m *exitMatcher) Match(actual interface{}) (success bool, err error) {
+ exiter, ok := actual.(Exiter)
+ if !ok {
+ return false, fmt.Errorf("Exit must be passed a gexec.Exiter (Missing method ExitCode() int) Got:\n%s", format.Object(actual, 1))
+ }
+
+ m.actualExitCode = exiter.ExitCode()
+
+ if m.actualExitCode == -1 {
+ return false, nil
+ }
+
+ if m.exitCode == -1 {
+ return true, nil
+ }
+ return m.exitCode == m.actualExitCode, nil
+}
+
+func (m *exitMatcher) FailureMessage(actual interface{}) (message string) {
+ if m.actualExitCode == -1 {
+ return "Expected process to exit. It did not."
+ }
+ return format.Message(m.actualExitCode, "to match exit code:", m.exitCode)
+}
+
+func (m *exitMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ if m.actualExitCode == -1 {
+ return "you really shouldn't be able to see this!"
+ } else {
+ if m.exitCode == -1 {
+ return "Expected process not to exit. It did."
+ }
+ return format.Message(m.actualExitCode, "not to match exit code:", m.exitCode)
+ }
+}
+
+func (m *exitMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
+ session, ok := actual.(*Session)
+ if ok {
+ return session.ExitCode() == -1
+ }
+ return true
+}
diff --git a/vendor/github.com/onsi/gomega/gexec/exit_matcher_test.go b/vendor/github.com/onsi/gomega/gexec/exit_matcher_test.go
new file mode 100644
index 000000000..9abc3226f
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gexec/exit_matcher_test.go
@@ -0,0 +1,114 @@
+package gexec_test
+
+import (
+ "os/exec"
+ "time"
+
+ . "github.com/onsi/gomega/gexec"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+type NeverExits struct{}
+
+func (e NeverExits) ExitCode() int {
+ return -1
+}
+
+var _ = Describe("ExitMatcher", func() {
+ var command *exec.Cmd
+ var session *Session
+
+ BeforeEach(func() {
+ var err error
+ command = exec.Command(fireflyPath, "0")
+ session, err = Start(command, nil, nil)
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ Describe("when passed something that is an Exiter", func() {
+ It("should act normally", func() {
+ failures := InterceptGomegaFailures(func() {
+ Expect(NeverExits{}).Should(Exit())
+ })
+
+ Expect(failures[0]).Should(ContainSubstring("Expected process to exit. It did not."))
+ })
+ })
+
+ Describe("when passed something that is not an Exiter", func() {
+ It("should error", func() {
+ failures := InterceptGomegaFailures(func() {
+ Expect("aardvark").Should(Exit())
+ })
+
+ Expect(failures[0]).Should(ContainSubstring("Exit must be passed a gexec.Exiter"))
+ })
+ })
+
+ Context("with no exit code", func() {
+ It("should say the right things when it fails", func() {
+ Expect(session).ShouldNot(Exit())
+
+ failures := InterceptGomegaFailures(func() {
+ Expect(session).Should(Exit())
+ })
+
+ Expect(failures[0]).Should(ContainSubstring("Expected process to exit. It did not."))
+
+ Eventually(session).Should(Exit())
+
+ Expect(session).Should(Exit())
+
+ failures = InterceptGomegaFailures(func() {
+ Expect(session).ShouldNot(Exit())
+ })
+
+ Expect(failures[0]).Should(ContainSubstring("Expected process not to exit. It did."))
+ })
+ })
+
+ Context("with an exit code", func() {
+ It("should say the right things when it fails", func() {
+ Expect(session).ShouldNot(Exit(0))
+ Expect(session).ShouldNot(Exit(1))
+
+ failures := InterceptGomegaFailures(func() {
+ Expect(session).Should(Exit(0))
+ })
+
+ Expect(failures[0]).Should(ContainSubstring("Expected process to exit. It did not."))
+
+ Eventually(session).Should(Exit(0))
+
+ Expect(session).Should(Exit(0))
+
+ failures = InterceptGomegaFailures(func() {
+ Expect(session).Should(Exit(1))
+ })
+
+ Expect(failures[0]).Should(ContainSubstring("to match exit code:"))
+
+ Expect(session).ShouldNot(Exit(1))
+
+ failures = InterceptGomegaFailures(func() {
+ Expect(session).ShouldNot(Exit(0))
+ })
+
+ Expect(failures[0]).Should(ContainSubstring("not to match exit code:"))
+ })
+ })
+
+ Describe("bailing out early", func() {
+ It("should bail out early once the process exits", func() {
+ t := time.Now()
+
+ failures := InterceptGomegaFailures(func() {
+ Eventually(session).Should(Exit(1))
+ })
+ Expect(time.Since(t)).Should(BeNumerically("<=", 500*time.Millisecond))
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/gexec/gexec_suite_test.go b/vendor/github.com/onsi/gomega/gexec/gexec_suite_test.go
new file mode 100644
index 000000000..dc8e1f40c
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gexec/gexec_suite_test.go
@@ -0,0 +1,26 @@
+package gexec_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gexec"
+
+ "testing"
+)
+
+var fireflyPath string
+
+func TestGexec(t *testing.T) {
+ BeforeSuite(func() {
+ var err error
+ fireflyPath, err = gexec.Build("./_fixture/firefly")
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ AfterSuite(func() {
+ gexec.CleanupBuildArtifacts()
+ })
+
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Gexec Suite")
+}
diff --git a/vendor/github.com/onsi/gomega/gexec/prefixed_writer.go b/vendor/github.com/onsi/gomega/gexec/prefixed_writer.go
new file mode 100644
index 000000000..05e695abc
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gexec/prefixed_writer.go
@@ -0,0 +1,53 @@
+package gexec
+
+import (
+ "io"
+ "sync"
+)
+
+/*
+PrefixedWriter wraps an io.Writer, emiting the passed in prefix at the beginning of each new line.
+This can be useful when running multiple gexec.Sessions concurrently - you can prefix the log output of each
+session by passing in a PrefixedWriter:
+
+gexec.Start(cmd, NewPrefixedWriter("[my-cmd] ", GinkgoWriter), NewPrefixedWriter("[my-cmd] ", GinkgoWriter))
+*/
+type PrefixedWriter struct {
+ prefix []byte
+ writer io.Writer
+ lock *sync.Mutex
+ atStartOfLine bool
+}
+
+func NewPrefixedWriter(prefix string, writer io.Writer) *PrefixedWriter {
+ return &PrefixedWriter{
+ prefix: []byte(prefix),
+ writer: writer,
+ lock: &sync.Mutex{},
+ atStartOfLine: true,
+ }
+}
+
+func (w *PrefixedWriter) Write(b []byte) (int, error) {
+ w.lock.Lock()
+ defer w.lock.Unlock()
+
+ toWrite := []byte{}
+
+ for _, c := range b {
+ if w.atStartOfLine {
+ toWrite = append(toWrite, w.prefix...)
+ }
+
+ toWrite = append(toWrite, c)
+
+ w.atStartOfLine = c == '\n'
+ }
+
+ _, err := w.writer.Write(toWrite)
+ if err != nil {
+ return 0, err
+ }
+
+ return len(b), nil
+}
diff --git a/vendor/github.com/onsi/gomega/gexec/prefixed_writer_test.go b/vendor/github.com/onsi/gomega/gexec/prefixed_writer_test.go
new file mode 100644
index 000000000..e847b1501
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gexec/prefixed_writer_test.go
@@ -0,0 +1,43 @@
+package gexec_test
+
+import (
+ "bytes"
+
+ . "github.com/onsi/gomega/gexec"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("PrefixedWriter", func() {
+ var buffer *bytes.Buffer
+ var writer *PrefixedWriter
+ BeforeEach(func() {
+ buffer = &bytes.Buffer{}
+ writer = NewPrefixedWriter("[p]", buffer)
+ })
+
+ It("should emit the prefix on newlines", func() {
+ writer.Write([]byte("abc"))
+ writer.Write([]byte("def\n"))
+ writer.Write([]byte("hij\n"))
+ writer.Write([]byte("\n\n"))
+ writer.Write([]byte("klm\n\nnop"))
+ writer.Write([]byte(""))
+ writer.Write([]byte("qrs"))
+ writer.Write([]byte("\ntuv\nwx"))
+ writer.Write([]byte("yz\n\n"))
+
+ Expect(buffer.String()).Should(Equal(`[p]abcdef
+[p]hij
+[p]
+[p]
+[p]klm
+[p]
+[p]nopqrs
+[p]tuv
+[p]wxyz
+[p]
+`))
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/gexec/session.go b/vendor/github.com/onsi/gomega/gexec/session.go
new file mode 100644
index 000000000..5cb00ca65
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gexec/session.go
@@ -0,0 +1,303 @@
+/*
+Package gexec provides support for testing external processes.
+*/
+package gexec
+
+import (
+ "io"
+ "os"
+ "os/exec"
+ "sync"
+ "syscall"
+
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/gbytes"
+)
+
+const INVALID_EXIT_CODE = 254
+
+type Session struct {
+ //The wrapped command
+ Command *exec.Cmd
+
+ //A *gbytes.Buffer connected to the command's stdout
+ Out *gbytes.Buffer
+
+ //A *gbytes.Buffer connected to the command's stderr
+ Err *gbytes.Buffer
+
+ //A channel that will close when the command exits
+ Exited <-chan struct{}
+
+ lock *sync.Mutex
+ exitCode int
+}
+
+/*
+Start starts the passed-in *exec.Cmd command. It wraps the command in a *gexec.Session.
+
+The session pipes the command's stdout and stderr to two *gbytes.Buffers available as properties on the session: session.Out and session.Err.
+These buffers can be used with the gbytes.Say matcher to match against unread output:
+
+ Expect(session.Out).Should(gbytes.Say("foo-out"))
+ Expect(session.Err).Should(gbytes.Say("foo-err"))
+
+In addition, Session satisfies the gbytes.BufferProvider interface and provides the stdout *gbytes.Buffer. This allows you to replace the first line, above, with:
+
+ Expect(session).Should(gbytes.Say("foo-out"))
+
+When outWriter and/or errWriter are non-nil, the session will pipe stdout and/or stderr output both into the session *gybtes.Buffers and to the passed-in outWriter/errWriter.
+This is useful for capturing the process's output or logging it to screen. In particular, when using Ginkgo it can be convenient to direct output to the GinkgoWriter:
+
+ session, err := Start(command, GinkgoWriter, GinkgoWriter)
+
+This will log output when running tests in verbose mode, but - otherwise - will only log output when a test fails.
+
+The session wrapper is responsible for waiting on the *exec.Cmd command. You *should not* call command.Wait() yourself.
+Instead, to assert that the command has exited you can use the gexec.Exit matcher:
+
+ Expect(session).Should(gexec.Exit())
+
+When the session exits it closes the stdout and stderr gbytes buffers. This will short circuit any
+Eventuallys waiting for the buffers to Say something.
+*/
+func Start(command *exec.Cmd, outWriter io.Writer, errWriter io.Writer) (*Session, error) {
+ exited := make(chan struct{})
+
+ session := &Session{
+ Command: command,
+ Out: gbytes.NewBuffer(),
+ Err: gbytes.NewBuffer(),
+ Exited: exited,
+ lock: &sync.Mutex{},
+ exitCode: -1,
+ }
+
+ var commandOut, commandErr io.Writer
+
+ commandOut, commandErr = session.Out, session.Err
+
+ if outWriter != nil {
+ commandOut = io.MultiWriter(commandOut, outWriter)
+ }
+
+ if errWriter != nil {
+ commandErr = io.MultiWriter(commandErr, errWriter)
+ }
+
+ command.Stdout = commandOut
+ command.Stderr = commandErr
+
+ err := command.Start()
+ if err == nil {
+ go session.monitorForExit(exited)
+ trackedSessionsMutex.Lock()
+ defer trackedSessionsMutex.Unlock()
+ trackedSessions = append(trackedSessions, session)
+ }
+
+ return session, err
+}
+
+/*
+Buffer implements the gbytes.BufferProvider interface and returns s.Out
+This allows you to make gbytes.Say matcher assertions against stdout without having to reference .Out:
+
+ Eventually(session).Should(gbytes.Say("foo"))
+*/
+func (s *Session) Buffer() *gbytes.Buffer {
+ return s.Out
+}
+
+/*
+ExitCode returns the wrapped command's exit code. If the command hasn't exited yet, ExitCode returns -1.
+
+To assert that the command has exited it is more convenient to use the Exit matcher:
+
+ Eventually(s).Should(gexec.Exit())
+
+When the process exits because it has received a particular signal, the exit code will be 128+signal-value
+(See http://www.tldp.org/LDP/abs/html/exitcodes.html and http://man7.org/linux/man-pages/man7/signal.7.html)
+
+*/
+func (s *Session) ExitCode() int {
+ s.lock.Lock()
+ defer s.lock.Unlock()
+ return s.exitCode
+}
+
+/*
+Wait waits until the wrapped command exits. It can be passed an optional timeout.
+If the command does not exit within the timeout, Wait will trigger a test failure.
+
+Wait returns the session, making it possible to chain:
+
+ session.Wait().Out.Contents()
+
+will wait for the command to exit then return the entirety of Out's contents.
+
+Wait uses eventually under the hood and accepts the same timeout/polling intervals that eventually does.
+*/
+func (s *Session) Wait(timeout ...interface{}) *Session {
+ EventuallyWithOffset(1, s, timeout...).Should(Exit())
+ return s
+}
+
+/*
+Kill sends the running command a SIGKILL signal. It does not wait for the process to exit.
+
+If the command has already exited, Kill returns silently.
+
+The session is returned to enable chaining.
+*/
+func (s *Session) Kill() *Session {
+ return s.Signal(syscall.SIGKILL)
+}
+
+/*
+Interrupt sends the running command a SIGINT signal. It does not wait for the process to exit.
+
+If the command has already exited, Interrupt returns silently.
+
+The session is returned to enable chaining.
+*/
+func (s *Session) Interrupt() *Session {
+ return s.Signal(syscall.SIGINT)
+}
+
+/*
+Terminate sends the running command a SIGTERM signal. It does not wait for the process to exit.
+
+If the command has already exited, Terminate returns silently.
+
+The session is returned to enable chaining.
+*/
+func (s *Session) Terminate() *Session {
+ return s.Signal(syscall.SIGTERM)
+}
+
+/*
+Signal sends the running command the passed in signal. It does not wait for the process to exit.
+
+If the command has already exited, Signal returns silently.
+
+The session is returned to enable chaining.
+*/
+func (s *Session) Signal(signal os.Signal) *Session {
+ if s.processIsAlive() {
+ s.Command.Process.Signal(signal)
+ }
+ return s
+}
+
+func (s *Session) monitorForExit(exited chan<- struct{}) {
+ err := s.Command.Wait()
+ s.lock.Lock()
+ s.Out.Close()
+ s.Err.Close()
+ status := s.Command.ProcessState.Sys().(syscall.WaitStatus)
+ if status.Signaled() {
+ s.exitCode = 128 + int(status.Signal())
+ } else {
+ exitStatus := status.ExitStatus()
+ if exitStatus == -1 && err != nil {
+ s.exitCode = INVALID_EXIT_CODE
+ }
+ s.exitCode = exitStatus
+ }
+ s.lock.Unlock()
+
+ close(exited)
+}
+
+func (s *Session) processIsAlive() bool {
+ return s.ExitCode() == -1 && s.Command.Process != nil
+}
+
+var trackedSessions = []*Session{}
+var trackedSessionsMutex = &sync.Mutex{}
+
+/*
+Kill sends a SIGKILL signal to all the processes started by Run, and waits for them to exit.
+The timeout specified is applied to each process killed.
+
+If any of the processes already exited, KillAndWait returns silently.
+*/
+func KillAndWait(timeout ...interface{}) {
+ trackedSessionsMutex.Lock()
+ defer trackedSessionsMutex.Unlock()
+ for _, session := range trackedSessions {
+ session.Kill().Wait(timeout...)
+ }
+ trackedSessions = []*Session{}
+}
+
+/*
+Kill sends a SIGTERM signal to all the processes started by Run, and waits for them to exit.
+The timeout specified is applied to each process killed.
+
+If any of the processes already exited, TerminateAndWait returns silently.
+*/
+func TerminateAndWait(timeout ...interface{}) {
+ trackedSessionsMutex.Lock()
+ defer trackedSessionsMutex.Unlock()
+ for _, session := range trackedSessions {
+ session.Terminate().Wait(timeout...)
+ }
+}
+
+/*
+Kill sends a SIGKILL signal to all the processes started by Run.
+It does not wait for the processes to exit.
+
+If any of the processes already exited, Kill returns silently.
+*/
+func Kill() {
+ trackedSessionsMutex.Lock()
+ defer trackedSessionsMutex.Unlock()
+ for _, session := range trackedSessions {
+ session.Kill()
+ }
+}
+
+/*
+Terminate sends a SIGTERM signal to all the processes started by Run.
+It does not wait for the processes to exit.
+
+If any of the processes already exited, Terminate returns silently.
+*/
+func Terminate() {
+ trackedSessionsMutex.Lock()
+ defer trackedSessionsMutex.Unlock()
+ for _, session := range trackedSessions {
+ session.Terminate()
+ }
+}
+
+/*
+Signal sends the passed in signal to all the processes started by Run.
+It does not wait for the processes to exit.
+
+If any of the processes already exited, Signal returns silently.
+*/
+func Signal(signal os.Signal) {
+ trackedSessionsMutex.Lock()
+ defer trackedSessionsMutex.Unlock()
+ for _, session := range trackedSessions {
+ session.Signal(signal)
+ }
+}
+
+/*
+Interrupt sends the SIGINT signal to all the processes started by Run.
+It does not wait for the processes to exit.
+
+If any of the processes already exited, Interrupt returns silently.
+*/
+func Interrupt() {
+ trackedSessionsMutex.Lock()
+ defer trackedSessionsMutex.Unlock()
+ for _, session := range trackedSessions {
+ session.Interrupt()
+ }
+}
diff --git a/vendor/github.com/onsi/gomega/gexec/session_test.go b/vendor/github.com/onsi/gomega/gexec/session_test.go
new file mode 100644
index 000000000..6fdf22d21
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gexec/session_test.go
@@ -0,0 +1,336 @@
+package gexec_test
+
+import (
+ "io"
+ "io/ioutil"
+ "os/exec"
+ "syscall"
+ "time"
+
+ . "github.com/onsi/gomega/gbytes"
+ . "github.com/onsi/gomega/gexec"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Session", func() {
+ var command *exec.Cmd
+ var session *Session
+
+ var outWriter, errWriter io.Writer
+
+ BeforeEach(func() {
+ outWriter = nil
+ errWriter = nil
+ })
+
+ JustBeforeEach(func() {
+ command = exec.Command(fireflyPath)
+ var err error
+ session, err = Start(command, outWriter, errWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ Context("running a command", func() {
+ It("should start the process", func() {
+ Expect(command.Process).ShouldNot(BeNil())
+ })
+
+ It("should wrap the process's stdout and stderr with gbytes buffers", func(done Done) {
+ Eventually(session.Out).Should(Say("We've done the impossible, and that makes us mighty"))
+ Eventually(session.Err).Should(Say("Ah, curse your sudden but inevitable betrayal!"))
+ defer session.Out.CancelDetects()
+
+ select {
+ case <-session.Out.Detect("Can we maybe vote on the whole murdering people issue"):
+ Eventually(session).Should(Exit(0))
+ case <-session.Out.Detect("I swear by my pretty floral bonnet, I will end you."):
+ Eventually(session).Should(Exit(1))
+ case <-session.Out.Detect("My work's illegal, but at least it's honest."):
+ Eventually(session).Should(Exit(2))
+ }
+
+ close(done)
+ })
+
+ It("should satisfy the gbytes.BufferProvider interface, passing Stdout", func() {
+ Eventually(session).Should(Say("We've done the impossible, and that makes us mighty"))
+ Eventually(session).Should(Exit())
+ })
+ })
+
+ Describe("providing the exit code", func() {
+ It("should provide the app's exit code", func() {
+ Expect(session.ExitCode()).Should(Equal(-1))
+
+ Eventually(session).Should(Exit())
+ Expect(session.ExitCode()).Should(BeNumerically(">=", 0))
+ Expect(session.ExitCode()).Should(BeNumerically("<", 3))
+ })
+ })
+
+ Describe("wait", func() {
+ It("should wait till the command exits", func() {
+ Expect(session.ExitCode()).Should(Equal(-1))
+ Expect(session.Wait().ExitCode()).Should(BeNumerically(">=", 0))
+ Expect(session.Wait().ExitCode()).Should(BeNumerically("<", 3))
+ })
+ })
+
+ Describe("exited", func() {
+ It("should close when the command exits", func() {
+ Eventually(session.Exited).Should(BeClosed())
+ Expect(session.ExitCode()).ShouldNot(Equal(-1))
+ })
+ })
+
+ Describe("kill", func() {
+ It("should kill the command", func() {
+ session, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session.Kill()
+ Eventually(session).Should(Exit(128 + 9))
+ })
+ })
+
+ Describe("interrupt", func() {
+ It("should interrupt the command", func() {
+ session, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session.Interrupt()
+ Eventually(session).Should(Exit(128 + 2))
+ })
+ })
+
+ Describe("terminate", func() {
+ It("should terminate the command", func() {
+ session, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session.Terminate()
+ Eventually(session).Should(Exit(128 + 15))
+ })
+ })
+
+ Describe("signal", func() {
+ It("should send the signal to the command", func() {
+ session, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session.Signal(syscall.SIGABRT)
+ Eventually(session).Should(Exit(128 + 6))
+ })
+
+ It("should ignore sending a signal if the command did not start", func() {
+ session, err := Start(exec.Command("notexisting"), GinkgoWriter, GinkgoWriter)
+ Expect(err).To(HaveOccurred())
+
+ Expect(func() { session.Signal(syscall.SIGUSR1) }).NotTo(Panic())
+ })
+ })
+
+ Context("tracking sessions", func() {
+ BeforeEach(func() {
+ KillAndWait()
+ })
+
+ Describe("kill", func() {
+ It("should kill all the started sessions", func() {
+ session1, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session2, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session3, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Kill()
+
+ Eventually(session1).Should(Exit(128 + 9))
+ Eventually(session2).Should(Exit(128 + 9))
+ Eventually(session3).Should(Exit(128 + 9))
+ })
+
+ It("should not track unstarted sessions", func() {
+ _, err := Start(exec.Command("does not exist", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).Should(HaveOccurred())
+
+ session2, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session3, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Kill()
+
+ Eventually(session2).Should(Exit(128 + 9))
+ Eventually(session3).Should(Exit(128 + 9))
+ })
+
+ })
+
+ Describe("killAndWait", func() {
+ It("should kill all the started sessions and wait for them to finish", func() {
+ session1, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session2, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session3, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ KillAndWait()
+ Expect(session1).Should(Exit(128+9), "Should have exited")
+ Expect(session2).Should(Exit(128+9), "Should have exited")
+ Expect(session3).Should(Exit(128+9), "Should have exited")
+ })
+ })
+
+ Describe("terminate", func() {
+ It("should terminate all the started sessions", func() {
+ session1, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session2, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session3, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Terminate()
+
+ Eventually(session1).Should(Exit(128 + 15))
+ Eventually(session2).Should(Exit(128 + 15))
+ Eventually(session3).Should(Exit(128 + 15))
+ })
+ })
+
+ Describe("terminateAndWait", func() {
+ It("should terminate all the started sessions, and wait for them to exit", func() {
+ session1, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session2, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session3, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ TerminateAndWait()
+
+ Expect(session1).Should(Exit(128+15), "Should have exited")
+ Expect(session2).Should(Exit(128+15), "Should have exited")
+ Expect(session3).Should(Exit(128+15), "Should have exited")
+ })
+ })
+
+ Describe("signal", func() {
+ It("should signal all the started sessions", func() {
+ session1, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session2, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session3, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Signal(syscall.SIGABRT)
+
+ Eventually(session1).Should(Exit(128 + 6))
+ Eventually(session2).Should(Exit(128 + 6))
+ Eventually(session3).Should(Exit(128 + 6))
+ })
+ })
+
+ Describe("interrupt", func() {
+ It("should interrupt all the started sessions, and not wait", func() {
+ session1, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session2, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ session3, err := Start(exec.Command("sleep", "10000000"), GinkgoWriter, GinkgoWriter)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Interrupt()
+
+ Eventually(session1).Should(Exit(128 + 2))
+ Eventually(session2).Should(Exit(128 + 2))
+ Eventually(session3).Should(Exit(128 + 2))
+ })
+ })
+ })
+
+ Context("when the command exits", func() {
+ It("should close the buffers", func() {
+ Eventually(session).Should(Exit())
+
+ Expect(session.Out.Closed()).Should(BeTrue())
+ Expect(session.Err.Closed()).Should(BeTrue())
+
+ Expect(session.Out).Should(Say("We've done the impossible, and that makes us mighty"))
+ })
+
+ var So = It
+
+ So("this means that eventually should short circuit", func() {
+ t := time.Now()
+ failures := InterceptGomegaFailures(func() {
+ Eventually(session).Should(Say("blah blah blah blah blah"))
+ })
+ Expect(time.Since(t)).Should(BeNumerically("<=", 500*time.Millisecond))
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+
+ Context("when wrapping out and err", func() {
+ var (
+ outWriterBuffer, errWriterBuffer *Buffer
+ )
+
+ BeforeEach(func() {
+ outWriterBuffer = NewBuffer()
+ outWriter = outWriterBuffer
+ errWriterBuffer = NewBuffer()
+ errWriter = errWriterBuffer
+ })
+
+ It("should route to both the provided writers and the gbytes buffers", func() {
+ Eventually(session.Out).Should(Say("We've done the impossible, and that makes us mighty"))
+ Eventually(session.Err).Should(Say("Ah, curse your sudden but inevitable betrayal!"))
+
+ Expect(outWriterBuffer.Contents()).Should(ContainSubstring("We've done the impossible, and that makes us mighty"))
+ Expect(errWriterBuffer.Contents()).Should(ContainSubstring("Ah, curse your sudden but inevitable betrayal!"))
+
+ Eventually(session).Should(Exit())
+
+ Expect(outWriterBuffer.Contents()).Should(Equal(session.Out.Contents()))
+ Expect(errWriterBuffer.Contents()).Should(Equal(session.Err.Contents()))
+ })
+
+ Context("when discarding the output of the command", func() {
+ BeforeEach(func() {
+ outWriter = ioutil.Discard
+ errWriter = ioutil.Discard
+ })
+
+ It("executes succesfuly", func() {
+ Eventually(session).Should(Exit())
+ })
+ })
+ })
+
+ Describe("when the command fails to start", func() {
+ It("should return an error", func() {
+ _, err := Start(exec.Command("agklsjdfas"), nil, nil)
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/ghttp/handlers.go b/vendor/github.com/onsi/gomega/ghttp/handlers.go
new file mode 100644
index 000000000..894eae6d4
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/ghttp/handlers.go
@@ -0,0 +1,322 @@
+package ghttp
+
+import (
+ "encoding/base64"
+ "encoding/json"
+ "fmt"
+ "io/ioutil"
+ "net/http"
+ "net/url"
+ "reflect"
+ "strings"
+
+ "github.com/golang/protobuf/proto"
+ . "github.com/onsi/gomega"
+ "github.com/onsi/gomega/types"
+)
+
+//CombineHandler takes variadic list of handlers and produces one handler
+//that calls each handler in order.
+func CombineHandlers(handlers ...http.HandlerFunc) http.HandlerFunc {
+ return func(w http.ResponseWriter, req *http.Request) {
+ for _, handler := range handlers {
+ handler(w, req)
+ }
+ }
+}
+
+//VerifyRequest returns a handler that verifies that a request uses the specified method to connect to the specified path
+//You may also pass in an optional rawQuery string which is tested against the request's `req.URL.RawQuery`
+//
+//For path, you may pass in a string, in which case strict equality will be applied
+//Alternatively you can pass in a matcher (ContainSubstring("/foo") and MatchRegexp("/foo/[a-f0-9]+") for example)
+func VerifyRequest(method string, path interface{}, rawQuery ...string) http.HandlerFunc {
+ return func(w http.ResponseWriter, req *http.Request) {
+ Expect(req.Method).Should(Equal(method), "Method mismatch")
+ switch p := path.(type) {
+ case types.GomegaMatcher:
+ Expect(req.URL.Path).Should(p, "Path mismatch")
+ default:
+ Expect(req.URL.Path).Should(Equal(path), "Path mismatch")
+ }
+ if len(rawQuery) > 0 {
+ values, err := url.ParseQuery(rawQuery[0])
+ Expect(err).ShouldNot(HaveOccurred(), "Expected RawQuery is malformed")
+
+ Expect(req.URL.Query()).Should(Equal(values), "RawQuery mismatch")
+ }
+ }
+}
+
+//VerifyContentType returns a handler that verifies that a request has a Content-Type header set to the
+//specified value
+func VerifyContentType(contentType string) http.HandlerFunc {
+ return func(w http.ResponseWriter, req *http.Request) {
+ Expect(req.Header.Get("Content-Type")).Should(Equal(contentType))
+ }
+}
+
+//VerifyMimeType returns a handler that verifies that a request has a specified mime type set
+//in Content-Type header
+func VerifyMimeType(mimeType string) http.HandlerFunc {
+ return func(w http.ResponseWriter, req *http.Request) {
+ Expect(strings.Split(req.Header.Get("Content-Type"), ";")[0]).Should(Equal(mimeType))
+ }
+}
+
+//VerifyBasicAuth returns a handler that verifies the request contains a BasicAuth Authorization header
+//matching the passed in username and password
+func VerifyBasicAuth(username string, password string) http.HandlerFunc {
+ return func(w http.ResponseWriter, req *http.Request) {
+ auth := req.Header.Get("Authorization")
+ Expect(auth).ShouldNot(Equal(""), "Authorization header must be specified")
+
+ decoded, err := base64.StdEncoding.DecodeString(auth[6:])
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(string(decoded)).Should(Equal(fmt.Sprintf("%s:%s", username, password)), "Authorization mismatch")
+ }
+}
+
+//VerifyHeader returns a handler that verifies the request contains the passed in headers.
+//The passed in header keys are first canonicalized via http.CanonicalHeaderKey.
+//
+//The request must contain *all* the passed in headers, but it is allowed to have additional headers
+//beyond the passed in set.
+func VerifyHeader(header http.Header) http.HandlerFunc {
+ return func(w http.ResponseWriter, req *http.Request) {
+ for key, values := range header {
+ key = http.CanonicalHeaderKey(key)
+ Expect(req.Header[key]).Should(Equal(values), "Header mismatch for key: %s", key)
+ }
+ }
+}
+
+//VerifyHeaderKV returns a handler that verifies the request contains a header matching the passed in key and values
+//(recall that a `http.Header` is a mapping from string (key) to []string (values))
+//It is a convenience wrapper around `VerifyHeader` that allows you to avoid having to create an `http.Header` object.
+func VerifyHeaderKV(key string, values ...string) http.HandlerFunc {
+ return VerifyHeader(http.Header{key: values})
+}
+
+//VerifyBody returns a handler that verifies that the body of the request matches the passed in byte array.
+//It does this using Equal().
+func VerifyBody(expectedBody []byte) http.HandlerFunc {
+ return CombineHandlers(
+ func(w http.ResponseWriter, req *http.Request) {
+ body, err := ioutil.ReadAll(req.Body)
+ req.Body.Close()
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(body).Should(Equal(expectedBody), "Body Mismatch")
+ },
+ )
+}
+
+//VerifyJSON returns a handler that verifies that the body of the request is a valid JSON representation
+//matching the passed in JSON string. It does this using Gomega's MatchJSON method
+//
+//VerifyJSON also verifies that the request's content type is application/json
+func VerifyJSON(expectedJSON string) http.HandlerFunc {
+ return CombineHandlers(
+ VerifyMimeType("application/json"),
+ func(w http.ResponseWriter, req *http.Request) {
+ body, err := ioutil.ReadAll(req.Body)
+ req.Body.Close()
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(body).Should(MatchJSON(expectedJSON), "JSON Mismatch")
+ },
+ )
+}
+
+//VerifyJSONRepresenting is similar to VerifyJSON. Instead of taking a JSON string, however, it
+//takes an arbitrary JSON-encodable object and verifies that the requests's body is a JSON representation
+//that matches the object
+func VerifyJSONRepresenting(object interface{}) http.HandlerFunc {
+ data, err := json.Marshal(object)
+ Expect(err).ShouldNot(HaveOccurred())
+ return CombineHandlers(
+ VerifyContentType("application/json"),
+ VerifyJSON(string(data)),
+ )
+}
+
+//VerifyForm returns a handler that verifies a request contains the specified form values.
+//
+//The request must contain *all* of the specified values, but it is allowed to have additional
+//form values beyond the passed in set.
+func VerifyForm(values url.Values) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ err := r.ParseForm()
+ Expect(err).ShouldNot(HaveOccurred())
+ for key, vals := range values {
+ Expect(r.Form[key]).Should(Equal(vals), "Form mismatch for key: %s", key)
+ }
+ }
+}
+
+//VerifyFormKV returns a handler that verifies a request contains a form key with the specified values.
+//
+//It is a convenience wrapper around `VerifyForm` that lets you avoid having to create a `url.Values` object.
+func VerifyFormKV(key string, values ...string) http.HandlerFunc {
+ return VerifyForm(url.Values{key: values})
+}
+
+//VerifyProtoRepresenting returns a handler that verifies that the body of the request is a valid protobuf
+//representation of the passed message.
+//
+//VerifyProtoRepresenting also verifies that the request's content type is application/x-protobuf
+func VerifyProtoRepresenting(expected proto.Message) http.HandlerFunc {
+ return CombineHandlers(
+ VerifyContentType("application/x-protobuf"),
+ func(w http.ResponseWriter, req *http.Request) {
+ body, err := ioutil.ReadAll(req.Body)
+ Expect(err).ShouldNot(HaveOccurred())
+ req.Body.Close()
+
+ expectedType := reflect.TypeOf(expected)
+ actualValuePtr := reflect.New(expectedType.Elem())
+
+ actual, ok := actualValuePtr.Interface().(proto.Message)
+ Expect(ok).Should(BeTrue(), "Message value is not a proto.Message")
+
+ err = proto.Unmarshal(body, actual)
+ Expect(err).ShouldNot(HaveOccurred(), "Failed to unmarshal protobuf")
+
+ Expect(actual).Should(Equal(expected), "ProtoBuf Mismatch")
+ },
+ )
+}
+
+func copyHeader(src http.Header, dst http.Header) {
+ for key, value := range src {
+ dst[key] = value
+ }
+}
+
+/*
+RespondWith returns a handler that responds to a request with the specified status code and body
+
+Body may be a string or []byte
+
+Also, RespondWith can be given an optional http.Header. The headers defined therein will be added to the response headers.
+*/
+func RespondWith(statusCode int, body interface{}, optionalHeader ...http.Header) http.HandlerFunc {
+ return func(w http.ResponseWriter, req *http.Request) {
+ if len(optionalHeader) == 1 {
+ copyHeader(optionalHeader[0], w.Header())
+ }
+ w.WriteHeader(statusCode)
+ switch x := body.(type) {
+ case string:
+ w.Write([]byte(x))
+ case []byte:
+ w.Write(x)
+ default:
+ Expect(body).Should(BeNil(), "Invalid type for body. Should be string or []byte.")
+ }
+ }
+}
+
+/*
+RespondWithPtr returns a handler that responds to a request with the specified status code and body
+
+Unlike RespondWith, you pass RepondWithPtr a pointer to the status code and body allowing different tests
+to share the same setup but specify different status codes and bodies.
+
+Also, RespondWithPtr can be given an optional http.Header. The headers defined therein will be added to the response headers.
+Since the http.Header can be mutated after the fact you don't need to pass in a pointer.
+*/
+func RespondWithPtr(statusCode *int, body interface{}, optionalHeader ...http.Header) http.HandlerFunc {
+ return func(w http.ResponseWriter, req *http.Request) {
+ if len(optionalHeader) == 1 {
+ copyHeader(optionalHeader[0], w.Header())
+ }
+ w.WriteHeader(*statusCode)
+ if body != nil {
+ switch x := (body).(type) {
+ case *string:
+ w.Write([]byte(*x))
+ case *[]byte:
+ w.Write(*x)
+ default:
+ Expect(body).Should(BeNil(), "Invalid type for body. Should be string or []byte.")
+ }
+ }
+ }
+}
+
+/*
+RespondWithJSONEncoded returns a handler that responds to a request with the specified status code and a body
+containing the JSON-encoding of the passed in object
+
+Also, RespondWithJSONEncoded can be given an optional http.Header. The headers defined therein will be added to the response headers.
+*/
+func RespondWithJSONEncoded(statusCode int, object interface{}, optionalHeader ...http.Header) http.HandlerFunc {
+ data, err := json.Marshal(object)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ var headers http.Header
+ if len(optionalHeader) == 1 {
+ headers = optionalHeader[0]
+ } else {
+ headers = make(http.Header)
+ }
+ if _, found := headers["Content-Type"]; !found {
+ headers["Content-Type"] = []string{"application/json"}
+ }
+ return RespondWith(statusCode, string(data), headers)
+}
+
+/*
+RespondWithJSONEncodedPtr behaves like RespondWithJSONEncoded but takes a pointer
+to a status code and object.
+
+This allows different tests to share the same setup but specify different status codes and JSON-encoded
+objects.
+
+Also, RespondWithJSONEncodedPtr can be given an optional http.Header. The headers defined therein will be added to the response headers.
+Since the http.Header can be mutated after the fact you don't need to pass in a pointer.
+*/
+func RespondWithJSONEncodedPtr(statusCode *int, object interface{}, optionalHeader ...http.Header) http.HandlerFunc {
+ return func(w http.ResponseWriter, req *http.Request) {
+ data, err := json.Marshal(object)
+ Expect(err).ShouldNot(HaveOccurred())
+ var headers http.Header
+ if len(optionalHeader) == 1 {
+ headers = optionalHeader[0]
+ } else {
+ headers = make(http.Header)
+ }
+ if _, found := headers["Content-Type"]; !found {
+ headers["Content-Type"] = []string{"application/json"}
+ }
+ copyHeader(headers, w.Header())
+ w.WriteHeader(*statusCode)
+ w.Write(data)
+ }
+}
+
+//RespondWithProto returns a handler that responds to a request with the specified status code and a body
+//containing the protobuf serialization of the provided message.
+//
+//Also, RespondWithProto can be given an optional http.Header. The headers defined therein will be added to the response headers.
+func RespondWithProto(statusCode int, message proto.Message, optionalHeader ...http.Header) http.HandlerFunc {
+ return func(w http.ResponseWriter, req *http.Request) {
+ data, err := proto.Marshal(message)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ var headers http.Header
+ if len(optionalHeader) == 1 {
+ headers = optionalHeader[0]
+ } else {
+ headers = make(http.Header)
+ }
+ if _, found := headers["Content-Type"]; !found {
+ headers["Content-Type"] = []string{"application/x-protobuf"}
+ }
+ copyHeader(headers, w.Header())
+
+ w.WriteHeader(statusCode)
+ w.Write(data)
+ }
+}
diff --git a/vendor/github.com/onsi/gomega/ghttp/protobuf/protobuf.go b/vendor/github.com/onsi/gomega/ghttp/protobuf/protobuf.go
new file mode 100644
index 000000000..b2972bc9f
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/ghttp/protobuf/protobuf.go
@@ -0,0 +1,3 @@
+package protobuf
+
+//go:generate protoc --go_out=. simple_message.proto
diff --git a/vendor/github.com/onsi/gomega/ghttp/protobuf/simple_message.pb.go b/vendor/github.com/onsi/gomega/ghttp/protobuf/simple_message.pb.go
new file mode 100644
index 000000000..c55a48448
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/ghttp/protobuf/simple_message.pb.go
@@ -0,0 +1,55 @@
+// Code generated by protoc-gen-go.
+// source: simple_message.proto
+// DO NOT EDIT!
+
+/*
+Package protobuf is a generated protocol buffer package.
+
+It is generated from these files:
+ simple_message.proto
+
+It has these top-level messages:
+ SimpleMessage
+*/
+package protobuf
+
+import proto "github.com/golang/protobuf/proto"
+import fmt "fmt"
+import math "math"
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+type SimpleMessage struct {
+ Description *string `protobuf:"bytes,1,req,name=description" json:"description,omitempty"`
+ Id *int32 `protobuf:"varint,2,req,name=id" json:"id,omitempty"`
+ Metadata *string `protobuf:"bytes,3,opt,name=metadata" json:"metadata,omitempty"`
+ XXX_unrecognized []byte `json:"-"`
+}
+
+func (m *SimpleMessage) Reset() { *m = SimpleMessage{} }
+func (m *SimpleMessage) String() string { return proto.CompactTextString(m) }
+func (*SimpleMessage) ProtoMessage() {}
+
+func (m *SimpleMessage) GetDescription() string {
+ if m != nil && m.Description != nil {
+ return *m.Description
+ }
+ return ""
+}
+
+func (m *SimpleMessage) GetId() int32 {
+ if m != nil && m.Id != nil {
+ return *m.Id
+ }
+ return 0
+}
+
+func (m *SimpleMessage) GetMetadata() string {
+ if m != nil && m.Metadata != nil {
+ return *m.Metadata
+ }
+ return ""
+}
diff --git a/vendor/github.com/onsi/gomega/ghttp/protobuf/simple_message.proto b/vendor/github.com/onsi/gomega/ghttp/protobuf/simple_message.proto
new file mode 100644
index 000000000..35b7145c2
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/ghttp/protobuf/simple_message.proto
@@ -0,0 +1,9 @@
+syntax = "proto2";
+
+package protobuf;
+
+message SimpleMessage {
+ required string description = 1;
+ required int32 id = 2;
+ optional string metadata = 3;
+}
diff --git a/vendor/github.com/onsi/gomega/ghttp/test_server.go b/vendor/github.com/onsi/gomega/ghttp/test_server.go
new file mode 100644
index 000000000..77535f309
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/ghttp/test_server.go
@@ -0,0 +1,422 @@
+/*
+Package ghttp supports testing HTTP clients by providing a test server (simply a thin wrapper around httptest's server) that supports
+registering multiple handlers. Incoming requests are not routed between the different handlers
+- rather it is merely the order of the handlers that matters. The first request is handled by the first
+registered handler, the second request by the second handler, etc.
+
+The intent here is to have each handler *verify* that the incoming request is valid. To accomplish, ghttp
+also provides a collection of bite-size handlers that each perform one aspect of request verification. These can
+be composed together and registered with a ghttp server. The result is an expressive language for describing
+the requests generated by the client under test.
+
+Here's a simple example, note that the server handler is only defined in one BeforeEach and then modified, as required, by the nested BeforeEaches.
+A more comprehensive example is available at https://onsi.github.io/gomega/#_testing_http_clients
+
+ var _ = Describe("A Sprockets Client", func() {
+ var server *ghttp.Server
+ var client *SprocketClient
+ BeforeEach(func() {
+ server = ghttp.NewServer()
+ client = NewSprocketClient(server.URL(), "skywalker", "tk427")
+ })
+
+ AfterEach(func() {
+ server.Close()
+ })
+
+ Describe("fetching sprockets", func() {
+ var statusCode int
+ var sprockets []Sprocket
+ BeforeEach(func() {
+ statusCode = http.StatusOK
+ sprockets = []Sprocket{}
+ server.AppendHandlers(ghttp.CombineHandlers(
+ ghttp.VerifyRequest("GET", "/sprockets"),
+ ghttp.VerifyBasicAuth("skywalker", "tk427"),
+ ghttp.RespondWithJSONEncodedPtr(&statusCode, &sprockets),
+ ))
+ })
+
+ Context("when requesting all sprockets", func() {
+ Context("when the response is succesful", func() {
+ BeforeEach(func() {
+ sprockets = []Sprocket{
+ NewSprocket("Alfalfa"),
+ NewSprocket("Banana"),
+ }
+ })
+
+ It("should return the returned sprockets", func() {
+ Expect(client.Sprockets()).Should(Equal(sprockets))
+ })
+ })
+
+ Context("when the response is missing", func() {
+ BeforeEach(func() {
+ statusCode = http.StatusNotFound
+ })
+
+ It("should return an empty list of sprockets", func() {
+ Expect(client.Sprockets()).Should(BeEmpty())
+ })
+ })
+
+ Context("when the response fails to authenticate", func() {
+ BeforeEach(func() {
+ statusCode = http.StatusUnauthorized
+ })
+
+ It("should return an AuthenticationError error", func() {
+ sprockets, err := client.Sprockets()
+ Expect(sprockets).Should(BeEmpty())
+ Expect(err).Should(MatchError(AuthenticationError))
+ })
+ })
+
+ Context("when the response is a server failure", func() {
+ BeforeEach(func() {
+ statusCode = http.StatusInternalServerError
+ })
+
+ It("should return an InternalError error", func() {
+ sprockets, err := client.Sprockets()
+ Expect(sprockets).Should(BeEmpty())
+ Expect(err).Should(MatchError(InternalError))
+ })
+ })
+ })
+
+ Context("when requesting some sprockets", func() {
+ BeforeEach(func() {
+ sprockets = []Sprocket{
+ NewSprocket("Alfalfa"),
+ NewSprocket("Banana"),
+ }
+
+ server.WrapHandler(0, ghttp.VerifyRequest("GET", "/sprockets", "filter=FOOD"))
+ })
+
+ It("should make the request with a filter", func() {
+ Expect(client.Sprockets("food")).Should(Equal(sprockets))
+ })
+ })
+ })
+ })
+*/
+package ghttp
+
+import (
+ "fmt"
+ "io"
+ "io/ioutil"
+ "net/http"
+ "net/http/httptest"
+ "net/http/httputil"
+ "reflect"
+ "regexp"
+ "strings"
+ "sync"
+
+ . "github.com/onsi/gomega"
+)
+
+func new() *Server {
+ return &Server{
+ AllowUnhandledRequests: false,
+ UnhandledRequestStatusCode: http.StatusInternalServerError,
+ rwMutex: &sync.RWMutex{},
+ }
+}
+
+type routedHandler struct {
+ method string
+ pathRegexp *regexp.Regexp
+ path string
+ handler http.HandlerFunc
+}
+
+// NewServer returns a new `*ghttp.Server` that wraps an `httptest` server. The server is started automatically.
+func NewServer() *Server {
+ s := new()
+ s.HTTPTestServer = httptest.NewServer(s)
+ return s
+}
+
+// NewUnstartedServer return a new, unstarted, `*ghttp.Server`. Useful for specifying a custom listener on `server.HTTPTestServer`.
+func NewUnstartedServer() *Server {
+ s := new()
+ s.HTTPTestServer = httptest.NewUnstartedServer(s)
+ return s
+}
+
+// NewTLSServer returns a new `*ghttp.Server` that wraps an `httptest` TLS server. The server is started automatically.
+func NewTLSServer() *Server {
+ s := new()
+ s.HTTPTestServer = httptest.NewTLSServer(s)
+ return s
+}
+
+type Server struct {
+ //The underlying httptest server
+ HTTPTestServer *httptest.Server
+
+ //Defaults to false. If set to true, the Server will allow more requests than there are registered handlers.
+ //Direct use of this property is deprecated and is likely to be removed, use GetAllowUnhandledRequests and SetAllowUnhandledRequests instead.
+ AllowUnhandledRequests bool
+
+ //The status code returned when receiving an unhandled request.
+ //Defaults to http.StatusInternalServerError.
+ //Only applies if AllowUnhandledRequests is true
+ //Direct use of this property is deprecated and is likely to be removed, use GetUnhandledRequestStatusCode and SetUnhandledRequestStatusCode instead.
+ UnhandledRequestStatusCode int
+
+ //If provided, ghttp will log about each request received to the provided io.Writer
+ //Defaults to nil
+ //If you're using Ginkgo, set this to GinkgoWriter to get improved output during failures
+ Writer io.Writer
+
+ receivedRequests []*http.Request
+ requestHandlers []http.HandlerFunc
+ routedHandlers []routedHandler
+
+ rwMutex *sync.RWMutex
+ calls int
+}
+
+//Start() starts an unstarted ghttp server. It is a catastrophic error to call Start more than once (thanks, httptest).
+func (s *Server) Start() {
+ s.HTTPTestServer.Start()
+}
+
+//URL() returns a url that will hit the server
+func (s *Server) URL() string {
+ s.rwMutex.RLock()
+ defer s.rwMutex.RUnlock()
+ return s.HTTPTestServer.URL
+}
+
+//Addr() returns the address on which the server is listening.
+func (s *Server) Addr() string {
+ s.rwMutex.RLock()
+ defer s.rwMutex.RUnlock()
+ return s.HTTPTestServer.Listener.Addr().String()
+}
+
+//Close() should be called at the end of each test. It spins down and cleans up the test server.
+func (s *Server) Close() {
+ s.rwMutex.Lock()
+ server := s.HTTPTestServer
+ s.HTTPTestServer = nil
+ s.rwMutex.Unlock()
+
+ if server != nil {
+ server.Close()
+ }
+}
+
+//ServeHTTP() makes Server an http.Handler
+//When the server receives a request it handles the request in the following order:
+//
+//1. If the request matches a handler registered with RouteToHandler, that handler is called.
+//2. Otherwise, if there are handlers registered via AppendHandlers, those handlers are called in order.
+//3. If all registered handlers have been called then:
+// a) If AllowUnhandledRequests is set to true, the request will be handled with response code of UnhandledRequestStatusCode
+// b) If AllowUnhandledRequests is false, the request will not be handled and the current test will be marked as failed.
+func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
+ s.rwMutex.Lock()
+ defer func() {
+ e := recover()
+ if e != nil {
+ w.WriteHeader(http.StatusInternalServerError)
+ }
+
+ //If the handler panics GHTTP will silently succeed. This is badâ„¢.
+ //To catch this case we need to fail the test if the handler has panicked.
+ //However, if the handler is panicking because Ginkgo's causing it to panic (i.e. an assertion failed)
+ //then we shouldn't double-report the error as this will confuse people.
+
+ //So: step 1, if this is a Ginkgo panic - do nothing, Ginkgo's aware of the failure
+ eAsString, ok := e.(string)
+ if ok && strings.Contains(eAsString, "defer GinkgoRecover()") {
+ return
+ }
+
+ //If we're here, we have to do step 2: assert that the error is nil. This assertion will
+ //allow us to fail the test suite (note: we can't call Fail since Gomega is not allowed to import Ginkgo).
+ //Since a failed assertion throws a panic, and we are likely in a goroutine, we need to defer within our defer!
+ defer func() {
+ recover()
+ }()
+ Expect(e).Should(BeNil(), "Handler Panicked")
+ }()
+
+ if s.Writer != nil {
+ s.Writer.Write([]byte(fmt.Sprintf("GHTTP Received Request: %s - %s\n", req.Method, req.URL)))
+ }
+
+ s.receivedRequests = append(s.receivedRequests, req)
+ if routedHandler, ok := s.handlerForRoute(req.Method, req.URL.Path); ok {
+ s.rwMutex.Unlock()
+ routedHandler(w, req)
+ } else if s.calls < len(s.requestHandlers) {
+ h := s.requestHandlers[s.calls]
+ s.calls++
+ s.rwMutex.Unlock()
+ h(w, req)
+ } else {
+ s.rwMutex.Unlock()
+ if s.GetAllowUnhandledRequests() {
+ ioutil.ReadAll(req.Body)
+ req.Body.Close()
+ w.WriteHeader(s.GetUnhandledRequestStatusCode())
+ } else {
+ formatted, err := httputil.DumpRequest(req, true)
+ Expect(err).NotTo(HaveOccurred(), "Encountered error while dumping HTTP request")
+ Expect(string(formatted)).Should(BeNil(), "Received Unhandled Request")
+ }
+ }
+}
+
+//ReceivedRequests is an array containing all requests received by the server (both handled and unhandled requests)
+func (s *Server) ReceivedRequests() []*http.Request {
+ s.rwMutex.RLock()
+ defer s.rwMutex.RUnlock()
+
+ return s.receivedRequests
+}
+
+//RouteToHandler can be used to register handlers that will always handle requests that match
+//the passed in method and path.
+//
+//The path may be either a string object or a *regexp.Regexp.
+func (s *Server) RouteToHandler(method string, path interface{}, handler http.HandlerFunc) {
+ s.rwMutex.Lock()
+ defer s.rwMutex.Unlock()
+
+ rh := routedHandler{
+ method: method,
+ handler: handler,
+ }
+
+ switch p := path.(type) {
+ case *regexp.Regexp:
+ rh.pathRegexp = p
+ case string:
+ rh.path = p
+ default:
+ panic("path must be a string or a regular expression")
+ }
+
+ for i, existingRH := range s.routedHandlers {
+ if existingRH.method == method &&
+ reflect.DeepEqual(existingRH.pathRegexp, rh.pathRegexp) &&
+ existingRH.path == rh.path {
+ s.routedHandlers[i] = rh
+ return
+ }
+ }
+ s.routedHandlers = append(s.routedHandlers, rh)
+}
+
+func (s *Server) handlerForRoute(method string, path string) (http.HandlerFunc, bool) {
+ for _, rh := range s.routedHandlers {
+ if rh.method == method {
+ if rh.pathRegexp != nil {
+ if rh.pathRegexp.Match([]byte(path)) {
+ return rh.handler, true
+ }
+ } else if rh.path == path {
+ return rh.handler, true
+ }
+ }
+ }
+
+ return nil, false
+}
+
+//AppendHandlers will appends http.HandlerFuncs to the server's list of registered handlers. The first incoming request is handled by the first handler, the second by the second, etc...
+func (s *Server) AppendHandlers(handlers ...http.HandlerFunc) {
+ s.rwMutex.Lock()
+ defer s.rwMutex.Unlock()
+
+ s.requestHandlers = append(s.requestHandlers, handlers...)
+}
+
+//SetHandler overrides the registered handler at the passed in index with the passed in handler
+//This is useful, for example, when a server has been set up in a shared context, but must be tweaked
+//for a particular test.
+func (s *Server) SetHandler(index int, handler http.HandlerFunc) {
+ s.rwMutex.Lock()
+ defer s.rwMutex.Unlock()
+
+ s.requestHandlers[index] = handler
+}
+
+//GetHandler returns the handler registered at the passed in index.
+func (s *Server) GetHandler(index int) http.HandlerFunc {
+ s.rwMutex.RLock()
+ defer s.rwMutex.RUnlock()
+
+ return s.requestHandlers[index]
+}
+
+func (s *Server) Reset() {
+ s.rwMutex.Lock()
+ defer s.rwMutex.Unlock()
+
+ s.HTTPTestServer.CloseClientConnections()
+ s.calls = 0
+ s.receivedRequests = nil
+ s.requestHandlers = nil
+ s.routedHandlers = nil
+}
+
+//WrapHandler combines the passed in handler with the handler registered at the passed in index.
+//This is useful, for example, when a server has been set up in a shared context but must be tweaked
+//for a particular test.
+//
+//If the currently registered handler is A, and the new passed in handler is B then
+//WrapHandler will generate a new handler that first calls A, then calls B, and assign it to index
+func (s *Server) WrapHandler(index int, handler http.HandlerFunc) {
+ existingHandler := s.GetHandler(index)
+ s.SetHandler(index, CombineHandlers(existingHandler, handler))
+}
+
+func (s *Server) CloseClientConnections() {
+ s.rwMutex.Lock()
+ defer s.rwMutex.Unlock()
+
+ s.HTTPTestServer.CloseClientConnections()
+}
+
+//SetAllowUnhandledRequests enables the server to accept unhandled requests.
+func (s *Server) SetAllowUnhandledRequests(allowUnhandledRequests bool) {
+ s.rwMutex.Lock()
+ defer s.rwMutex.Unlock()
+
+ s.AllowUnhandledRequests = allowUnhandledRequests
+}
+
+//GetAllowUnhandledRequests returns true if the server accepts unhandled requests.
+func (s *Server) GetAllowUnhandledRequests() bool {
+ s.rwMutex.RLock()
+ defer s.rwMutex.RUnlock()
+
+ return s.AllowUnhandledRequests
+}
+
+//SetUnhandledRequestStatusCode status code to be returned when the server receives unhandled requests
+func (s *Server) SetUnhandledRequestStatusCode(statusCode int) {
+ s.rwMutex.Lock()
+ defer s.rwMutex.Unlock()
+
+ s.UnhandledRequestStatusCode = statusCode
+}
+
+//GetUnhandledRequestStatusCode returns the current status code being returned for unhandled requests
+func (s *Server) GetUnhandledRequestStatusCode() int {
+ s.rwMutex.RLock()
+ defer s.rwMutex.RUnlock()
+
+ return s.UnhandledRequestStatusCode
+}
diff --git a/vendor/github.com/onsi/gomega/ghttp/test_server_suite_test.go b/vendor/github.com/onsi/gomega/ghttp/test_server_suite_test.go
new file mode 100644
index 000000000..7c1236082
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/ghttp/test_server_suite_test.go
@@ -0,0 +1,13 @@
+package ghttp_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestGHTTP(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "GHTTP Suite")
+}
diff --git a/vendor/github.com/onsi/gomega/ghttp/test_server_test.go b/vendor/github.com/onsi/gomega/ghttp/test_server_test.go
new file mode 100644
index 000000000..be1c58e82
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/ghttp/test_server_test.go
@@ -0,0 +1,1129 @@
+package ghttp_test
+
+import (
+ "bytes"
+ "io"
+ "io/ioutil"
+ "net/http"
+ "net/url"
+ "regexp"
+
+ "github.com/golang/protobuf/proto"
+ "github.com/onsi/gomega/gbytes"
+ "github.com/onsi/gomega/ghttp/protobuf"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/ghttp"
+)
+
+var _ = Describe("TestServer", func() {
+ var (
+ resp *http.Response
+ err error
+ s *Server
+ )
+
+ BeforeEach(func() {
+ s = NewServer()
+ })
+
+ AfterEach(func() {
+ s.Close()
+ })
+
+ Describe("Resetting the server", func() {
+ BeforeEach(func() {
+ s.RouteToHandler("GET", "/", func(w http.ResponseWriter, req *http.Request) {})
+ s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) {})
+ http.Get(s.URL() + "/")
+
+ Expect(s.ReceivedRequests()).Should(HaveLen(1))
+ })
+
+ It("clears all handlers and call counts", func() {
+ s.Reset()
+ Expect(s.ReceivedRequests()).Should(HaveLen(0))
+ Expect(func() { s.GetHandler(0) }).Should(Panic())
+ })
+ })
+
+ Describe("closing client connections", func() {
+ It("closes", func() {
+ s.RouteToHandler("GET", "/",
+ func(w http.ResponseWriter, req *http.Request) {
+ io.WriteString(w, req.RemoteAddr)
+ },
+ )
+ client := http.Client{Transport: &http.Transport{DisableKeepAlives: true}}
+ resp, err := client.Get(s.URL())
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(resp.StatusCode).Should(Equal(200))
+
+ body, err := ioutil.ReadAll(resp.Body)
+ resp.Body.Close()
+ Expect(err).ShouldNot(HaveOccurred())
+
+ s.CloseClientConnections()
+
+ resp, err = client.Get(s.URL())
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(resp.StatusCode).Should(Equal(200))
+
+ body2, err := ioutil.ReadAll(resp.Body)
+ resp.Body.Close()
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(body2).ShouldNot(Equal(body))
+ })
+ })
+
+ Describe("closing server mulitple times", func() {
+ It("should not fail", func() {
+ s.Close()
+ Expect(s.Close).ShouldNot(Panic())
+ })
+ })
+
+ Describe("allowing unhandled requests", func() {
+ It("is not permitted by default", func() {
+ Expect(s.GetAllowUnhandledRequests()).To(BeFalse())
+ })
+
+ Context("when true", func() {
+ BeforeEach(func() {
+ s.SetAllowUnhandledRequests(true)
+ s.SetUnhandledRequestStatusCode(http.StatusForbidden)
+ resp, err = http.Get(s.URL() + "/foo")
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should allow unhandled requests and respond with the passed in status code", func() {
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(resp.StatusCode).Should(Equal(http.StatusForbidden))
+
+ data, err := ioutil.ReadAll(resp.Body)
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(data).Should(BeEmpty())
+ })
+
+ It("should record the requests", func() {
+ Expect(s.ReceivedRequests()).Should(HaveLen(1))
+ Expect(s.ReceivedRequests()[0].URL.Path).Should(Equal("/foo"))
+ })
+ })
+
+ Context("when false", func() {
+ It("should fail when attempting a request", func() {
+ failures := InterceptGomegaFailures(func() {
+ http.Get(s.URL() + "/foo")
+ })
+
+ Expect(failures[0]).Should(ContainSubstring("Received Unhandled Request"))
+ })
+ })
+ })
+
+ Describe("Managing Handlers", func() {
+ var called []string
+ BeforeEach(func() {
+ called = []string{}
+ s.RouteToHandler("GET", "/routed", func(w http.ResponseWriter, req *http.Request) {
+ called = append(called, "r1")
+ })
+ s.RouteToHandler("POST", regexp.MustCompile(`/routed\d`), func(w http.ResponseWriter, req *http.Request) {
+ called = append(called, "r2")
+ })
+ s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) {
+ called = append(called, "A")
+ }, func(w http.ResponseWriter, req *http.Request) {
+ called = append(called, "B")
+ })
+ })
+
+ It("should prefer routed handlers if there is a match", func() {
+ http.Get(s.URL() + "/routed")
+ http.Post(s.URL()+"/routed7", "application/json", nil)
+ http.Get(s.URL() + "/foo")
+ http.Get(s.URL() + "/routed")
+ http.Post(s.URL()+"/routed9", "application/json", nil)
+ http.Get(s.URL() + "/bar")
+
+ failures := InterceptGomegaFailures(func() {
+ http.Get(s.URL() + "/foo")
+ http.Get(s.URL() + "/routed/not/a/match")
+ http.Get(s.URL() + "/routed7")
+ http.Post(s.URL()+"/routed", "application/json", nil)
+ })
+
+ Expect(failures[0]).Should(ContainSubstring("Received Unhandled Request"))
+ Expect(failures).Should(HaveLen(4))
+
+ http.Post(s.URL()+"/routed3", "application/json", nil)
+
+ Expect(called).Should(Equal([]string{"r1", "r2", "A", "r1", "r2", "B", "r2"}))
+ })
+
+ It("should override routed handlers when reregistered", func() {
+ s.RouteToHandler("GET", "/routed", func(w http.ResponseWriter, req *http.Request) {
+ called = append(called, "r3")
+ })
+ s.RouteToHandler("POST", regexp.MustCompile(`/routed\d`), func(w http.ResponseWriter, req *http.Request) {
+ called = append(called, "r4")
+ })
+
+ http.Get(s.URL() + "/routed")
+ http.Post(s.URL()+"/routed7", "application/json", nil)
+
+ Expect(called).Should(Equal([]string{"r3", "r4"}))
+ })
+
+ It("should call the appended handlers, in order, as requests come in", func() {
+ http.Get(s.URL() + "/foo")
+ Expect(called).Should(Equal([]string{"A"}))
+
+ http.Get(s.URL() + "/foo")
+ Expect(called).Should(Equal([]string{"A", "B"}))
+
+ failures := InterceptGomegaFailures(func() {
+ http.Get(s.URL() + "/foo")
+ })
+
+ Expect(failures[0]).Should(ContainSubstring("Received Unhandled Request"))
+ })
+
+ Describe("Overwriting an existing handler", func() {
+ BeforeEach(func() {
+ s.SetHandler(0, func(w http.ResponseWriter, req *http.Request) {
+ called = append(called, "C")
+ })
+ })
+
+ It("should override the specified handler", func() {
+ http.Get(s.URL() + "/foo")
+ http.Get(s.URL() + "/foo")
+ Expect(called).Should(Equal([]string{"C", "B"}))
+ })
+ })
+
+ Describe("Getting an existing handler", func() {
+ It("should return the handler func", func() {
+ s.GetHandler(1)(nil, nil)
+ Expect(called).Should(Equal([]string{"B"}))
+ })
+ })
+
+ Describe("Wrapping an existing handler", func() {
+ BeforeEach(func() {
+ s.WrapHandler(0, func(w http.ResponseWriter, req *http.Request) {
+ called = append(called, "C")
+ })
+ })
+
+ It("should wrap the existing handler in a new handler", func() {
+ http.Get(s.URL() + "/foo")
+ http.Get(s.URL() + "/foo")
+ Expect(called).Should(Equal([]string{"A", "C", "B"}))
+ })
+ })
+ })
+
+ Describe("When a handler fails", func() {
+ BeforeEach(func() {
+ s.SetUnhandledRequestStatusCode(http.StatusForbidden) //just to be clear that 500s aren't coming from unhandled requests
+ })
+
+ Context("because the handler has panicked", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) {
+ panic("bam")
+ })
+ })
+
+ It("should respond with a 500 and make a failing assertion", func() {
+ var resp *http.Response
+ var err error
+
+ failures := InterceptGomegaFailures(func() {
+ resp, err = http.Get(s.URL())
+ })
+
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(resp.StatusCode).Should(Equal(http.StatusInternalServerError))
+ Expect(failures).Should(ConsistOf(ContainSubstring("Handler Panicked")))
+ })
+ })
+
+ Context("because an assertion has failed", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) {
+ // Expect(true).Should(BeFalse()) <-- would be nice to do it this way, but the test just can't be written this way
+
+ By("We're cheating a bit here -- we're throwing a GINKGO_PANIC which simulates a failed assertion")
+ panic(GINKGO_PANIC)
+ })
+ })
+
+ It("should respond with a 500 and *not* make a failing assertion, instead relying on Ginkgo to have already been notified of the error", func() {
+ resp, err := http.Get(s.URL())
+
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(resp.StatusCode).Should(Equal(http.StatusInternalServerError))
+ })
+ })
+ })
+
+ Describe("Logging to the Writer", func() {
+ var buf *gbytes.Buffer
+ BeforeEach(func() {
+ buf = gbytes.NewBuffer()
+ s.Writer = buf
+ s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) {})
+ s.AppendHandlers(func(w http.ResponseWriter, req *http.Request) {})
+ })
+
+ It("should write to the buffer when a request comes in", func() {
+ http.Get(s.URL() + "/foo")
+ Expect(buf).Should(gbytes.Say("GHTTP Received Request: GET - /foo\n"))
+
+ http.Post(s.URL()+"/bar", "", nil)
+ Expect(buf).Should(gbytes.Say("GHTTP Received Request: POST - /bar\n"))
+ })
+ })
+
+ Describe("Request Handlers", func() {
+ Describe("VerifyRequest", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(VerifyRequest("GET", "/foo"))
+ })
+
+ It("should verify the method, path", func() {
+ resp, err = http.Get(s.URL() + "/foo?baz=bar")
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should verify the method, path", func() {
+ failures := InterceptGomegaFailures(func() {
+ http.Get(s.URL() + "/foo2")
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+
+ It("should verify the method, path", func() {
+ failures := InterceptGomegaFailures(func() {
+ http.Post(s.URL()+"/foo", "application/json", nil)
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+
+ Context("when passed a rawQuery", func() {
+ It("should also be possible to verify the rawQuery", func() {
+ s.SetHandler(0, VerifyRequest("GET", "/foo", "baz=bar"))
+ resp, err = http.Get(s.URL() + "/foo?baz=bar")
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should match irregardless of query parameter ordering", func() {
+ s.SetHandler(0, VerifyRequest("GET", "/foo", "type=get&name=money"))
+ u, _ := url.Parse(s.URL() + "/foo")
+ u.RawQuery = url.Values{
+ "type": []string{"get"},
+ "name": []string{"money"},
+ }.Encode()
+
+ resp, err = http.Get(u.String())
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+ })
+
+ Context("when passed a matcher for path", func() {
+ It("should apply the matcher", func() {
+ s.SetHandler(0, VerifyRequest("GET", MatchRegexp(`/foo/[a-f]*/3`)))
+ resp, err = http.Get(s.URL() + "/foo/abcdefa/3")
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+ })
+ })
+
+ Describe("VerifyContentType", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("GET", "/foo"),
+ VerifyContentType("application/octet-stream"),
+ ))
+ })
+
+ It("should verify the content type", func() {
+ req, err := http.NewRequest("GET", s.URL()+"/foo", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+ req.Header.Set("Content-Type", "application/octet-stream")
+
+ resp, err = http.DefaultClient.Do(req)
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should verify the content type", func() {
+ req, err := http.NewRequest("GET", s.URL()+"/foo", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+ req.Header.Set("Content-Type", "application/json")
+
+ failures := InterceptGomegaFailures(func() {
+ http.DefaultClient.Do(req)
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+
+ It("should verify the content type", func() {
+ req, err := http.NewRequest("GET", s.URL()+"/foo", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+ req.Header.Set("Content-Type", "application/octet-stream; charset=utf-8")
+
+ failures := InterceptGomegaFailures(func() {
+ http.DefaultClient.Do(req)
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+
+ Describe("Verify BasicAuth", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("GET", "/foo"),
+ VerifyBasicAuth("bob", "password"),
+ ))
+ })
+
+ It("should verify basic auth", func() {
+ req, err := http.NewRequest("GET", s.URL()+"/foo", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+ req.SetBasicAuth("bob", "password")
+
+ resp, err = http.DefaultClient.Do(req)
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should verify basic auth", func() {
+ req, err := http.NewRequest("GET", s.URL()+"/foo", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+ req.SetBasicAuth("bob", "bassword")
+
+ failures := InterceptGomegaFailures(func() {
+ http.DefaultClient.Do(req)
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+
+ It("should require basic auth header", func() {
+ req, err := http.NewRequest("GET", s.URL()+"/foo", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ failures := InterceptGomegaFailures(func() {
+ http.DefaultClient.Do(req)
+ })
+ Expect(failures).Should(ContainElement(ContainSubstring("Authorization header must be specified")))
+ })
+ })
+
+ Describe("VerifyHeader", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("GET", "/foo"),
+ VerifyHeader(http.Header{
+ "accept": []string{"jpeg", "png"},
+ "cache-control": []string{"omicron"},
+ "Return-Path": []string{"hobbiton"},
+ }),
+ ))
+ })
+
+ It("should verify the headers", func() {
+ req, err := http.NewRequest("GET", s.URL()+"/foo", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+ req.Header.Add("Accept", "jpeg")
+ req.Header.Add("Accept", "png")
+ req.Header.Add("Cache-Control", "omicron")
+ req.Header.Add("return-path", "hobbiton")
+
+ resp, err = http.DefaultClient.Do(req)
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should verify the headers", func() {
+ req, err := http.NewRequest("GET", s.URL()+"/foo", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+ req.Header.Add("Schmaccept", "jpeg")
+ req.Header.Add("Schmaccept", "png")
+ req.Header.Add("Cache-Control", "omicron")
+ req.Header.Add("return-path", "hobbiton")
+
+ failures := InterceptGomegaFailures(func() {
+ http.DefaultClient.Do(req)
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+
+ Describe("VerifyHeaderKV", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("GET", "/foo"),
+ VerifyHeaderKV("accept", "jpeg", "png"),
+ VerifyHeaderKV("cache-control", "omicron"),
+ VerifyHeaderKV("Return-Path", "hobbiton"),
+ ))
+ })
+
+ It("should verify the headers", func() {
+ req, err := http.NewRequest("GET", s.URL()+"/foo", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+ req.Header.Add("Accept", "jpeg")
+ req.Header.Add("Accept", "png")
+ req.Header.Add("Cache-Control", "omicron")
+ req.Header.Add("return-path", "hobbiton")
+
+ resp, err = http.DefaultClient.Do(req)
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should verify the headers", func() {
+ req, err := http.NewRequest("GET", s.URL()+"/foo", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+ req.Header.Add("Accept", "jpeg")
+ req.Header.Add("Cache-Control", "omicron")
+ req.Header.Add("return-path", "hobbiton")
+
+ failures := InterceptGomegaFailures(func() {
+ http.DefaultClient.Do(req)
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+
+ Describe("VerifyBody", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("POST", "/foo"),
+ VerifyBody([]byte("some body")),
+ ))
+ })
+
+ It("should verify the body", func() {
+ resp, err = http.Post(s.URL()+"/foo", "", bytes.NewReader([]byte("some body")))
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should verify the body", func() {
+ failures := InterceptGomegaFailures(func() {
+ http.Post(s.URL()+"/foo", "", bytes.NewReader([]byte("wrong body")))
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+
+ Describe("VerifyMimeType", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyMimeType("application/json"),
+ ))
+ })
+
+ It("should verify the mime type in content-type header", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json; charset=utf-8", bytes.NewReader([]byte(`{}`)))
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should verify the mime type in content-type header", func() {
+ failures := InterceptGomegaFailures(func() {
+ http.Post(s.URL()+"/foo", "text/plain", bytes.NewReader([]byte(`{}`)))
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+
+ Describe("VerifyJSON", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("POST", "/foo"),
+ VerifyJSON(`{"a":3, "b":2}`),
+ ))
+ })
+
+ It("should verify the json body and the content type", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json", bytes.NewReader([]byte(`{"b":2, "a":3}`)))
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should verify the json body and the content type", func() {
+ failures := InterceptGomegaFailures(func() {
+ http.Post(s.URL()+"/foo", "application/json", bytes.NewReader([]byte(`{"b":2, "a":4}`)))
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+
+ It("should verify the json body and the content type", func() {
+ failures := InterceptGomegaFailures(func() {
+ http.Post(s.URL()+"/foo", "application/not-json", bytes.NewReader([]byte(`{"b":2, "a":3}`)))
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+
+ It("should verify the json body and the content type", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json; charset=utf-8", bytes.NewReader([]byte(`{"b":2, "a":3}`)))
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+ })
+
+ Describe("VerifyJSONRepresenting", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("POST", "/foo"),
+ VerifyJSONRepresenting([]int{1, 3, 5}),
+ ))
+ })
+
+ It("should verify the json body and the content type", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json", bytes.NewReader([]byte(`[1,3,5]`)))
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should verify the json body and the content type", func() {
+ failures := InterceptGomegaFailures(func() {
+ http.Post(s.URL()+"/foo", "application/json", bytes.NewReader([]byte(`[1,3]`)))
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+
+ Describe("VerifyForm", func() {
+ var formValues url.Values
+
+ BeforeEach(func() {
+ formValues = make(url.Values)
+ formValues.Add("users", "user1")
+ formValues.Add("users", "user2")
+ formValues.Add("group", "users")
+ })
+
+ Context("when encoded in the URL", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("GET", "/foo"),
+ VerifyForm(url.Values{
+ "users": []string{"user1", "user2"},
+ "group": []string{"users"},
+ }),
+ ))
+ })
+
+ It("should verify form values", func() {
+ resp, err = http.Get(s.URL() + "/foo?" + formValues.Encode())
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should ignore extra values", func() {
+ formValues.Add("extra", "value")
+ resp, err = http.Get(s.URL() + "/foo?" + formValues.Encode())
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("fail on missing values", func() {
+ formValues.Del("group")
+ failures := InterceptGomegaFailures(func() {
+ resp, err = http.Get(s.URL() + "/foo?" + formValues.Encode())
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+
+ It("fail on incorrect values", func() {
+ formValues.Set("group", "wheel")
+ failures := InterceptGomegaFailures(func() {
+ resp, err = http.Get(s.URL() + "/foo?" + formValues.Encode())
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+
+ Context("when present in the body", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("POST", "/foo"),
+ VerifyForm(url.Values{
+ "users": []string{"user1", "user2"},
+ "group": []string{"users"},
+ }),
+ ))
+ })
+
+ It("should verify form values", func() {
+ resp, err = http.PostForm(s.URL()+"/foo", formValues)
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should ignore extra values", func() {
+ formValues.Add("extra", "value")
+ resp, err = http.PostForm(s.URL()+"/foo", formValues)
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("fail on missing values", func() {
+ formValues.Del("group")
+ failures := InterceptGomegaFailures(func() {
+ resp, err = http.PostForm(s.URL()+"/foo", formValues)
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+
+ It("fail on incorrect values", func() {
+ formValues.Set("group", "wheel")
+ failures := InterceptGomegaFailures(func() {
+ resp, err = http.PostForm(s.URL()+"/foo", formValues)
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+ })
+
+ Describe("VerifyFormKV", func() {
+ Context("when encoded in the URL", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("GET", "/foo"),
+ VerifyFormKV("users", "user1", "user2"),
+ ))
+ })
+
+ It("verifies the form value", func() {
+ resp, err = http.Get(s.URL() + "/foo?users=user1&users=user2")
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("verifies the form value", func() {
+ failures := InterceptGomegaFailures(func() {
+ resp, err = http.Get(s.URL() + "/foo?users=user1")
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+
+ Context("when present in the body", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("POST", "/foo"),
+ VerifyFormKV("users", "user1", "user2"),
+ ))
+ })
+
+ It("verifies the form value", func() {
+ resp, err = http.PostForm(s.URL()+"/foo", url.Values{"users": []string{"user1", "user2"}})
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("verifies the form value", func() {
+ failures := InterceptGomegaFailures(func() {
+ resp, err = http.PostForm(s.URL()+"/foo", url.Values{"users": []string{"user1"}})
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+ })
+
+ Describe("VerifyProtoRepresenting", func() {
+ var message *protobuf.SimpleMessage
+
+ BeforeEach(func() {
+ message = new(protobuf.SimpleMessage)
+ message.Description = proto.String("A description")
+ message.Id = proto.Int32(0)
+
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("POST", "/proto"),
+ VerifyProtoRepresenting(message),
+ ))
+ })
+
+ It("verifies the proto body and the content type", func() {
+ serialized, err := proto.Marshal(message)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ resp, err = http.Post(s.URL()+"/proto", "application/x-protobuf", bytes.NewReader(serialized))
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should verify the proto body and the content type", func() {
+ serialized, err := proto.Marshal(&protobuf.SimpleMessage{
+ Description: proto.String("A description"),
+ Id: proto.Int32(0),
+ Metadata: proto.String("some metadata"),
+ })
+ Expect(err).ShouldNot(HaveOccurred())
+
+ failures := InterceptGomegaFailures(func() {
+ http.Post(s.URL()+"/proto", "application/x-protobuf", bytes.NewReader(serialized))
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+
+ It("should verify the proto body and the content type", func() {
+ serialized, err := proto.Marshal(message)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ failures := InterceptGomegaFailures(func() {
+ http.Post(s.URL()+"/proto", "application/not-x-protobuf", bytes.NewReader(serialized))
+ })
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+
+ Describe("RespondWith", func() {
+ Context("without headers", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("POST", "/foo"),
+ RespondWith(http.StatusCreated, "sweet"),
+ ), CombineHandlers(
+ VerifyRequest("POST", "/foo"),
+ RespondWith(http.StatusOK, []byte("sour")),
+ ))
+ })
+
+ It("should return the response", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.StatusCode).Should(Equal(http.StatusCreated))
+
+ body, err := ioutil.ReadAll(resp.Body)
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(body).Should(Equal([]byte("sweet")))
+
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.StatusCode).Should(Equal(http.StatusOK))
+
+ body, err = ioutil.ReadAll(resp.Body)
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(body).Should(Equal([]byte("sour")))
+ })
+ })
+
+ Context("with headers", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("POST", "/foo"),
+ RespondWith(http.StatusCreated, "sweet", http.Header{"X-Custom-Header": []string{"my header"}}),
+ ))
+ })
+
+ It("should return the headers too", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.StatusCode).Should(Equal(http.StatusCreated))
+ Expect(ioutil.ReadAll(resp.Body)).Should(Equal([]byte("sweet")))
+ Expect(resp.Header.Get("X-Custom-Header")).Should(Equal("my header"))
+ })
+ })
+ })
+
+ Describe("RespondWithPtr", func() {
+ var code int
+ var byteBody []byte
+ var stringBody string
+ BeforeEach(func() {
+ code = http.StatusOK
+ byteBody = []byte("sweet")
+ stringBody = "sour"
+
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("POST", "/foo"),
+ RespondWithPtr(&code, &byteBody),
+ ), CombineHandlers(
+ VerifyRequest("POST", "/foo"),
+ RespondWithPtr(&code, &stringBody),
+ ))
+ })
+
+ It("should return the response", func() {
+ code = http.StatusCreated
+ byteBody = []byte("tasty")
+ stringBody = "treat"
+
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.StatusCode).Should(Equal(http.StatusCreated))
+
+ body, err := ioutil.ReadAll(resp.Body)
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(body).Should(Equal([]byte("tasty")))
+
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.StatusCode).Should(Equal(http.StatusCreated))
+
+ body, err = ioutil.ReadAll(resp.Body)
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(body).Should(Equal([]byte("treat")))
+ })
+
+ Context("when passed a nil body", func() {
+ BeforeEach(func() {
+ s.SetHandler(0, CombineHandlers(
+ VerifyRequest("POST", "/foo"),
+ RespondWithPtr(&code, nil),
+ ))
+ })
+
+ It("should return an empty body and not explode", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(resp.StatusCode).Should(Equal(http.StatusOK))
+ body, err := ioutil.ReadAll(resp.Body)
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(body).Should(BeEmpty())
+
+ Expect(s.ReceivedRequests()).Should(HaveLen(1))
+ })
+ })
+ })
+
+ Describe("RespondWithJSON", func() {
+ Context("when no optional headers are set", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("POST", "/foo"),
+ RespondWithJSONEncoded(http.StatusCreated, []int{1, 2, 3}),
+ ))
+ })
+
+ It("should return the response", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.StatusCode).Should(Equal(http.StatusCreated))
+
+ body, err := ioutil.ReadAll(resp.Body)
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(body).Should(MatchJSON("[1,2,3]"))
+ })
+
+ It("should set the Content-Type header to application/json", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.Header["Content-Type"]).Should(Equal([]string{"application/json"}))
+ })
+ })
+
+ Context("when optional headers are set", func() {
+ var headers http.Header
+ BeforeEach(func() {
+ headers = http.Header{"Stuff": []string{"things"}}
+ })
+
+ JustBeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("POST", "/foo"),
+ RespondWithJSONEncoded(http.StatusCreated, []int{1, 2, 3}, headers),
+ ))
+ })
+
+ It("should preserve those headers", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.Header["Stuff"]).Should(Equal([]string{"things"}))
+ })
+
+ It("should set the Content-Type header to application/json", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.Header["Content-Type"]).Should(Equal([]string{"application/json"}))
+ })
+
+ Context("when setting the Content-Type explicitly", func() {
+ BeforeEach(func() {
+ headers["Content-Type"] = []string{"not-json"}
+ })
+
+ It("should use the Content-Type header that was explicitly set", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.Header["Content-Type"]).Should(Equal([]string{"not-json"}))
+ })
+ })
+ })
+ })
+
+ Describe("RespondWithJSONPtr", func() {
+ type testObject struct {
+ Key string
+ Value string
+ }
+
+ var code int
+ var object testObject
+
+ Context("when no optional headers are set", func() {
+ BeforeEach(func() {
+ code = http.StatusOK
+ object = testObject{}
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("POST", "/foo"),
+ RespondWithJSONEncodedPtr(&code, &object),
+ ))
+ })
+
+ It("should return the response", func() {
+ code = http.StatusCreated
+ object = testObject{
+ Key: "Jim",
+ Value: "Codes",
+ }
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.StatusCode).Should(Equal(http.StatusCreated))
+
+ body, err := ioutil.ReadAll(resp.Body)
+ Expect(err).ShouldNot(HaveOccurred())
+ Expect(body).Should(MatchJSON(`{"Key": "Jim", "Value": "Codes"}`))
+ })
+
+ It("should set the Content-Type header to application/json", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.Header["Content-Type"]).Should(Equal([]string{"application/json"}))
+ })
+ })
+
+ Context("when optional headers are set", func() {
+ var headers http.Header
+ BeforeEach(func() {
+ headers = http.Header{"Stuff": []string{"things"}}
+ })
+
+ JustBeforeEach(func() {
+ code = http.StatusOK
+ object = testObject{}
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("POST", "/foo"),
+ RespondWithJSONEncodedPtr(&code, &object, headers),
+ ))
+ })
+
+ It("should preserve those headers", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.Header["Stuff"]).Should(Equal([]string{"things"}))
+ })
+
+ It("should set the Content-Type header to application/json", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.Header["Content-Type"]).Should(Equal([]string{"application/json"}))
+ })
+
+ Context("when setting the Content-Type explicitly", func() {
+ BeforeEach(func() {
+ headers["Content-Type"] = []string{"not-json"}
+ })
+
+ It("should use the Content-Type header that was explicitly set", func() {
+ resp, err = http.Post(s.URL()+"/foo", "application/json", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.Header["Content-Type"]).Should(Equal([]string{"not-json"}))
+ })
+ })
+ })
+ })
+
+ Describe("RespondWithProto", func() {
+ var message *protobuf.SimpleMessage
+
+ BeforeEach(func() {
+ message = new(protobuf.SimpleMessage)
+ message.Description = proto.String("A description")
+ message.Id = proto.Int32(99)
+ })
+
+ Context("when no optional headers are set", func() {
+ BeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("POST", "/proto"),
+ RespondWithProto(http.StatusCreated, message),
+ ))
+ })
+
+ It("should return the response", func() {
+ resp, err = http.Post(s.URL()+"/proto", "application/x-protobuf", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.StatusCode).Should(Equal(http.StatusCreated))
+
+ var received protobuf.SimpleMessage
+ body, err := ioutil.ReadAll(resp.Body)
+ err = proto.Unmarshal(body, &received)
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+
+ It("should set the Content-Type header to application/x-protobuf", func() {
+ resp, err = http.Post(s.URL()+"/proto", "application/x-protobuf", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.Header["Content-Type"]).Should(Equal([]string{"application/x-protobuf"}))
+ })
+ })
+
+ Context("when optional headers are set", func() {
+ var headers http.Header
+ BeforeEach(func() {
+ headers = http.Header{"Stuff": []string{"things"}}
+ })
+
+ JustBeforeEach(func() {
+ s.AppendHandlers(CombineHandlers(
+ VerifyRequest("POST", "/proto"),
+ RespondWithProto(http.StatusCreated, message, headers),
+ ))
+ })
+
+ It("should preserve those headers", func() {
+ resp, err = http.Post(s.URL()+"/proto", "application/x-protobuf", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.Header["Stuff"]).Should(Equal([]string{"things"}))
+ })
+
+ It("should set the Content-Type header to application/x-protobuf", func() {
+ resp, err = http.Post(s.URL()+"/proto", "application/x-protobuf", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.Header["Content-Type"]).Should(Equal([]string{"application/x-protobuf"}))
+ })
+
+ Context("when setting the Content-Type explicitly", func() {
+ BeforeEach(func() {
+ headers["Content-Type"] = []string{"not-x-protobuf"}
+ })
+
+ It("should use the Content-Type header that was explicitly set", func() {
+ resp, err = http.Post(s.URL()+"/proto", "application/x-protobuf", nil)
+ Expect(err).ShouldNot(HaveOccurred())
+
+ Expect(resp.Header["Content-Type"]).Should(Equal([]string{"not-x-protobuf"}))
+ })
+ })
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/go.mod b/vendor/github.com/onsi/gomega/go.mod
new file mode 100644
index 000000000..65eedf696
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/go.mod
@@ -0,0 +1,15 @@
+module github.com/onsi/gomega
+
+require (
+ github.com/fsnotify/fsnotify v1.4.7 // indirect
+ github.com/golang/protobuf v1.2.0
+ github.com/hpcloud/tail v1.0.0 // indirect
+ github.com/onsi/ginkgo v1.6.0
+ golang.org/x/net v0.0.0-20180906233101-161cd47e91fd
+ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect
+ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e // indirect
+ golang.org/x/text v0.3.0 // indirect
+ gopkg.in/fsnotify.v1 v1.4.7 // indirect
+ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
+ gopkg.in/yaml.v2 v2.2.1
+)
diff --git a/vendor/github.com/onsi/gomega/go.sum b/vendor/github.com/onsi/gomega/go.sum
new file mode 100644
index 000000000..b23f6ef02
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/go.sum
@@ -0,0 +1,24 @@
+github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
+github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
+github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
+github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
+github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw=
+github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
+golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs=
+golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
+gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
+gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
+gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/vendor/github.com/onsi/gomega/gomega_dsl.go b/vendor/github.com/onsi/gomega/gomega_dsl.go
new file mode 100644
index 000000000..471f691a6
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gomega_dsl.go
@@ -0,0 +1,421 @@
+/*
+Gomega is the Ginkgo BDD-style testing framework's preferred matcher library.
+
+The godoc documentation describes Gomega's API. More comprehensive documentation (with examples!) is available at http://onsi.github.io/gomega/
+
+Gomega on Github: http://github.com/onsi/gomega
+
+Learn more about Ginkgo online: http://onsi.github.io/ginkgo
+
+Ginkgo on Github: http://github.com/onsi/ginkgo
+
+Gomega is MIT-Licensed
+*/
+package gomega
+
+import (
+ "fmt"
+ "reflect"
+ "time"
+
+ "github.com/onsi/gomega/internal/assertion"
+ "github.com/onsi/gomega/internal/asyncassertion"
+ "github.com/onsi/gomega/internal/testingtsupport"
+ "github.com/onsi/gomega/types"
+)
+
+const GOMEGA_VERSION = "1.4.3"
+
+const nilFailHandlerPanic = `You are trying to make an assertion, but Gomega's fail handler is nil.
+If you're using Ginkgo then you probably forgot to put your assertion in an It().
+Alternatively, you may have forgotten to register a fail handler with RegisterFailHandler() or RegisterTestingT().
+Depending on your vendoring solution you may be inadvertently importing gomega and subpackages (e.g. ghhtp, gexec,...) from different locations.
+`
+
+var globalFailWrapper *types.GomegaFailWrapper
+
+var defaultEventuallyTimeout = time.Second
+var defaultEventuallyPollingInterval = 10 * time.Millisecond
+var defaultConsistentlyDuration = 100 * time.Millisecond
+var defaultConsistentlyPollingInterval = 10 * time.Millisecond
+
+//RegisterFailHandler connects Ginkgo to Gomega. When a matcher fails
+//the fail handler passed into RegisterFailHandler is called.
+func RegisterFailHandler(handler types.GomegaFailHandler) {
+ if handler == nil {
+ globalFailWrapper = nil
+ return
+ }
+
+ globalFailWrapper = &types.GomegaFailWrapper{
+ Fail: handler,
+ TWithHelper: testingtsupport.EmptyTWithHelper{},
+ }
+}
+
+func RegisterFailHandlerWithT(t types.TWithHelper, handler types.GomegaFailHandler) {
+ if handler == nil {
+ globalFailWrapper = nil
+ return
+ }
+
+ globalFailWrapper = &types.GomegaFailWrapper{
+ Fail: handler,
+ TWithHelper: t,
+ }
+}
+
+//RegisterTestingT connects Gomega to Golang's XUnit style
+//Testing.T tests. It is now deprecated and you should use NewGomegaWithT() instead.
+//
+//Legacy Documentation:
+//
+//You'll need to call this at the top of each XUnit style test:
+//
+// func TestFarmHasCow(t *testing.T) {
+// RegisterTestingT(t)
+//
+// f := farm.New([]string{"Cow", "Horse"})
+// Expect(f.HasCow()).To(BeTrue(), "Farm should have cow")
+// }
+//
+// Note that this *testing.T is registered *globally* by Gomega (this is why you don't have to
+// pass `t` down to the matcher itself). This means that you cannot run the XUnit style tests
+// in parallel as the global fail handler cannot point to more than one testing.T at a time.
+//
+// NewGomegaWithT() does not have this limitation
+//
+// (As an aside: Ginkgo gets around this limitation by running parallel tests in different *processes*).
+func RegisterTestingT(t types.GomegaTestingT) {
+ tWithHelper, hasHelper := t.(types.TWithHelper)
+ if !hasHelper {
+ RegisterFailHandler(testingtsupport.BuildTestingTGomegaFailWrapper(t).Fail)
+ return
+ }
+ RegisterFailHandlerWithT(tWithHelper, testingtsupport.BuildTestingTGomegaFailWrapper(t).Fail)
+}
+
+//InterceptGomegaHandlers runs a given callback and returns an array of
+//failure messages generated by any Gomega assertions within the callback.
+//
+//This is accomplished by temporarily replacing the *global* fail handler
+//with a fail handler that simply annotates failures. The original fail handler
+//is reset when InterceptGomegaFailures returns.
+//
+//This is most useful when testing custom matchers, but can also be used to check
+//on a value using a Gomega assertion without causing a test failure.
+func InterceptGomegaFailures(f func()) []string {
+ originalHandler := globalFailWrapper.Fail
+ failures := []string{}
+ RegisterFailHandler(func(message string, callerSkip ...int) {
+ failures = append(failures, message)
+ })
+ f()
+ RegisterFailHandler(originalHandler)
+ return failures
+}
+
+//Ω wraps an actual value allowing assertions to be made on it:
+// Ω("foo").Should(Equal("foo"))
+//
+//If Ω is passed more than one argument it will pass the *first* argument to the matcher.
+//All subsequent arguments will be required to be nil/zero.
+//
+//This is convenient if you want to make an assertion on a method/function that returns
+//a value and an error - a common patter in Go.
+//
+//For example, given a function with signature:
+// func MyAmazingThing() (int, error)
+//
+//Then:
+// Ω(MyAmazingThing()).Should(Equal(3))
+//Will succeed only if `MyAmazingThing()` returns `(3, nil)`
+//
+//Ω and Expect are identical
+func Ω(actual interface{}, extra ...interface{}) GomegaAssertion {
+ return ExpectWithOffset(0, actual, extra...)
+}
+
+//Expect wraps an actual value allowing assertions to be made on it:
+// Expect("foo").To(Equal("foo"))
+//
+//If Expect is passed more than one argument it will pass the *first* argument to the matcher.
+//All subsequent arguments will be required to be nil/zero.
+//
+//This is convenient if you want to make an assertion on a method/function that returns
+//a value and an error - a common patter in Go.
+//
+//For example, given a function with signature:
+// func MyAmazingThing() (int, error)
+//
+//Then:
+// Expect(MyAmazingThing()).Should(Equal(3))
+//Will succeed only if `MyAmazingThing()` returns `(3, nil)`
+//
+//Expect and Ω are identical
+func Expect(actual interface{}, extra ...interface{}) GomegaAssertion {
+ return ExpectWithOffset(0, actual, extra...)
+}
+
+//ExpectWithOffset wraps an actual value allowing assertions to be made on it:
+// ExpectWithOffset(1, "foo").To(Equal("foo"))
+//
+//Unlike `Expect` and `Ω`, `ExpectWithOffset` takes an additional integer argument
+//this is used to modify the call-stack offset when computing line numbers.
+//
+//This is most useful in helper functions that make assertions. If you want Gomega's
+//error message to refer to the calling line in the test (as opposed to the line in the helper function)
+//set the first argument of `ExpectWithOffset` appropriately.
+func ExpectWithOffset(offset int, actual interface{}, extra ...interface{}) GomegaAssertion {
+ if globalFailWrapper == nil {
+ panic(nilFailHandlerPanic)
+ }
+ return assertion.New(actual, globalFailWrapper, offset, extra...)
+}
+
+//Eventually wraps an actual value allowing assertions to be made on it.
+//The assertion is tried periodically until it passes or a timeout occurs.
+//
+//Both the timeout and polling interval are configurable as optional arguments:
+//The first optional argument is the timeout
+//The second optional argument is the polling interval
+//
+//Both intervals can either be specified as time.Duration, parsable duration strings or as floats/integers. In the
+//last case they are interpreted as seconds.
+//
+//If Eventually is passed an actual that is a function taking no arguments and returning at least one value,
+//then Eventually will call the function periodically and try the matcher against the function's first return value.
+//
+//Example:
+//
+// Eventually(func() int {
+// return thingImPolling.Count()
+// }).Should(BeNumerically(">=", 17))
+//
+//Note that this example could be rewritten:
+//
+// Eventually(thingImPolling.Count).Should(BeNumerically(">=", 17))
+//
+//If the function returns more than one value, then Eventually will pass the first value to the matcher and
+//assert that all other values are nil/zero.
+//This allows you to pass Eventually a function that returns a value and an error - a common pattern in Go.
+//
+//For example, consider a method that returns a value and an error:
+// func FetchFromDB() (string, error)
+//
+//Then
+// Eventually(FetchFromDB).Should(Equal("hasselhoff"))
+//
+//Will pass only if the the returned error is nil and the returned string passes the matcher.
+//
+//Eventually's default timeout is 1 second, and its default polling interval is 10ms
+func Eventually(actual interface{}, intervals ...interface{}) GomegaAsyncAssertion {
+ return EventuallyWithOffset(0, actual, intervals...)
+}
+
+//EventuallyWithOffset operates like Eventually but takes an additional
+//initial argument to indicate an offset in the call stack. This is useful when building helper
+//functions that contain matchers. To learn more, read about `ExpectWithOffset`.
+func EventuallyWithOffset(offset int, actual interface{}, intervals ...interface{}) GomegaAsyncAssertion {
+ if globalFailWrapper == nil {
+ panic(nilFailHandlerPanic)
+ }
+ timeoutInterval := defaultEventuallyTimeout
+ pollingInterval := defaultEventuallyPollingInterval
+ if len(intervals) > 0 {
+ timeoutInterval = toDuration(intervals[0])
+ }
+ if len(intervals) > 1 {
+ pollingInterval = toDuration(intervals[1])
+ }
+ return asyncassertion.New(asyncassertion.AsyncAssertionTypeEventually, actual, globalFailWrapper, timeoutInterval, pollingInterval, offset)
+}
+
+//Consistently wraps an actual value allowing assertions to be made on it.
+//The assertion is tried periodically and is required to pass for a period of time.
+//
+//Both the total time and polling interval are configurable as optional arguments:
+//The first optional argument is the duration that Consistently will run for
+//The second optional argument is the polling interval
+//
+//Both intervals can either be specified as time.Duration, parsable duration strings or as floats/integers. In the
+//last case they are interpreted as seconds.
+//
+//If Consistently is passed an actual that is a function taking no arguments and returning at least one value,
+//then Consistently will call the function periodically and try the matcher against the function's first return value.
+//
+//If the function returns more than one value, then Consistently will pass the first value to the matcher and
+//assert that all other values are nil/zero.
+//This allows you to pass Consistently a function that returns a value and an error - a common pattern in Go.
+//
+//Consistently is useful in cases where you want to assert that something *does not happen* over a period of tiem.
+//For example, you want to assert that a goroutine does *not* send data down a channel. In this case, you could:
+//
+// Consistently(channel).ShouldNot(Receive())
+//
+//Consistently's default duration is 100ms, and its default polling interval is 10ms
+func Consistently(actual interface{}, intervals ...interface{}) GomegaAsyncAssertion {
+ return ConsistentlyWithOffset(0, actual, intervals...)
+}
+
+//ConsistentlyWithOffset operates like Consistnetly but takes an additional
+//initial argument to indicate an offset in the call stack. This is useful when building helper
+//functions that contain matchers. To learn more, read about `ExpectWithOffset`.
+func ConsistentlyWithOffset(offset int, actual interface{}, intervals ...interface{}) GomegaAsyncAssertion {
+ if globalFailWrapper == nil {
+ panic(nilFailHandlerPanic)
+ }
+ timeoutInterval := defaultConsistentlyDuration
+ pollingInterval := defaultConsistentlyPollingInterval
+ if len(intervals) > 0 {
+ timeoutInterval = toDuration(intervals[0])
+ }
+ if len(intervals) > 1 {
+ pollingInterval = toDuration(intervals[1])
+ }
+ return asyncassertion.New(asyncassertion.AsyncAssertionTypeConsistently, actual, globalFailWrapper, timeoutInterval, pollingInterval, offset)
+}
+
+//Set the default timeout duration for Eventually. Eventually will repeatedly poll your condition until it succeeds, or until this timeout elapses.
+func SetDefaultEventuallyTimeout(t time.Duration) {
+ defaultEventuallyTimeout = t
+}
+
+//Set the default polling interval for Eventually.
+func SetDefaultEventuallyPollingInterval(t time.Duration) {
+ defaultEventuallyPollingInterval = t
+}
+
+//Set the default duration for Consistently. Consistently will verify that your condition is satsified for this long.
+func SetDefaultConsistentlyDuration(t time.Duration) {
+ defaultConsistentlyDuration = t
+}
+
+//Set the default polling interval for Consistently.
+func SetDefaultConsistentlyPollingInterval(t time.Duration) {
+ defaultConsistentlyPollingInterval = t
+}
+
+//GomegaAsyncAssertion is returned by Eventually and Consistently and polls the actual value passed into Eventually against
+//the matcher passed to the Should and ShouldNot methods.
+//
+//Both Should and ShouldNot take a variadic optionalDescription argument. This is passed on to
+//fmt.Sprintf() and is used to annotate failure messages. This allows you to make your failure messages more
+//descriptive
+//
+//Both Should and ShouldNot return a boolean that is true if the assertion passed and false if it failed.
+//
+//Example:
+//
+// Eventually(myChannel).Should(Receive(), "Something should have come down the pipe.")
+// Consistently(myChannel).ShouldNot(Receive(), "Nothing should have come down the pipe.")
+type GomegaAsyncAssertion interface {
+ Should(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool
+ ShouldNot(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool
+}
+
+//GomegaAssertion is returned by Ω and Expect and compares the actual value to the matcher
+//passed to the Should/ShouldNot and To/ToNot/NotTo methods.
+//
+//Typically Should/ShouldNot are used with Ω and To/ToNot/NotTo are used with Expect
+//though this is not enforced.
+//
+//All methods take a variadic optionalDescription argument. This is passed on to fmt.Sprintf()
+//and is used to annotate failure messages.
+//
+//All methods return a bool that is true if hte assertion passed and false if it failed.
+//
+//Example:
+//
+// Ω(farm.HasCow()).Should(BeTrue(), "Farm %v should have a cow", farm)
+type GomegaAssertion interface {
+ Should(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool
+ ShouldNot(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool
+
+ To(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool
+ ToNot(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool
+ NotTo(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool
+}
+
+//OmegaMatcher is deprecated in favor of the better-named and better-organized types.GomegaMatcher but sticks around to support existing code that uses it
+type OmegaMatcher types.GomegaMatcher
+
+//GomegaWithT wraps a *testing.T and provides `Expect`, `Eventually`, and `Consistently` methods. This allows you to leverage
+//Gomega's rich ecosystem of matchers in standard `testing` test suites.
+//
+//Use `NewGomegaWithT` to instantiate a `GomegaWithT`
+type GomegaWithT struct {
+ t types.GomegaTestingT
+}
+
+//NewGomegaWithT takes a *testing.T and returngs a `GomegaWithT` allowing you to use `Expect`, `Eventually`, and `Consistently` along with
+//Gomega's rich ecosystem of matchers in standard `testing` test suits.
+//
+// func TestFarmHasCow(t *testing.T) {
+// g := GomegaWithT(t)
+//
+// f := farm.New([]string{"Cow", "Horse"})
+// g.Expect(f.HasCow()).To(BeTrue(), "Farm should have cow")
+// }
+func NewGomegaWithT(t types.GomegaTestingT) *GomegaWithT {
+ return &GomegaWithT{
+ t: t,
+ }
+}
+
+//See documentation for Expect
+func (g *GomegaWithT) Expect(actual interface{}, extra ...interface{}) GomegaAssertion {
+ return assertion.New(actual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), 0, extra...)
+}
+
+//See documentation for Eventually
+func (g *GomegaWithT) Eventually(actual interface{}, intervals ...interface{}) GomegaAsyncAssertion {
+ timeoutInterval := defaultEventuallyTimeout
+ pollingInterval := defaultEventuallyPollingInterval
+ if len(intervals) > 0 {
+ timeoutInterval = toDuration(intervals[0])
+ }
+ if len(intervals) > 1 {
+ pollingInterval = toDuration(intervals[1])
+ }
+ return asyncassertion.New(asyncassertion.AsyncAssertionTypeEventually, actual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), timeoutInterval, pollingInterval, 0)
+}
+
+//See documentation for Consistently
+func (g *GomegaWithT) Consistently(actual interface{}, intervals ...interface{}) GomegaAsyncAssertion {
+ timeoutInterval := defaultConsistentlyDuration
+ pollingInterval := defaultConsistentlyPollingInterval
+ if len(intervals) > 0 {
+ timeoutInterval = toDuration(intervals[0])
+ }
+ if len(intervals) > 1 {
+ pollingInterval = toDuration(intervals[1])
+ }
+ return asyncassertion.New(asyncassertion.AsyncAssertionTypeConsistently, actual, testingtsupport.BuildTestingTGomegaFailWrapper(g.t), timeoutInterval, pollingInterval, 0)
+}
+
+func toDuration(input interface{}) time.Duration {
+ duration, ok := input.(time.Duration)
+ if ok {
+ return duration
+ }
+
+ value := reflect.ValueOf(input)
+ kind := reflect.TypeOf(input).Kind()
+
+ if reflect.Int <= kind && kind <= reflect.Int64 {
+ return time.Duration(value.Int()) * time.Second
+ } else if reflect.Uint <= kind && kind <= reflect.Uint64 {
+ return time.Duration(value.Uint()) * time.Second
+ } else if reflect.Float32 <= kind && kind <= reflect.Float64 {
+ return time.Duration(value.Float() * float64(time.Second))
+ } else if reflect.String == kind {
+ duration, err := time.ParseDuration(value.String())
+ if err != nil {
+ panic(fmt.Sprintf("%#v is not a valid parsable duration string.", input))
+ }
+ return duration
+ }
+
+ panic(fmt.Sprintf("%v is not a valid interval. Must be time.Duration, parsable duration string or a number.", input))
+}
diff --git a/vendor/github.com/onsi/gomega/gstruct/elements.go b/vendor/github.com/onsi/gomega/gstruct/elements.go
new file mode 100644
index 000000000..13bf5b895
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gstruct/elements.go
@@ -0,0 +1,159 @@
+package gstruct
+
+import (
+ "errors"
+ "fmt"
+ "reflect"
+ "runtime/debug"
+
+ "github.com/onsi/gomega/format"
+ errorsutil "github.com/onsi/gomega/gstruct/errors"
+ "github.com/onsi/gomega/types"
+)
+
+//MatchAllElements succeeds if every element of a slice matches the element matcher it maps to
+//through the id function, and every element matcher is matched.
+// idFn := func(element interface{}) string {
+// return fmt.Sprintf("%v", element)
+// }
+//
+// Expect([]string{"a", "b"}).To(MatchAllElements(idFn, Elements{
+// "a": Equal("a"),
+// "b": Equal("b"),
+// }))
+func MatchAllElements(identifier Identifier, elements Elements) types.GomegaMatcher {
+ return &ElementsMatcher{
+ Identifier: identifier,
+ Elements: elements,
+ }
+}
+
+//MatchElements succeeds if each element of a slice matches the element matcher it maps to
+//through the id function. It can ignore extra elements and/or missing elements.
+// idFn := func(element interface{}) string {
+// return fmt.Sprintf("%v", element)
+// }
+//
+// Expect([]string{"a", "b", "c"}).To(MatchElements(idFn, IgnoreExtras, Elements{
+// "a": Equal("a"),
+// "b": Equal("b"),
+// }))
+// Expect([]string{"a", "c"}).To(MatchElements(idFn, IgnoreMissing, Elements{
+// "a": Equal("a"),
+// "b": Equal("b"),
+// "c": Equal("c"),
+// "d": Equal("d"),
+// }))
+func MatchElements(identifier Identifier, options Options, elements Elements) types.GomegaMatcher {
+ return &ElementsMatcher{
+ Identifier: identifier,
+ Elements: elements,
+ IgnoreExtras: options&IgnoreExtras != 0,
+ IgnoreMissing: options&IgnoreMissing != 0,
+ AllowDuplicates: options&AllowDuplicates != 0,
+ }
+}
+
+// ElementsMatcher is a NestingMatcher that applies custom matchers to each element of a slice mapped
+// by the Identifier function.
+// TODO: Extend this to work with arrays & maps (map the key) as well.
+type ElementsMatcher struct {
+ // Matchers for each element.
+ Elements Elements
+ // Function mapping an element to the string key identifying its matcher.
+ Identifier Identifier
+
+ // Whether to ignore extra elements or consider it an error.
+ IgnoreExtras bool
+ // Whether to ignore missing elements or consider it an error.
+ IgnoreMissing bool
+ // Whether to key duplicates when matching IDs.
+ AllowDuplicates bool
+
+ // State.
+ failures []error
+}
+
+// Element ID to matcher.
+type Elements map[string]types.GomegaMatcher
+
+// Function for identifying (mapping) elements.
+type Identifier func(element interface{}) string
+
+func (m *ElementsMatcher) Match(actual interface{}) (success bool, err error) {
+ if reflect.TypeOf(actual).Kind() != reflect.Slice {
+ return false, fmt.Errorf("%v is type %T, expected slice", actual, actual)
+ }
+
+ m.failures = m.matchElements(actual)
+ if len(m.failures) > 0 {
+ return false, nil
+ }
+ return true, nil
+}
+
+func (m *ElementsMatcher) matchElements(actual interface{}) (errs []error) {
+ // Provide more useful error messages in the case of a panic.
+ defer func() {
+ if err := recover(); err != nil {
+ errs = append(errs, fmt.Errorf("panic checking %+v: %v\n%s", actual, err, debug.Stack()))
+ }
+ }()
+
+ val := reflect.ValueOf(actual)
+ elements := map[string]bool{}
+ for i := 0; i < val.Len(); i++ {
+ element := val.Index(i).Interface()
+ id := m.Identifier(element)
+ if elements[id] {
+ if !m.AllowDuplicates {
+ errs = append(errs, fmt.Errorf("found duplicate element ID %s", id))
+ continue
+ }
+ }
+ elements[id] = true
+
+ matcher, expected := m.Elements[id]
+ if !expected {
+ if !m.IgnoreExtras {
+ errs = append(errs, fmt.Errorf("unexpected element %s", id))
+ }
+ continue
+ }
+
+ match, err := matcher.Match(element)
+ if match {
+ continue
+ }
+
+ if err == nil {
+ if nesting, ok := matcher.(errorsutil.NestingMatcher); ok {
+ err = errorsutil.AggregateError(nesting.Failures())
+ } else {
+ err = errors.New(matcher.FailureMessage(element))
+ }
+ }
+ errs = append(errs, errorsutil.Nest(fmt.Sprintf("[%s]", id), err))
+ }
+
+ for id := range m.Elements {
+ if !elements[id] && !m.IgnoreMissing {
+ errs = append(errs, fmt.Errorf("missing expected element %s", id))
+ }
+ }
+
+ return errs
+}
+
+func (m *ElementsMatcher) FailureMessage(actual interface{}) (message string) {
+ failure := errorsutil.AggregateError(m.failures)
+ return format.Message(actual, fmt.Sprintf("to match elements: %v", failure))
+}
+
+func (m *ElementsMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to match elements")
+}
+
+func (m *ElementsMatcher) Failures() []error {
+ return m.failures
+}
diff --git a/vendor/github.com/onsi/gomega/gstruct/elements_test.go b/vendor/github.com/onsi/gomega/gstruct/elements_test.go
new file mode 100644
index 000000000..355d463eb
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gstruct/elements_test.go
@@ -0,0 +1,144 @@
+package gstruct_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/gstruct"
+)
+
+var _ = Describe("Slice", func() {
+ allElements := []string{"a", "b"}
+ missingElements := []string{"a"}
+ extraElements := []string{"a", "b", "c"}
+ duplicateElements := []string{"a", "a", "b"}
+ empty := []string{}
+ var nils []string
+
+ It("should strictly match all elements", func() {
+ m := MatchAllElements(id, Elements{
+ "b": Equal("b"),
+ "a": Equal("a"),
+ })
+ Expect(allElements).Should(m, "should match all elements")
+ Expect(missingElements).ShouldNot(m, "should fail with missing elements")
+ Expect(extraElements).ShouldNot(m, "should fail with extra elements")
+ Expect(duplicateElements).ShouldNot(m, "should fail with duplicate elements")
+ Expect(nils).ShouldNot(m, "should fail with an uninitialized slice")
+
+ m = MatchAllElements(id, Elements{
+ "a": Equal("a"),
+ "b": Equal("fail"),
+ })
+ Expect(allElements).ShouldNot(m, "should run nested matchers")
+
+ m = MatchAllElements(id, Elements{})
+ Expect(empty).Should(m, "should handle empty slices")
+ Expect(allElements).ShouldNot(m, "should handle only empty slices")
+ Expect(nils).Should(m, "should handle nil slices")
+ })
+
+ It("should ignore extra elements", func() {
+ m := MatchElements(id, IgnoreExtras, Elements{
+ "b": Equal("b"),
+ "a": Equal("a"),
+ })
+ Expect(allElements).Should(m, "should match all elements")
+ Expect(missingElements).ShouldNot(m, "should fail with missing elements")
+ Expect(extraElements).Should(m, "should ignore extra elements")
+ Expect(duplicateElements).ShouldNot(m, "should fail with duplicate elements")
+ Expect(nils).ShouldNot(m, "should fail with an uninitialized slice")
+ })
+
+ It("should ignore missing elements", func() {
+ m := MatchElements(id, IgnoreMissing, Elements{
+ "a": Equal("a"),
+ "b": Equal("b"),
+ })
+ Expect(allElements).Should(m, "should match all elements")
+ Expect(missingElements).Should(m, "should ignore missing elements")
+ Expect(extraElements).ShouldNot(m, "should fail with extra elements")
+ Expect(duplicateElements).ShouldNot(m, "should fail with duplicate elements")
+ Expect(nils).Should(m, "should ignore an uninitialized slice")
+ })
+
+ It("should ignore missing and extra elements", func() {
+ m := MatchElements(id, IgnoreMissing|IgnoreExtras, Elements{
+ "a": Equal("a"),
+ "b": Equal("b"),
+ })
+ Expect(allElements).Should(m, "should match all elements")
+ Expect(missingElements).Should(m, "should ignore missing elements")
+ Expect(extraElements).Should(m, "should ignore extra elements")
+ Expect(duplicateElements).ShouldNot(m, "should fail with duplicate elements")
+ Expect(nils).Should(m, "should ignore an uninitialized slice")
+
+ m = MatchElements(id, IgnoreExtras|IgnoreMissing, Elements{
+ "a": Equal("a"),
+ "b": Equal("fail"),
+ })
+ Expect(allElements).ShouldNot(m, "should run nested matchers")
+ })
+
+ Context("with elements that share a key", func() {
+ nonUniqueID := func(element interface{}) string {
+ return element.(string)[0:1]
+ }
+
+ allElements := []string{"a123", "a213", "b321"}
+ includingBadElements := []string{"a123", "b123", "b5555"}
+ extraElements := []string{"a123", "b1234", "c345"}
+ missingElements := []string{"b123", "b1234", "b1345"}
+
+ It("should strictly allow multiple matches", func() {
+ m := MatchElements(nonUniqueID, AllowDuplicates, Elements{
+ "a": ContainSubstring("1"),
+ "b": ContainSubstring("1"),
+ })
+ Expect(allElements).Should(m, "should match all elements")
+ Expect(includingBadElements).ShouldNot(m, "should reject if a member fails the matcher")
+ Expect(extraElements).ShouldNot(m, "should reject with extra keys")
+ Expect(missingElements).ShouldNot(m, "should reject with missing keys")
+ Expect(nils).ShouldNot(m, "should fail with an uninitialized slice")
+ })
+
+ It("should ignore missing", func() {
+ m := MatchElements(nonUniqueID, AllowDuplicates|IgnoreMissing, Elements{
+ "a": ContainSubstring("1"),
+ "b": ContainSubstring("1"),
+ })
+ Expect(allElements).Should(m, "should match all elements")
+ Expect(includingBadElements).ShouldNot(m, "should reject if a member fails the matcher")
+ Expect(extraElements).ShouldNot(m, "should reject with extra keys")
+ Expect(missingElements).Should(m, "should allow missing keys")
+ Expect(nils).Should(m, "should allow an uninitialized slice")
+ })
+
+ It("should ignore extras", func() {
+ m := MatchElements(nonUniqueID, AllowDuplicates|IgnoreExtras, Elements{
+ "a": ContainSubstring("1"),
+ "b": ContainSubstring("1"),
+ })
+ Expect(allElements).Should(m, "should match all elements")
+ Expect(includingBadElements).ShouldNot(m, "should reject if a member fails the matcher")
+ Expect(extraElements).Should(m, "should allow extra keys")
+ Expect(missingElements).ShouldNot(m, "should reject missing keys")
+ Expect(nils).ShouldNot(m, "should reject an uninitialized slice")
+ })
+
+ It("should ignore missing and extras", func() {
+ m := MatchElements(nonUniqueID, AllowDuplicates|IgnoreExtras|IgnoreMissing, Elements{
+ "a": ContainSubstring("1"),
+ "b": ContainSubstring("1"),
+ })
+ Expect(allElements).Should(m, "should match all elements")
+ Expect(includingBadElements).ShouldNot(m, "should reject if a member fails the matcher")
+ Expect(extraElements).Should(m, "should allow extra keys")
+ Expect(missingElements).Should(m, "should allow missing keys")
+ Expect(nils).Should(m, "should allow an uninitialized slice")
+ })
+ })
+})
+
+func id(element interface{}) string {
+ return element.(string)
+}
diff --git a/vendor/github.com/onsi/gomega/gstruct/errors/nested_types.go b/vendor/github.com/onsi/gomega/gstruct/errors/nested_types.go
new file mode 100644
index 000000000..188492b21
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gstruct/errors/nested_types.go
@@ -0,0 +1,72 @@
+package errors
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/onsi/gomega/types"
+)
+
+// A stateful matcher that nests other matchers within it and preserves the error types of the
+// nested matcher failures.
+type NestingMatcher interface {
+ types.GomegaMatcher
+
+ // Returns the failures of nested matchers.
+ Failures() []error
+}
+
+// An error type for labeling errors on deeply nested matchers.
+type NestedError struct {
+ Path string
+ Err error
+}
+
+func (e *NestedError) Error() string {
+ // Indent Errors.
+ indented := strings.Replace(e.Err.Error(), "\n", "\n\t", -1)
+ return fmt.Sprintf("%s:\n\t%v", e.Path, indented)
+}
+
+// Create a NestedError with the given path.
+// If err is a NestedError, prepend the path to it.
+// If err is an AggregateError, recursively Nest each error.
+func Nest(path string, err error) error {
+ if ag, ok := err.(AggregateError); ok {
+ var errs AggregateError
+ for _, e := range ag {
+ errs = append(errs, Nest(path, e))
+ }
+ return errs
+ }
+ if ne, ok := err.(*NestedError); ok {
+ return &NestedError{
+ Path: path + ne.Path,
+ Err: ne.Err,
+ }
+ }
+ return &NestedError{
+ Path: path,
+ Err: err,
+ }
+}
+
+// An error type for treating multiple errors as a single error.
+type AggregateError []error
+
+// Error is part of the error interface.
+func (err AggregateError) Error() string {
+ if len(err) == 0 {
+ // This should never happen, really.
+ return ""
+ }
+ if len(err) == 1 {
+ return err[0].Error()
+ }
+ result := fmt.Sprintf("[%s", err[0].Error())
+ for i := 1; i < len(err); i++ {
+ result += fmt.Sprintf(", %s", err[i].Error())
+ }
+ result += "]"
+ return result
+}
diff --git a/vendor/github.com/onsi/gomega/gstruct/fields.go b/vendor/github.com/onsi/gomega/gstruct/fields.go
new file mode 100644
index 000000000..2eb2d0887
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gstruct/fields.go
@@ -0,0 +1,168 @@
+package gstruct
+
+import (
+ "errors"
+ "fmt"
+ "reflect"
+ "runtime/debug"
+ "strings"
+
+ "github.com/onsi/gomega/format"
+ errorsutil "github.com/onsi/gomega/gstruct/errors"
+ "github.com/onsi/gomega/types"
+)
+
+//MatchAllFields succeeds if every field of a struct matches the field matcher associated with
+//it, and every element matcher is matched.
+// actual := struct{
+// A int
+// B []bool
+// C string
+// }{
+// A: 5,
+// B: []bool{true, false},
+// C: "foo",
+// }
+//
+// Expect(actual).To(MatchAllFields(Fields{
+// "A": Equal(5),
+// "B": ConsistOf(true, false),
+// "C": Equal("foo"),
+// }))
+func MatchAllFields(fields Fields) types.GomegaMatcher {
+ return &FieldsMatcher{
+ Fields: fields,
+ }
+}
+
+//MatchFields succeeds if each element of a struct matches the field matcher associated with
+//it. It can ignore extra fields and/or missing fields.
+// actual := struct{
+// A int
+// B []bool
+// C string
+// }{
+// A: 5,
+// B: []bool{true, false},
+// C: "foo",
+// }
+//
+// Expect(actual).To(MatchFields(IgnoreExtras, Fields{
+// "A": Equal(5),
+// "B": ConsistOf(true, false),
+// }))
+// Expect(actual).To(MatchFields(IgnoreMissing, Fields{
+// "A": Equal(5),
+// "B": ConsistOf(true, false),
+// "C": Equal("foo"),
+// "D": Equal("extra"),
+// }))
+func MatchFields(options Options, fields Fields) types.GomegaMatcher {
+ return &FieldsMatcher{
+ Fields: fields,
+ IgnoreExtras: options&IgnoreExtras != 0,
+ IgnoreMissing: options&IgnoreMissing != 0,
+ }
+}
+
+type FieldsMatcher struct {
+ // Matchers for each field.
+ Fields Fields
+
+ // Whether to ignore extra elements or consider it an error.
+ IgnoreExtras bool
+ // Whether to ignore missing elements or consider it an error.
+ IgnoreMissing bool
+
+ // State.
+ failures []error
+}
+
+// Field name to matcher.
+type Fields map[string]types.GomegaMatcher
+
+func (m *FieldsMatcher) Match(actual interface{}) (success bool, err error) {
+ if reflect.TypeOf(actual).Kind() != reflect.Struct {
+ return false, fmt.Errorf("%v is type %T, expected struct", actual, actual)
+ }
+
+ m.failures = m.matchFields(actual)
+ if len(m.failures) > 0 {
+ return false, nil
+ }
+ return true, nil
+}
+
+func (m *FieldsMatcher) matchFields(actual interface{}) (errs []error) {
+ val := reflect.ValueOf(actual)
+ typ := val.Type()
+ fields := map[string]bool{}
+ for i := 0; i < val.NumField(); i++ {
+ fieldName := typ.Field(i).Name
+ fields[fieldName] = true
+
+ err := func() (err error) {
+ // This test relies heavily on reflect, which tends to panic.
+ // Recover here to provide more useful error messages in that case.
+ defer func() {
+ if r := recover(); r != nil {
+ err = fmt.Errorf("panic checking %+v: %v\n%s", actual, r, debug.Stack())
+ }
+ }()
+
+ matcher, expected := m.Fields[fieldName]
+ if !expected {
+ if !m.IgnoreExtras {
+ return fmt.Errorf("unexpected field %s: %+v", fieldName, actual)
+ }
+ return nil
+ }
+
+ var field interface{}
+ if val.Field(i).IsValid() {
+ field = val.Field(i).Interface()
+ } else {
+ field = reflect.Zero(typ.Field(i).Type)
+ }
+
+ match, err := matcher.Match(field)
+ if err != nil {
+ return err
+ } else if !match {
+ if nesting, ok := matcher.(errorsutil.NestingMatcher); ok {
+ return errorsutil.AggregateError(nesting.Failures())
+ }
+ return errors.New(matcher.FailureMessage(field))
+ }
+ return nil
+ }()
+ if err != nil {
+ errs = append(errs, errorsutil.Nest("."+fieldName, err))
+ }
+ }
+
+ for field := range m.Fields {
+ if !fields[field] && !m.IgnoreMissing {
+ errs = append(errs, fmt.Errorf("missing expected field %s", field))
+ }
+ }
+
+ return errs
+}
+
+func (m *FieldsMatcher) FailureMessage(actual interface{}) (message string) {
+ failures := make([]string, len(m.failures))
+ for i := range m.failures {
+ failures[i] = m.failures[i].Error()
+ }
+ return format.Message(reflect.TypeOf(actual).Name(),
+ fmt.Sprintf("to match fields: {\n%v\n}\n", strings.Join(failures, "\n")))
+}
+
+func (m *FieldsMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to match fields")
+}
+
+func (m *FieldsMatcher) Failures() []error {
+ return m.failures
+}
diff --git a/vendor/github.com/onsi/gomega/gstruct/fields_test.go b/vendor/github.com/onsi/gomega/gstruct/fields_test.go
new file mode 100644
index 000000000..e4e039e21
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gstruct/fields_test.go
@@ -0,0 +1,76 @@
+package gstruct_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/gstruct"
+)
+
+var _ = Describe("Struct", func() {
+ allFields := struct{ A, B string }{"a", "b"}
+ missingFields := struct{ A string }{"a"}
+ extraFields := struct{ A, B, C string }{"a", "b", "c"}
+ emptyFields := struct{ A, B string }{}
+
+ It("should strictly match all fields", func() {
+ m := MatchAllFields(Fields{
+ "B": Equal("b"),
+ "A": Equal("a"),
+ })
+ Expect(allFields).Should(m, "should match all fields")
+ Expect(missingFields).ShouldNot(m, "should fail with missing fields")
+ Expect(extraFields).ShouldNot(m, "should fail with extra fields")
+ Expect(emptyFields).ShouldNot(m, "should fail with empty fields")
+
+ m = MatchAllFields(Fields{
+ "A": Equal("a"),
+ "B": Equal("fail"),
+ })
+ Expect(allFields).ShouldNot(m, "should run nested matchers")
+ })
+
+ It("should handle empty structs", func() {
+ m := MatchAllFields(Fields{})
+ Expect(struct{}{}).Should(m, "should handle empty structs")
+ Expect(allFields).ShouldNot(m, "should fail with extra fields")
+ })
+
+ It("should ignore missing fields", func() {
+ m := MatchFields(IgnoreMissing, Fields{
+ "B": Equal("b"),
+ "A": Equal("a"),
+ })
+ Expect(allFields).Should(m, "should match all fields")
+ Expect(missingFields).Should(m, "should ignore missing fields")
+ Expect(extraFields).ShouldNot(m, "should fail with extra fields")
+ Expect(emptyFields).ShouldNot(m, "should fail with empty fields")
+ })
+
+ It("should ignore extra fields", func() {
+ m := MatchFields(IgnoreExtras, Fields{
+ "B": Equal("b"),
+ "A": Equal("a"),
+ })
+ Expect(allFields).Should(m, "should match all fields")
+ Expect(missingFields).ShouldNot(m, "should fail with missing fields")
+ Expect(extraFields).Should(m, "should ignore extra fields")
+ Expect(emptyFields).ShouldNot(m, "should fail with empty fields")
+ })
+
+ It("should ignore missing and extra fields", func() {
+ m := MatchFields(IgnoreMissing|IgnoreExtras, Fields{
+ "B": Equal("b"),
+ "A": Equal("a"),
+ })
+ Expect(allFields).Should(m, "should match all fields")
+ Expect(missingFields).Should(m, "should ignore missing fields")
+ Expect(extraFields).Should(m, "should ignore extra fields")
+ Expect(emptyFields).ShouldNot(m, "should fail with empty fields")
+
+ m = MatchFields(IgnoreMissing|IgnoreExtras, Fields{
+ "A": Equal("a"),
+ "B": Equal("fail"),
+ })
+ Expect(allFields).ShouldNot(m, "should run nested matchers")
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/gstruct/gstruct_tests_suite_test.go b/vendor/github.com/onsi/gomega/gstruct/gstruct_tests_suite_test.go
new file mode 100644
index 000000000..d47566304
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gstruct/gstruct_tests_suite_test.go
@@ -0,0 +1,13 @@
+package gstruct_test
+
+import (
+ "testing"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+func Test(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Gstruct Suite")
+}
diff --git a/vendor/github.com/onsi/gomega/gstruct/ignore.go b/vendor/github.com/onsi/gomega/gstruct/ignore.go
new file mode 100644
index 000000000..0365f32ad
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gstruct/ignore.go
@@ -0,0 +1,37 @@
+package gstruct
+
+import (
+ "github.com/onsi/gomega/types"
+)
+
+//Ignore ignores the actual value and always succeeds.
+// Expect(nil).To(Ignore())
+// Expect(true).To(Ignore())
+func Ignore() types.GomegaMatcher {
+ return &IgnoreMatcher{true}
+}
+
+//Reject ignores the actual value and always fails. It can be used in conjunction with IgnoreMissing
+//to catch problematic elements, or to verify tests are running.
+// Expect(nil).NotTo(Reject())
+// Expect(true).NotTo(Reject())
+func Reject() types.GomegaMatcher {
+ return &IgnoreMatcher{false}
+}
+
+// A matcher that either always succeeds or always fails.
+type IgnoreMatcher struct {
+ Succeed bool
+}
+
+func (m *IgnoreMatcher) Match(actual interface{}) (bool, error) {
+ return m.Succeed, nil
+}
+
+func (m *IgnoreMatcher) FailureMessage(_ interface{}) (message string) {
+ return "Unconditional failure"
+}
+
+func (m *IgnoreMatcher) NegatedFailureMessage(_ interface{}) (message string) {
+ return "Unconditional success"
+}
diff --git a/vendor/github.com/onsi/gomega/gstruct/ignore_test.go b/vendor/github.com/onsi/gomega/gstruct/ignore_test.go
new file mode 100644
index 000000000..07775e742
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gstruct/ignore_test.go
@@ -0,0 +1,23 @@
+package gstruct_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/gstruct"
+)
+
+var _ = Describe("Ignore", func() {
+ It("should always succeed", func() {
+ Expect(nil).Should(Ignore())
+ Expect(struct{}{}).Should(Ignore())
+ Expect(0).Should(Ignore())
+ Expect(false).Should(Ignore())
+ })
+
+ It("should always fail", func() {
+ Expect(nil).ShouldNot(Reject())
+ Expect(struct{}{}).ShouldNot(Reject())
+ Expect(1).ShouldNot(Reject())
+ Expect(true).ShouldNot(Reject())
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/gstruct/pointer.go b/vendor/github.com/onsi/gomega/gstruct/pointer.go
new file mode 100644
index 000000000..0a2f35de3
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gstruct/pointer.go
@@ -0,0 +1,56 @@
+package gstruct
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/format"
+ "github.com/onsi/gomega/types"
+)
+
+//PointTo applies the given matcher to the value pointed to by actual. It fails if the pointer is
+//nil.
+// actual := 5
+// Expect(&actual).To(PointTo(Equal(5)))
+func PointTo(matcher types.GomegaMatcher) types.GomegaMatcher {
+ return &PointerMatcher{
+ Matcher: matcher,
+ }
+}
+
+type PointerMatcher struct {
+ Matcher types.GomegaMatcher
+
+ // Failure message.
+ failure string
+}
+
+func (m *PointerMatcher) Match(actual interface{}) (bool, error) {
+ val := reflect.ValueOf(actual)
+
+ // return error if actual type is not a pointer
+ if val.Kind() != reflect.Ptr {
+ return false, fmt.Errorf("PointerMatcher expects a pointer but we have '%s'", val.Kind())
+ }
+
+ if !val.IsValid() || val.IsNil() {
+ m.failure = format.Message(actual, "not to be <nil>")
+ return false, nil
+ }
+
+ // Forward the value.
+ elem := val.Elem().Interface()
+ match, err := m.Matcher.Match(elem)
+ if !match {
+ m.failure = m.Matcher.FailureMessage(elem)
+ }
+ return match, err
+}
+
+func (m *PointerMatcher) FailureMessage(_ interface{}) (message string) {
+ return m.failure
+}
+
+func (m *PointerMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return m.Matcher.NegatedFailureMessage(actual)
+}
diff --git a/vendor/github.com/onsi/gomega/gstruct/pointer_test.go b/vendor/github.com/onsi/gomega/gstruct/pointer_test.go
new file mode 100644
index 000000000..805a92abe
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gstruct/pointer_test.go
@@ -0,0 +1,33 @@
+package gstruct_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/gstruct"
+)
+
+var _ = Describe("PointTo", func() {
+ It("should fail when passed nil", func() {
+ var p *struct{}
+ Expect(p).Should(BeNil())
+ })
+
+ It("should succeed when passed non-nil pointer", func() {
+ var s struct{}
+ Expect(&s).Should(PointTo(Ignore()))
+ })
+
+ It("should unwrap the pointee value", func() {
+ i := 1
+ Expect(&i).Should(PointTo(Equal(1)))
+ Expect(&i).ShouldNot(PointTo(Equal(2)))
+ })
+
+ It("should work with nested pointers", func() {
+ i := 1
+ ip := &i
+ ipp := &ip
+ Expect(ipp).Should(PointTo(PointTo(Equal(1))))
+ Expect(ipp).ShouldNot(PointTo(PointTo(Equal(2))))
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/gstruct/types.go b/vendor/github.com/onsi/gomega/gstruct/types.go
new file mode 100644
index 000000000..48cbbe8f6
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/gstruct/types.go
@@ -0,0 +1,15 @@
+package gstruct
+
+//Options is the type for options passed to some matchers.
+type Options int
+
+const (
+ //IgnoreExtras tells the matcher to ignore extra elements or fields, rather than triggering a failure.
+ IgnoreExtras Options = 1 << iota
+ //IgnoreMissing tells the matcher to ignore missing elements or fields, rather than triggering a failure.
+ IgnoreMissing
+ //AllowDuplicates tells the matcher to permit multiple members of the slice to produce the same ID when
+ //considered by the indentifier function. All members that map to a given key must still match successfully
+ //with the matcher that is provided for that key.
+ AllowDuplicates
+)
diff --git a/vendor/github.com/onsi/gomega/internal/assertion/assertion.go b/vendor/github.com/onsi/gomega/internal/assertion/assertion.go
new file mode 100644
index 000000000..00197b67a
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/internal/assertion/assertion.go
@@ -0,0 +1,105 @@
+package assertion
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/types"
+)
+
+type Assertion struct {
+ actualInput interface{}
+ failWrapper *types.GomegaFailWrapper
+ offset int
+ extra []interface{}
+}
+
+func New(actualInput interface{}, failWrapper *types.GomegaFailWrapper, offset int, extra ...interface{}) *Assertion {
+ return &Assertion{
+ actualInput: actualInput,
+ failWrapper: failWrapper,
+ offset: offset,
+ extra: extra,
+ }
+}
+
+func (assertion *Assertion) Should(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
+ assertion.failWrapper.TWithHelper.Helper()
+ return assertion.vetExtras(optionalDescription...) && assertion.match(matcher, true, optionalDescription...)
+}
+
+func (assertion *Assertion) ShouldNot(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
+ assertion.failWrapper.TWithHelper.Helper()
+ return assertion.vetExtras(optionalDescription...) && assertion.match(matcher, false, optionalDescription...)
+}
+
+func (assertion *Assertion) To(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
+ assertion.failWrapper.TWithHelper.Helper()
+ return assertion.vetExtras(optionalDescription...) && assertion.match(matcher, true, optionalDescription...)
+}
+
+func (assertion *Assertion) ToNot(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
+ assertion.failWrapper.TWithHelper.Helper()
+ return assertion.vetExtras(optionalDescription...) && assertion.match(matcher, false, optionalDescription...)
+}
+
+func (assertion *Assertion) NotTo(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
+ assertion.failWrapper.TWithHelper.Helper()
+ return assertion.vetExtras(optionalDescription...) && assertion.match(matcher, false, optionalDescription...)
+}
+
+func (assertion *Assertion) buildDescription(optionalDescription ...interface{}) string {
+ switch len(optionalDescription) {
+ case 0:
+ return ""
+ default:
+ return fmt.Sprintf(optionalDescription[0].(string), optionalDescription[1:]...) + "\n"
+ }
+}
+
+func (assertion *Assertion) match(matcher types.GomegaMatcher, desiredMatch bool, optionalDescription ...interface{}) bool {
+ matches, err := matcher.Match(assertion.actualInput)
+ description := assertion.buildDescription(optionalDescription...)
+ assertion.failWrapper.TWithHelper.Helper()
+ if err != nil {
+ assertion.failWrapper.Fail(description+err.Error(), 2+assertion.offset)
+ return false
+ }
+ if matches != desiredMatch {
+ var message string
+ if desiredMatch {
+ message = matcher.FailureMessage(assertion.actualInput)
+ } else {
+ message = matcher.NegatedFailureMessage(assertion.actualInput)
+ }
+ assertion.failWrapper.Fail(description+message, 2+assertion.offset)
+ return false
+ }
+
+ return true
+}
+
+func (assertion *Assertion) vetExtras(optionalDescription ...interface{}) bool {
+ success, message := vetExtras(assertion.extra)
+ if success {
+ return true
+ }
+
+ description := assertion.buildDescription(optionalDescription...)
+ assertion.failWrapper.TWithHelper.Helper()
+ assertion.failWrapper.Fail(description+message, 2+assertion.offset)
+ return false
+}
+
+func vetExtras(extras []interface{}) (bool, string) {
+ for i, extra := range extras {
+ if extra != nil {
+ zeroValue := reflect.Zero(reflect.TypeOf(extra)).Interface()
+ if !reflect.DeepEqual(zeroValue, extra) {
+ message := fmt.Sprintf("Unexpected non-nil/non-zero extra argument at index %d:\n\t<%T>: %#v", i+1, extra, extra)
+ return false, message
+ }
+ }
+ }
+ return true, ""
+}
diff --git a/vendor/github.com/onsi/gomega/internal/assertion/assertion_suite_test.go b/vendor/github.com/onsi/gomega/internal/assertion/assertion_suite_test.go
new file mode 100644
index 000000000..dae47a48b
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/internal/assertion/assertion_suite_test.go
@@ -0,0 +1,13 @@
+package assertion_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestAssertion(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Assertion Suite")
+}
diff --git a/vendor/github.com/onsi/gomega/internal/assertion/assertion_test.go b/vendor/github.com/onsi/gomega/internal/assertion/assertion_test.go
new file mode 100644
index 000000000..cac0d24c5
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/internal/assertion/assertion_test.go
@@ -0,0 +1,258 @@
+package assertion_test
+
+import (
+ "errors"
+
+ "github.com/onsi/gomega/internal/testingtsupport"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/internal/assertion"
+ "github.com/onsi/gomega/internal/fakematcher"
+ "github.com/onsi/gomega/types"
+)
+
+var _ = Describe("Assertion", func() {
+ var (
+ a *Assertion
+ failureMessage string
+ failureCallerSkip int
+ matcher *fakematcher.FakeMatcher
+ )
+
+ input := "The thing I'm testing"
+
+ var fakeFailWrapper = &types.GomegaFailWrapper{
+ Fail: func(message string, callerSkip ...int) {
+ failureMessage = message
+ if len(callerSkip) == 1 {
+ failureCallerSkip = callerSkip[0]
+ }
+ },
+ TWithHelper: testingtsupport.EmptyTWithHelper{},
+ }
+
+ BeforeEach(func() {
+ matcher = &fakematcher.FakeMatcher{}
+ failureMessage = ""
+ failureCallerSkip = 0
+ a = New(input, fakeFailWrapper, 1)
+ })
+
+ Context("when called", func() {
+ It("should pass the provided input value to the matcher", func() {
+ a.Should(matcher)
+
+ Expect(matcher.ReceivedActual).Should(Equal(input))
+ matcher.ReceivedActual = ""
+
+ a.ShouldNot(matcher)
+
+ Expect(matcher.ReceivedActual).Should(Equal(input))
+ matcher.ReceivedActual = ""
+
+ a.To(matcher)
+
+ Expect(matcher.ReceivedActual).Should(Equal(input))
+ matcher.ReceivedActual = ""
+
+ a.ToNot(matcher)
+
+ Expect(matcher.ReceivedActual).Should(Equal(input))
+ matcher.ReceivedActual = ""
+
+ a.NotTo(matcher)
+
+ Expect(matcher.ReceivedActual).Should(Equal(input))
+ })
+ })
+
+ Context("when the matcher succeeds", func() {
+ BeforeEach(func() {
+ matcher.MatchesToReturn = true
+ matcher.ErrToReturn = nil
+ })
+
+ Context("and a positive assertion is being made", func() {
+ It("should not call the failure callback", func() {
+ a.Should(matcher)
+ Expect(failureMessage).Should(Equal(""))
+ })
+
+ It("should be true", func() {
+ Expect(a.Should(matcher)).Should(BeTrue())
+ })
+ })
+
+ Context("and a negative assertion is being made", func() {
+ It("should call the failure callback", func() {
+ a.ShouldNot(matcher)
+ Expect(failureMessage).Should(Equal("negative: The thing I'm testing"))
+ Expect(failureCallerSkip).Should(Equal(3))
+ })
+
+ It("should be false", func() {
+ Expect(a.ShouldNot(matcher)).Should(BeFalse())
+ })
+ })
+ })
+
+ Context("when the matcher fails", func() {
+ BeforeEach(func() {
+ matcher.MatchesToReturn = false
+ matcher.ErrToReturn = nil
+ })
+
+ Context("and a positive assertion is being made", func() {
+ It("should call the failure callback", func() {
+ a.Should(matcher)
+ Expect(failureMessage).Should(Equal("positive: The thing I'm testing"))
+ Expect(failureCallerSkip).Should(Equal(3))
+ })
+
+ It("should be false", func() {
+ Expect(a.Should(matcher)).Should(BeFalse())
+ })
+ })
+
+ Context("and a negative assertion is being made", func() {
+ It("should not call the failure callback", func() {
+ a.ShouldNot(matcher)
+ Expect(failureMessage).Should(Equal(""))
+ })
+
+ It("should be true", func() {
+ Expect(a.ShouldNot(matcher)).Should(BeTrue())
+ })
+ })
+ })
+
+ Context("When reporting a failure", func() {
+ BeforeEach(func() {
+ matcher.MatchesToReturn = false
+ matcher.ErrToReturn = nil
+ })
+
+ Context("and there is an optional description", func() {
+ It("should append the description to the failure message", func() {
+ a.Should(matcher, "A description")
+ Expect(failureMessage).Should(Equal("A description\npositive: The thing I'm testing"))
+ Expect(failureCallerSkip).Should(Equal(3))
+ })
+ })
+
+ Context("and there are multiple arguments to the optional description", func() {
+ It("should append the formatted description to the failure message", func() {
+ a.Should(matcher, "A description of [%d]", 3)
+ Expect(failureMessage).Should(Equal("A description of [3]\npositive: The thing I'm testing"))
+ Expect(failureCallerSkip).Should(Equal(3))
+ })
+ })
+ })
+
+ Context("When the matcher returns an error", func() {
+ BeforeEach(func() {
+ matcher.ErrToReturn = errors.New("Kaboom!")
+ })
+
+ Context("and a positive assertion is being made", func() {
+ It("should call the failure callback", func() {
+ matcher.MatchesToReturn = true
+ a.Should(matcher)
+ Expect(failureMessage).Should(Equal("Kaboom!"))
+ Expect(failureCallerSkip).Should(Equal(3))
+ })
+ })
+
+ Context("and a negative assertion is being made", func() {
+ It("should call the failure callback", func() {
+ matcher.MatchesToReturn = false
+ a.ShouldNot(matcher)
+ Expect(failureMessage).Should(Equal("Kaboom!"))
+ Expect(failureCallerSkip).Should(Equal(3))
+ })
+ })
+
+ It("should always be false", func() {
+ Expect(a.Should(matcher)).Should(BeFalse())
+ Expect(a.ShouldNot(matcher)).Should(BeFalse())
+ })
+ })
+
+ Context("when there are extra parameters", func() {
+ It("(a simple example)", func() {
+ Expect(func() (string, int, error) {
+ return "foo", 0, nil
+ }()).Should(Equal("foo"))
+ })
+
+ Context("when the parameters are all nil or zero", func() {
+ It("should invoke the matcher", func() {
+ matcher.MatchesToReturn = true
+ matcher.ErrToReturn = nil
+
+ var typedNil []string
+ a = New(input, fakeFailWrapper, 1, 0, nil, typedNil)
+
+ result := a.Should(matcher)
+ Expect(result).Should(BeTrue())
+ Expect(matcher.ReceivedActual).Should(Equal(input))
+
+ Expect(failureMessage).Should(BeZero())
+ })
+ })
+
+ Context("when any of the parameters are not nil or zero", func() {
+ It("should call the failure callback", func() {
+ matcher.MatchesToReturn = false
+ matcher.ErrToReturn = nil
+
+ a = New(input, fakeFailWrapper, 1, errors.New("foo"))
+ result := a.Should(matcher)
+ Expect(result).Should(BeFalse())
+ Expect(matcher.ReceivedActual).Should(BeZero(), "The matcher doesn't even get called")
+ Expect(failureMessage).Should(ContainSubstring("foo"))
+ failureMessage = ""
+
+ a = New(input, fakeFailWrapper, 1, nil, 1)
+ result = a.ShouldNot(matcher)
+ Expect(result).Should(BeFalse())
+ Expect(failureMessage).Should(ContainSubstring("1"))
+ failureMessage = ""
+
+ a = New(input, fakeFailWrapper, 1, nil, 0, []string{"foo"})
+ result = a.To(matcher)
+ Expect(result).Should(BeFalse())
+ Expect(failureMessage).Should(ContainSubstring("foo"))
+ failureMessage = ""
+
+ a = New(input, fakeFailWrapper, 1, nil, 0, []string{"foo"})
+ result = a.ToNot(matcher)
+ Expect(result).Should(BeFalse())
+ Expect(failureMessage).Should(ContainSubstring("foo"))
+ failureMessage = ""
+
+ a = New(input, fakeFailWrapper, 1, nil, 0, []string{"foo"})
+ result = a.NotTo(matcher)
+ Expect(result).Should(BeFalse())
+ Expect(failureMessage).Should(ContainSubstring("foo"))
+ Expect(failureCallerSkip).Should(Equal(3))
+ })
+ })
+ })
+
+ Context("Making an assertion without a registered fail handler", func() {
+ It("should panic", func() {
+ defer func() {
+ e := recover()
+ RegisterFailHandler(Fail)
+ if e == nil {
+ Fail("expected a panic to have occurred")
+ }
+ }()
+
+ RegisterFailHandler(nil)
+ Expect(true).Should(BeTrue())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion.go b/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion.go
new file mode 100644
index 000000000..cdab233eb
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion.go
@@ -0,0 +1,194 @@
+package asyncassertion
+
+import (
+ "errors"
+ "fmt"
+ "reflect"
+ "time"
+
+ "github.com/onsi/gomega/internal/oraclematcher"
+ "github.com/onsi/gomega/types"
+)
+
+type AsyncAssertionType uint
+
+const (
+ AsyncAssertionTypeEventually AsyncAssertionType = iota
+ AsyncAssertionTypeConsistently
+)
+
+type AsyncAssertion struct {
+ asyncType AsyncAssertionType
+ actualInput interface{}
+ timeoutInterval time.Duration
+ pollingInterval time.Duration
+ failWrapper *types.GomegaFailWrapper
+ offset int
+}
+
+func New(asyncType AsyncAssertionType, actualInput interface{}, failWrapper *types.GomegaFailWrapper, timeoutInterval time.Duration, pollingInterval time.Duration, offset int) *AsyncAssertion {
+ actualType := reflect.TypeOf(actualInput)
+ if actualType.Kind() == reflect.Func {
+ if actualType.NumIn() != 0 || actualType.NumOut() == 0 {
+ panic("Expected a function with no arguments and one or more return values.")
+ }
+ }
+
+ return &AsyncAssertion{
+ asyncType: asyncType,
+ actualInput: actualInput,
+ failWrapper: failWrapper,
+ timeoutInterval: timeoutInterval,
+ pollingInterval: pollingInterval,
+ offset: offset,
+ }
+}
+
+func (assertion *AsyncAssertion) Should(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
+ assertion.failWrapper.TWithHelper.Helper()
+ return assertion.match(matcher, true, optionalDescription...)
+}
+
+func (assertion *AsyncAssertion) ShouldNot(matcher types.GomegaMatcher, optionalDescription ...interface{}) bool {
+ assertion.failWrapper.TWithHelper.Helper()
+ return assertion.match(matcher, false, optionalDescription...)
+}
+
+func (assertion *AsyncAssertion) buildDescription(optionalDescription ...interface{}) string {
+ switch len(optionalDescription) {
+ case 0:
+ return ""
+ default:
+ return fmt.Sprintf(optionalDescription[0].(string), optionalDescription[1:]...) + "\n"
+ }
+}
+
+func (assertion *AsyncAssertion) actualInputIsAFunction() bool {
+ actualType := reflect.TypeOf(assertion.actualInput)
+ return actualType.Kind() == reflect.Func && actualType.NumIn() == 0 && actualType.NumOut() > 0
+}
+
+func (assertion *AsyncAssertion) pollActual() (interface{}, error) {
+ if assertion.actualInputIsAFunction() {
+ values := reflect.ValueOf(assertion.actualInput).Call([]reflect.Value{})
+
+ extras := []interface{}{}
+ for _, value := range values[1:] {
+ extras = append(extras, value.Interface())
+ }
+
+ success, message := vetExtras(extras)
+
+ if !success {
+ return nil, errors.New(message)
+ }
+
+ return values[0].Interface(), nil
+ }
+
+ return assertion.actualInput, nil
+}
+
+func (assertion *AsyncAssertion) matcherMayChange(matcher types.GomegaMatcher, value interface{}) bool {
+ if assertion.actualInputIsAFunction() {
+ return true
+ }
+
+ return oraclematcher.MatchMayChangeInTheFuture(matcher, value)
+}
+
+func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch bool, optionalDescription ...interface{}) bool {
+ timer := time.Now()
+ timeout := time.After(assertion.timeoutInterval)
+
+ description := assertion.buildDescription(optionalDescription...)
+
+ var matches bool
+ var err error
+ mayChange := true
+ value, err := assertion.pollActual()
+ if err == nil {
+ mayChange = assertion.matcherMayChange(matcher, value)
+ matches, err = matcher.Match(value)
+ }
+
+ assertion.failWrapper.TWithHelper.Helper()
+
+ fail := func(preamble string) {
+ errMsg := ""
+ message := ""
+ if err != nil {
+ errMsg = "Error: " + err.Error()
+ } else {
+ if desiredMatch {
+ message = matcher.FailureMessage(value)
+ } else {
+ message = matcher.NegatedFailureMessage(value)
+ }
+ }
+ assertion.failWrapper.TWithHelper.Helper()
+ assertion.failWrapper.Fail(fmt.Sprintf("%s after %.3fs.\n%s%s%s", preamble, time.Since(timer).Seconds(), description, message, errMsg), 3+assertion.offset)
+ }
+
+ if assertion.asyncType == AsyncAssertionTypeEventually {
+ for {
+ if err == nil && matches == desiredMatch {
+ return true
+ }
+
+ if !mayChange {
+ fail("No future change is possible. Bailing out early")
+ return false
+ }
+
+ select {
+ case <-time.After(assertion.pollingInterval):
+ value, err = assertion.pollActual()
+ if err == nil {
+ mayChange = assertion.matcherMayChange(matcher, value)
+ matches, err = matcher.Match(value)
+ }
+ case <-timeout:
+ fail("Timed out")
+ return false
+ }
+ }
+ } else if assertion.asyncType == AsyncAssertionTypeConsistently {
+ for {
+ if !(err == nil && matches == desiredMatch) {
+ fail("Failed")
+ return false
+ }
+
+ if !mayChange {
+ return true
+ }
+
+ select {
+ case <-time.After(assertion.pollingInterval):
+ value, err = assertion.pollActual()
+ if err == nil {
+ mayChange = assertion.matcherMayChange(matcher, value)
+ matches, err = matcher.Match(value)
+ }
+ case <-timeout:
+ return true
+ }
+ }
+ }
+
+ return false
+}
+
+func vetExtras(extras []interface{}) (bool, string) {
+ for i, extra := range extras {
+ if extra != nil {
+ zeroValue := reflect.Zero(reflect.TypeOf(extra)).Interface()
+ if !reflect.DeepEqual(zeroValue, extra) {
+ message := fmt.Sprintf("Unexpected non-nil/non-zero extra argument at index %d:\n\t<%T>: %#v", i+1, extra, extra)
+ return false, message
+ }
+ }
+ }
+ return true, ""
+}
diff --git a/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_suite_test.go b/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_suite_test.go
new file mode 100644
index 000000000..bdb0c3d22
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_suite_test.go
@@ -0,0 +1,13 @@
+package asyncassertion_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "testing"
+)
+
+func TestAsyncAssertion(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "AsyncAssertion Suite")
+}
diff --git a/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_test.go b/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_test.go
new file mode 100644
index 000000000..afd61a7cd
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/internal/asyncassertion/async_assertion_test.go
@@ -0,0 +1,351 @@
+package asyncassertion_test
+
+import (
+ "errors"
+ "time"
+
+ "github.com/onsi/gomega/internal/testingtsupport"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/internal/asyncassertion"
+ "github.com/onsi/gomega/types"
+)
+
+var _ = Describe("Async Assertion", func() {
+ var (
+ failureMessage string
+ callerSkip int
+ )
+
+ var fakeFailWrapper = &types.GomegaFailWrapper{
+ Fail: func(message string, skip ...int) {
+ failureMessage = message
+ callerSkip = skip[0]
+ },
+ TWithHelper: testingtsupport.EmptyTWithHelper{},
+ }
+
+ BeforeEach(func() {
+ failureMessage = ""
+ callerSkip = 0
+ })
+
+ Describe("Eventually", func() {
+ Context("the positive case", func() {
+ It("should poll the function and matcher", func() {
+ counter := 0
+ a := New(AsyncAssertionTypeEventually, func() int {
+ counter++
+ return counter
+ }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
+
+ a.Should(BeNumerically("==", 5))
+ Expect(failureMessage).Should(BeZero())
+ })
+
+ It("should continue when the matcher errors", func() {
+ counter := 0
+ a := New(AsyncAssertionTypeEventually, func() interface{} {
+ counter++
+ if counter == 5 {
+ return "not-a-number" //this should cause the matcher to error
+ }
+ return counter
+ }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
+
+ a.Should(BeNumerically("==", 5), "My description %d", 2)
+
+ Expect(failureMessage).Should(ContainSubstring("Timed out after"))
+ Expect(failureMessage).Should(ContainSubstring("My description 2"))
+ Expect(callerSkip).Should(Equal(4))
+ })
+
+ It("should be able to timeout", func() {
+ counter := 0
+ a := New(AsyncAssertionTypeEventually, func() int {
+ counter++
+ return counter
+ }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
+
+ a.Should(BeNumerically(">", 100), "My description %d", 2)
+
+ Expect(counter).Should(BeNumerically(">", 8))
+ Expect(counter).Should(BeNumerically("<=", 10))
+ Expect(failureMessage).Should(ContainSubstring("Timed out after"))
+ Expect(failureMessage).Should(MatchRegexp(`\<int\>: \d`), "Should pass the correct value to the matcher message formatter.")
+ Expect(failureMessage).Should(ContainSubstring("My description 2"))
+ Expect(callerSkip).Should(Equal(4))
+ })
+ })
+
+ Context("the negative case", func() {
+ It("should poll the function and matcher", func() {
+ counter := 0
+ a := New(AsyncAssertionTypeEventually, func() int {
+ counter += 1
+ return counter
+ }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
+
+ a.ShouldNot(BeNumerically("<", 3))
+
+ Expect(counter).Should(Equal(3))
+ Expect(failureMessage).Should(BeZero())
+ })
+
+ It("should timeout when the matcher errors", func() {
+ a := New(AsyncAssertionTypeEventually, func() interface{} {
+ return 0 //this should cause the matcher to error
+ }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
+
+ a.ShouldNot(HaveLen(0), "My description %d", 2)
+
+ Expect(failureMessage).Should(ContainSubstring("Timed out after"))
+ Expect(failureMessage).Should(ContainSubstring("Error:"))
+ Expect(failureMessage).Should(ContainSubstring("My description 2"))
+ Expect(callerSkip).Should(Equal(4))
+ })
+
+ It("should be able to timeout", func() {
+ a := New(AsyncAssertionTypeEventually, func() int {
+ return 0
+ }, fakeFailWrapper, time.Duration(0.1*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
+
+ a.ShouldNot(Equal(0), "My description %d", 2)
+
+ Expect(failureMessage).Should(ContainSubstring("Timed out after"))
+ Expect(failureMessage).Should(ContainSubstring("<int>: 0"), "Should pass the correct value to the matcher message formatter.")
+ Expect(failureMessage).Should(ContainSubstring("My description 2"))
+ Expect(callerSkip).Should(Equal(4))
+ })
+ })
+
+ Context("with a function that returns multiple values", func() {
+ It("should eventually succeed if the additional arguments are nil", func() {
+ i := 0
+ Eventually(func() (int, error) {
+ i++
+ return i, nil
+ }).Should(Equal(10))
+ })
+
+ It("should eventually timeout if the additional arguments are not nil", func() {
+ i := 0
+ a := New(AsyncAssertionTypeEventually, func() (int, error) {
+ i++
+ return i, errors.New("bam")
+ }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
+ a.Should(Equal(2))
+
+ Expect(failureMessage).Should(ContainSubstring("Timed out after"))
+ Expect(failureMessage).Should(ContainSubstring("Error:"))
+ Expect(failureMessage).Should(ContainSubstring("bam"))
+ Expect(callerSkip).Should(Equal(4))
+ })
+ })
+
+ Context("Making an assertion without a registered fail handler", func() {
+ It("should panic", func() {
+ defer func() {
+ e := recover()
+ RegisterFailHandler(Fail)
+ if e == nil {
+ Fail("expected a panic to have occurred")
+ }
+ }()
+
+ RegisterFailHandler(nil)
+ c := make(chan bool, 1)
+ c <- true
+ Eventually(c).Should(Receive())
+ })
+ })
+ })
+
+ Describe("Consistently", func() {
+ Describe("The positive case", func() {
+ Context("when the matcher consistently passes for the duration", func() {
+ It("should pass", func() {
+ calls := 0
+ a := New(AsyncAssertionTypeConsistently, func() string {
+ calls++
+ return "foo"
+ }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
+
+ a.Should(Equal("foo"))
+ Expect(calls).Should(BeNumerically(">", 8))
+ Expect(calls).Should(BeNumerically("<=", 10))
+ Expect(failureMessage).Should(BeZero())
+ })
+ })
+
+ Context("when the matcher fails at some point", func() {
+ It("should fail", func() {
+ calls := 0
+ a := New(AsyncAssertionTypeConsistently, func() interface{} {
+ calls++
+ if calls > 5 {
+ return "bar"
+ }
+ return "foo"
+ }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
+
+ a.Should(Equal("foo"))
+ Expect(failureMessage).Should(ContainSubstring("to equal"))
+ Expect(callerSkip).Should(Equal(4))
+ })
+ })
+
+ Context("when the matcher errors at some point", func() {
+ It("should fail", func() {
+ calls := 0
+ a := New(AsyncAssertionTypeConsistently, func() interface{} {
+ calls++
+ if calls > 5 {
+ return 3
+ }
+ return []int{1, 2, 3}
+ }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
+
+ a.Should(HaveLen(3))
+ Expect(failureMessage).Should(ContainSubstring("HaveLen matcher expects"))
+ Expect(callerSkip).Should(Equal(4))
+ })
+ })
+ })
+
+ Describe("The negative case", func() {
+ Context("when the matcher consistently passes for the duration", func() {
+ It("should pass", func() {
+ c := make(chan bool)
+ a := New(AsyncAssertionTypeConsistently, c, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
+
+ a.ShouldNot(Receive())
+ Expect(failureMessage).Should(BeZero())
+ })
+ })
+
+ Context("when the matcher fails at some point", func() {
+ It("should fail", func() {
+ c := make(chan bool)
+ go func() {
+ time.Sleep(time.Duration(100 * time.Millisecond))
+ c <- true
+ }()
+
+ a := New(AsyncAssertionTypeConsistently, c, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
+
+ a.ShouldNot(Receive())
+ Expect(failureMessage).Should(ContainSubstring("not to receive anything"))
+ })
+ })
+
+ Context("when the matcher errors at some point", func() {
+ It("should fail", func() {
+ calls := 0
+ a := New(AsyncAssertionTypeConsistently, func() interface{} {
+ calls++
+ return calls
+ }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
+
+ a.ShouldNot(BeNumerically(">", 5))
+ Expect(failureMessage).Should(ContainSubstring("not to be >"))
+ Expect(callerSkip).Should(Equal(4))
+ })
+ })
+ })
+
+ Context("with a function that returns multiple values", func() {
+ It("should consistently succeed if the additional arguments are nil", func() {
+ i := 2
+ Consistently(func() (int, error) {
+ i++
+ return i, nil
+ }).Should(BeNumerically(">=", 2))
+ })
+
+ It("should eventually timeout if the additional arguments are not nil", func() {
+ i := 2
+ a := New(AsyncAssertionTypeEventually, func() (int, error) {
+ i++
+ return i, errors.New("bam")
+ }, fakeFailWrapper, time.Duration(0.2*float64(time.Second)), time.Duration(0.02*float64(time.Second)), 1)
+ a.Should(BeNumerically(">=", 2))
+
+ Expect(failureMessage).Should(ContainSubstring("Error:"))
+ Expect(failureMessage).Should(ContainSubstring("bam"))
+ Expect(callerSkip).Should(Equal(4))
+ })
+ })
+
+ Context("Making an assertion without a registered fail handler", func() {
+ It("should panic", func() {
+ defer func() {
+ e := recover()
+ RegisterFailHandler(Fail)
+ if e == nil {
+ Fail("expected a panic to have occurred")
+ }
+ }()
+
+ RegisterFailHandler(nil)
+ c := make(chan bool)
+ Consistently(c).ShouldNot(Receive())
+ })
+ })
+ })
+
+ Context("when passed a function with the wrong # or arguments & returns", func() {
+ It("should panic", func() {
+ Expect(func() {
+ New(AsyncAssertionTypeEventually, func() {}, fakeFailWrapper, 0, 0, 1)
+ }).Should(Panic())
+
+ Expect(func() {
+ New(AsyncAssertionTypeEventually, func(a string) int { return 0 }, fakeFailWrapper, 0, 0, 1)
+ }).Should(Panic())
+
+ Expect(func() {
+ New(AsyncAssertionTypeEventually, func() int { return 0 }, fakeFailWrapper, 0, 0, 1)
+ }).ShouldNot(Panic())
+
+ Expect(func() {
+ New(AsyncAssertionTypeEventually, func() (int, error) { return 0, nil }, fakeFailWrapper, 0, 0, 1)
+ }).ShouldNot(Panic())
+ })
+ })
+
+ Describe("bailing early", func() {
+ Context("when actual is a value", func() {
+ It("Eventually should bail out and fail early if the matcher says to", func() {
+ c := make(chan bool)
+ close(c)
+
+ t := time.Now()
+ failures := InterceptGomegaFailures(func() {
+ Eventually(c, 0.1).Should(Receive())
+ })
+ Expect(time.Since(t)).Should(BeNumerically("<", 90*time.Millisecond))
+
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+
+ Context("when actual is a function", func() {
+ It("should never bail early", func() {
+ c := make(chan bool)
+ close(c)
+
+ t := time.Now()
+ failures := InterceptGomegaFailures(func() {
+ Eventually(func() chan bool {
+ return c
+ }, 0.1).Should(Receive())
+ })
+ Expect(time.Since(t)).Should(BeNumerically(">=", 90*time.Millisecond))
+
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/internal/fakematcher/fake_matcher.go b/vendor/github.com/onsi/gomega/internal/fakematcher/fake_matcher.go
new file mode 100644
index 000000000..6e351a7de
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/internal/fakematcher/fake_matcher.go
@@ -0,0 +1,23 @@
+package fakematcher
+
+import "fmt"
+
+type FakeMatcher struct {
+ ReceivedActual interface{}
+ MatchesToReturn bool
+ ErrToReturn error
+}
+
+func (matcher *FakeMatcher) Match(actual interface{}) (bool, error) {
+ matcher.ReceivedActual = actual
+
+ return matcher.MatchesToReturn, matcher.ErrToReturn
+}
+
+func (matcher *FakeMatcher) FailureMessage(actual interface{}) string {
+ return fmt.Sprintf("positive: %v", actual)
+}
+
+func (matcher *FakeMatcher) NegatedFailureMessage(actual interface{}) string {
+ return fmt.Sprintf("negative: %v", actual)
+}
diff --git a/vendor/github.com/onsi/gomega/internal/oraclematcher/oracle_matcher.go b/vendor/github.com/onsi/gomega/internal/oraclematcher/oracle_matcher.go
new file mode 100644
index 000000000..66cad88a1
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/internal/oraclematcher/oracle_matcher.go
@@ -0,0 +1,25 @@
+package oraclematcher
+
+import "github.com/onsi/gomega/types"
+
+/*
+GomegaMatchers that also match the OracleMatcher interface can convey information about
+whether or not their result will change upon future attempts.
+
+This allows `Eventually` and `Consistently` to short circuit if success becomes impossible.
+
+For example, a process' exit code can never change. So, gexec's Exit matcher returns `true`
+for `MatchMayChangeInTheFuture` until the process exits, at which point it returns `false` forevermore.
+*/
+type OracleMatcher interface {
+ MatchMayChangeInTheFuture(actual interface{}) bool
+}
+
+func MatchMayChangeInTheFuture(matcher types.GomegaMatcher, value interface{}) bool {
+ oracleMatcher, ok := matcher.(OracleMatcher)
+ if !ok {
+ return true
+ }
+
+ return oracleMatcher.MatchMayChangeInTheFuture(value)
+}
diff --git a/vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support.go b/vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support.go
new file mode 100644
index 000000000..bb27032f6
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support.go
@@ -0,0 +1,60 @@
+package testingtsupport
+
+import (
+ "regexp"
+ "runtime/debug"
+ "strings"
+
+ "github.com/onsi/gomega/types"
+)
+
+var StackTracePruneRE = regexp.MustCompile(`\/gomega\/|\/ginkgo\/|\/pkg\/testing\/|\/pkg\/runtime\/`)
+
+type EmptyTWithHelper struct{}
+
+func (e EmptyTWithHelper) Helper() {}
+
+type gomegaTestingT interface {
+ Fatalf(format string, args ...interface{})
+}
+
+func BuildTestingTGomegaFailWrapper(t gomegaTestingT) *types.GomegaFailWrapper {
+ tWithHelper, hasHelper := t.(types.TWithHelper)
+ if !hasHelper {
+ tWithHelper = EmptyTWithHelper{}
+ }
+
+ fail := func(message string, callerSkip ...int) {
+ if hasHelper {
+ tWithHelper.Helper()
+ t.Fatalf("\n%s", message)
+ } else {
+ skip := 2
+ if len(callerSkip) > 0 {
+ skip += callerSkip[0]
+ }
+ stackTrace := pruneStack(string(debug.Stack()), skip)
+ t.Fatalf("\n%s\n%s\n", stackTrace, message)
+ }
+ }
+
+ return &types.GomegaFailWrapper{
+ Fail: fail,
+ TWithHelper: tWithHelper,
+ }
+}
+
+func pruneStack(fullStackTrace string, skip int) string {
+ stack := strings.Split(fullStackTrace, "\n")[1:]
+ if len(stack) > 2*skip {
+ stack = stack[2*skip:]
+ }
+ prunedStack := []string{}
+ for i := 0; i < len(stack)/2; i++ {
+ if !StackTracePruneRE.Match([]byte(stack[i*2])) {
+ prunedStack = append(prunedStack, stack[i*2])
+ prunedStack = append(prunedStack, stack[i*2+1])
+ }
+ }
+ return strings.Join(prunedStack, "\n")
+}
diff --git a/vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support_test.go b/vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support_test.go
new file mode 100644
index 000000000..8fd8f0a6c
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support_test.go
@@ -0,0 +1,92 @@
+package testingtsupport_test
+
+import (
+ "regexp"
+ "time"
+
+ "github.com/onsi/gomega/internal/testingtsupport"
+
+ . "github.com/onsi/gomega"
+
+ "fmt"
+ "testing"
+)
+
+func TestTestingT(t *testing.T) {
+ RegisterTestingT(t)
+ Ω(true).Should(BeTrue())
+}
+
+type FakeTWithHelper struct {
+ LastFatal string
+}
+
+func (f *FakeTWithHelper) Fatalf(format string, args ...interface{}) {
+ f.LastFatal = fmt.Sprintf(format, args...)
+}
+
+func TestGomegaWithTWithoutHelper(t *testing.T) {
+ g := NewGomegaWithT(t)
+
+ testingtsupport.StackTracePruneRE = regexp.MustCompile(`\/ginkgo\/`)
+
+ f := &FakeTWithHelper{}
+ testG := NewGomegaWithT(f)
+
+ testG.Expect("foo").To(Equal("foo"))
+ g.Expect(f.LastFatal).To(BeZero())
+
+ testG.Expect("foo").To(Equal("bar"))
+ g.Expect(f.LastFatal).To(ContainSubstring("<string>: foo"))
+ g.Expect(f.LastFatal).To(ContainSubstring("testingtsupport_test"), "It should include a stacktrace")
+
+ testG.Eventually("foo2", time.Millisecond).Should(Equal("bar"))
+ g.Expect(f.LastFatal).To(ContainSubstring("<string>: foo2"))
+
+ testG.Consistently("foo3", time.Millisecond).Should(Equal("bar"))
+ g.Expect(f.LastFatal).To(ContainSubstring("<string>: foo3"))
+}
+
+type FakeTWithoutHelper struct {
+ LastFatal string
+ HelperCount int
+}
+
+func (f *FakeTWithoutHelper) Fatalf(format string, args ...interface{}) {
+ f.LastFatal = fmt.Sprintf(format, args...)
+}
+
+func (f *FakeTWithoutHelper) Helper() {
+ f.HelperCount += 1
+}
+
+func (f *FakeTWithoutHelper) ResetHelper() {
+ f.HelperCount = 0
+}
+
+func TestGomegaWithTWithHelper(t *testing.T) {
+ g := NewGomegaWithT(t)
+
+ f := &FakeTWithoutHelper{}
+ testG := NewGomegaWithT(f)
+
+ testG.Expect("foo").To(Equal("foo"))
+ g.Expect(f.LastFatal).To(BeZero())
+ g.Expect(f.HelperCount).To(BeNumerically(">", 0))
+ f.ResetHelper()
+
+ testG.Expect("foo").To(Equal("bar"))
+ g.Expect(f.LastFatal).To(ContainSubstring("<string>: foo"))
+ g.Expect(f.LastFatal).NotTo(ContainSubstring("testingtsupport_test"), "It should _not_ include a stacktrace")
+ g.Expect(f.HelperCount).To(BeNumerically(">", 0))
+ f.ResetHelper()
+
+ testG.Eventually("foo2", time.Millisecond).Should(Equal("bar"))
+ g.Expect(f.LastFatal).To(ContainSubstring("<string>: foo2"))
+ g.Expect(f.HelperCount).To(BeNumerically(">", 0))
+ f.ResetHelper()
+
+ testG.Consistently("foo3", time.Millisecond).Should(Equal("bar"))
+ g.Expect(f.LastFatal).To(ContainSubstring("<string>: foo3"))
+ g.Expect(f.HelperCount).To(BeNumerically(">", 0))
+}
diff --git a/vendor/github.com/onsi/gomega/matchers.go b/vendor/github.com/onsi/gomega/matchers.go
new file mode 100644
index 000000000..c3a326dd4
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers.go
@@ -0,0 +1,427 @@
+package gomega
+
+import (
+ "time"
+
+ "github.com/onsi/gomega/matchers"
+ "github.com/onsi/gomega/types"
+)
+
+//Equal uses reflect.DeepEqual to compare actual with expected. Equal is strict about
+//types when performing comparisons.
+//It is an error for both actual and expected to be nil. Use BeNil() instead.
+func Equal(expected interface{}) types.GomegaMatcher {
+ return &matchers.EqualMatcher{
+ Expected: expected,
+ }
+}
+
+//BeEquivalentTo is more lax than Equal, allowing equality between different types.
+//This is done by converting actual to have the type of expected before
+//attempting equality with reflect.DeepEqual.
+//It is an error for actual and expected to be nil. Use BeNil() instead.
+func BeEquivalentTo(expected interface{}) types.GomegaMatcher {
+ return &matchers.BeEquivalentToMatcher{
+ Expected: expected,
+ }
+}
+
+//BeIdenticalTo uses the == operator to compare actual with expected.
+//BeIdenticalTo is strict about types when performing comparisons.
+//It is an error for both actual and expected to be nil. Use BeNil() instead.
+func BeIdenticalTo(expected interface{}) types.GomegaMatcher {
+ return &matchers.BeIdenticalToMatcher{
+ Expected: expected,
+ }
+}
+
+//BeNil succeeds if actual is nil
+func BeNil() types.GomegaMatcher {
+ return &matchers.BeNilMatcher{}
+}
+
+//BeTrue succeeds if actual is true
+func BeTrue() types.GomegaMatcher {
+ return &matchers.BeTrueMatcher{}
+}
+
+//BeFalse succeeds if actual is false
+func BeFalse() types.GomegaMatcher {
+ return &matchers.BeFalseMatcher{}
+}
+
+//HaveOccurred succeeds if actual is a non-nil error
+//The typical Go error checking pattern looks like:
+// err := SomethingThatMightFail()
+// Expect(err).ShouldNot(HaveOccurred())
+func HaveOccurred() types.GomegaMatcher {
+ return &matchers.HaveOccurredMatcher{}
+}
+
+//Succeed passes if actual is a nil error
+//Succeed is intended to be used with functions that return a single error value. Instead of
+// err := SomethingThatMightFail()
+// Expect(err).ShouldNot(HaveOccurred())
+//
+//You can write:
+// Expect(SomethingThatMightFail()).Should(Succeed())
+//
+//It is a mistake to use Succeed with a function that has multiple return values. Gomega's Ω and Expect
+//functions automatically trigger failure if any return values after the first return value are non-zero/non-nil.
+//This means that Ω(MultiReturnFunc()).ShouldNot(Succeed()) can never pass.
+func Succeed() types.GomegaMatcher {
+ return &matchers.SucceedMatcher{}
+}
+
+//MatchError succeeds if actual is a non-nil error that matches the passed in string/error.
+//
+//These are valid use-cases:
+// Expect(err).Should(MatchError("an error")) //asserts that err.Error() == "an error"
+// Expect(err).Should(MatchError(SomeError)) //asserts that err == SomeError (via reflect.DeepEqual)
+//
+//It is an error for err to be nil or an object that does not implement the Error interface
+func MatchError(expected interface{}) types.GomegaMatcher {
+ return &matchers.MatchErrorMatcher{
+ Expected: expected,
+ }
+}
+
+//BeClosed succeeds if actual is a closed channel.
+//It is an error to pass a non-channel to BeClosed, it is also an error to pass nil
+//
+//In order to check whether or not the channel is closed, Gomega must try to read from the channel
+//(even in the `ShouldNot(BeClosed())` case). You should keep this in mind if you wish to make subsequent assertions about
+//values coming down the channel.
+//
+//Also, if you are testing that a *buffered* channel is closed you must first read all values out of the channel before
+//asserting that it is closed (it is not possible to detect that a buffered-channel has been closed until all its buffered values are read).
+//
+//Finally, as a corollary: it is an error to check whether or not a send-only channel is closed.
+func BeClosed() types.GomegaMatcher {
+ return &matchers.BeClosedMatcher{}
+}
+
+//Receive succeeds if there is a value to be received on actual.
+//Actual must be a channel (and cannot be a send-only channel) -- anything else is an error.
+//
+//Receive returns immediately and never blocks:
+//
+//- If there is nothing on the channel `c` then Expect(c).Should(Receive()) will fail and Ω(c).ShouldNot(Receive()) will pass.
+//
+//- If the channel `c` is closed then Expect(c).Should(Receive()) will fail and Ω(c).ShouldNot(Receive()) will pass.
+//
+//- If there is something on the channel `c` ready to be read, then Expect(c).Should(Receive()) will pass and Ω(c).ShouldNot(Receive()) will fail.
+//
+//If you have a go-routine running in the background that will write to channel `c` you can:
+// Eventually(c).Should(Receive())
+//
+//This will timeout if nothing gets sent to `c` (you can modify the timeout interval as you normally do with `Eventually`)
+//
+//A similar use-case is to assert that no go-routine writes to a channel (for a period of time). You can do this with `Consistently`:
+// Consistently(c).ShouldNot(Receive())
+//
+//You can pass `Receive` a matcher. If you do so, it will match the received object against the matcher. For example:
+// Expect(c).Should(Receive(Equal("foo")))
+//
+//When given a matcher, `Receive` will always fail if there is nothing to be received on the channel.
+//
+//Passing Receive a matcher is especially useful when paired with Eventually:
+//
+// Eventually(c).Should(Receive(ContainSubstring("bar")))
+//
+//will repeatedly attempt to pull values out of `c` until a value matching "bar" is received.
+//
+//Finally, if you want to have a reference to the value *sent* to the channel you can pass the `Receive` matcher a pointer to a variable of the appropriate type:
+// var myThing thing
+// Eventually(thingChan).Should(Receive(&myThing))
+// Expect(myThing.Sprocket).Should(Equal("foo"))
+// Expect(myThing.IsValid()).Should(BeTrue())
+func Receive(args ...interface{}) types.GomegaMatcher {
+ var arg interface{}
+ if len(args) > 0 {
+ arg = args[0]
+ }
+
+ return &matchers.ReceiveMatcher{
+ Arg: arg,
+ }
+}
+
+//BeSent succeeds if a value can be sent to actual.
+//Actual must be a channel (and cannot be a receive-only channel) that can sent the type of the value passed into BeSent -- anything else is an error.
+//In addition, actual must not be closed.
+//
+//BeSent never blocks:
+//
+//- If the channel `c` is not ready to receive then Expect(c).Should(BeSent("foo")) will fail immediately
+//- If the channel `c` is eventually ready to receive then Eventually(c).Should(BeSent("foo")) will succeed.. presuming the channel becomes ready to receive before Eventually's timeout
+//- If the channel `c` is closed then Expect(c).Should(BeSent("foo")) and Ω(c).ShouldNot(BeSent("foo")) will both fail immediately
+//
+//Of course, the value is actually sent to the channel. The point of `BeSent` is less to make an assertion about the availability of the channel (which is typically an implementation detail that your test should not be concerned with).
+//Rather, the point of `BeSent` is to make it possible to easily and expressively write tests that can timeout on blocked channel sends.
+func BeSent(arg interface{}) types.GomegaMatcher {
+ return &matchers.BeSentMatcher{
+ Arg: arg,
+ }
+}
+
+//MatchRegexp succeeds if actual is a string or stringer that matches the
+//passed-in regexp. Optional arguments can be provided to construct a regexp
+//via fmt.Sprintf().
+func MatchRegexp(regexp string, args ...interface{}) types.GomegaMatcher {
+ return &matchers.MatchRegexpMatcher{
+ Regexp: regexp,
+ Args: args,
+ }
+}
+
+//ContainSubstring succeeds if actual is a string or stringer that contains the
+//passed-in substring. Optional arguments can be provided to construct the substring
+//via fmt.Sprintf().
+func ContainSubstring(substr string, args ...interface{}) types.GomegaMatcher {
+ return &matchers.ContainSubstringMatcher{
+ Substr: substr,
+ Args: args,
+ }
+}
+
+//HavePrefix succeeds if actual is a string or stringer that contains the
+//passed-in string as a prefix. Optional arguments can be provided to construct
+//via fmt.Sprintf().
+func HavePrefix(prefix string, args ...interface{}) types.GomegaMatcher {
+ return &matchers.HavePrefixMatcher{
+ Prefix: prefix,
+ Args: args,
+ }
+}
+
+//HaveSuffix succeeds if actual is a string or stringer that contains the
+//passed-in string as a suffix. Optional arguments can be provided to construct
+//via fmt.Sprintf().
+func HaveSuffix(suffix string, args ...interface{}) types.GomegaMatcher {
+ return &matchers.HaveSuffixMatcher{
+ Suffix: suffix,
+ Args: args,
+ }
+}
+
+//MatchJSON succeeds if actual is a string or stringer of JSON that matches
+//the expected JSON. The JSONs are decoded and the resulting objects are compared via
+//reflect.DeepEqual so things like key-ordering and whitespace shouldn't matter.
+func MatchJSON(json interface{}) types.GomegaMatcher {
+ return &matchers.MatchJSONMatcher{
+ JSONToMatch: json,
+ }
+}
+
+//MatchXML succeeds if actual is a string or stringer of XML that matches
+//the expected XML. The XMLs are decoded and the resulting objects are compared via
+//reflect.DeepEqual so things like whitespaces shouldn't matter.
+func MatchXML(xml interface{}) types.GomegaMatcher {
+ return &matchers.MatchXMLMatcher{
+ XMLToMatch: xml,
+ }
+}
+
+//MatchYAML succeeds if actual is a string or stringer of YAML that matches
+//the expected YAML. The YAML's are decoded and the resulting objects are compared via
+//reflect.DeepEqual so things like key-ordering and whitespace shouldn't matter.
+func MatchYAML(yaml interface{}) types.GomegaMatcher {
+ return &matchers.MatchYAMLMatcher{
+ YAMLToMatch: yaml,
+ }
+}
+
+//BeEmpty succeeds if actual is empty. Actual must be of type string, array, map, chan, or slice.
+func BeEmpty() types.GomegaMatcher {
+ return &matchers.BeEmptyMatcher{}
+}
+
+//HaveLen succeeds if actual has the passed-in length. Actual must be of type string, array, map, chan, or slice.
+func HaveLen(count int) types.GomegaMatcher {
+ return &matchers.HaveLenMatcher{
+ Count: count,
+ }
+}
+
+//HaveCap succeeds if actual has the passed-in capacity. Actual must be of type array, chan, or slice.
+func HaveCap(count int) types.GomegaMatcher {
+ return &matchers.HaveCapMatcher{
+ Count: count,
+ }
+}
+
+//BeZero succeeds if actual is the zero value for its type or if actual is nil.
+func BeZero() types.GomegaMatcher {
+ return &matchers.BeZeroMatcher{}
+}
+
+//ContainElement succeeds if actual contains the passed in element.
+//By default ContainElement() uses Equal() to perform the match, however a
+//matcher can be passed in instead:
+// Expect([]string{"Foo", "FooBar"}).Should(ContainElement(ContainSubstring("Bar")))
+//
+//Actual must be an array, slice or map.
+//For maps, ContainElement searches through the map's values.
+func ContainElement(element interface{}) types.GomegaMatcher {
+ return &matchers.ContainElementMatcher{
+ Element: element,
+ }
+}
+
+//ConsistOf succeeds if actual contains precisely the elements passed into the matcher. The ordering of the elements does not matter.
+//By default ConsistOf() uses Equal() to match the elements, however custom matchers can be passed in instead. Here are some examples:
+//
+// Expect([]string{"Foo", "FooBar"}).Should(ConsistOf("FooBar", "Foo"))
+// Expect([]string{"Foo", "FooBar"}).Should(ConsistOf(ContainSubstring("Bar"), "Foo"))
+// Expect([]string{"Foo", "FooBar"}).Should(ConsistOf(ContainSubstring("Foo"), ContainSubstring("Foo")))
+//
+//Actual must be an array, slice or map. For maps, ConsistOf matches against the map's values.
+//
+//You typically pass variadic arguments to ConsistOf (as in the examples above). However, if you need to pass in a slice you can provided that it
+//is the only element passed in to ConsistOf:
+//
+// Expect([]string{"Foo", "FooBar"}).Should(ConsistOf([]string{"FooBar", "Foo"}))
+//
+//Note that Go's type system does not allow you to write this as ConsistOf([]string{"FooBar", "Foo"}...) as []string and []interface{} are different types - hence the need for this special rule.
+func ConsistOf(elements ...interface{}) types.GomegaMatcher {
+ return &matchers.ConsistOfMatcher{
+ Elements: elements,
+ }
+}
+
+//HaveKey succeeds if actual is a map with the passed in key.
+//By default HaveKey uses Equal() to perform the match, however a
+//matcher can be passed in instead:
+// Expect(map[string]string{"Foo": "Bar", "BazFoo": "Duck"}).Should(HaveKey(MatchRegexp(`.+Foo$`)))
+func HaveKey(key interface{}) types.GomegaMatcher {
+ return &matchers.HaveKeyMatcher{
+ Key: key,
+ }
+}
+
+//HaveKeyWithValue succeeds if actual is a map with the passed in key and value.
+//By default HaveKeyWithValue uses Equal() to perform the match, however a
+//matcher can be passed in instead:
+// Expect(map[string]string{"Foo": "Bar", "BazFoo": "Duck"}).Should(HaveKeyWithValue("Foo", "Bar"))
+// Expect(map[string]string{"Foo": "Bar", "BazFoo": "Duck"}).Should(HaveKeyWithValue(MatchRegexp(`.+Foo$`), "Bar"))
+func HaveKeyWithValue(key interface{}, value interface{}) types.GomegaMatcher {
+ return &matchers.HaveKeyWithValueMatcher{
+ Key: key,
+ Value: value,
+ }
+}
+
+//BeNumerically performs numerical assertions in a type-agnostic way.
+//Actual and expected should be numbers, though the specific type of
+//number is irrelevant (float32, float64, uint8, etc...).
+//
+//There are six, self-explanatory, supported comparators:
+// Expect(1.0).Should(BeNumerically("==", 1))
+// Expect(1.0).Should(BeNumerically("~", 0.999, 0.01))
+// Expect(1.0).Should(BeNumerically(">", 0.9))
+// Expect(1.0).Should(BeNumerically(">=", 1.0))
+// Expect(1.0).Should(BeNumerically("<", 3))
+// Expect(1.0).Should(BeNumerically("<=", 1.0))
+func BeNumerically(comparator string, compareTo ...interface{}) types.GomegaMatcher {
+ return &matchers.BeNumericallyMatcher{
+ Comparator: comparator,
+ CompareTo: compareTo,
+ }
+}
+
+//BeTemporally compares time.Time's like BeNumerically
+//Actual and expected must be time.Time. The comparators are the same as for BeNumerically
+// Expect(time.Now()).Should(BeTemporally(">", time.Time{}))
+// Expect(time.Now()).Should(BeTemporally("~", time.Now(), time.Second))
+func BeTemporally(comparator string, compareTo time.Time, threshold ...time.Duration) types.GomegaMatcher {
+ return &matchers.BeTemporallyMatcher{
+ Comparator: comparator,
+ CompareTo: compareTo,
+ Threshold: threshold,
+ }
+}
+
+//BeAssignableToTypeOf succeeds if actual is assignable to the type of expected.
+//It will return an error when one of the values is nil.
+// Expect(0).Should(BeAssignableToTypeOf(0)) // Same values
+// Expect(5).Should(BeAssignableToTypeOf(-1)) // different values same type
+// Expect("foo").Should(BeAssignableToTypeOf("bar")) // different values same type
+// Expect(struct{ Foo string }{}).Should(BeAssignableToTypeOf(struct{ Foo string }{}))
+func BeAssignableToTypeOf(expected interface{}) types.GomegaMatcher {
+ return &matchers.AssignableToTypeOfMatcher{
+ Expected: expected,
+ }
+}
+
+//Panic succeeds if actual is a function that, when invoked, panics.
+//Actual must be a function that takes no arguments and returns no results.
+func Panic() types.GomegaMatcher {
+ return &matchers.PanicMatcher{}
+}
+
+//BeAnExistingFile succeeds if a file exists.
+//Actual must be a string representing the abs path to the file being checked.
+func BeAnExistingFile() types.GomegaMatcher {
+ return &matchers.BeAnExistingFileMatcher{}
+}
+
+//BeARegularFile succeeds if a file exists and is a regular file.
+//Actual must be a string representing the abs path to the file being checked.
+func BeARegularFile() types.GomegaMatcher {
+ return &matchers.BeARegularFileMatcher{}
+}
+
+//BeADirectory succeeds if a file exists and is a directory.
+//Actual must be a string representing the abs path to the file being checked.
+func BeADirectory() types.GomegaMatcher {
+ return &matchers.BeADirectoryMatcher{}
+}
+
+//And succeeds only if all of the given matchers succeed.
+//The matchers are tried in order, and will fail-fast if one doesn't succeed.
+// Expect("hi").To(And(HaveLen(2), Equal("hi"))
+//
+//And(), Or(), Not() and WithTransform() allow matchers to be composed into complex expressions.
+func And(ms ...types.GomegaMatcher) types.GomegaMatcher {
+ return &matchers.AndMatcher{Matchers: ms}
+}
+
+//SatisfyAll is an alias for And().
+// Expect("hi").Should(SatisfyAll(HaveLen(2), Equal("hi")))
+func SatisfyAll(matchers ...types.GomegaMatcher) types.GomegaMatcher {
+ return And(matchers...)
+}
+
+//Or succeeds if any of the given matchers succeed.
+//The matchers are tried in order and will return immediately upon the first successful match.
+// Expect("hi").To(Or(HaveLen(3), HaveLen(2))
+//
+//And(), Or(), Not() and WithTransform() allow matchers to be composed into complex expressions.
+func Or(ms ...types.GomegaMatcher) types.GomegaMatcher {
+ return &matchers.OrMatcher{Matchers: ms}
+}
+
+//SatisfyAny is an alias for Or().
+// Expect("hi").SatisfyAny(Or(HaveLen(3), HaveLen(2))
+func SatisfyAny(matchers ...types.GomegaMatcher) types.GomegaMatcher {
+ return Or(matchers...)
+}
+
+//Not negates the given matcher; it succeeds if the given matcher fails.
+// Expect(1).To(Not(Equal(2))
+//
+//And(), Or(), Not() and WithTransform() allow matchers to be composed into complex expressions.
+func Not(matcher types.GomegaMatcher) types.GomegaMatcher {
+ return &matchers.NotMatcher{Matcher: matcher}
+}
+
+//WithTransform applies the `transform` to the actual value and matches it against `matcher`.
+//The given transform must be a function of one parameter that returns one value.
+// var plus1 = func(i int) int { return i + 1 }
+// Expect(1).To(WithTransform(plus1, Equal(2))
+//
+//And(), Or(), Not() and WithTransform() allow matchers to be composed into complex expressions.
+func WithTransform(transform interface{}, matcher types.GomegaMatcher) types.GomegaMatcher {
+ return matchers.NewWithTransformMatcher(transform, matcher)
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/and.go b/vendor/github.com/onsi/gomega/matchers/and.go
new file mode 100644
index 000000000..d83a29164
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/and.go
@@ -0,0 +1,63 @@
+package matchers
+
+import (
+ "fmt"
+
+ "github.com/onsi/gomega/format"
+ "github.com/onsi/gomega/internal/oraclematcher"
+ "github.com/onsi/gomega/types"
+)
+
+type AndMatcher struct {
+ Matchers []types.GomegaMatcher
+
+ // state
+ firstFailedMatcher types.GomegaMatcher
+}
+
+func (m *AndMatcher) Match(actual interface{}) (success bool, err error) {
+ m.firstFailedMatcher = nil
+ for _, matcher := range m.Matchers {
+ success, err := matcher.Match(actual)
+ if !success || err != nil {
+ m.firstFailedMatcher = matcher
+ return false, err
+ }
+ }
+ return true, nil
+}
+
+func (m *AndMatcher) FailureMessage(actual interface{}) (message string) {
+ return m.firstFailedMatcher.FailureMessage(actual)
+}
+
+func (m *AndMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ // not the most beautiful list of matchers, but not bad either...
+ return format.Message(actual, fmt.Sprintf("To not satisfy all of these matchers: %s", m.Matchers))
+}
+
+func (m *AndMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
+ /*
+ Example with 3 matchers: A, B, C
+
+ Match evaluates them: T, F, <?> => F
+ So match is currently F, what should MatchMayChangeInTheFuture() return?
+ Seems like it only depends on B, since currently B MUST change to allow the result to become T
+
+ Match eval: T, T, T => T
+ So match is currently T, what should MatchMayChangeInTheFuture() return?
+ Seems to depend on ANY of them being able to change to F.
+ */
+
+ if m.firstFailedMatcher == nil {
+ // so all matchers succeeded.. Any one of them changing would change the result.
+ for _, matcher := range m.Matchers {
+ if oraclematcher.MatchMayChangeInTheFuture(matcher, actual) {
+ return true
+ }
+ }
+ return false // none of were going to change
+ }
+ // one of the matchers failed.. it must be able to change in order to affect the result
+ return oraclematcher.MatchMayChangeInTheFuture(m.firstFailedMatcher, actual)
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/and_test.go b/vendor/github.com/onsi/gomega/matchers/and_test.go
new file mode 100644
index 000000000..acf778cd6
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/and_test.go
@@ -0,0 +1,103 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+ "github.com/onsi/gomega/types"
+)
+
+// sample data
+var (
+ // example input
+ input = "hi"
+ // some matchers that succeed against the input
+ true1 = HaveLen(2)
+ true2 = Equal("hi")
+ true3 = MatchRegexp("hi")
+ // some matchers that fail against the input.
+ false1 = HaveLen(1)
+ false2 = Equal("hip")
+ false3 = MatchRegexp("hope")
+)
+
+// verifyFailureMessage expects the matcher to fail with the given input, and verifies the failure message.
+func verifyFailureMessage(m types.GomegaMatcher, input string, expectedFailureMsgFragment string) {
+ Expect(m.Match(input)).To(BeFalse())
+ Expect(m.FailureMessage(input)).To(Equal(
+ "Expected\n <string>: " + input + "\n" + expectedFailureMsgFragment))
+}
+
+var _ = Describe("AndMatcher", func() {
+ It("works with positive cases", func() {
+ Expect(input).To(And())
+ Expect(input).To(And(true1))
+ Expect(input).To(And(true1, true2))
+ Expect(input).To(And(true1, true2, true3))
+
+ // use alias
+ Expect(input).To(SatisfyAll(true1, true2, true3))
+ })
+
+ It("works with negative cases", func() {
+ Expect(input).ToNot(And(false1, false2))
+ Expect(input).ToNot(And(true1, true2, false3))
+ Expect(input).ToNot(And(true1, false2, false3))
+ Expect(input).ToNot(And(false1, true1, true2))
+ })
+
+ Context("failure messages", func() {
+ Context("when match fails", func() {
+ It("gives a descriptive message", func() {
+ verifyFailureMessage(And(false1, true1), input, "to have length 1")
+ verifyFailureMessage(And(true1, false2), input, "to equal\n <string>: hip")
+ verifyFailureMessage(And(true1, true2, false3), input, "to match regular expression\n <string>: hope")
+ })
+ })
+
+ Context("when match succeeds, but expected it to fail", func() {
+ It("gives a descriptive message", func() {
+ verifyFailureMessage(Not(And(true1, true2)), input,
+ `To not satisfy all of these matchers: [%!s(*matchers.HaveLenMatcher=&{2}) %!s(*matchers.EqualMatcher=&{hi})]`)
+ })
+ })
+ })
+
+ Context("MatchMayChangeInTheFuture", func() {
+ Context("Match returned false", func() {
+ Context("returns value of the failed matcher", func() {
+ It("false if failed matcher not going to change", func() {
+ // 3 matchers: 1st returns true, 2nd returns false and is not going to change, 3rd is never called
+ m := And(Not(BeNil()), Or(), Equal(1))
+ Expect(m.Match("hi")).To(BeFalse())
+ Expect(m.(*AndMatcher).MatchMayChangeInTheFuture("hi")).To(BeFalse()) // empty Or() indicates not going to change
+ })
+ It("true if failed matcher indicates it might change", func() {
+ // 3 matchers: 1st returns true, 2nd returns false and "might" change, 3rd is never called
+ m := And(Not(BeNil()), Equal(5), Equal(1))
+ Expect(m.Match("hi")).To(BeFalse())
+ Expect(m.(*AndMatcher).MatchMayChangeInTheFuture("hi")).To(BeTrue()) // Equal(5) indicates it might change
+ })
+ })
+ })
+ Context("Match returned true", func() {
+ It("returns true if any of the matchers could change", func() {
+ // 3 matchers, all return true, and all could change
+ m := And(Not(BeNil()), Equal("hi"), HaveLen(2))
+ Expect(m.Match("hi")).To(BeTrue())
+ Expect(m.(*AndMatcher).MatchMayChangeInTheFuture("hi")).To(BeTrue()) // all 3 of these matchers default to 'true'
+ })
+ It("returns false if none of the matchers could change", func() {
+ // empty And() has the property of always matching, and never can change since there are no sub-matchers that could change
+ m := And()
+ Expect(m.Match("anything")).To(BeTrue())
+ Expect(m.(*AndMatcher).MatchMayChangeInTheFuture("anything")).To(BeFalse())
+
+ // And() with 3 sub-matchers that return true, and can't change
+ m = And(And(), And(), And())
+ Expect(m.Match("hi")).To(BeTrue())
+ Expect(m.(*AndMatcher).MatchMayChangeInTheFuture("hi")).To(BeFalse()) // the 3 empty And()'s won't change
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher.go b/vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher.go
new file mode 100644
index 000000000..51f8be6ae
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher.go
@@ -0,0 +1,35 @@
+package matchers
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/format"
+)
+
+type AssignableToTypeOfMatcher struct {
+ Expected interface{}
+}
+
+func (matcher *AssignableToTypeOfMatcher) Match(actual interface{}) (success bool, err error) {
+ if actual == nil && matcher.Expected == nil {
+ return false, fmt.Errorf("Refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
+ } else if matcher.Expected == nil {
+ return false, fmt.Errorf("Refusing to compare type to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
+ } else if actual == nil {
+ return false, nil
+ }
+
+ actualType := reflect.TypeOf(actual)
+ expectedType := reflect.TypeOf(matcher.Expected)
+
+ return actualType.AssignableTo(expectedType), nil
+}
+
+func (matcher *AssignableToTypeOfMatcher) FailureMessage(actual interface{}) string {
+ return format.Message(actual, fmt.Sprintf("to be assignable to the type: %T", matcher.Expected))
+}
+
+func (matcher *AssignableToTypeOfMatcher) NegatedFailureMessage(actual interface{}) string {
+ return format.Message(actual, fmt.Sprintf("not to be assignable to the type: %T", matcher.Expected))
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher_test.go
new file mode 100644
index 000000000..471a46d97
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher_test.go
@@ -0,0 +1,46 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("AssignableToTypeOf", func() {
+ Context("When asserting assignability between types", func() {
+ It("should do the right thing", func() {
+ Expect(0).Should(BeAssignableToTypeOf(0))
+ Expect(5).Should(BeAssignableToTypeOf(-1))
+ Expect("foo").Should(BeAssignableToTypeOf("bar"))
+ Expect(struct{ Foo string }{}).Should(BeAssignableToTypeOf(struct{ Foo string }{}))
+
+ Expect(0).ShouldNot(BeAssignableToTypeOf("bar"))
+ Expect(5).ShouldNot(BeAssignableToTypeOf(struct{ Foo string }{}))
+ Expect("foo").ShouldNot(BeAssignableToTypeOf(42))
+ })
+ })
+
+ Context("When asserting nil values", func() {
+ It("should error", func() {
+ success, err := (&AssignableToTypeOfMatcher{Expected: nil}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+
+ Context("When actual is nil and expected is not nil", func() {
+ It("should return false without error", func() {
+ success, err := (&AssignableToTypeOfMatcher{Expected: 17}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+ })
+
+ Context("When actual is not nil and expected is nil", func() {
+ It("should error", func() {
+ success, err := (&AssignableToTypeOfMatcher{Expected: nil}).Match(17)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/attributes_slice.go b/vendor/github.com/onsi/gomega/matchers/attributes_slice.go
new file mode 100644
index 000000000..355b362f4
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/attributes_slice.go
@@ -0,0 +1,14 @@
+package matchers
+
+import (
+ "encoding/xml"
+ "strings"
+)
+
+type attributesSlice []xml.Attr
+
+func (attrs attributesSlice) Len() int { return len(attrs) }
+func (attrs attributesSlice) Less(i, j int) bool {
+ return strings.Compare(attrs[i].Name.Local, attrs[j].Name.Local) == -1
+}
+func (attrs attributesSlice) Swap(i, j int) { attrs[i], attrs[j] = attrs[j], attrs[i] }
diff --git a/vendor/github.com/onsi/gomega/matchers/be_a_directory.go b/vendor/github.com/onsi/gomega/matchers/be_a_directory.go
new file mode 100644
index 000000000..7b6975e41
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_a_directory.go
@@ -0,0 +1,54 @@
+package matchers
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/onsi/gomega/format"
+)
+
+type notADirectoryError struct {
+ os.FileInfo
+}
+
+func (t notADirectoryError) Error() string {
+ fileInfo := os.FileInfo(t)
+ switch {
+ case fileInfo.Mode().IsRegular():
+ return "file is a regular file"
+ default:
+ return fmt.Sprintf("file mode is: %s", fileInfo.Mode().String())
+ }
+}
+
+type BeADirectoryMatcher struct {
+ expected interface{}
+ err error
+}
+
+func (matcher *BeADirectoryMatcher) Match(actual interface{}) (success bool, err error) {
+ actualFilename, ok := actual.(string)
+ if !ok {
+ return false, fmt.Errorf("BeADirectoryMatcher matcher expects a file path")
+ }
+
+ fileInfo, err := os.Stat(actualFilename)
+ if err != nil {
+ matcher.err = err
+ return false, nil
+ }
+
+ if !fileInfo.Mode().IsDir() {
+ matcher.err = notADirectoryError{fileInfo}
+ return false, nil
+ }
+ return true, nil
+}
+
+func (matcher *BeADirectoryMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, fmt.Sprintf("to be a directory: %s", matcher.err))
+}
+
+func (matcher *BeADirectoryMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, fmt.Sprintf("not be a directory"))
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/be_a_directory_test.go b/vendor/github.com/onsi/gomega/matchers/be_a_directory_test.go
new file mode 100644
index 000000000..bc8742763
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_a_directory_test.go
@@ -0,0 +1,40 @@
+package matchers_test
+
+import (
+ "io/ioutil"
+ "os"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("BeADirectoryMatcher", func() {
+ Context("when passed a string", func() {
+ It("should do the right thing", func() {
+ Expect("/dne/test").ShouldNot(BeADirectory())
+
+ tmpFile, err := ioutil.TempFile("", "gomega-test-tempfile")
+ Expect(err).ShouldNot(HaveOccurred())
+ defer os.Remove(tmpFile.Name())
+ Expect(tmpFile.Name()).ShouldNot(BeADirectory())
+
+ tmpDir, err := ioutil.TempDir("", "gomega-test-tempdir")
+ Expect(err).ShouldNot(HaveOccurred())
+ defer os.Remove(tmpDir)
+ Expect(tmpDir).Should(BeADirectory())
+ })
+ })
+
+ Context("when passed something else", func() {
+ It("should error", func() {
+ success, err := (&BeADirectoryMatcher{}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&BeADirectoryMatcher{}).Match(true)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/be_a_regular_file.go b/vendor/github.com/onsi/gomega/matchers/be_a_regular_file.go
new file mode 100644
index 000000000..e239131fb
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_a_regular_file.go
@@ -0,0 +1,54 @@
+package matchers
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/onsi/gomega/format"
+)
+
+type notARegularFileError struct {
+ os.FileInfo
+}
+
+func (t notARegularFileError) Error() string {
+ fileInfo := os.FileInfo(t)
+ switch {
+ case fileInfo.IsDir():
+ return "file is a directory"
+ default:
+ return fmt.Sprintf("file mode is: %s", fileInfo.Mode().String())
+ }
+}
+
+type BeARegularFileMatcher struct {
+ expected interface{}
+ err error
+}
+
+func (matcher *BeARegularFileMatcher) Match(actual interface{}) (success bool, err error) {
+ actualFilename, ok := actual.(string)
+ if !ok {
+ return false, fmt.Errorf("BeARegularFileMatcher matcher expects a file path")
+ }
+
+ fileInfo, err := os.Stat(actualFilename)
+ if err != nil {
+ matcher.err = err
+ return false, nil
+ }
+
+ if !fileInfo.Mode().IsRegular() {
+ matcher.err = notARegularFileError{fileInfo}
+ return false, nil
+ }
+ return true, nil
+}
+
+func (matcher *BeARegularFileMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, fmt.Sprintf("to be a regular file: %s", matcher.err))
+}
+
+func (matcher *BeARegularFileMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, fmt.Sprintf("not be a regular file"))
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/be_a_regular_file_test.go b/vendor/github.com/onsi/gomega/matchers/be_a_regular_file_test.go
new file mode 100644
index 000000000..eae06a03e
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_a_regular_file_test.go
@@ -0,0 +1,40 @@
+package matchers_test
+
+import (
+ "io/ioutil"
+ "os"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("BeARegularFileMatcher", func() {
+ Context("when passed a string", func() {
+ It("should do the right thing", func() {
+ Expect("/dne/test").ShouldNot(BeARegularFile())
+
+ tmpFile, err := ioutil.TempFile("", "gomega-test-tempfile")
+ Expect(err).ShouldNot(HaveOccurred())
+ defer os.Remove(tmpFile.Name())
+ Expect(tmpFile.Name()).Should(BeARegularFile())
+
+ tmpDir, err := ioutil.TempDir("", "gomega-test-tempdir")
+ Expect(err).ShouldNot(HaveOccurred())
+ defer os.Remove(tmpDir)
+ Expect(tmpDir).ShouldNot(BeARegularFile())
+ })
+ })
+
+ Context("when passed something else", func() {
+ It("should error", func() {
+ success, err := (&BeARegularFileMatcher{}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&BeARegularFileMatcher{}).Match(true)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/be_an_existing_file.go b/vendor/github.com/onsi/gomega/matchers/be_an_existing_file.go
new file mode 100644
index 000000000..d42eba223
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_an_existing_file.go
@@ -0,0 +1,38 @@
+package matchers
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/onsi/gomega/format"
+)
+
+type BeAnExistingFileMatcher struct {
+ expected interface{}
+}
+
+func (matcher *BeAnExistingFileMatcher) Match(actual interface{}) (success bool, err error) {
+ actualFilename, ok := actual.(string)
+ if !ok {
+ return false, fmt.Errorf("BeAnExistingFileMatcher matcher expects a file path")
+ }
+
+ if _, err = os.Stat(actualFilename); err != nil {
+ switch {
+ case os.IsNotExist(err):
+ return false, nil
+ default:
+ return false, err
+ }
+ }
+
+ return true, nil
+}
+
+func (matcher *BeAnExistingFileMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, fmt.Sprintf("to exist"))
+}
+
+func (matcher *BeAnExistingFileMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, fmt.Sprintf("not to exist"))
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/be_an_existing_file_test.go b/vendor/github.com/onsi/gomega/matchers/be_an_existing_file_test.go
new file mode 100644
index 000000000..e28bd0d65
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_an_existing_file_test.go
@@ -0,0 +1,40 @@
+package matchers_test
+
+import (
+ "io/ioutil"
+ "os"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("BeAnExistingFileMatcher", func() {
+ Context("when passed a string", func() {
+ It("should do the right thing", func() {
+ Expect("/dne/test").ShouldNot(BeAnExistingFile())
+
+ tmpFile, err := ioutil.TempFile("", "gomega-test-tempfile")
+ Expect(err).ShouldNot(HaveOccurred())
+ defer os.Remove(tmpFile.Name())
+ Expect(tmpFile.Name()).Should(BeAnExistingFile())
+
+ tmpDir, err := ioutil.TempDir("", "gomega-test-tempdir")
+ Expect(err).ShouldNot(HaveOccurred())
+ defer os.Remove(tmpDir)
+ Expect(tmpDir).Should(BeAnExistingFile())
+ })
+ })
+
+ Context("when passed something else", func() {
+ It("should error", func() {
+ success, err := (&BeAnExistingFileMatcher{}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&BeAnExistingFileMatcher{}).Match(true)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/be_closed_matcher.go b/vendor/github.com/onsi/gomega/matchers/be_closed_matcher.go
new file mode 100644
index 000000000..80c9c8bb1
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_closed_matcher.go
@@ -0,0 +1,46 @@
+package matchers
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/format"
+)
+
+type BeClosedMatcher struct {
+}
+
+func (matcher *BeClosedMatcher) Match(actual interface{}) (success bool, err error) {
+ if !isChan(actual) {
+ return false, fmt.Errorf("BeClosed matcher expects a channel. Got:\n%s", format.Object(actual, 1))
+ }
+
+ channelType := reflect.TypeOf(actual)
+ channelValue := reflect.ValueOf(actual)
+
+ if channelType.ChanDir() == reflect.SendDir {
+ return false, fmt.Errorf("BeClosed matcher cannot determine if a send-only channel is closed or open. Got:\n%s", format.Object(actual, 1))
+ }
+
+ winnerIndex, _, open := reflect.Select([]reflect.SelectCase{
+ {Dir: reflect.SelectRecv, Chan: channelValue},
+ {Dir: reflect.SelectDefault},
+ })
+
+ var closed bool
+ if winnerIndex == 0 {
+ closed = !open
+ } else if winnerIndex == 1 {
+ closed = false
+ }
+
+ return closed, nil
+}
+
+func (matcher *BeClosedMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to be closed")
+}
+
+func (matcher *BeClosedMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to be open")
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/be_closed_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_closed_matcher_test.go
new file mode 100644
index 000000000..c2e49ab50
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_closed_matcher_test.go
@@ -0,0 +1,70 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("BeClosedMatcher", func() {
+ Context("when passed a channel", func() {
+ It("should do the right thing", func() {
+ openChannel := make(chan bool)
+ Expect(openChannel).ShouldNot(BeClosed())
+
+ var openReaderChannel <-chan bool
+ openReaderChannel = openChannel
+ Expect(openReaderChannel).ShouldNot(BeClosed())
+
+ closedChannel := make(chan bool)
+ close(closedChannel)
+
+ Expect(closedChannel).Should(BeClosed())
+
+ var closedReaderChannel <-chan bool
+ closedReaderChannel = closedChannel
+ Expect(closedReaderChannel).Should(BeClosed())
+ })
+ })
+
+ Context("when passed a send-only channel", func() {
+ It("should error", func() {
+ openChannel := make(chan bool)
+ var openWriterChannel chan<- bool
+ openWriterChannel = openChannel
+
+ success, err := (&BeClosedMatcher{}).Match(openWriterChannel)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ closedChannel := make(chan bool)
+ close(closedChannel)
+
+ var closedWriterChannel chan<- bool
+ closedWriterChannel = closedChannel
+
+ success, err = (&BeClosedMatcher{}).Match(closedWriterChannel)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ })
+ })
+
+ Context("when passed something else", func() {
+ It("should error", func() {
+ var nilChannel chan bool
+
+ success, err := (&BeClosedMatcher{}).Match(nilChannel)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&BeClosedMatcher{}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&BeClosedMatcher{}).Match(7)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/be_empty_matcher.go b/vendor/github.com/onsi/gomega/matchers/be_empty_matcher.go
new file mode 100644
index 000000000..8b00311b0
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_empty_matcher.go
@@ -0,0 +1,27 @@
+package matchers
+
+import (
+ "fmt"
+
+ "github.com/onsi/gomega/format"
+)
+
+type BeEmptyMatcher struct {
+}
+
+func (matcher *BeEmptyMatcher) Match(actual interface{}) (success bool, err error) {
+ length, ok := lengthOf(actual)
+ if !ok {
+ return false, fmt.Errorf("BeEmpty matcher expects a string/array/map/channel/slice. Got:\n%s", format.Object(actual, 1))
+ }
+
+ return length == 0, nil
+}
+
+func (matcher *BeEmptyMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to be empty")
+}
+
+func (matcher *BeEmptyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to be empty")
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/be_empty_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_empty_matcher_test.go
new file mode 100644
index 000000000..132480cfc
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_empty_matcher_test.go
@@ -0,0 +1,52 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("BeEmpty", func() {
+ Context("when passed a supported type", func() {
+ It("should do the right thing", func() {
+ Expect("").Should(BeEmpty())
+ Expect(" ").ShouldNot(BeEmpty())
+
+ Expect([0]int{}).Should(BeEmpty())
+ Expect([1]int{1}).ShouldNot(BeEmpty())
+
+ Expect([]int{}).Should(BeEmpty())
+ Expect([]int{1}).ShouldNot(BeEmpty())
+
+ Expect(map[string]int{}).Should(BeEmpty())
+ Expect(map[string]int{"a": 1}).ShouldNot(BeEmpty())
+
+ c := make(chan bool, 1)
+ Expect(c).Should(BeEmpty())
+ c <- true
+ Expect(c).ShouldNot(BeEmpty())
+ })
+ })
+
+ Context("when passed a correctly typed nil", func() {
+ It("should be true", func() {
+ var nilSlice []int
+ Expect(nilSlice).Should(BeEmpty())
+
+ var nilMap map[int]string
+ Expect(nilMap).Should(BeEmpty())
+ })
+ })
+
+ Context("when passed an unsupported type", func() {
+ It("should error", func() {
+ success, err := (&BeEmptyMatcher{}).Match(0)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&BeEmptyMatcher{}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher.go b/vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher.go
new file mode 100644
index 000000000..97ab20a4e
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher.go
@@ -0,0 +1,34 @@
+package matchers
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/format"
+)
+
+type BeEquivalentToMatcher struct {
+ Expected interface{}
+}
+
+func (matcher *BeEquivalentToMatcher) Match(actual interface{}) (success bool, err error) {
+ if actual == nil && matcher.Expected == nil {
+ return false, fmt.Errorf("Both actual and expected must not be nil.")
+ }
+
+ convertedActual := actual
+
+ if actual != nil && matcher.Expected != nil && reflect.TypeOf(actual).ConvertibleTo(reflect.TypeOf(matcher.Expected)) {
+ convertedActual = reflect.ValueOf(actual).Convert(reflect.TypeOf(matcher.Expected)).Interface()
+ }
+
+ return reflect.DeepEqual(convertedActual, matcher.Expected), nil
+}
+
+func (matcher *BeEquivalentToMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to be equivalent to", matcher.Expected)
+}
+
+func (matcher *BeEquivalentToMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to be equivalent to", matcher.Expected)
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher_test.go
new file mode 100644
index 000000000..4d9d11d2d
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher_test.go
@@ -0,0 +1,50 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("BeEquivalentTo", func() {
+ Context("when asserting that nil is equivalent to nil", func() {
+ It("should error", func() {
+ success, err := (&BeEquivalentToMatcher{Expected: nil}).Match(nil)
+
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("When asserting on nil", func() {
+ It("should do the right thing", func() {
+ Expect("foo").ShouldNot(BeEquivalentTo(nil))
+ Expect(nil).ShouldNot(BeEquivalentTo(3))
+ Expect([]int{1, 2}).ShouldNot(BeEquivalentTo(nil))
+ })
+ })
+
+ Context("When asserting on type aliases", func() {
+ It("should the right thing", func() {
+ Expect(StringAlias("foo")).Should(BeEquivalentTo("foo"))
+ Expect("foo").Should(BeEquivalentTo(StringAlias("foo")))
+ Expect(StringAlias("foo")).ShouldNot(BeEquivalentTo("bar"))
+ Expect("foo").ShouldNot(BeEquivalentTo(StringAlias("bar")))
+ })
+ })
+
+ Context("When asserting on numbers", func() {
+ It("should convert actual to expected and do the right thing", func() {
+ Expect(5).Should(BeEquivalentTo(5))
+ Expect(5.0).Should(BeEquivalentTo(5.0))
+ Expect(5).Should(BeEquivalentTo(5.0))
+
+ Expect(5).ShouldNot(BeEquivalentTo("5"))
+ Expect(5).ShouldNot(BeEquivalentTo(3))
+
+ //Here be dragons!
+ Expect(5.1).Should(BeEquivalentTo(5))
+ Expect(5).ShouldNot(BeEquivalentTo(5.1))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/be_false_matcher.go b/vendor/github.com/onsi/gomega/matchers/be_false_matcher.go
new file mode 100644
index 000000000..91d3b779e
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_false_matcher.go
@@ -0,0 +1,26 @@
+package matchers
+
+import (
+ "fmt"
+
+ "github.com/onsi/gomega/format"
+)
+
+type BeFalseMatcher struct {
+}
+
+func (matcher *BeFalseMatcher) Match(actual interface{}) (success bool, err error) {
+ if !isBool(actual) {
+ return false, fmt.Errorf("Expected a boolean. Got:\n%s", format.Object(actual, 1))
+ }
+
+ return actual == false, nil
+}
+
+func (matcher *BeFalseMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to be false")
+}
+
+func (matcher *BeFalseMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to be false")
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/be_false_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_false_matcher_test.go
new file mode 100644
index 000000000..25e70633d
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_false_matcher_test.go
@@ -0,0 +1,20 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("BeFalse", func() {
+ It("should handle true and false correctly", func() {
+ Expect(true).ShouldNot(BeFalse())
+ Expect(false).Should(BeFalse())
+ })
+
+ It("should only support booleans", func() {
+ success, err := (&BeFalseMatcher{}).Match("foo")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/be_identical_to.go b/vendor/github.com/onsi/gomega/matchers/be_identical_to.go
new file mode 100644
index 000000000..fdcda4d1f
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_identical_to.go
@@ -0,0 +1,37 @@
+package matchers
+
+import (
+ "fmt"
+ "runtime"
+
+ "github.com/onsi/gomega/format"
+)
+
+type BeIdenticalToMatcher struct {
+ Expected interface{}
+}
+
+func (matcher *BeIdenticalToMatcher) Match(actual interface{}) (success bool, matchErr error) {
+ if actual == nil && matcher.Expected == nil {
+ return false, fmt.Errorf("Refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
+ }
+
+ defer func() {
+ if r := recover(); r != nil {
+ if _, ok := r.(runtime.Error); ok {
+ success = false
+ matchErr = nil
+ }
+ }
+ }()
+
+ return actual == matcher.Expected, nil
+}
+
+func (matcher *BeIdenticalToMatcher) FailureMessage(actual interface{}) string {
+ return format.Message(actual, "to be identical to", matcher.Expected)
+}
+
+func (matcher *BeIdenticalToMatcher) NegatedFailureMessage(actual interface{}) string {
+ return format.Message(actual, "not to be identical to", matcher.Expected)
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/be_identical_to_test.go b/vendor/github.com/onsi/gomega/matchers/be_identical_to_test.go
new file mode 100644
index 000000000..7fdd56eed
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_identical_to_test.go
@@ -0,0 +1,61 @@
+package matchers_test
+
+import (
+ "errors"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("BeIdenticalTo", func() {
+ Context("when asserting that nil equals nil", func() {
+ It("should error", func() {
+ success, err := (&BeIdenticalToMatcher{Expected: nil}).Match(nil)
+
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ It("should treat the same pointer to a struct as identical", func() {
+ mySpecialStruct := myCustomType{}
+ Expect(&mySpecialStruct).Should(BeIdenticalTo(&mySpecialStruct))
+ Expect(&myCustomType{}).ShouldNot(BeIdenticalTo(&mySpecialStruct))
+ })
+
+ It("should be strict about types", func() {
+ Expect(5).ShouldNot(BeIdenticalTo("5"))
+ Expect(5).ShouldNot(BeIdenticalTo(5.0))
+ Expect(5).ShouldNot(BeIdenticalTo(3))
+ })
+
+ It("should treat primtives as identical", func() {
+ Expect("5").Should(BeIdenticalTo("5"))
+ Expect("5").ShouldNot(BeIdenticalTo("55"))
+
+ Expect(5.55).Should(BeIdenticalTo(5.55))
+ Expect(5.55).ShouldNot(BeIdenticalTo(6.66))
+
+ Expect(5).Should(BeIdenticalTo(5))
+ Expect(5).ShouldNot(BeIdenticalTo(55))
+ })
+
+ It("should treat the same pointers to a slice as identical", func() {
+ mySlice := []int{1, 2}
+ Expect(&mySlice).Should(BeIdenticalTo(&mySlice))
+ Expect(&mySlice).ShouldNot(BeIdenticalTo(&[]int{1, 2}))
+ })
+
+ It("should treat the same pointers to a map as identical", func() {
+ myMap := map[string]string{"a": "b", "c": "d"}
+ Expect(&myMap).Should(BeIdenticalTo(&myMap))
+ Expect(myMap).ShouldNot(BeIdenticalTo(map[string]string{"a": "b", "c": "d"}))
+ })
+
+ It("should treat the same pointers to an error as identical", func() {
+ myError := errors.New("foo")
+ Expect(&myError).Should(BeIdenticalTo(&myError))
+ Expect(errors.New("foo")).ShouldNot(BeIdenticalTo(errors.New("bar")))
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/be_nil_matcher.go b/vendor/github.com/onsi/gomega/matchers/be_nil_matcher.go
new file mode 100644
index 000000000..7ee84fe1b
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_nil_matcher.go
@@ -0,0 +1,18 @@
+package matchers
+
+import "github.com/onsi/gomega/format"
+
+type BeNilMatcher struct {
+}
+
+func (matcher *BeNilMatcher) Match(actual interface{}) (success bool, err error) {
+ return isNil(actual), nil
+}
+
+func (matcher *BeNilMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to be nil")
+}
+
+func (matcher *BeNilMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to be nil")
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/be_nil_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_nil_matcher_test.go
new file mode 100644
index 000000000..c35aa3d7c
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_nil_matcher_test.go
@@ -0,0 +1,28 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("BeNil", func() {
+ It("should succeed when passed nil", func() {
+ Expect(nil).Should(BeNil())
+ })
+
+ It("should succeed when passed a typed nil", func() {
+ var a []int
+ Expect(a).Should(BeNil())
+ })
+
+ It("should succeed when passing nil pointer", func() {
+ var f *struct{}
+ Expect(f).Should(BeNil())
+ })
+
+ It("should not succeed when not passed nil", func() {
+ Expect(0).ShouldNot(BeNil())
+ Expect(false).ShouldNot(BeNil())
+ Expect("").ShouldNot(BeNil())
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go b/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go
new file mode 100644
index 000000000..9f4f77eec
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher.go
@@ -0,0 +1,132 @@
+package matchers
+
+import (
+ "fmt"
+ "math"
+
+ "github.com/onsi/gomega/format"
+)
+
+type BeNumericallyMatcher struct {
+ Comparator string
+ CompareTo []interface{}
+}
+
+func (matcher *BeNumericallyMatcher) FailureMessage(actual interface{}) (message string) {
+ return matcher.FormatFailureMessage(actual, false)
+}
+
+func (matcher *BeNumericallyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return matcher.FormatFailureMessage(actual, true)
+}
+
+func (matcher *BeNumericallyMatcher) FormatFailureMessage(actual interface{}, negated bool) (message string) {
+ if len(matcher.CompareTo) == 1 {
+ message = fmt.Sprintf("to be %s", matcher.Comparator)
+ } else {
+ message = fmt.Sprintf("to be within %v of %s", matcher.CompareTo[1], matcher.Comparator)
+ }
+ if negated {
+ message = "not " + message
+ }
+ return format.Message(actual, message, matcher.CompareTo[0])
+}
+
+func (matcher *BeNumericallyMatcher) Match(actual interface{}) (success bool, err error) {
+ if len(matcher.CompareTo) == 0 || len(matcher.CompareTo) > 2 {
+ return false, fmt.Errorf("BeNumerically requires 1 or 2 CompareTo arguments. Got:\n%s", format.Object(matcher.CompareTo, 1))
+ }
+ if !isNumber(actual) {
+ return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(actual, 1))
+ }
+ if !isNumber(matcher.CompareTo[0]) {
+ return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(matcher.CompareTo[0], 1))
+ }
+ if len(matcher.CompareTo) == 2 && !isNumber(matcher.CompareTo[1]) {
+ return false, fmt.Errorf("Expected a number. Got:\n%s", format.Object(matcher.CompareTo[0], 1))
+ }
+
+ switch matcher.Comparator {
+ case "==", "~", ">", ">=", "<", "<=":
+ default:
+ return false, fmt.Errorf("Unknown comparator: %s", matcher.Comparator)
+ }
+
+ if isFloat(actual) || isFloat(matcher.CompareTo[0]) {
+ var secondOperand float64 = 1e-8
+ if len(matcher.CompareTo) == 2 {
+ secondOperand = toFloat(matcher.CompareTo[1])
+ }
+ success = matcher.matchFloats(toFloat(actual), toFloat(matcher.CompareTo[0]), secondOperand)
+ } else if isInteger(actual) {
+ var secondOperand int64 = 0
+ if len(matcher.CompareTo) == 2 {
+ secondOperand = toInteger(matcher.CompareTo[1])
+ }
+ success = matcher.matchIntegers(toInteger(actual), toInteger(matcher.CompareTo[0]), secondOperand)
+ } else if isUnsignedInteger(actual) {
+ var secondOperand uint64 = 0
+ if len(matcher.CompareTo) == 2 {
+ secondOperand = toUnsignedInteger(matcher.CompareTo[1])
+ }
+ success = matcher.matchUnsignedIntegers(toUnsignedInteger(actual), toUnsignedInteger(matcher.CompareTo[0]), secondOperand)
+ } else {
+ return false, fmt.Errorf("Failed to compare:\n%s\n%s:\n%s", format.Object(actual, 1), matcher.Comparator, format.Object(matcher.CompareTo[0], 1))
+ }
+
+ return success, nil
+}
+
+func (matcher *BeNumericallyMatcher) matchIntegers(actual, compareTo, threshold int64) (success bool) {
+ switch matcher.Comparator {
+ case "==", "~":
+ diff := actual - compareTo
+ return -threshold <= diff && diff <= threshold
+ case ">":
+ return (actual > compareTo)
+ case ">=":
+ return (actual >= compareTo)
+ case "<":
+ return (actual < compareTo)
+ case "<=":
+ return (actual <= compareTo)
+ }
+ return false
+}
+
+func (matcher *BeNumericallyMatcher) matchUnsignedIntegers(actual, compareTo, threshold uint64) (success bool) {
+ switch matcher.Comparator {
+ case "==", "~":
+ if actual < compareTo {
+ actual, compareTo = compareTo, actual
+ }
+ return actual-compareTo <= threshold
+ case ">":
+ return (actual > compareTo)
+ case ">=":
+ return (actual >= compareTo)
+ case "<":
+ return (actual < compareTo)
+ case "<=":
+ return (actual <= compareTo)
+ }
+ return false
+}
+
+func (matcher *BeNumericallyMatcher) matchFloats(actual, compareTo, threshold float64) (success bool) {
+ switch matcher.Comparator {
+ case "~":
+ return math.Abs(actual-compareTo) <= threshold
+ case "==":
+ return (actual == compareTo)
+ case ">":
+ return (actual > compareTo)
+ case ">=":
+ return (actual >= compareTo)
+ case "<":
+ return (actual < compareTo)
+ case "<=":
+ return (actual <= compareTo)
+ }
+ return false
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher_test.go
new file mode 100644
index 000000000..a32d2b8b1
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_numerically_matcher_test.go
@@ -0,0 +1,172 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("BeNumerically", func() {
+ Context("when passed a number", func() {
+ It("should support ==", func() {
+ Expect(uint32(5)).Should(BeNumerically("==", 5))
+ Expect(float64(5.0)).Should(BeNumerically("==", 5))
+ Expect(int8(5)).Should(BeNumerically("==", 5))
+ })
+
+ It("should not have false positives", func() {
+ Expect(5.1).ShouldNot(BeNumerically("==", 5))
+ Expect(5).ShouldNot(BeNumerically("==", 5.1))
+ })
+
+ It("should support >", func() {
+ Expect(uint32(5)).Should(BeNumerically(">", 4))
+ Expect(float64(5.0)).Should(BeNumerically(">", 4.9))
+ Expect(int8(5)).Should(BeNumerically(">", 4))
+
+ Expect(uint32(5)).ShouldNot(BeNumerically(">", 5))
+ Expect(float64(5.0)).ShouldNot(BeNumerically(">", 5.0))
+ Expect(int8(5)).ShouldNot(BeNumerically(">", 5))
+ })
+
+ It("should support <", func() {
+ Expect(uint32(5)).Should(BeNumerically("<", 6))
+ Expect(float64(5.0)).Should(BeNumerically("<", 5.1))
+ Expect(int8(5)).Should(BeNumerically("<", 6))
+
+ Expect(uint32(5)).ShouldNot(BeNumerically("<", 5))
+ Expect(float64(5.0)).ShouldNot(BeNumerically("<", 5.0))
+ Expect(int8(5)).ShouldNot(BeNumerically("<", 5))
+ })
+
+ It("should support >=", func() {
+ Expect(uint32(5)).Should(BeNumerically(">=", 4))
+ Expect(float64(5.0)).Should(BeNumerically(">=", 4.9))
+ Expect(int8(5)).Should(BeNumerically(">=", 4))
+
+ Expect(uint32(5)).Should(BeNumerically(">=", 5))
+ Expect(float64(5.0)).Should(BeNumerically(">=", 5.0))
+ Expect(int8(5)).Should(BeNumerically(">=", 5))
+
+ Expect(uint32(5)).ShouldNot(BeNumerically(">=", 6))
+ Expect(float64(5.0)).ShouldNot(BeNumerically(">=", 5.1))
+ Expect(int8(5)).ShouldNot(BeNumerically(">=", 6))
+ })
+
+ It("should support <=", func() {
+ Expect(uint32(5)).Should(BeNumerically("<=", 6))
+ Expect(float64(5.0)).Should(BeNumerically("<=", 5.1))
+ Expect(int8(5)).Should(BeNumerically("<=", 6))
+
+ Expect(uint32(5)).Should(BeNumerically("<=", 5))
+ Expect(float64(5.0)).Should(BeNumerically("<=", 5.0))
+ Expect(int8(5)).Should(BeNumerically("<=", 5))
+
+ Expect(uint32(5)).ShouldNot(BeNumerically("<=", 4))
+ Expect(float64(5.0)).ShouldNot(BeNumerically("<=", 4.9))
+ Expect(int8(5)).Should(BeNumerically("<=", 5))
+ })
+
+ Context("when passed ~", func() {
+ Context("when passed a float", func() {
+ Context("and there is no precision parameter", func() {
+ It("should default to 1e-8", func() {
+ Expect(5.00000001).Should(BeNumerically("~", 5.00000002))
+ Expect(5.00000001).ShouldNot(BeNumerically("~", 5.0000001))
+ })
+
+ It("should show failure message", func() {
+ actual := BeNumerically("~", 4.98).FailureMessage(123)
+ expected := "Expected\n <int>: 123\nto be ~\n <float64>: 4.98"
+ Expect(actual).To(Equal(expected))
+ })
+
+ It("should show negated failure message", func() {
+ actual := BeNumerically("~", 4.98).NegatedFailureMessage(123)
+ expected := "Expected\n <int>: 123\nnot to be ~\n <float64>: 4.98"
+ Expect(actual).To(Equal(expected))
+ })
+ })
+
+ Context("and there is a precision parameter", func() {
+ It("should use the precision parameter", func() {
+ Expect(5.1).Should(BeNumerically("~", 5.19, 0.1))
+ Expect(5.1).Should(BeNumerically("~", 5.01, 0.1))
+ Expect(5.1).ShouldNot(BeNumerically("~", 5.22, 0.1))
+ Expect(5.1).ShouldNot(BeNumerically("~", 4.98, 0.1))
+ })
+
+ It("should show precision in failure message", func() {
+ actual := BeNumerically("~", 4.98, 0.1).FailureMessage(123)
+ expected := "Expected\n <int>: 123\nto be within 0.1 of ~\n <float64>: 4.98"
+ Expect(actual).To(Equal(expected))
+ })
+
+ It("should show precision in negated failure message", func() {
+ actual := BeNumerically("~", 4.98, 0.1).NegatedFailureMessage(123)
+ expected := "Expected\n <int>: 123\nnot to be within 0.1 of ~\n <float64>: 4.98"
+ Expect(actual).To(Equal(expected))
+ })
+ })
+ })
+
+ Context("when passed an int/uint", func() {
+ Context("and there is no precision parameter", func() {
+ It("should just do strict equality", func() {
+ Expect(5).Should(BeNumerically("~", 5))
+ Expect(5).ShouldNot(BeNumerically("~", 6))
+ Expect(uint(5)).ShouldNot(BeNumerically("~", 6))
+ })
+ })
+
+ Context("and there is a precision parameter", func() {
+ It("should use precision paramter", func() {
+ Expect(5).Should(BeNumerically("~", 6, 2))
+ Expect(5).ShouldNot(BeNumerically("~", 8, 2))
+ Expect(uint(5)).Should(BeNumerically("~", 6, 1))
+ })
+ })
+ })
+ })
+ })
+
+ Context("when passed a non-number", func() {
+ It("should error", func() {
+ success, err := (&BeNumericallyMatcher{Comparator: "==", CompareTo: []interface{}{5}}).Match("foo")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&BeNumericallyMatcher{Comparator: "=="}).Match(5)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&BeNumericallyMatcher{Comparator: "~", CompareTo: []interface{}{3.0, "foo"}}).Match(5.0)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&BeNumericallyMatcher{Comparator: "==", CompareTo: []interface{}{"bar"}}).Match(5)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&BeNumericallyMatcher{Comparator: "==", CompareTo: []interface{}{"bar"}}).Match("foo")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&BeNumericallyMatcher{Comparator: "==", CompareTo: []interface{}{nil}}).Match(0)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&BeNumericallyMatcher{Comparator: "==", CompareTo: []interface{}{0}}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("when passed an unsupported comparator", func() {
+ It("should error", func() {
+ success, err := (&BeNumericallyMatcher{Comparator: "!=", CompareTo: []interface{}{5}}).Match(4)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/be_sent_matcher.go b/vendor/github.com/onsi/gomega/matchers/be_sent_matcher.go
new file mode 100644
index 000000000..302dd1a0a
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_sent_matcher.go
@@ -0,0 +1,71 @@
+package matchers
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/format"
+)
+
+type BeSentMatcher struct {
+ Arg interface{}
+ channelClosed bool
+}
+
+func (matcher *BeSentMatcher) Match(actual interface{}) (success bool, err error) {
+ if !isChan(actual) {
+ return false, fmt.Errorf("BeSent expects a channel. Got:\n%s", format.Object(actual, 1))
+ }
+
+ channelType := reflect.TypeOf(actual)
+ channelValue := reflect.ValueOf(actual)
+
+ if channelType.ChanDir() == reflect.RecvDir {
+ return false, fmt.Errorf("BeSent matcher cannot be passed a receive-only channel. Got:\n%s", format.Object(actual, 1))
+ }
+
+ argType := reflect.TypeOf(matcher.Arg)
+ assignable := argType.AssignableTo(channelType.Elem())
+
+ if !assignable {
+ return false, fmt.Errorf("Cannot pass:\n%s to the channel:\n%s\nThe types don't match.", format.Object(matcher.Arg, 1), format.Object(actual, 1))
+ }
+
+ argValue := reflect.ValueOf(matcher.Arg)
+
+ defer func() {
+ if e := recover(); e != nil {
+ success = false
+ err = fmt.Errorf("Cannot send to a closed channel")
+ matcher.channelClosed = true
+ }
+ }()
+
+ winnerIndex, _, _ := reflect.Select([]reflect.SelectCase{
+ {Dir: reflect.SelectSend, Chan: channelValue, Send: argValue},
+ {Dir: reflect.SelectDefault},
+ })
+
+ var didSend bool
+ if winnerIndex == 0 {
+ didSend = true
+ }
+
+ return didSend, nil
+}
+
+func (matcher *BeSentMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to send:", matcher.Arg)
+}
+
+func (matcher *BeSentMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to send:", matcher.Arg)
+}
+
+func (matcher *BeSentMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
+ if !isChan(actual) {
+ return false
+ }
+
+ return !matcher.channelClosed
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/be_sent_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_sent_matcher_test.go
new file mode 100644
index 000000000..68ec72879
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_sent_matcher_test.go
@@ -0,0 +1,107 @@
+package matchers_test
+
+import (
+ "time"
+
+ . "github.com/onsi/gomega/matchers"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("BeSent", func() {
+ Context("when passed a channel and a matching type", func() {
+ Context("when the channel is ready to receive", func() {
+ It("should succeed and send the value down the channel", func() {
+ c := make(chan string)
+ d := make(chan string)
+ go func() {
+ val := <-c
+ d <- val
+ }()
+
+ time.Sleep(10 * time.Millisecond)
+
+ Expect(c).Should(BeSent("foo"))
+ Eventually(d).Should(Receive(Equal("foo")))
+ })
+
+ It("should succeed (with a buffered channel)", func() {
+ c := make(chan string, 1)
+ Expect(c).Should(BeSent("foo"))
+ Expect(<-c).Should(Equal("foo"))
+ })
+ })
+
+ Context("when the channel is not ready to receive", func() {
+ It("should fail and not send down the channel", func() {
+ c := make(chan string)
+ Expect(c).ShouldNot(BeSent("foo"))
+ Consistently(c).ShouldNot(Receive())
+ })
+ })
+
+ Context("when the channel is eventually ready to receive", func() {
+ It("should succeed", func() {
+ c := make(chan string)
+ d := make(chan string)
+ go func() {
+ time.Sleep(30 * time.Millisecond)
+ val := <-c
+ d <- val
+ }()
+
+ Eventually(c).Should(BeSent("foo"))
+ Eventually(d).Should(Receive(Equal("foo")))
+ })
+ })
+
+ Context("when the channel is closed", func() {
+ It("should error", func() {
+ c := make(chan string)
+ close(c)
+ success, err := (&BeSentMatcher{Arg: "foo"}).Match(c)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+
+ It("should short-circuit Eventually", func() {
+ c := make(chan string)
+ close(c)
+
+ t := time.Now()
+ failures := InterceptGomegaFailures(func() {
+ Eventually(c, 10.0).Should(BeSent("foo"))
+ })
+ Expect(failures).Should(HaveLen(1))
+ Expect(time.Since(t)).Should(BeNumerically("<", time.Second))
+ })
+ })
+ })
+
+ Context("when passed a channel and a non-matching type", func() {
+ It("should error", func() {
+ success, err := (&BeSentMatcher{Arg: "foo"}).Match(make(chan int, 1))
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("when passed a receive-only channel", func() {
+ It("should error", func() {
+ var c <-chan string
+ c = make(chan string, 1)
+ success, err := (&BeSentMatcher{Arg: "foo"}).Match(c)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("when passed a nonchannel", func() {
+ It("should error", func() {
+ success, err := (&BeSentMatcher{Arg: "foo"}).Match("bar")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/be_temporally_matcher.go b/vendor/github.com/onsi/gomega/matchers/be_temporally_matcher.go
new file mode 100644
index 000000000..cb7c038ef
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_temporally_matcher.go
@@ -0,0 +1,66 @@
+package matchers
+
+import (
+ "fmt"
+ "time"
+
+ "github.com/onsi/gomega/format"
+)
+
+type BeTemporallyMatcher struct {
+ Comparator string
+ CompareTo time.Time
+ Threshold []time.Duration
+}
+
+func (matcher *BeTemporallyMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, fmt.Sprintf("to be %s", matcher.Comparator), matcher.CompareTo)
+}
+
+func (matcher *BeTemporallyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, fmt.Sprintf("not to be %s", matcher.Comparator), matcher.CompareTo)
+}
+
+func (matcher *BeTemporallyMatcher) Match(actual interface{}) (bool, error) {
+ // predicate to test for time.Time type
+ isTime := func(t interface{}) bool {
+ _, ok := t.(time.Time)
+ return ok
+ }
+
+ if !isTime(actual) {
+ return false, fmt.Errorf("Expected a time.Time. Got:\n%s", format.Object(actual, 1))
+ }
+
+ switch matcher.Comparator {
+ case "==", "~", ">", ">=", "<", "<=":
+ default:
+ return false, fmt.Errorf("Unknown comparator: %s", matcher.Comparator)
+ }
+
+ var threshold = time.Millisecond
+ if len(matcher.Threshold) == 1 {
+ threshold = matcher.Threshold[0]
+ }
+
+ return matcher.matchTimes(actual.(time.Time), matcher.CompareTo, threshold), nil
+}
+
+func (matcher *BeTemporallyMatcher) matchTimes(actual, compareTo time.Time, threshold time.Duration) (success bool) {
+ switch matcher.Comparator {
+ case "==":
+ return actual.Equal(compareTo)
+ case "~":
+ diff := actual.Sub(compareTo)
+ return -threshold <= diff && diff <= threshold
+ case ">":
+ return actual.After(compareTo)
+ case ">=":
+ return !actual.Before(compareTo)
+ case "<":
+ return actual.Before(compareTo)
+ case "<=":
+ return !actual.After(compareTo)
+ }
+ return false
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/be_temporally_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_temporally_matcher_test.go
new file mode 100644
index 000000000..95a3a103e
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_temporally_matcher_test.go
@@ -0,0 +1,99 @@
+package matchers_test
+
+import (
+ "time"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("BeTemporally", func() {
+
+ var t0, t1, t2 time.Time
+ BeforeEach(func() {
+ t0 = time.Now()
+ t1 = t0.Add(time.Second)
+ t2 = t0.Add(-time.Second)
+ })
+
+ Context("When comparing times", func() {
+
+ It("should support ==", func() {
+ Expect(t0).Should(BeTemporally("==", t0))
+ Expect(t1).ShouldNot(BeTemporally("==", t0))
+ Expect(t0).ShouldNot(BeTemporally("==", t1))
+ Expect(t0).ShouldNot(BeTemporally("==", time.Time{}))
+ })
+
+ It("should support >", func() {
+ Expect(t0).Should(BeTemporally(">", t2))
+ Expect(t0).ShouldNot(BeTemporally(">", t0))
+ Expect(t2).ShouldNot(BeTemporally(">", t0))
+ })
+
+ It("should support <", func() {
+ Expect(t0).Should(BeTemporally("<", t1))
+ Expect(t0).ShouldNot(BeTemporally("<", t0))
+ Expect(t1).ShouldNot(BeTemporally("<", t0))
+ })
+
+ It("should support >=", func() {
+ Expect(t0).Should(BeTemporally(">=", t2))
+ Expect(t0).Should(BeTemporally(">=", t0))
+ Expect(t0).ShouldNot(BeTemporally(">=", t1))
+ })
+
+ It("should support <=", func() {
+ Expect(t0).Should(BeTemporally("<=", t1))
+ Expect(t0).Should(BeTemporally("<=", t0))
+ Expect(t0).ShouldNot(BeTemporally("<=", t2))
+ })
+
+ Context("when passed ~", func() {
+ Context("and there is no precision parameter", func() {
+ BeforeEach(func() {
+ t1 = t0.Add(time.Millisecond / 2)
+ t2 = t0.Add(-2 * time.Millisecond)
+ })
+ It("should approximate", func() {
+ Expect(t0).Should(BeTemporally("~", t0))
+ Expect(t0).Should(BeTemporally("~", t1))
+ Expect(t0).ShouldNot(BeTemporally("~", t2))
+ })
+ })
+
+ Context("and there is a precision parameter", func() {
+ BeforeEach(func() {
+ t2 = t0.Add(3 * time.Second)
+ })
+ It("should use precision paramter", func() {
+ d := 2 * time.Second
+ Expect(t0).Should(BeTemporally("~", t0, d))
+ Expect(t0).Should(BeTemporally("~", t1, d))
+ Expect(t0).ShouldNot(BeTemporally("~", t2, d))
+ })
+ })
+ })
+ })
+
+ Context("when passed a non-time", func() {
+ It("should error", func() {
+ success, err := (&BeTemporallyMatcher{Comparator: "==", CompareTo: t0}).Match("foo")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&BeTemporallyMatcher{Comparator: "=="}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("when passed an unsupported comparator", func() {
+ It("should error", func() {
+ success, err := (&BeTemporallyMatcher{Comparator: "!=", CompareTo: t0}).Match(t2)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/be_true_matcher.go b/vendor/github.com/onsi/gomega/matchers/be_true_matcher.go
new file mode 100644
index 000000000..ec57c5db4
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_true_matcher.go
@@ -0,0 +1,26 @@
+package matchers
+
+import (
+ "fmt"
+
+ "github.com/onsi/gomega/format"
+)
+
+type BeTrueMatcher struct {
+}
+
+func (matcher *BeTrueMatcher) Match(actual interface{}) (success bool, err error) {
+ if !isBool(actual) {
+ return false, fmt.Errorf("Expected a boolean. Got:\n%s", format.Object(actual, 1))
+ }
+
+ return actual.(bool), nil
+}
+
+func (matcher *BeTrueMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to be true")
+}
+
+func (matcher *BeTrueMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to be true")
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/be_true_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_true_matcher_test.go
new file mode 100644
index 000000000..9eda62c33
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_true_matcher_test.go
@@ -0,0 +1,20 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("BeTrue", func() {
+ It("should handle true and false correctly", func() {
+ Expect(true).Should(BeTrue())
+ Expect(false).ShouldNot(BeTrue())
+ })
+
+ It("should only support booleans", func() {
+ success, err := (&BeTrueMatcher{}).Match("foo")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/be_zero_matcher.go b/vendor/github.com/onsi/gomega/matchers/be_zero_matcher.go
new file mode 100644
index 000000000..26196f168
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_zero_matcher.go
@@ -0,0 +1,28 @@
+package matchers
+
+import (
+ "reflect"
+
+ "github.com/onsi/gomega/format"
+)
+
+type BeZeroMatcher struct {
+}
+
+func (matcher *BeZeroMatcher) Match(actual interface{}) (success bool, err error) {
+ if actual == nil {
+ return true, nil
+ }
+ zeroValue := reflect.Zero(reflect.TypeOf(actual)).Interface()
+
+ return reflect.DeepEqual(zeroValue, actual), nil
+
+}
+
+func (matcher *BeZeroMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to be zero-valued")
+}
+
+func (matcher *BeZeroMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to be zero-valued")
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/be_zero_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/be_zero_matcher_test.go
new file mode 100644
index 000000000..c89e10330
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/be_zero_matcher_test.go
@@ -0,0 +1,40 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("BeZero", func() {
+ It("succeeds for zero values for its type", func() {
+ Expect(nil).Should(BeZero())
+
+ Expect("").Should(BeZero())
+ Expect(" ").ShouldNot(BeZero())
+
+ Expect(0).Should(BeZero())
+ Expect(1).ShouldNot(BeZero())
+
+ Expect(0.0).Should(BeZero())
+ Expect(0.1).ShouldNot(BeZero())
+
+ // Expect([]int{}).Should(BeZero())
+ Expect([]int{1}).ShouldNot(BeZero())
+
+ // Expect(map[string]int{}).Should(BeZero())
+ Expect(map[string]int{"a": 1}).ShouldNot(BeZero())
+
+ Expect(myCustomType{}).Should(BeZero())
+ Expect(myCustomType{s: "a"}).ShouldNot(BeZero())
+ })
+
+ It("builds failure message", func() {
+ actual := BeZero().FailureMessage(123)
+ Expect(actual).To(Equal("Expected\n <int>: 123\nto be zero-valued"))
+ })
+
+ It("builds negated failure message", func() {
+ actual := BeZero().NegatedFailureMessage(123)
+ Expect(actual).To(Equal("Expected\n <int>: 123\nnot to be zero-valued"))
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/consist_of.go b/vendor/github.com/onsi/gomega/matchers/consist_of.go
new file mode 100644
index 000000000..7b0e08868
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/consist_of.go
@@ -0,0 +1,80 @@
+package matchers
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/format"
+ "github.com/onsi/gomega/matchers/support/goraph/bipartitegraph"
+)
+
+type ConsistOfMatcher struct {
+ Elements []interface{}
+}
+
+func (matcher *ConsistOfMatcher) Match(actual interface{}) (success bool, err error) {
+ if !isArrayOrSlice(actual) && !isMap(actual) {
+ return false, fmt.Errorf("ConsistOf matcher expects an array/slice/map. Got:\n%s", format.Object(actual, 1))
+ }
+
+ elements := matcher.Elements
+ if len(matcher.Elements) == 1 && isArrayOrSlice(matcher.Elements[0]) {
+ elements = []interface{}{}
+ value := reflect.ValueOf(matcher.Elements[0])
+ for i := 0; i < value.Len(); i++ {
+ elements = append(elements, value.Index(i).Interface())
+ }
+ }
+
+ matchers := []interface{}{}
+ for _, element := range elements {
+ matcher, isMatcher := element.(omegaMatcher)
+ if !isMatcher {
+ matcher = &EqualMatcher{Expected: element}
+ }
+ matchers = append(matchers, matcher)
+ }
+
+ values := matcher.valuesOf(actual)
+
+ if len(values) != len(matchers) {
+ return false, nil
+ }
+
+ neighbours := func(v, m interface{}) (bool, error) {
+ match, err := m.(omegaMatcher).Match(v)
+ return match && err == nil, nil
+ }
+
+ bipartiteGraph, err := bipartitegraph.NewBipartiteGraph(values, matchers, neighbours)
+ if err != nil {
+ return false, err
+ }
+
+ return len(bipartiteGraph.LargestMatching()) == len(values), nil
+}
+
+func (matcher *ConsistOfMatcher) valuesOf(actual interface{}) []interface{} {
+ value := reflect.ValueOf(actual)
+ values := []interface{}{}
+ if isMap(actual) {
+ keys := value.MapKeys()
+ for i := 0; i < value.Len(); i++ {
+ values = append(values, value.MapIndex(keys[i]).Interface())
+ }
+ } else {
+ for i := 0; i < value.Len(); i++ {
+ values = append(values, value.Index(i).Interface())
+ }
+ }
+
+ return values
+}
+
+func (matcher *ConsistOfMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to consist of", matcher.Elements)
+}
+
+func (matcher *ConsistOfMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to consist of", matcher.Elements)
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/consist_of_test.go b/vendor/github.com/onsi/gomega/matchers/consist_of_test.go
new file mode 100644
index 000000000..f6971c4f5
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/consist_of_test.go
@@ -0,0 +1,75 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("ConsistOf", func() {
+ Context("with a slice", func() {
+ It("should do the right thing", func() {
+ Expect([]string{"foo", "bar", "baz"}).Should(ConsistOf("foo", "bar", "baz"))
+ Expect([]string{"foo", "bar", "baz"}).Should(ConsistOf("foo", "bar", "baz"))
+ Expect([]string{"foo", "bar", "baz"}).Should(ConsistOf("baz", "bar", "foo"))
+ Expect([]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf("baz", "bar", "foo", "foo"))
+ Expect([]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf("baz", "foo"))
+ })
+ })
+
+ Context("with an array", func() {
+ It("should do the right thing", func() {
+ Expect([3]string{"foo", "bar", "baz"}).Should(ConsistOf("foo", "bar", "baz"))
+ Expect([3]string{"foo", "bar", "baz"}).Should(ConsistOf("baz", "bar", "foo"))
+ Expect([3]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf("baz", "bar", "foo", "foo"))
+ Expect([3]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf("baz", "foo"))
+ })
+ })
+
+ Context("with a map", func() {
+ It("should apply to the values", func() {
+ Expect(map[int]string{1: "foo", 2: "bar", 3: "baz"}).Should(ConsistOf("foo", "bar", "baz"))
+ Expect(map[int]string{1: "foo", 2: "bar", 3: "baz"}).Should(ConsistOf("baz", "bar", "foo"))
+ Expect(map[int]string{1: "foo", 2: "bar", 3: "baz"}).ShouldNot(ConsistOf("baz", "bar", "foo", "foo"))
+ Expect(map[int]string{1: "foo", 2: "bar", 3: "baz"}).ShouldNot(ConsistOf("baz", "foo"))
+ })
+
+ })
+
+ Context("with anything else", func() {
+ It("should error", func() {
+ failures := InterceptGomegaFailures(func() {
+ Expect("foo").Should(ConsistOf("f", "o", "o"))
+ })
+
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+
+ Context("when passed matchers", func() {
+ It("should pass if the matchers pass", func() {
+ Expect([]string{"foo", "bar", "baz"}).Should(ConsistOf("foo", MatchRegexp("^ba"), "baz"))
+ Expect([]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf("foo", MatchRegexp("^ba")))
+ Expect([]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf("foo", MatchRegexp("^ba"), MatchRegexp("foo")))
+ Expect([]string{"foo", "bar", "baz"}).Should(ConsistOf("foo", MatchRegexp("^ba"), MatchRegexp("^ba")))
+ Expect([]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf("foo", MatchRegexp("^ba"), MatchRegexp("turducken")))
+ })
+
+ It("should not depend on the order of the matchers", func() {
+ Expect([][]int{{1, 2}, {2}}).Should(ConsistOf(ContainElement(1), ContainElement(2)))
+ Expect([][]int{{1, 2}, {2}}).Should(ConsistOf(ContainElement(2), ContainElement(1)))
+ })
+
+ Context("when a matcher errors", func() {
+ It("should soldier on", func() {
+ Expect([]string{"foo", "bar", "baz"}).ShouldNot(ConsistOf(BeFalse(), "foo", "bar"))
+ Expect([]interface{}{"foo", "bar", false}).Should(ConsistOf(BeFalse(), ContainSubstring("foo"), "bar"))
+ })
+ })
+ })
+
+ Context("when passed exactly one argument, and that argument is a slice", func() {
+ It("should match against the elements of that argument", func() {
+ Expect([]string{"foo", "bar", "baz"}).Should(ConsistOf([]string{"foo", "bar", "baz"}))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/contain_element_matcher.go b/vendor/github.com/onsi/gomega/matchers/contain_element_matcher.go
new file mode 100644
index 000000000..4159335d0
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/contain_element_matcher.go
@@ -0,0 +1,56 @@
+package matchers
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/format"
+)
+
+type ContainElementMatcher struct {
+ Element interface{}
+}
+
+func (matcher *ContainElementMatcher) Match(actual interface{}) (success bool, err error) {
+ if !isArrayOrSlice(actual) && !isMap(actual) {
+ return false, fmt.Errorf("ContainElement matcher expects an array/slice/map. Got:\n%s", format.Object(actual, 1))
+ }
+
+ elemMatcher, elementIsMatcher := matcher.Element.(omegaMatcher)
+ if !elementIsMatcher {
+ elemMatcher = &EqualMatcher{Expected: matcher.Element}
+ }
+
+ value := reflect.ValueOf(actual)
+ var keys []reflect.Value
+ if isMap(actual) {
+ keys = value.MapKeys()
+ }
+ var lastError error
+ for i := 0; i < value.Len(); i++ {
+ var success bool
+ var err error
+ if isMap(actual) {
+ success, err = elemMatcher.Match(value.MapIndex(keys[i]).Interface())
+ } else {
+ success, err = elemMatcher.Match(value.Index(i).Interface())
+ }
+ if err != nil {
+ lastError = err
+ continue
+ }
+ if success {
+ return true, nil
+ }
+ }
+
+ return false, lastError
+}
+
+func (matcher *ContainElementMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to contain element matching", matcher.Element)
+}
+
+func (matcher *ContainElementMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to contain element matching", matcher.Element)
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/contain_element_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/contain_element_matcher_test.go
new file mode 100644
index 000000000..60fb55e96
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/contain_element_matcher_test.go
@@ -0,0 +1,76 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("ContainElement", func() {
+ Context("when passed a supported type", func() {
+ Context("and expecting a non-matcher", func() {
+ It("should do the right thing", func() {
+ Expect([2]int{1, 2}).Should(ContainElement(2))
+ Expect([2]int{1, 2}).ShouldNot(ContainElement(3))
+
+ Expect([]int{1, 2}).Should(ContainElement(2))
+ Expect([]int{1, 2}).ShouldNot(ContainElement(3))
+
+ Expect(map[string]int{"foo": 1, "bar": 2}).Should(ContainElement(2))
+ Expect(map[int]int{3: 1, 4: 2}).ShouldNot(ContainElement(3))
+
+ arr := make([]myCustomType, 2)
+ arr[0] = myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}
+ arr[1] = myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "c"}}
+ Expect(arr).Should(ContainElement(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}))
+ Expect(arr).ShouldNot(ContainElement(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"b", "c"}}))
+ })
+ })
+
+ Context("and expecting a matcher", func() {
+ It("should pass each element through the matcher", func() {
+ Expect([]int{1, 2, 3}).Should(ContainElement(BeNumerically(">=", 3)))
+ Expect([]int{1, 2, 3}).ShouldNot(ContainElement(BeNumerically(">", 3)))
+ Expect(map[string]int{"foo": 1, "bar": 2}).Should(ContainElement(BeNumerically(">=", 2)))
+ Expect(map[string]int{"foo": 1, "bar": 2}).ShouldNot(ContainElement(BeNumerically(">", 2)))
+ })
+
+ It("should power through even if the matcher ever fails", func() {
+ Expect([]interface{}{1, 2, "3", 4}).Should(ContainElement(BeNumerically(">=", 3)))
+ })
+
+ It("should fail if the matcher fails", func() {
+ actual := []interface{}{1, 2, "3", "4"}
+ success, err := (&ContainElementMatcher{Element: BeNumerically(">=", 3)}).Match(actual)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+ })
+
+ Context("when passed a correctly typed nil", func() {
+ It("should operate succesfully on the passed in value", func() {
+ var nilSlice []int
+ Expect(nilSlice).ShouldNot(ContainElement(1))
+
+ var nilMap map[int]string
+ Expect(nilMap).ShouldNot(ContainElement("foo"))
+ })
+ })
+
+ Context("when passed an unsupported type", func() {
+ It("should error", func() {
+ success, err := (&ContainElementMatcher{Element: 0}).Match(0)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&ContainElementMatcher{Element: 0}).Match("abc")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&ContainElementMatcher{Element: 0}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/contain_substring_matcher.go b/vendor/github.com/onsi/gomega/matchers/contain_substring_matcher.go
new file mode 100644
index 000000000..f8dc41e74
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/contain_substring_matcher.go
@@ -0,0 +1,38 @@
+package matchers
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/onsi/gomega/format"
+)
+
+type ContainSubstringMatcher struct {
+ Substr string
+ Args []interface{}
+}
+
+func (matcher *ContainSubstringMatcher) Match(actual interface{}) (success bool, err error) {
+ actualString, ok := toString(actual)
+ if !ok {
+ return false, fmt.Errorf("ContainSubstring matcher requires a string or stringer. Got:\n%s", format.Object(actual, 1))
+ }
+
+ return strings.Contains(actualString, matcher.stringToMatch()), nil
+}
+
+func (matcher *ContainSubstringMatcher) stringToMatch() string {
+ stringToMatch := matcher.Substr
+ if len(matcher.Args) > 0 {
+ stringToMatch = fmt.Sprintf(matcher.Substr, matcher.Args...)
+ }
+ return stringToMatch
+}
+
+func (matcher *ContainSubstringMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to contain substring", matcher.stringToMatch())
+}
+
+func (matcher *ContainSubstringMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to contain substring", matcher.stringToMatch())
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/contain_substring_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/contain_substring_matcher_test.go
new file mode 100644
index 000000000..efffb4732
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/contain_substring_matcher_test.go
@@ -0,0 +1,36 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("ContainSubstringMatcher", func() {
+ Context("when actual is a string", func() {
+ It("should match against the string", func() {
+ Expect("Marvelous").Should(ContainSubstring("rve"))
+ Expect("Marvelous").ShouldNot(ContainSubstring("boo"))
+ })
+ })
+
+ Context("when the matcher is called with multiple arguments", func() {
+ It("should pass the string and arguments to sprintf", func() {
+ Expect("Marvelous3").Should(ContainSubstring("velous%d", 3))
+ })
+ })
+
+ Context("when actual is a stringer", func() {
+ It("should call the stringer and match agains the returned string", func() {
+ Expect(&myStringer{a: "Abc3"}).Should(ContainSubstring("bc3"))
+ })
+ })
+
+ Context("when actual is neither a string nor a stringer", func() {
+ It("should error", func() {
+ success, err := (&ContainSubstringMatcher{Substr: "2"}).Match(2)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/equal_matcher.go b/vendor/github.com/onsi/gomega/matchers/equal_matcher.go
new file mode 100644
index 000000000..befb7bdfd
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/equal_matcher.go
@@ -0,0 +1,42 @@
+package matchers
+
+import (
+ "bytes"
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/format"
+)
+
+type EqualMatcher struct {
+ Expected interface{}
+}
+
+func (matcher *EqualMatcher) Match(actual interface{}) (success bool, err error) {
+ if actual == nil && matcher.Expected == nil {
+ return false, fmt.Errorf("Refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.")
+ }
+ // Shortcut for byte slices.
+ // Comparing long byte slices with reflect.DeepEqual is very slow,
+ // so use bytes.Equal if actual and expected are both byte slices.
+ if actualByteSlice, ok := actual.([]byte); ok {
+ if expectedByteSlice, ok := matcher.Expected.([]byte); ok {
+ return bytes.Equal(actualByteSlice, expectedByteSlice), nil
+ }
+ }
+ return reflect.DeepEqual(actual, matcher.Expected), nil
+}
+
+func (matcher *EqualMatcher) FailureMessage(actual interface{}) (message string) {
+ actualString, actualOK := actual.(string)
+ expectedString, expectedOK := matcher.Expected.(string)
+ if actualOK && expectedOK {
+ return format.MessageWithDiff(actualString, "to equal", expectedString)
+ }
+
+ return format.Message(actual, "to equal", matcher.Expected)
+}
+
+func (matcher *EqualMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to equal", matcher.Expected)
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/equal_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/equal_matcher_test.go
new file mode 100644
index 000000000..3ab991e4f
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/equal_matcher_test.go
@@ -0,0 +1,80 @@
+package matchers_test
+
+import (
+ "errors"
+ "strings"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("Equal", func() {
+ Context("when asserting that nil equals nil", func() {
+ It("should error", func() {
+ success, err := (&EqualMatcher{Expected: nil}).Match(nil)
+
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("When asserting equality between objects", func() {
+ It("should do the right thing", func() {
+ Expect(5).Should(Equal(5))
+ Expect(5.0).Should(Equal(5.0))
+
+ Expect(5).ShouldNot(Equal("5"))
+ Expect(5).ShouldNot(Equal(5.0))
+ Expect(5).ShouldNot(Equal(3))
+
+ Expect("5").Should(Equal("5"))
+ Expect([]int{1, 2}).Should(Equal([]int{1, 2}))
+ Expect([]int{1, 2}).ShouldNot(Equal([]int{2, 1}))
+ Expect([]byte{'f', 'o', 'o'}).Should(Equal([]byte{'f', 'o', 'o'}))
+ Expect([]byte{'f', 'o', 'o'}).ShouldNot(Equal([]byte{'b', 'a', 'r'}))
+ Expect(map[string]string{"a": "b", "c": "d"}).Should(Equal(map[string]string{"a": "b", "c": "d"}))
+ Expect(map[string]string{"a": "b", "c": "d"}).ShouldNot(Equal(map[string]string{"a": "b", "c": "e"}))
+ Expect(errors.New("foo")).Should(Equal(errors.New("foo")))
+ Expect(errors.New("foo")).ShouldNot(Equal(errors.New("bar")))
+
+ Expect(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}).Should(Equal(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}))
+ Expect(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}).ShouldNot(Equal(myCustomType{s: "bar", n: 3, f: 2.0, arr: []string{"a", "b"}}))
+ Expect(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}).ShouldNot(Equal(myCustomType{s: "foo", n: 2, f: 2.0, arr: []string{"a", "b"}}))
+ Expect(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}).ShouldNot(Equal(myCustomType{s: "foo", n: 3, f: 3.0, arr: []string{"a", "b"}}))
+ Expect(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b"}}).ShouldNot(Equal(myCustomType{s: "foo", n: 3, f: 2.0, arr: []string{"a", "b", "c"}}))
+ })
+ })
+
+ Describe("failure messages", func() {
+ It("shows the two strings simply when they are short", func() {
+ subject := EqualMatcher{Expected: "eric"}
+
+ failureMessage := subject.FailureMessage("tim")
+ Expect(failureMessage).To(BeEquivalentTo(expectedShortStringFailureMessage))
+ })
+
+ It("shows the exact point where two long strings differ", func() {
+ stringWithB := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+ stringWithZ := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+
+ subject := EqualMatcher{Expected: stringWithZ}
+
+ failureMessage := subject.FailureMessage(stringWithB)
+ Expect(failureMessage).To(BeEquivalentTo(expectedLongStringFailureMessage))
+ })
+ })
+})
+
+var expectedShortStringFailureMessage = strings.TrimSpace(`
+Expected
+ <string>: tim
+to equal
+ <string>: eric
+`)
+var expectedLongStringFailureMessage = strings.TrimSpace(`
+Expected
+ <string>: "...aaaaabaaaaa..."
+to equal |
+ <string>: "...aaaaazaaaaa..."
+`)
diff --git a/vendor/github.com/onsi/gomega/matchers/have_cap_matcher.go b/vendor/github.com/onsi/gomega/matchers/have_cap_matcher.go
new file mode 100644
index 000000000..7ace93dc3
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/have_cap_matcher.go
@@ -0,0 +1,28 @@
+package matchers
+
+import (
+ "fmt"
+
+ "github.com/onsi/gomega/format"
+)
+
+type HaveCapMatcher struct {
+ Count int
+}
+
+func (matcher *HaveCapMatcher) Match(actual interface{}) (success bool, err error) {
+ length, ok := capOf(actual)
+ if !ok {
+ return false, fmt.Errorf("HaveCap matcher expects a array/channel/slice. Got:\n%s", format.Object(actual, 1))
+ }
+
+ return length == matcher.Count, nil
+}
+
+func (matcher *HaveCapMatcher) FailureMessage(actual interface{}) (message string) {
+ return fmt.Sprintf("Expected\n%s\nto have capacity %d", format.Object(actual, 1), matcher.Count)
+}
+
+func (matcher *HaveCapMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return fmt.Sprintf("Expected\n%s\nnot to have capacity %d", format.Object(actual, 1), matcher.Count)
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/have_cap_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/have_cap_matcher_test.go
new file mode 100644
index 000000000..8a61f2e2c
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/have_cap_matcher_test.go
@@ -0,0 +1,50 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("HaveCap", func() {
+ Context("when passed a supported type", func() {
+ It("should do the right thing", func() {
+ Expect([0]int{}).Should(HaveCap(0))
+ Expect([2]int{1}).Should(HaveCap(2))
+
+ Expect([]int{}).Should(HaveCap(0))
+ Expect([]int{1, 2, 3, 4, 5}[:2]).Should(HaveCap(5))
+ Expect(make([]int, 0, 5)).Should(HaveCap(5))
+
+ c := make(chan bool, 3)
+ Expect(c).Should(HaveCap(3))
+ c <- true
+ c <- true
+ Expect(c).Should(HaveCap(3))
+
+ Expect(make(chan bool)).Should(HaveCap(0))
+ })
+ })
+
+ Context("when passed a correctly typed nil", func() {
+ It("should operate succesfully on the passed in value", func() {
+ var nilSlice []int
+ Expect(nilSlice).Should(HaveCap(0))
+
+ var nilChan chan int
+ Expect(nilChan).Should(HaveCap(0))
+ })
+ })
+
+ Context("when passed an unsupported type", func() {
+ It("should error", func() {
+ success, err := (&HaveCapMatcher{Count: 0}).Match(0)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&HaveCapMatcher{Count: 0}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/have_key_matcher.go b/vendor/github.com/onsi/gomega/matchers/have_key_matcher.go
new file mode 100644
index 000000000..ea5b92336
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/have_key_matcher.go
@@ -0,0 +1,54 @@
+package matchers
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/format"
+)
+
+type HaveKeyMatcher struct {
+ Key interface{}
+}
+
+func (matcher *HaveKeyMatcher) Match(actual interface{}) (success bool, err error) {
+ if !isMap(actual) {
+ return false, fmt.Errorf("HaveKey matcher expects a map. Got:%s", format.Object(actual, 1))
+ }
+
+ keyMatcher, keyIsMatcher := matcher.Key.(omegaMatcher)
+ if !keyIsMatcher {
+ keyMatcher = &EqualMatcher{Expected: matcher.Key}
+ }
+
+ keys := reflect.ValueOf(actual).MapKeys()
+ for i := 0; i < len(keys); i++ {
+ success, err := keyMatcher.Match(keys[i].Interface())
+ if err != nil {
+ return false, fmt.Errorf("HaveKey's key matcher failed with:\n%s%s", format.Indent, err.Error())
+ }
+ if success {
+ return true, nil
+ }
+ }
+
+ return false, nil
+}
+
+func (matcher *HaveKeyMatcher) FailureMessage(actual interface{}) (message string) {
+ switch matcher.Key.(type) {
+ case omegaMatcher:
+ return format.Message(actual, "to have key matching", matcher.Key)
+ default:
+ return format.Message(actual, "to have key", matcher.Key)
+ }
+}
+
+func (matcher *HaveKeyMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ switch matcher.Key.(type) {
+ case omegaMatcher:
+ return format.Message(actual, "not to have key matching", matcher.Key)
+ default:
+ return format.Message(actual, "not to have key", matcher.Key)
+ }
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/have_key_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/have_key_matcher_test.go
new file mode 100644
index 000000000..0f1561b7d
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/have_key_matcher_test.go
@@ -0,0 +1,73 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("HaveKey", func() {
+ var (
+ stringKeys map[string]int
+ intKeys map[int]string
+ objKeys map[*myCustomType]string
+
+ customA *myCustomType
+ customB *myCustomType
+ )
+ BeforeEach(func() {
+ stringKeys = map[string]int{"foo": 2, "bar": 3}
+ intKeys = map[int]string{2: "foo", 3: "bar"}
+
+ customA = &myCustomType{s: "a", n: 2, f: 2.3, arr: []string{"ice", "cream"}}
+ customB = &myCustomType{s: "b", n: 4, f: 3.1, arr: []string{"cake"}}
+ objKeys = map[*myCustomType]string{customA: "aardvark", customB: "kangaroo"}
+ })
+
+ Context("when passed a map", func() {
+ It("should do the right thing", func() {
+ Expect(stringKeys).Should(HaveKey("foo"))
+ Expect(stringKeys).ShouldNot(HaveKey("baz"))
+
+ Expect(intKeys).Should(HaveKey(2))
+ Expect(intKeys).ShouldNot(HaveKey(4))
+
+ Expect(objKeys).Should(HaveKey(customA))
+ Expect(objKeys).Should(HaveKey(&myCustomType{s: "b", n: 4, f: 3.1, arr: []string{"cake"}}))
+ Expect(objKeys).ShouldNot(HaveKey(&myCustomType{s: "b", n: 4, f: 3.1, arr: []string{"apple", "pie"}}))
+ })
+ })
+
+ Context("when passed a correctly typed nil", func() {
+ It("should operate succesfully on the passed in value", func() {
+ var nilMap map[int]string
+ Expect(nilMap).ShouldNot(HaveKey("foo"))
+ })
+ })
+
+ Context("when the passed in key is actually a matcher", func() {
+ It("should pass each element through the matcher", func() {
+ Expect(stringKeys).Should(HaveKey(ContainSubstring("oo")))
+ Expect(stringKeys).ShouldNot(HaveKey(ContainSubstring("foobar")))
+ })
+
+ It("should fail if the matcher ever fails", func() {
+ actual := map[int]string{1: "a", 3: "b", 2: "c"}
+ success, err := (&HaveKeyMatcher{Key: ContainSubstring("ar")}).Match(actual)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("when passed something that is not a map", func() {
+ It("should error", func() {
+ success, err := (&HaveKeyMatcher{Key: "foo"}).Match([]string{"foo"})
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&HaveKeyMatcher{Key: "foo"}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/have_key_with_value_matcher.go b/vendor/github.com/onsi/gomega/matchers/have_key_with_value_matcher.go
new file mode 100644
index 000000000..06355b1e9
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/have_key_with_value_matcher.go
@@ -0,0 +1,74 @@
+package matchers
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/format"
+)
+
+type HaveKeyWithValueMatcher struct {
+ Key interface{}
+ Value interface{}
+}
+
+func (matcher *HaveKeyWithValueMatcher) Match(actual interface{}) (success bool, err error) {
+ if !isMap(actual) {
+ return false, fmt.Errorf("HaveKeyWithValue matcher expects a map. Got:%s", format.Object(actual, 1))
+ }
+
+ keyMatcher, keyIsMatcher := matcher.Key.(omegaMatcher)
+ if !keyIsMatcher {
+ keyMatcher = &EqualMatcher{Expected: matcher.Key}
+ }
+
+ valueMatcher, valueIsMatcher := matcher.Value.(omegaMatcher)
+ if !valueIsMatcher {
+ valueMatcher = &EqualMatcher{Expected: matcher.Value}
+ }
+
+ keys := reflect.ValueOf(actual).MapKeys()
+ for i := 0; i < len(keys); i++ {
+ success, err := keyMatcher.Match(keys[i].Interface())
+ if err != nil {
+ return false, fmt.Errorf("HaveKeyWithValue's key matcher failed with:\n%s%s", format.Indent, err.Error())
+ }
+ if success {
+ actualValue := reflect.ValueOf(actual).MapIndex(keys[i])
+ success, err := valueMatcher.Match(actualValue.Interface())
+ if err != nil {
+ return false, fmt.Errorf("HaveKeyWithValue's value matcher failed with:\n%s%s", format.Indent, err.Error())
+ }
+ return success, nil
+ }
+ }
+
+ return false, nil
+}
+
+func (matcher *HaveKeyWithValueMatcher) FailureMessage(actual interface{}) (message string) {
+ str := "to have {key: value}"
+ if _, ok := matcher.Key.(omegaMatcher); ok {
+ str += " matching"
+ } else if _, ok := matcher.Value.(omegaMatcher); ok {
+ str += " matching"
+ }
+
+ expect := make(map[interface{}]interface{}, 1)
+ expect[matcher.Key] = matcher.Value
+ return format.Message(actual, str, expect)
+}
+
+func (matcher *HaveKeyWithValueMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ kStr := "not to have key"
+ if _, ok := matcher.Key.(omegaMatcher); ok {
+ kStr = "not to have key matching"
+ }
+
+ vStr := "or that key's value not be"
+ if _, ok := matcher.Value.(omegaMatcher); ok {
+ vStr = "or to have that key's value not matching"
+ }
+
+ return format.Message(actual, kStr, matcher.Key, vStr, matcher.Value)
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/have_key_with_value_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/have_key_with_value_matcher_test.go
new file mode 100644
index 000000000..0a49ec993
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/have_key_with_value_matcher_test.go
@@ -0,0 +1,82 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("HaveKeyWithValue", func() {
+ var (
+ stringKeys map[string]int
+ intKeys map[int]string
+ objKeys map[*myCustomType]*myCustomType
+
+ customA *myCustomType
+ customB *myCustomType
+ )
+ BeforeEach(func() {
+ stringKeys = map[string]int{"foo": 2, "bar": 3}
+ intKeys = map[int]string{2: "foo", 3: "bar"}
+
+ customA = &myCustomType{s: "a", n: 2, f: 2.3, arr: []string{"ice", "cream"}}
+ customB = &myCustomType{s: "b", n: 4, f: 3.1, arr: []string{"cake"}}
+ objKeys = map[*myCustomType]*myCustomType{customA: customA, customB: customA}
+ })
+
+ Context("when passed a map", func() {
+ It("should do the right thing", func() {
+ Expect(stringKeys).Should(HaveKeyWithValue("foo", 2))
+ Expect(stringKeys).ShouldNot(HaveKeyWithValue("foo", 1))
+ Expect(stringKeys).ShouldNot(HaveKeyWithValue("baz", 2))
+ Expect(stringKeys).ShouldNot(HaveKeyWithValue("baz", 1))
+
+ Expect(intKeys).Should(HaveKeyWithValue(2, "foo"))
+ Expect(intKeys).ShouldNot(HaveKeyWithValue(4, "foo"))
+ Expect(intKeys).ShouldNot(HaveKeyWithValue(2, "baz"))
+
+ Expect(objKeys).Should(HaveKeyWithValue(customA, customA))
+ Expect(objKeys).Should(HaveKeyWithValue(&myCustomType{s: "b", n: 4, f: 3.1, arr: []string{"cake"}}, &myCustomType{s: "a", n: 2, f: 2.3, arr: []string{"ice", "cream"}}))
+ Expect(objKeys).ShouldNot(HaveKeyWithValue(&myCustomType{s: "b", n: 4, f: 3.1, arr: []string{"apple", "pie"}}, customA))
+ })
+ })
+
+ Context("when passed a correctly typed nil", func() {
+ It("should operate succesfully on the passed in value", func() {
+ var nilMap map[int]string
+ Expect(nilMap).ShouldNot(HaveKeyWithValue("foo", "bar"))
+ })
+ })
+
+ Context("when the passed in key or value is actually a matcher", func() {
+ It("should pass each element through the matcher", func() {
+ Expect(stringKeys).Should(HaveKeyWithValue(ContainSubstring("oo"), 2))
+ Expect(intKeys).Should(HaveKeyWithValue(2, ContainSubstring("oo")))
+ Expect(stringKeys).ShouldNot(HaveKeyWithValue(ContainSubstring("foobar"), 2))
+ })
+
+ It("should fail if the matcher ever fails", func() {
+ actual := map[int]string{1: "a", 3: "b", 2: "c"}
+ success, err := (&HaveKeyWithValueMatcher{Key: ContainSubstring("ar"), Value: 2}).Match(actual)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ otherActual := map[string]int{"a": 1, "b": 2, "c": 3}
+ success, err = (&HaveKeyWithValueMatcher{Key: "a", Value: ContainSubstring("1")}).Match(otherActual)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("when passed something that is not a map", func() {
+ It("should error", func() {
+ success, err := (&HaveKeyWithValueMatcher{Key: "foo", Value: "bar"}).Match([]string{"foo"})
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&HaveKeyWithValueMatcher{Key: "foo", Value: "bar"}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/have_len_matcher.go b/vendor/github.com/onsi/gomega/matchers/have_len_matcher.go
new file mode 100644
index 000000000..ee4276189
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/have_len_matcher.go
@@ -0,0 +1,28 @@
+package matchers
+
+import (
+ "fmt"
+
+ "github.com/onsi/gomega/format"
+)
+
+type HaveLenMatcher struct {
+ Count int
+}
+
+func (matcher *HaveLenMatcher) Match(actual interface{}) (success bool, err error) {
+ length, ok := lengthOf(actual)
+ if !ok {
+ return false, fmt.Errorf("HaveLen matcher expects a string/array/map/channel/slice. Got:\n%s", format.Object(actual, 1))
+ }
+
+ return length == matcher.Count, nil
+}
+
+func (matcher *HaveLenMatcher) FailureMessage(actual interface{}) (message string) {
+ return fmt.Sprintf("Expected\n%s\nto have length %d", format.Object(actual, 1), matcher.Count)
+}
+
+func (matcher *HaveLenMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return fmt.Sprintf("Expected\n%s\nnot to have length %d", format.Object(actual, 1), matcher.Count)
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/have_len_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/have_len_matcher_test.go
new file mode 100644
index 000000000..c60f63886
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/have_len_matcher_test.go
@@ -0,0 +1,53 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("HaveLen", func() {
+ Context("when passed a supported type", func() {
+ It("should do the right thing", func() {
+ Expect("").Should(HaveLen(0))
+ Expect("AA").Should(HaveLen(2))
+
+ Expect([0]int{}).Should(HaveLen(0))
+ Expect([2]int{1, 2}).Should(HaveLen(2))
+
+ Expect([]int{}).Should(HaveLen(0))
+ Expect([]int{1, 2, 3}).Should(HaveLen(3))
+
+ Expect(map[string]int{}).Should(HaveLen(0))
+ Expect(map[string]int{"a": 1, "b": 2, "c": 3, "d": 4}).Should(HaveLen(4))
+
+ c := make(chan bool, 3)
+ Expect(c).Should(HaveLen(0))
+ c <- true
+ c <- true
+ Expect(c).Should(HaveLen(2))
+ })
+ })
+
+ Context("when passed a correctly typed nil", func() {
+ It("should operate succesfully on the passed in value", func() {
+ var nilSlice []int
+ Expect(nilSlice).Should(HaveLen(0))
+
+ var nilMap map[int]string
+ Expect(nilMap).Should(HaveLen(0))
+ })
+ })
+
+ Context("when passed an unsupported type", func() {
+ It("should error", func() {
+ success, err := (&HaveLenMatcher{Count: 0}).Match(0)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&HaveLenMatcher{Count: 0}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/have_occurred_matcher.go b/vendor/github.com/onsi/gomega/matchers/have_occurred_matcher.go
new file mode 100644
index 000000000..ebdd71786
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/have_occurred_matcher.go
@@ -0,0 +1,33 @@
+package matchers
+
+import (
+ "fmt"
+
+ "github.com/onsi/gomega/format"
+)
+
+type HaveOccurredMatcher struct {
+}
+
+func (matcher *HaveOccurredMatcher) Match(actual interface{}) (success bool, err error) {
+ // is purely nil?
+ if actual == nil {
+ return false, nil
+ }
+
+ // must be an 'error' type
+ if !isError(actual) {
+ return false, fmt.Errorf("Expected an error-type. Got:\n%s", format.Object(actual, 1))
+ }
+
+ // must be non-nil (or a pointer to a non-nil)
+ return !isNil(actual), nil
+}
+
+func (matcher *HaveOccurredMatcher) FailureMessage(actual interface{}) (message string) {
+ return fmt.Sprintf("Expected an error to have occurred. Got:\n%s", format.Object(actual, 1))
+}
+
+func (matcher *HaveOccurredMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return fmt.Sprintf("Expected error:\n%s\n%s\n%s", format.Object(actual, 1), format.IndentString(actual.(error).Error(), 1), "not to have occurred")
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/have_occurred_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/have_occurred_matcher_test.go
new file mode 100644
index 000000000..0ad632ec1
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/have_occurred_matcher_test.go
@@ -0,0 +1,59 @@
+package matchers_test
+
+import (
+ "errors"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+type CustomErr struct {
+ msg string
+}
+
+func (e *CustomErr) Error() string {
+ return e.msg
+}
+
+var _ = Describe("HaveOccurred", func() {
+ It("should succeed if matching an error", func() {
+ Expect(errors.New("Foo")).Should(HaveOccurred())
+ })
+
+ It("should not succeed with nil", func() {
+ Expect(nil).ShouldNot(HaveOccurred())
+ })
+
+ It("should only support errors and nil", func() {
+ success, err := (&HaveOccurredMatcher{}).Match("foo")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&HaveOccurredMatcher{}).Match("")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+
+ It("doesn't support non-error type", func() {
+ success, err := (&HaveOccurredMatcher{}).Match(AnyType{})
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(MatchError("Expected an error-type. Got:\n <matchers_test.AnyType>: {}"))
+ })
+
+ It("doesn't support non-error pointer type", func() {
+ success, err := (&HaveOccurredMatcher{}).Match(&AnyType{})
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(MatchError(MatchRegexp(`Expected an error-type. Got:\n <*matchers_test.AnyType | 0x[[:xdigit:]]+>: {}`)))
+ })
+
+ It("should succeed with pointer types that conform to error interface", func() {
+ err := &CustomErr{"ohai"}
+ Expect(err).Should(HaveOccurred())
+ })
+
+ It("should not succeed with nil pointers to types that conform to error interface", func() {
+ var err *CustomErr = nil
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/have_prefix_matcher.go b/vendor/github.com/onsi/gomega/matchers/have_prefix_matcher.go
new file mode 100644
index 000000000..1d8e80270
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/have_prefix_matcher.go
@@ -0,0 +1,36 @@
+package matchers
+
+import (
+ "fmt"
+
+ "github.com/onsi/gomega/format"
+)
+
+type HavePrefixMatcher struct {
+ Prefix string
+ Args []interface{}
+}
+
+func (matcher *HavePrefixMatcher) Match(actual interface{}) (success bool, err error) {
+ actualString, ok := toString(actual)
+ if !ok {
+ return false, fmt.Errorf("HavePrefix matcher requires a string or stringer. Got:\n%s", format.Object(actual, 1))
+ }
+ prefix := matcher.prefix()
+ return len(actualString) >= len(prefix) && actualString[0:len(prefix)] == prefix, nil
+}
+
+func (matcher *HavePrefixMatcher) prefix() string {
+ if len(matcher.Args) > 0 {
+ return fmt.Sprintf(matcher.Prefix, matcher.Args...)
+ }
+ return matcher.Prefix
+}
+
+func (matcher *HavePrefixMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to have prefix", matcher.prefix())
+}
+
+func (matcher *HavePrefixMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to have prefix", matcher.prefix())
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/have_prefix_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/have_prefix_matcher_test.go
new file mode 100644
index 000000000..fe29b7b5d
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/have_prefix_matcher_test.go
@@ -0,0 +1,36 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("HavePrefixMatcher", func() {
+ Context("when actual is a string", func() {
+ It("should match a string prefix", func() {
+ Expect("Ab").Should(HavePrefix("A"))
+ Expect("A").ShouldNot(HavePrefix("Ab"))
+ })
+ })
+
+ Context("when the matcher is called with multiple arguments", func() {
+ It("should pass the string and arguments to sprintf", func() {
+ Expect("C3PO").Should(HavePrefix("C%dP", 3))
+ })
+ })
+
+ Context("when actual is a stringer", func() {
+ It("should call the stringer and match against the returned string", func() {
+ Expect(&myStringer{a: "Ab"}).Should(HavePrefix("A"))
+ })
+ })
+
+ Context("when actual is neither a string nor a stringer", func() {
+ It("should error", func() {
+ success, err := (&HavePrefixMatcher{Prefix: "2"}).Match(2)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/have_suffix_matcher.go b/vendor/github.com/onsi/gomega/matchers/have_suffix_matcher.go
new file mode 100644
index 000000000..40a3526eb
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/have_suffix_matcher.go
@@ -0,0 +1,36 @@
+package matchers
+
+import (
+ "fmt"
+
+ "github.com/onsi/gomega/format"
+)
+
+type HaveSuffixMatcher struct {
+ Suffix string
+ Args []interface{}
+}
+
+func (matcher *HaveSuffixMatcher) Match(actual interface{}) (success bool, err error) {
+ actualString, ok := toString(actual)
+ if !ok {
+ return false, fmt.Errorf("HaveSuffix matcher requires a string or stringer. Got:\n%s", format.Object(actual, 1))
+ }
+ suffix := matcher.suffix()
+ return len(actualString) >= len(suffix) && actualString[len(actualString)-len(suffix):] == suffix, nil
+}
+
+func (matcher *HaveSuffixMatcher) suffix() string {
+ if len(matcher.Args) > 0 {
+ return fmt.Sprintf(matcher.Suffix, matcher.Args...)
+ }
+ return matcher.Suffix
+}
+
+func (matcher *HaveSuffixMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to have suffix", matcher.suffix())
+}
+
+func (matcher *HaveSuffixMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to have suffix", matcher.suffix())
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/have_suffix_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/have_suffix_matcher_test.go
new file mode 100644
index 000000000..2ae29821a
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/have_suffix_matcher_test.go
@@ -0,0 +1,36 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("HaveSuffixMatcher", func() {
+ Context("when actual is a string", func() {
+ It("should match a string suffix", func() {
+ Expect("Ab").Should(HaveSuffix("b"))
+ Expect("A").ShouldNot(HaveSuffix("Ab"))
+ })
+ })
+
+ Context("when the matcher is called with multiple arguments", func() {
+ It("should pass the string and arguments to sprintf", func() {
+ Expect("C3PO").Should(HaveSuffix("%dPO", 3))
+ })
+ })
+
+ Context("when actual is a stringer", func() {
+ It("should call the stringer and match against the returned string", func() {
+ Expect(&myStringer{a: "Ab"}).Should(HaveSuffix("b"))
+ })
+ })
+
+ Context("when actual is neither a string nor a stringer", func() {
+ It("should error", func() {
+ success, err := (&HaveSuffixMatcher{Suffix: "2"}).Match(2)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go b/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go
new file mode 100644
index 000000000..07499ac95
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/match_error_matcher.go
@@ -0,0 +1,51 @@
+package matchers
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/format"
+)
+
+type MatchErrorMatcher struct {
+ Expected interface{}
+}
+
+func (matcher *MatchErrorMatcher) Match(actual interface{}) (success bool, err error) {
+ if isNil(actual) {
+ return false, fmt.Errorf("Expected an error, got nil")
+ }
+
+ if !isError(actual) {
+ return false, fmt.Errorf("Expected an error. Got:\n%s", format.Object(actual, 1))
+ }
+
+ actualErr := actual.(error)
+
+ if isError(matcher.Expected) {
+ return reflect.DeepEqual(actualErr, matcher.Expected), nil
+ }
+
+ if isString(matcher.Expected) {
+ return actualErr.Error() == matcher.Expected, nil
+ }
+
+ var subMatcher omegaMatcher
+ var hasSubMatcher bool
+ if matcher.Expected != nil {
+ subMatcher, hasSubMatcher = (matcher.Expected).(omegaMatcher)
+ if hasSubMatcher {
+ return subMatcher.Match(actualErr.Error())
+ }
+ }
+
+ return false, fmt.Errorf("MatchError must be passed an error, string, or Matcher that can match on strings. Got:\n%s", format.Object(matcher.Expected, 1))
+}
+
+func (matcher *MatchErrorMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to match error", matcher.Expected)
+}
+
+func (matcher *MatchErrorMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to match error", matcher.Expected)
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/match_error_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/match_error_matcher_test.go
new file mode 100644
index 000000000..9bf89fc46
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/match_error_matcher_test.go
@@ -0,0 +1,107 @@
+package matchers_test
+
+import (
+ "errors"
+ "fmt"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+type CustomError struct {
+}
+
+func (c CustomError) Error() string {
+ return "an error"
+}
+
+var _ = Describe("MatchErrorMatcher", func() {
+ Context("When asserting against an error", func() {
+ It("should succeed when matching with an error", func() {
+ err := errors.New("an error")
+ fmtErr := fmt.Errorf("an error")
+ customErr := CustomError{}
+
+ Expect(err).Should(MatchError(errors.New("an error")))
+ Expect(err).ShouldNot(MatchError(errors.New("another error")))
+
+ Expect(fmtErr).Should(MatchError(errors.New("an error")))
+ Expect(customErr).Should(MatchError(CustomError{}))
+ })
+
+ It("should succeed when matching with a string", func() {
+ err := errors.New("an error")
+ fmtErr := fmt.Errorf("an error")
+ customErr := CustomError{}
+
+ Expect(err).Should(MatchError("an error"))
+ Expect(err).ShouldNot(MatchError("another error"))
+
+ Expect(fmtErr).Should(MatchError("an error"))
+ Expect(customErr).Should(MatchError("an error"))
+ })
+
+ Context("when passed a matcher", func() {
+ It("should pass if the matcher passes against the error string", func() {
+ err := errors.New("error 123 abc")
+
+ Expect(err).Should(MatchError(MatchRegexp(`\d{3}`)))
+ })
+
+ It("should fail if the matcher fails against the error string", func() {
+ err := errors.New("no digits")
+ Expect(err).ShouldNot(MatchError(MatchRegexp(`\d`)))
+ })
+ })
+
+ It("should fail when passed anything else", func() {
+ actualErr := errors.New("an error")
+ _, err := (&MatchErrorMatcher{
+ Expected: []byte("an error"),
+ }).Match(actualErr)
+ Expect(err).Should(HaveOccurred())
+
+ _, err = (&MatchErrorMatcher{
+ Expected: 3,
+ }).Match(actualErr)
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("when passed nil", func() {
+ It("should fail", func() {
+ _, err := (&MatchErrorMatcher{
+ Expected: "an error",
+ }).Match(nil)
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("when passed a non-error", func() {
+ It("should fail", func() {
+ _, err := (&MatchErrorMatcher{
+ Expected: "an error",
+ }).Match("an error")
+ Expect(err).Should(HaveOccurred())
+
+ _, err = (&MatchErrorMatcher{
+ Expected: "an error",
+ }).Match(3)
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("when passed an error that is also a string", func() {
+ It("should use it as an error", func() {
+ var e mockErr = "mockErr"
+
+ // this fails if the matcher casts e to a string before comparison
+ Expect(e).Should(MatchError(e))
+ })
+ })
+})
+
+type mockErr string
+
+func (m mockErr) Error() string { return string(m) }
diff --git a/vendor/github.com/onsi/gomega/matchers/match_json_matcher.go b/vendor/github.com/onsi/gomega/matchers/match_json_matcher.go
new file mode 100644
index 000000000..f962f139f
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/match_json_matcher.go
@@ -0,0 +1,65 @@
+package matchers
+
+import (
+ "bytes"
+ "encoding/json"
+ "fmt"
+
+ "github.com/onsi/gomega/format"
+)
+
+type MatchJSONMatcher struct {
+ JSONToMatch interface{}
+ firstFailurePath []interface{}
+}
+
+func (matcher *MatchJSONMatcher) Match(actual interface{}) (success bool, err error) {
+ actualString, expectedString, err := matcher.prettyPrint(actual)
+ if err != nil {
+ return false, err
+ }
+
+ var aval interface{}
+ var eval interface{}
+
+ // this is guarded by prettyPrint
+ json.Unmarshal([]byte(actualString), &aval)
+ json.Unmarshal([]byte(expectedString), &eval)
+ var equal bool
+ equal, matcher.firstFailurePath = deepEqual(aval, eval)
+ return equal, nil
+}
+
+func (matcher *MatchJSONMatcher) FailureMessage(actual interface{}) (message string) {
+ actualString, expectedString, _ := matcher.prettyPrint(actual)
+ return formattedMessage(format.Message(actualString, "to match JSON of", expectedString), matcher.firstFailurePath)
+}
+
+func (matcher *MatchJSONMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ actualString, expectedString, _ := matcher.prettyPrint(actual)
+ return formattedMessage(format.Message(actualString, "not to match JSON of", expectedString), matcher.firstFailurePath)
+}
+
+func (matcher *MatchJSONMatcher) prettyPrint(actual interface{}) (actualFormatted, expectedFormatted string, err error) {
+ actualString, ok := toString(actual)
+ if !ok {
+ return "", "", fmt.Errorf("MatchJSONMatcher matcher requires a string, stringer, or []byte. Got actual:\n%s", format.Object(actual, 1))
+ }
+ expectedString, ok := toString(matcher.JSONToMatch)
+ if !ok {
+ return "", "", fmt.Errorf("MatchJSONMatcher matcher requires a string, stringer, or []byte. Got expected:\n%s", format.Object(matcher.JSONToMatch, 1))
+ }
+
+ abuf := new(bytes.Buffer)
+ ebuf := new(bytes.Buffer)
+
+ if err := json.Indent(abuf, []byte(actualString), "", " "); err != nil {
+ return "", "", fmt.Errorf("Actual '%s' should be valid JSON, but it is not.\nUnderlying error:%s", actualString, err)
+ }
+
+ if err := json.Indent(ebuf, []byte(expectedString), "", " "); err != nil {
+ return "", "", fmt.Errorf("Expected '%s' should be valid JSON, but it is not.\nUnderlying error:%s", expectedString, err)
+ }
+
+ return abuf.String(), ebuf.String(), nil
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/match_json_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/match_json_matcher_test.go
new file mode 100644
index 000000000..4a1a9db20
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/match_json_matcher_test.go
@@ -0,0 +1,103 @@
+package matchers_test
+
+import (
+ "encoding/json"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("MatchJSONMatcher", func() {
+ Context("When passed stringifiables", func() {
+ It("should succeed if the JSON matches", func() {
+ Expect("{}").Should(MatchJSON("{}"))
+ Expect(`{"a":1}`).Should(MatchJSON(`{"a":1}`))
+ Expect(`{
+ "a":1
+ }`).Should(MatchJSON(`{"a":1}`))
+ Expect(`{"a":1, "b":2}`).Should(MatchJSON(`{"b":2, "a":1}`))
+ Expect(`{"a":1}`).ShouldNot(MatchJSON(`{"b":2, "a":1}`))
+
+ Expect(`{"a":"a", "b":"b"}`).ShouldNot(MatchJSON(`{"a":"a", "b":"b", "c":"c"}`))
+ Expect(`{"a":"a", "b":"b", "c":"c"}`).ShouldNot(MatchJSON(`{"a":"a", "b":"b"}`))
+
+ Expect(`{"a":null, "b":null}`).ShouldNot(MatchJSON(`{"c":"c", "d":"d"}`))
+ Expect(`{"a":null, "b":null, "c":null}`).ShouldNot(MatchJSON(`{"a":null, "b":null, "d":null}`))
+ })
+
+ It("should work with byte arrays", func() {
+ Expect([]byte("{}")).Should(MatchJSON([]byte("{}")))
+ Expect("{}").Should(MatchJSON([]byte("{}")))
+ Expect([]byte("{}")).Should(MatchJSON("{}"))
+ })
+
+ It("should work with json.RawMessage", func() {
+ Expect([]byte(`{"a": 1}`)).Should(MatchJSON(json.RawMessage(`{"a": 1}`)))
+ })
+ })
+
+ Context("when a key mismatch is found", func() {
+ It("reports the first found mismatch", func() {
+ subject := MatchJSONMatcher{JSONToMatch: `5`}
+ actual := `7`
+ subject.Match(actual)
+
+ failureMessage := subject.FailureMessage(`7`)
+ Expect(failureMessage).ToNot(ContainSubstring("first mismatched key"))
+
+ subject = MatchJSONMatcher{JSONToMatch: `{"a": 1, "b.g": {"c": 2, "1": ["hello", "see ya"]}}`}
+ actual = `{"a": 1, "b.g": {"c": 2, "1": ["hello", "goodbye"]}}`
+ subject.Match(actual)
+
+ failureMessage = subject.FailureMessage(actual)
+ Expect(failureMessage).To(ContainSubstring(`first mismatched key: "b.g"."1"[1]`))
+ })
+ })
+
+ Context("when the expected is not valid JSON", func() {
+ It("should error and explain why", func() {
+ success, err := (&MatchJSONMatcher{JSONToMatch: `{}`}).Match(`oops`)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("Actual 'oops' should be valid JSON"))
+ })
+ })
+
+ Context("when the actual is not valid JSON", func() {
+ It("should error and explain why", func() {
+ success, err := (&MatchJSONMatcher{JSONToMatch: `oops`}).Match(`{}`)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("Expected 'oops' should be valid JSON"))
+ })
+ })
+
+ Context("when the expected is neither a string nor a stringer nor a byte array", func() {
+ It("should error", func() {
+ success, err := (&MatchJSONMatcher{JSONToMatch: 2}).Match("{}")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("MatchJSONMatcher matcher requires a string, stringer, or []byte. Got expected:\n <int>: 2"))
+
+ success, err = (&MatchJSONMatcher{JSONToMatch: nil}).Match("{}")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("MatchJSONMatcher matcher requires a string, stringer, or []byte. Got expected:\n <nil>: nil"))
+ })
+ })
+
+ Context("when the actual is neither a string nor a stringer nor a byte array", func() {
+ It("should error", func() {
+ success, err := (&MatchJSONMatcher{JSONToMatch: "{}"}).Match(2)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("MatchJSONMatcher matcher requires a string, stringer, or []byte. Got actual:\n <int>: 2"))
+
+ success, err = (&MatchJSONMatcher{JSONToMatch: "{}"}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("MatchJSONMatcher matcher requires a string, stringer, or []byte. Got actual:\n <nil>: nil"))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/match_regexp_matcher.go b/vendor/github.com/onsi/gomega/matchers/match_regexp_matcher.go
new file mode 100644
index 000000000..adac5db6b
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/match_regexp_matcher.go
@@ -0,0 +1,43 @@
+package matchers
+
+import (
+ "fmt"
+ "regexp"
+
+ "github.com/onsi/gomega/format"
+)
+
+type MatchRegexpMatcher struct {
+ Regexp string
+ Args []interface{}
+}
+
+func (matcher *MatchRegexpMatcher) Match(actual interface{}) (success bool, err error) {
+ actualString, ok := toString(actual)
+ if !ok {
+ return false, fmt.Errorf("RegExp matcher requires a string or stringer.\nGot:%s", format.Object(actual, 1))
+ }
+
+ match, err := regexp.Match(matcher.regexp(), []byte(actualString))
+ if err != nil {
+ return false, fmt.Errorf("RegExp match failed to compile with error:\n\t%s", err.Error())
+ }
+
+ return match, nil
+}
+
+func (matcher *MatchRegexpMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to match regular expression", matcher.regexp())
+}
+
+func (matcher *MatchRegexpMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "not to match regular expression", matcher.regexp())
+}
+
+func (matcher *MatchRegexpMatcher) regexp() string {
+ re := matcher.Regexp
+ if len(matcher.Args) > 0 {
+ re = fmt.Sprintf(matcher.Regexp, matcher.Args...)
+ }
+ return re
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/match_regexp_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/match_regexp_matcher_test.go
new file mode 100644
index 000000000..ac2538bb4
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/match_regexp_matcher_test.go
@@ -0,0 +1,44 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("MatchRegexp", func() {
+ Context("when actual is a string", func() {
+ It("should match against the string", func() {
+ Expect(" a2!bla").Should(MatchRegexp(`\d!`))
+ Expect(" a2!bla").ShouldNot(MatchRegexp(`[A-Z]`))
+ })
+ })
+
+ Context("when actual is a stringer", func() {
+ It("should call the stringer and match agains the returned string", func() {
+ Expect(&myStringer{a: "Abc3"}).Should(MatchRegexp(`[A-Z][a-z]+\d`))
+ })
+ })
+
+ Context("when the matcher is called with multiple arguments", func() {
+ It("should pass the string and arguments to sprintf", func() {
+ Expect(" a23!bla").Should(MatchRegexp(`\d%d!`, 3))
+ })
+ })
+
+ Context("when actual is neither a string nor a stringer", func() {
+ It("should error", func() {
+ success, err := (&MatchRegexpMatcher{Regexp: `\d`}).Match(2)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("when the passed in regexp fails to compile", func() {
+ It("should error", func() {
+ success, err := (&MatchRegexpMatcher{Regexp: "("}).Match("Foo")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/match_xml_matcher.go b/vendor/github.com/onsi/gomega/matchers/match_xml_matcher.go
new file mode 100644
index 000000000..3b412ce81
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/match_xml_matcher.go
@@ -0,0 +1,134 @@
+package matchers
+
+import (
+ "bytes"
+ "encoding/xml"
+ "errors"
+ "fmt"
+ "io"
+ "reflect"
+ "sort"
+ "strings"
+
+ "github.com/onsi/gomega/format"
+ "golang.org/x/net/html/charset"
+)
+
+type MatchXMLMatcher struct {
+ XMLToMatch interface{}
+}
+
+func (matcher *MatchXMLMatcher) Match(actual interface{}) (success bool, err error) {
+ actualString, expectedString, err := matcher.formattedPrint(actual)
+ if err != nil {
+ return false, err
+ }
+
+ aval, err := parseXmlContent(actualString)
+ if err != nil {
+ return false, fmt.Errorf("Actual '%s' should be valid XML, but it is not.\nUnderlying error:%s", actualString, err)
+ }
+
+ eval, err := parseXmlContent(expectedString)
+ if err != nil {
+ return false, fmt.Errorf("Expected '%s' should be valid XML, but it is not.\nUnderlying error:%s", expectedString, err)
+ }
+
+ return reflect.DeepEqual(aval, eval), nil
+}
+
+func (matcher *MatchXMLMatcher) FailureMessage(actual interface{}) (message string) {
+ actualString, expectedString, _ := matcher.formattedPrint(actual)
+ return fmt.Sprintf("Expected\n%s\nto match XML of\n%s", actualString, expectedString)
+}
+
+func (matcher *MatchXMLMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ actualString, expectedString, _ := matcher.formattedPrint(actual)
+ return fmt.Sprintf("Expected\n%s\nnot to match XML of\n%s", actualString, expectedString)
+}
+
+func (matcher *MatchXMLMatcher) formattedPrint(actual interface{}) (actualString, expectedString string, err error) {
+ var ok bool
+ actualString, ok = toString(actual)
+ if !ok {
+ return "", "", fmt.Errorf("MatchXMLMatcher matcher requires a string, stringer, or []byte. Got actual:\n%s", format.Object(actual, 1))
+ }
+ expectedString, ok = toString(matcher.XMLToMatch)
+ if !ok {
+ return "", "", fmt.Errorf("MatchXMLMatcher matcher requires a string, stringer, or []byte. Got expected:\n%s", format.Object(matcher.XMLToMatch, 1))
+ }
+ return actualString, expectedString, nil
+}
+
+func parseXmlContent(content string) (*xmlNode, error) {
+ allNodes := []*xmlNode{}
+
+ dec := newXmlDecoder(strings.NewReader(content))
+ for {
+ tok, err := dec.Token()
+ if err != nil {
+ if err == io.EOF {
+ break
+ }
+ return nil, fmt.Errorf("failed to decode next token: %v", err)
+ }
+
+ lastNodeIndex := len(allNodes) - 1
+ var lastNode *xmlNode
+ if len(allNodes) > 0 {
+ lastNode = allNodes[lastNodeIndex]
+ } else {
+ lastNode = &xmlNode{}
+ }
+
+ switch tok := tok.(type) {
+ case xml.StartElement:
+ attrs := attributesSlice(tok.Attr)
+ sort.Sort(attrs)
+ allNodes = append(allNodes, &xmlNode{XMLName: tok.Name, XMLAttr: tok.Attr})
+ case xml.EndElement:
+ if len(allNodes) > 1 {
+ allNodes[lastNodeIndex-1].Nodes = append(allNodes[lastNodeIndex-1].Nodes, lastNode)
+ allNodes = allNodes[:lastNodeIndex]
+ }
+ case xml.CharData:
+ lastNode.Content = append(lastNode.Content, tok.Copy()...)
+ case xml.Comment:
+ lastNode.Comments = append(lastNode.Comments, tok.Copy())
+ case xml.ProcInst:
+ lastNode.ProcInsts = append(lastNode.ProcInsts, tok.Copy())
+ }
+ }
+
+ if len(allNodes) == 0 {
+ return nil, errors.New("found no nodes")
+ }
+ firstNode := allNodes[0]
+ trimParentNodesContentSpaces(firstNode)
+
+ return firstNode, nil
+}
+
+func newXmlDecoder(reader io.Reader) *xml.Decoder {
+ dec := xml.NewDecoder(reader)
+ dec.CharsetReader = charset.NewReaderLabel
+ return dec
+}
+
+func trimParentNodesContentSpaces(node *xmlNode) {
+ if len(node.Nodes) > 0 {
+ node.Content = bytes.TrimSpace(node.Content)
+ for _, childNode := range node.Nodes {
+ trimParentNodesContentSpaces(childNode)
+ }
+ }
+}
+
+type xmlNode struct {
+ XMLName xml.Name
+ Comments []xml.Comment
+ ProcInsts []xml.ProcInst
+ XMLAttr []xml.Attr
+ Content []byte
+ Nodes []*xmlNode
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/match_xml_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/match_xml_matcher_test.go
new file mode 100644
index 000000000..0b559b22e
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/match_xml_matcher_test.go
@@ -0,0 +1,97 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("MatchXMLMatcher", func() {
+
+ var (
+ sample_01 = readFileContents("test_data/xml/sample_01.xml")
+ sample_02 = readFileContents("test_data/xml/sample_02.xml")
+ sample_03 = readFileContents("test_data/xml/sample_03.xml")
+ sample_04 = readFileContents("test_data/xml/sample_04.xml")
+ sample_05 = readFileContents("test_data/xml/sample_05.xml")
+ sample_06 = readFileContents("test_data/xml/sample_06.xml")
+ sample_07 = readFileContents("test_data/xml/sample_07.xml")
+ sample_08 = readFileContents("test_data/xml/sample_08.xml")
+ sample_09 = readFileContents("test_data/xml/sample_09.xml")
+ sample_10 = readFileContents("test_data/xml/sample_10.xml")
+ sample_11 = readFileContents("test_data/xml/sample_11.xml")
+ )
+
+ Context("When passed stringifiables", func() {
+ It("matches documents regardless of the attribute order", func() {
+ a := `<a foo="bar" ka="boom"></a>`
+ b := `<a ka="boom" foo="bar"></a>`
+ Expect(b).Should(MatchXML(a))
+ Expect(a).Should(MatchXML(b))
+ })
+
+ It("should succeed if the XML matches", func() {
+ Expect(sample_01).Should(MatchXML(sample_01)) // same XML
+ Expect(sample_01).Should(MatchXML(sample_02)) // same XML with blank lines
+ Expect(sample_01).Should(MatchXML(sample_03)) // same XML with different formatting
+ Expect(sample_01).ShouldNot(MatchXML(sample_04)) // same structures with different values
+ Expect(sample_01).ShouldNot(MatchXML(sample_05)) // different structures
+ Expect(sample_06).ShouldNot(MatchXML(sample_07)) // same xml names with different namespaces
+ Expect(sample_07).ShouldNot(MatchXML(sample_08)) // same structures with different values
+ Expect(sample_09).ShouldNot(MatchXML(sample_10)) // same structures with different attribute values
+ Expect(sample_11).Should(MatchXML(sample_11)) // with non UTF-8 encoding
+ })
+
+ It("should work with byte arrays", func() {
+ Expect([]byte(sample_01)).Should(MatchXML([]byte(sample_01)))
+ Expect([]byte(sample_01)).Should(MatchXML(sample_01))
+ Expect(sample_01).Should(MatchXML([]byte(sample_01)))
+ })
+ })
+
+ Context("when the expected is not valid XML", func() {
+ It("should error and explain why", func() {
+ success, err := (&MatchXMLMatcher{XMLToMatch: sample_01}).Match(`oops`)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("Actual 'oops' should be valid XML"))
+ })
+ })
+
+ Context("when the actual is not valid XML", func() {
+ It("should error and explain why", func() {
+ success, err := (&MatchXMLMatcher{XMLToMatch: `oops`}).Match(sample_01)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("Expected 'oops' should be valid XML"))
+ })
+ })
+
+ Context("when the expected is neither a string nor a stringer nor a byte array", func() {
+ It("should error", func() {
+ success, err := (&MatchXMLMatcher{XMLToMatch: 2}).Match(sample_01)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("MatchXMLMatcher matcher requires a string, stringer, or []byte. Got expected:\n <int>: 2"))
+
+ success, err = (&MatchXMLMatcher{XMLToMatch: nil}).Match(sample_01)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("MatchXMLMatcher matcher requires a string, stringer, or []byte. Got expected:\n <nil>: nil"))
+ })
+ })
+
+ Context("when the actual is neither a string nor a stringer nor a byte array", func() {
+ It("should error", func() {
+ success, err := (&MatchXMLMatcher{XMLToMatch: sample_01}).Match(2)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("MatchXMLMatcher matcher requires a string, stringer, or []byte. Got actual:\n <int>: 2"))
+
+ success, err = (&MatchXMLMatcher{XMLToMatch: sample_01}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("MatchXMLMatcher matcher requires a string, stringer, or []byte. Got actual:\n <nil>: nil"))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/match_yaml_matcher.go b/vendor/github.com/onsi/gomega/matchers/match_yaml_matcher.go
new file mode 100644
index 000000000..0c83c2b63
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/match_yaml_matcher.go
@@ -0,0 +1,76 @@
+package matchers
+
+import (
+ "fmt"
+ "strings"
+
+ "github.com/onsi/gomega/format"
+ "gopkg.in/yaml.v2"
+)
+
+type MatchYAMLMatcher struct {
+ YAMLToMatch interface{}
+ firstFailurePath []interface{}
+}
+
+func (matcher *MatchYAMLMatcher) Match(actual interface{}) (success bool, err error) {
+ actualString, expectedString, err := matcher.toStrings(actual)
+ if err != nil {
+ return false, err
+ }
+
+ var aval interface{}
+ var eval interface{}
+
+ if err := yaml.Unmarshal([]byte(actualString), &aval); err != nil {
+ return false, fmt.Errorf("Actual '%s' should be valid YAML, but it is not.\nUnderlying error:%s", actualString, err)
+ }
+ if err := yaml.Unmarshal([]byte(expectedString), &eval); err != nil {
+ return false, fmt.Errorf("Expected '%s' should be valid YAML, but it is not.\nUnderlying error:%s", expectedString, err)
+ }
+
+ var equal bool
+ equal, matcher.firstFailurePath = deepEqual(aval, eval)
+ return equal, nil
+}
+
+func (matcher *MatchYAMLMatcher) FailureMessage(actual interface{}) (message string) {
+ actualString, expectedString, _ := matcher.toNormalisedStrings(actual)
+ return formattedMessage(format.Message(actualString, "to match YAML of", expectedString), matcher.firstFailurePath)
+}
+
+func (matcher *MatchYAMLMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ actualString, expectedString, _ := matcher.toNormalisedStrings(actual)
+ return formattedMessage(format.Message(actualString, "not to match YAML of", expectedString), matcher.firstFailurePath)
+}
+
+func (matcher *MatchYAMLMatcher) toNormalisedStrings(actual interface{}) (actualFormatted, expectedFormatted string, err error) {
+ actualString, expectedString, err := matcher.toStrings(actual)
+ return normalise(actualString), normalise(expectedString), err
+}
+
+func normalise(input string) string {
+ var val interface{}
+ err := yaml.Unmarshal([]byte(input), &val)
+ if err != nil {
+ panic(err) // unreachable since Match already calls Unmarshal
+ }
+ output, err := yaml.Marshal(val)
+ if err != nil {
+ panic(err) // untested section, unreachable since we Unmarshal above
+ }
+ return strings.TrimSpace(string(output))
+}
+
+func (matcher *MatchYAMLMatcher) toStrings(actual interface{}) (actualFormatted, expectedFormatted string, err error) {
+ actualString, ok := toString(actual)
+ if !ok {
+ return "", "", fmt.Errorf("MatchYAMLMatcher matcher requires a string, stringer, or []byte. Got actual:\n%s", format.Object(actual, 1))
+ }
+ expectedString, ok := toString(matcher.YAMLToMatch)
+ if !ok {
+ return "", "", fmt.Errorf("MatchYAMLMatcher matcher requires a string, stringer, or []byte. Got expected:\n%s", format.Object(matcher.YAMLToMatch, 1))
+ }
+
+ return actualString, expectedString, nil
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/match_yaml_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/match_yaml_matcher_test.go
new file mode 100644
index 000000000..1b0044fd0
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/match_yaml_matcher_test.go
@@ -0,0 +1,101 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("MatchYAMLMatcher", func() {
+ Context("When passed stringifiables", func() {
+ It("should succeed if the YAML matches", func() {
+ Expect("---").Should(MatchYAML(""))
+ Expect("a: 1").Should(MatchYAML(`{"a":1}`))
+ Expect("a: 1\nb: 2").Should(MatchYAML(`{"b":2, "a":1}`))
+ })
+
+ It("should explain if the YAML does not match when it should", func() {
+ message := (&MatchYAMLMatcher{YAMLToMatch: "a: 1"}).FailureMessage("b: 2")
+ Expect(message).To(MatchRegexp(`Expected\s+<string>: b: 2\s+to match YAML of\s+<string>: a: 1`))
+ })
+
+ It("should normalise the expected and actual when explaining if the YAML does not match when it should", func() {
+ message := (&MatchYAMLMatcher{YAMLToMatch: "a: 'one'"}).FailureMessage("{b: two}")
+ Expect(message).To(MatchRegexp(`Expected\s+<string>: b: two\s+to match YAML of\s+<string>: a: one`))
+ })
+
+ It("should explain if the YAML matches when it should not", func() {
+ message := (&MatchYAMLMatcher{YAMLToMatch: "a: 1"}).NegatedFailureMessage("a: 1")
+ Expect(message).To(MatchRegexp(`Expected\s+<string>: a: 1\s+not to match YAML of\s+<string>: a: 1`))
+ })
+
+ It("should normalise the expected and actual when explaining if the YAML matches when it should not", func() {
+ message := (&MatchYAMLMatcher{YAMLToMatch: "a: 'one'"}).NegatedFailureMessage("{a: one}")
+ Expect(message).To(MatchRegexp(`Expected\s+<string>: a: one\s+not to match YAML of\s+<string>: a: one`))
+ })
+
+ It("should fail if the YAML does not match", func() {
+ Expect("a: 1").ShouldNot(MatchYAML(`{"b":2, "a":1}`))
+ })
+
+ It("should work with byte arrays", func() {
+ Expect([]byte("a: 1")).Should(MatchYAML([]byte("a: 1")))
+ Expect("a: 1").Should(MatchYAML([]byte("a: 1")))
+ Expect([]byte("a: 1")).Should(MatchYAML("a: 1"))
+ })
+ })
+
+ Context("when the expected is not valid YAML", func() {
+ It("should error and explain why", func() {
+ success, err := (&MatchYAMLMatcher{YAMLToMatch: ""}).Match("good:\nbad")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("Actual 'good:\nbad' should be valid YAML"))
+ })
+ })
+
+ Context("when the actual is not valid YAML", func() {
+ It("should error and explain why", func() {
+ success, err := (&MatchYAMLMatcher{YAMLToMatch: "good:\nbad"}).Match("")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("Expected 'good:\nbad' should be valid YAML"))
+ })
+
+ It("errors when passed directly to Message", func() {
+ Expect(func() {
+ matcher := MatchYAMLMatcher{YAMLToMatch: "good"}
+ matcher.FailureMessage("good:\nbad")
+ }).To(Panic())
+ })
+ })
+
+ Context("when the expected is neither a string nor a stringer nor a byte array", func() {
+ It("should error", func() {
+ success, err := (&MatchYAMLMatcher{YAMLToMatch: 2}).Match("")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("MatchYAMLMatcher matcher requires a string, stringer, or []byte. Got expected:\n <int>: 2"))
+
+ success, err = (&MatchYAMLMatcher{YAMLToMatch: nil}).Match("")
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("MatchYAMLMatcher matcher requires a string, stringer, or []byte. Got expected:\n <nil>: nil"))
+ })
+ })
+
+ Context("when the actual is neither a string nor a stringer nor a byte array", func() {
+ It("should error", func() {
+ success, err := (&MatchYAMLMatcher{YAMLToMatch: ""}).Match(2)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("MatchYAMLMatcher matcher requires a string, stringer, or []byte. Got actual:\n <int>: 2"))
+
+ success, err = (&MatchYAMLMatcher{YAMLToMatch: ""}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ Expect(err.Error()).Should(ContainSubstring("MatchYAMLMatcher matcher requires a string, stringer, or []byte. Got actual:\n <nil>: nil"))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/matcher_tests_suite_test.go b/vendor/github.com/onsi/gomega/matchers/matcher_tests_suite_test.go
new file mode 100644
index 000000000..b5f76c995
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/matcher_tests_suite_test.go
@@ -0,0 +1,50 @@
+package matchers_test
+
+import (
+ "fmt"
+ "io/ioutil"
+ "os"
+ "testing"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+type myStringer struct {
+ a string
+}
+
+func (s *myStringer) String() string {
+ return s.a
+}
+
+type StringAlias string
+
+type myCustomType struct {
+ s string
+ n int
+ f float32
+ arr []string
+}
+
+func Test(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Gomega Matchers")
+}
+
+func readFileContents(filePath string) []byte {
+ f := openFile(filePath)
+ b, err := ioutil.ReadAll(f)
+ if err != nil {
+ panic(fmt.Errorf("failed to read file contents: %v", err))
+ }
+ return b
+}
+
+func openFile(filePath string) *os.File {
+ f, err := os.Open(filePath)
+ if err != nil {
+ panic(fmt.Errorf("failed to open file: %v", err))
+ }
+ return f
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/not.go b/vendor/github.com/onsi/gomega/matchers/not.go
new file mode 100644
index 000000000..2c91670bd
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/not.go
@@ -0,0 +1,30 @@
+package matchers
+
+import (
+ "github.com/onsi/gomega/internal/oraclematcher"
+ "github.com/onsi/gomega/types"
+)
+
+type NotMatcher struct {
+ Matcher types.GomegaMatcher
+}
+
+func (m *NotMatcher) Match(actual interface{}) (bool, error) {
+ success, err := m.Matcher.Match(actual)
+ if err != nil {
+ return false, err
+ }
+ return !success, nil
+}
+
+func (m *NotMatcher) FailureMessage(actual interface{}) (message string) {
+ return m.Matcher.NegatedFailureMessage(actual) // works beautifully
+}
+
+func (m *NotMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return m.Matcher.FailureMessage(actual) // works beautifully
+}
+
+func (m *NotMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
+ return oraclematcher.MatchMayChangeInTheFuture(m.Matcher, actual) // just return m.Matcher's value
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/not_test.go b/vendor/github.com/onsi/gomega/matchers/not_test.go
new file mode 100644
index 000000000..06d3ebd17
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/not_test.go
@@ -0,0 +1,64 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("NotMatcher", func() {
+ Context("basic examples", func() {
+ It("works", func() {
+ Expect(input).To(Not(false1))
+ Expect(input).To(Not(Not(true2)))
+ Expect(input).ToNot(Not(true3))
+ Expect(input).ToNot(Not(Not(false1)))
+ Expect(input).To(Not(Not(Not(false2))))
+ })
+
+ It("fails on error", func() {
+ failuresMessages := InterceptGomegaFailures(func() {
+ Expect(input).To(Not(Panic()))
+ })
+ Expect(failuresMessages).To(Equal([]string{"PanicMatcher expects a function. Got:\n <string>: hi"}))
+ })
+ })
+
+ Context("De Morgan's laws", func() {
+ It("~(A && B) == ~A || ~B", func() {
+ Expect(input).To(Not(And(false1, false2)))
+ Expect(input).To(Or(Not(false1), Not(false2)))
+ })
+ It("~(A || B) == ~A && ~B", func() {
+ Expect(input).To(Not(Or(false1, false2)))
+ Expect(input).To(And(Not(false1), Not(false2)))
+ })
+ })
+
+ Context("failure messages are opposite of original matchers' failure messages", func() {
+ Context("when match fails", func() {
+ It("gives a descriptive message", func() {
+ verifyFailureMessage(Not(HaveLen(2)), input, "not to have length 2")
+ })
+ })
+
+ Context("when match succeeds, but expected it to fail", func() {
+ It("gives a descriptive message", func() {
+ verifyFailureMessage(Not(Not(HaveLen(3))), input, "to have length 3")
+ })
+ })
+ })
+
+ Context("MatchMayChangeInTheFuture()", func() {
+ It("Propagates value from wrapped matcher", func() {
+ m := Not(Or()) // an empty Or() always returns false, and indicates it cannot change
+ Expect(m.Match("anything")).To(BeTrue())
+ Expect(m.(*NotMatcher).MatchMayChangeInTheFuture("anything")).To(BeFalse())
+ })
+ It("Defaults to true", func() {
+ m := Not(Equal(1)) // Equal does not have this method
+ Expect(m.Match(2)).To(BeTrue())
+ Expect(m.(*NotMatcher).MatchMayChangeInTheFuture(2)).To(BeTrue()) // defaults to true
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/or.go b/vendor/github.com/onsi/gomega/matchers/or.go
new file mode 100644
index 000000000..3bf799800
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/or.go
@@ -0,0 +1,67 @@
+package matchers
+
+import (
+ "fmt"
+
+ "github.com/onsi/gomega/format"
+ "github.com/onsi/gomega/internal/oraclematcher"
+ "github.com/onsi/gomega/types"
+)
+
+type OrMatcher struct {
+ Matchers []types.GomegaMatcher
+
+ // state
+ firstSuccessfulMatcher types.GomegaMatcher
+}
+
+func (m *OrMatcher) Match(actual interface{}) (success bool, err error) {
+ m.firstSuccessfulMatcher = nil
+ for _, matcher := range m.Matchers {
+ success, err := matcher.Match(actual)
+ if err != nil {
+ return false, err
+ }
+ if success {
+ m.firstSuccessfulMatcher = matcher
+ return true, nil
+ }
+ }
+ return false, nil
+}
+
+func (m *OrMatcher) FailureMessage(actual interface{}) (message string) {
+ // not the most beautiful list of matchers, but not bad either...
+ return format.Message(actual, fmt.Sprintf("To satisfy at least one of these matchers: %s", m.Matchers))
+}
+
+func (m *OrMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return m.firstSuccessfulMatcher.NegatedFailureMessage(actual)
+}
+
+func (m *OrMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
+ /*
+ Example with 3 matchers: A, B, C
+
+ Match evaluates them: F, T, <?> => T
+ So match is currently T, what should MatchMayChangeInTheFuture() return?
+ Seems like it only depends on B, since currently B MUST change to allow the result to become F
+
+ Match eval: F, F, F => F
+ So match is currently F, what should MatchMayChangeInTheFuture() return?
+ Seems to depend on ANY of them being able to change to T.
+ */
+
+ if m.firstSuccessfulMatcher != nil {
+ // one of the matchers succeeded.. it must be able to change in order to affect the result
+ return oraclematcher.MatchMayChangeInTheFuture(m.firstSuccessfulMatcher, actual)
+ } else {
+ // so all matchers failed.. Any one of them changing would change the result.
+ for _, matcher := range m.Matchers {
+ if oraclematcher.MatchMayChangeInTheFuture(matcher, actual) {
+ return true
+ }
+ }
+ return false // none of were going to change
+ }
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/or_test.go b/vendor/github.com/onsi/gomega/matchers/or_test.go
new file mode 100644
index 000000000..1f6dfaf61
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/or_test.go
@@ -0,0 +1,92 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("OrMatcher", func() {
+ It("works with positive cases", func() {
+ Expect(input).To(Or(true1))
+ Expect(input).To(Or(true1, true2))
+ Expect(input).To(Or(true1, false1))
+ Expect(input).To(Or(false1, true2))
+ Expect(input).To(Or(true1, true2, true3))
+ Expect(input).To(Or(true1, true2, false3))
+ Expect(input).To(Or(true1, false2, true3))
+ Expect(input).To(Or(false1, true2, true3))
+ Expect(input).To(Or(true1, false2, false3))
+ Expect(input).To(Or(false1, false2, true3))
+
+ // use alias
+ Expect(input).To(SatisfyAny(false1, false2, true3))
+ })
+
+ It("stops on errors", func() {
+ failuresMessages := InterceptGomegaFailures(func() {
+ Expect(input).To(Or(Panic(), true1))
+ })
+ Expect(failuresMessages).To(Equal([]string{"PanicMatcher expects a function. Got:\n <string>: hi"}))
+ })
+
+ It("works with negative cases", func() {
+ Expect(input).ToNot(Or())
+ Expect(input).ToNot(Or(false1))
+ Expect(input).ToNot(Or(false1, false2))
+ Expect(input).ToNot(Or(false1, false2, false3))
+ })
+
+ Context("failure messages", func() {
+ Context("when match fails", func() {
+ It("gives a descriptive message", func() {
+ verifyFailureMessage(Or(false1, false2), input,
+ "To satisfy at least one of these matchers: [%!s(*matchers.HaveLenMatcher=&{1}) %!s(*matchers.EqualMatcher=&{hip})]")
+ })
+ })
+
+ Context("when match succeeds, but expected it to fail", func() {
+ It("gives a descriptive message", func() {
+ verifyFailureMessage(Not(Or(true1, true2)), input, `not to have length 2`)
+ })
+ })
+ })
+
+ Context("MatchMayChangeInTheFuture", func() {
+ Context("Match returned false", func() {
+ It("returns true if any of the matchers could change", func() {
+ // 3 matchers, all return false, and all could change
+ m := Or(BeNil(), Equal("hip"), HaveLen(1))
+ Expect(m.Match("hi")).To(BeFalse())
+ Expect(m.(*OrMatcher).MatchMayChangeInTheFuture("hi")).To(BeTrue()) // all 3 of these matchers default to 'true'
+ })
+ It("returns false if none of the matchers could change", func() {
+ // empty Or() has the property of never matching, and never can change since there are no sub-matchers that could change
+ m := Or()
+ Expect(m.Match("anything")).To(BeFalse())
+ Expect(m.(*OrMatcher).MatchMayChangeInTheFuture("anything")).To(BeFalse())
+
+ // Or() with 3 sub-matchers that return false, and can't change
+ m = Or(Or(), Or(), Or())
+ Expect(m.Match("hi")).To(BeFalse())
+ Expect(m.(*OrMatcher).MatchMayChangeInTheFuture("hi")).To(BeFalse()) // the 3 empty Or()'s won't change
+ })
+ })
+ Context("Match returned true", func() {
+ Context("returns value of the successful matcher", func() {
+ It("false if successful matcher not going to change", func() {
+ // 3 matchers: 1st returns false, 2nd returns true and is not going to change, 3rd is never called
+ m := Or(BeNil(), And(), Equal(1))
+ Expect(m.Match("hi")).To(BeTrue())
+ Expect(m.(*OrMatcher).MatchMayChangeInTheFuture("hi")).To(BeFalse())
+ })
+ It("true if successful matcher indicates it might change", func() {
+ // 3 matchers: 1st returns false, 2nd returns true and "might" change, 3rd is never called
+ m := Or(Not(BeNil()), Equal("hi"), Equal(1))
+ Expect(m.Match("hi")).To(BeTrue())
+ Expect(m.(*OrMatcher).MatchMayChangeInTheFuture("hi")).To(BeTrue()) // Equal("hi") indicates it might change
+ })
+ })
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/panic_matcher.go b/vendor/github.com/onsi/gomega/matchers/panic_matcher.go
new file mode 100644
index 000000000..640f4db1a
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/panic_matcher.go
@@ -0,0 +1,46 @@
+package matchers
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/format"
+)
+
+type PanicMatcher struct {
+ object interface{}
+}
+
+func (matcher *PanicMatcher) Match(actual interface{}) (success bool, err error) {
+ if actual == nil {
+ return false, fmt.Errorf("PanicMatcher expects a non-nil actual.")
+ }
+
+ actualType := reflect.TypeOf(actual)
+ if actualType.Kind() != reflect.Func {
+ return false, fmt.Errorf("PanicMatcher expects a function. Got:\n%s", format.Object(actual, 1))
+ }
+ if !(actualType.NumIn() == 0 && actualType.NumOut() == 0) {
+ return false, fmt.Errorf("PanicMatcher expects a function with no arguments and no return value. Got:\n%s", format.Object(actual, 1))
+ }
+
+ success = false
+ defer func() {
+ if e := recover(); e != nil {
+ matcher.object = e
+ success = true
+ }
+ }()
+
+ reflect.ValueOf(actual).Call([]reflect.Value{})
+
+ return
+}
+
+func (matcher *PanicMatcher) FailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, "to panic")
+}
+
+func (matcher *PanicMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return format.Message(actual, fmt.Sprintf("not to panic, but panicked with\n%s", format.Object(matcher.object, 1)))
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/panic_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/panic_matcher_test.go
new file mode 100644
index 000000000..326bb10a4
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/panic_matcher_test.go
@@ -0,0 +1,52 @@
+package matchers_test
+
+import (
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("Panic", func() {
+ Context("when passed something that's not a function that takes zero arguments and returns nothing", func() {
+ It("should error", func() {
+ success, err := (&PanicMatcher{}).Match("foo")
+ Expect(success).To(BeFalse())
+ Expect(err).To(HaveOccurred())
+
+ success, err = (&PanicMatcher{}).Match(nil)
+ Expect(success).To(BeFalse())
+ Expect(err).To(HaveOccurred())
+
+ success, err = (&PanicMatcher{}).Match(func(foo string) {})
+ Expect(success).To(BeFalse())
+ Expect(err).To(HaveOccurred())
+
+ success, err = (&PanicMatcher{}).Match(func() string { return "bar" })
+ Expect(success).To(BeFalse())
+ Expect(err).To(HaveOccurred())
+ })
+ })
+
+ Context("when passed a function of the correct type", func() {
+ It("should call the function and pass if the function panics", func() {
+ Expect(func() { panic("ack!") }).To(Panic())
+ Expect(func() {}).NotTo(Panic())
+ })
+ })
+
+ Context("when assertion fails", func() {
+ It("prints the object passed to Panic when negative", func() {
+ failuresMessages := InterceptGomegaFailures(func() {
+ Expect(func() { panic("ack!") }).NotTo(Panic())
+ })
+ Expect(failuresMessages).To(ConsistOf(ContainSubstring("not to panic, but panicked with\n <string>: ack!")))
+ })
+
+ It("prints simple message when positive", func() {
+ failuresMessages := InterceptGomegaFailures(func() {
+ Expect(func() {}).To(Panic())
+ })
+ Expect(failuresMessages).To(ConsistOf(MatchRegexp("Expected\n\\s+<func\\(\\)>: .+\nto panic")))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/receive_matcher.go b/vendor/github.com/onsi/gomega/matchers/receive_matcher.go
new file mode 100644
index 000000000..2018a6128
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/receive_matcher.go
@@ -0,0 +1,128 @@
+package matchers
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/format"
+)
+
+type ReceiveMatcher struct {
+ Arg interface{}
+ receivedValue reflect.Value
+ channelClosed bool
+}
+
+func (matcher *ReceiveMatcher) Match(actual interface{}) (success bool, err error) {
+ if !isChan(actual) {
+ return false, fmt.Errorf("ReceiveMatcher expects a channel. Got:\n%s", format.Object(actual, 1))
+ }
+
+ channelType := reflect.TypeOf(actual)
+ channelValue := reflect.ValueOf(actual)
+
+ if channelType.ChanDir() == reflect.SendDir {
+ return false, fmt.Errorf("ReceiveMatcher matcher cannot be passed a send-only channel. Got:\n%s", format.Object(actual, 1))
+ }
+
+ var subMatcher omegaMatcher
+ var hasSubMatcher bool
+
+ if matcher.Arg != nil {
+ subMatcher, hasSubMatcher = (matcher.Arg).(omegaMatcher)
+ if !hasSubMatcher {
+ argType := reflect.TypeOf(matcher.Arg)
+ if argType.Kind() != reflect.Ptr {
+ return false, fmt.Errorf("Cannot assign a value from the channel:\n%s\nTo:\n%s\nYou need to pass a pointer!", format.Object(actual, 1), format.Object(matcher.Arg, 1))
+ }
+ }
+ }
+
+ winnerIndex, value, open := reflect.Select([]reflect.SelectCase{
+ {Dir: reflect.SelectRecv, Chan: channelValue},
+ {Dir: reflect.SelectDefault},
+ })
+
+ var closed bool
+ var didReceive bool
+ if winnerIndex == 0 {
+ closed = !open
+ didReceive = open
+ }
+ matcher.channelClosed = closed
+
+ if closed {
+ return false, nil
+ }
+
+ if hasSubMatcher {
+ if didReceive {
+ matcher.receivedValue = value
+ return subMatcher.Match(matcher.receivedValue.Interface())
+ }
+ return false, nil
+ }
+
+ if didReceive {
+ if matcher.Arg != nil {
+ outValue := reflect.ValueOf(matcher.Arg)
+
+ if value.Type().AssignableTo(outValue.Elem().Type()) {
+ outValue.Elem().Set(value)
+ return true, nil
+ }
+ if value.Type().Kind() == reflect.Interface && value.Elem().Type().AssignableTo(outValue.Elem().Type()) {
+ outValue.Elem().Set(value.Elem())
+ return true, nil
+ } else {
+ return false, fmt.Errorf("Cannot assign a value from the channel:\n%s\nType:\n%s\nTo:\n%s", format.Object(actual, 1), format.Object(value.Interface(), 1), format.Object(matcher.Arg, 1))
+ }
+
+ }
+
+ return true, nil
+ }
+ return false, nil
+}
+
+func (matcher *ReceiveMatcher) FailureMessage(actual interface{}) (message string) {
+ subMatcher, hasSubMatcher := (matcher.Arg).(omegaMatcher)
+
+ closedAddendum := ""
+ if matcher.channelClosed {
+ closedAddendum = " The channel is closed."
+ }
+
+ if hasSubMatcher {
+ if matcher.receivedValue.IsValid() {
+ return subMatcher.FailureMessage(matcher.receivedValue.Interface())
+ }
+ return "When passed a matcher, ReceiveMatcher's channel *must* receive something."
+ }
+ return format.Message(actual, "to receive something."+closedAddendum)
+}
+
+func (matcher *ReceiveMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ subMatcher, hasSubMatcher := (matcher.Arg).(omegaMatcher)
+
+ closedAddendum := ""
+ if matcher.channelClosed {
+ closedAddendum = " The channel is closed."
+ }
+
+ if hasSubMatcher {
+ if matcher.receivedValue.IsValid() {
+ return subMatcher.NegatedFailureMessage(matcher.receivedValue.Interface())
+ }
+ return "When passed a matcher, ReceiveMatcher's channel *must* receive something."
+ }
+ return format.Message(actual, "not to receive anything."+closedAddendum)
+}
+
+func (matcher *ReceiveMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
+ if !isChan(actual) {
+ return false
+ }
+
+ return !matcher.channelClosed
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/receive_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/receive_matcher_test.go
new file mode 100644
index 000000000..cf04e85dd
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/receive_matcher_test.go
@@ -0,0 +1,304 @@
+package matchers_test
+
+import (
+ "time"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+type kungFuActor interface {
+ DrunkenMaster() bool
+}
+
+type jackie struct {
+ name string
+}
+
+func (j *jackie) DrunkenMaster() bool {
+ return true
+}
+
+type someError struct{ s string }
+
+func (e *someError) Error() string { return e.s }
+
+var _ = Describe("ReceiveMatcher", func() {
+ Context("with no argument", func() {
+ Context("for a buffered channel", func() {
+ It("should succeed", func() {
+ channel := make(chan bool, 1)
+
+ Expect(channel).ShouldNot(Receive())
+
+ channel <- true
+
+ Expect(channel).Should(Receive())
+ })
+ })
+
+ Context("for an unbuffered channel", func() {
+ It("should succeed (eventually)", func() {
+ channel := make(chan bool)
+
+ Expect(channel).ShouldNot(Receive())
+
+ go func() {
+ time.Sleep(10 * time.Millisecond)
+ channel <- true
+ }()
+
+ Eventually(channel).Should(Receive())
+ })
+ })
+ })
+
+ Context("with a pointer argument", func() {
+ Context("of the correct type", func() {
+ Context("when the channel has an interface type", func() {
+ It("should write the value received on the channel to the pointer", func() {
+ channel := make(chan error, 1)
+
+ var value *someError
+
+ Ω(channel).ShouldNot(Receive(&value))
+ Ω(value).Should(BeZero())
+
+ channel <- &someError{"boooom!"}
+
+ Ω(channel).Should(Receive(&value))
+ Ω(value).Should(MatchError("boooom!"))
+ })
+ })
+ })
+
+ Context("of the correct type", func() {
+ It("should write the value received on the channel to the pointer", func() {
+ channel := make(chan int, 1)
+
+ var value int
+
+ Expect(channel).ShouldNot(Receive(&value))
+ Expect(value).Should(BeZero())
+
+ channel <- 17
+
+ Expect(channel).Should(Receive(&value))
+ Expect(value).Should(Equal(17))
+ })
+ })
+
+ Context("to various types of objects", func() {
+ It("should work", func() {
+ //channels of strings
+ stringChan := make(chan string, 1)
+ stringChan <- "foo"
+
+ var s string
+ Expect(stringChan).Should(Receive(&s))
+ Expect(s).Should(Equal("foo"))
+
+ //channels of slices
+ sliceChan := make(chan []bool, 1)
+ sliceChan <- []bool{true, true, false}
+
+ var sl []bool
+ Expect(sliceChan).Should(Receive(&sl))
+ Expect(sl).Should(Equal([]bool{true, true, false}))
+
+ //channels of channels
+ chanChan := make(chan chan bool, 1)
+ c := make(chan bool)
+ chanChan <- c
+
+ var receivedC chan bool
+ Expect(chanChan).Should(Receive(&receivedC))
+ Expect(receivedC).Should(Equal(c))
+
+ //channels of interfaces
+ jackieChan := make(chan kungFuActor, 1)
+ aJackie := &jackie{name: "Jackie Chan"}
+ jackieChan <- aJackie
+
+ var theJackie kungFuActor
+ Expect(jackieChan).Should(Receive(&theJackie))
+ Expect(theJackie).Should(Equal(aJackie))
+ })
+ })
+
+ Context("of the wrong type", func() {
+ It("should error", func() {
+ channel := make(chan int, 1)
+ channel <- 10
+
+ var incorrectType bool
+
+ success, err := (&ReceiveMatcher{Arg: &incorrectType}).Match(channel)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ var notAPointer int
+ success, err = (&ReceiveMatcher{Arg: notAPointer}).Match(channel)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+ })
+
+ Context("with a matcher", func() {
+ It("should defer to the underlying matcher", func() {
+ intChannel := make(chan int, 1)
+ intChannel <- 3
+ Expect(intChannel).Should(Receive(Equal(3)))
+
+ intChannel <- 2
+ Expect(intChannel).ShouldNot(Receive(Equal(3)))
+
+ stringChannel := make(chan []string, 1)
+ stringChannel <- []string{"foo", "bar", "baz"}
+ Expect(stringChannel).Should(Receive(ContainElement(ContainSubstring("fo"))))
+
+ stringChannel <- []string{"foo", "bar", "baz"}
+ Expect(stringChannel).ShouldNot(Receive(ContainElement(ContainSubstring("archipelago"))))
+ })
+
+ It("should defer to the underlying matcher for the message", func() {
+ matcher := Receive(Equal(3))
+ channel := make(chan int, 1)
+ channel <- 2
+ matcher.Match(channel)
+ Expect(matcher.FailureMessage(channel)).Should(MatchRegexp(`Expected\s+<int>: 2\s+to equal\s+<int>: 3`))
+
+ channel <- 3
+ matcher.Match(channel)
+ Expect(matcher.NegatedFailureMessage(channel)).Should(MatchRegexp(`Expected\s+<int>: 3\s+not to equal\s+<int>: 3`))
+ })
+
+ It("should work just fine with Eventually", func() {
+ stringChannel := make(chan string)
+
+ go func() {
+ time.Sleep(5 * time.Millisecond)
+ stringChannel <- "A"
+ time.Sleep(5 * time.Millisecond)
+ stringChannel <- "B"
+ }()
+
+ Eventually(stringChannel).Should(Receive(Equal("B")))
+ })
+
+ Context("if the matcher errors", func() {
+ It("should error", func() {
+ channel := make(chan int, 1)
+ channel <- 3
+ success, err := (&ReceiveMatcher{Arg: ContainSubstring("three")}).Match(channel)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("if nothing is received", func() {
+ It("should fail", func() {
+ channel := make(chan int, 1)
+ success, err := (&ReceiveMatcher{Arg: Equal(1)}).Match(channel)
+ Expect(success).Should(BeFalse())
+ Expect(err).ShouldNot(HaveOccurred())
+ })
+ })
+ })
+
+ Context("When actual is a *closed* channel", func() {
+ Context("for a buffered channel", func() {
+ It("should work until it hits the end of the buffer", func() {
+ channel := make(chan bool, 1)
+ channel <- true
+
+ close(channel)
+
+ Expect(channel).Should(Receive())
+ Expect(channel).ShouldNot(Receive())
+ })
+ })
+
+ Context("for an unbuffered channel", func() {
+ It("should always fail", func() {
+ channel := make(chan bool)
+ close(channel)
+
+ Expect(channel).ShouldNot(Receive())
+ })
+ })
+ })
+
+ Context("When actual is a send-only channel", func() {
+ It("should error", func() {
+ channel := make(chan bool)
+
+ var writerChannel chan<- bool
+ writerChannel = channel
+
+ success, err := (&ReceiveMatcher{}).Match(writerChannel)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ Context("when acutal is a non-channel", func() {
+ It("should error", func() {
+ var nilChannel chan bool
+
+ success, err := (&ReceiveMatcher{}).Match(nilChannel)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&ReceiveMatcher{}).Match(nil)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+
+ success, err = (&ReceiveMatcher{}).Match(3)
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(HaveOccurred())
+ })
+ })
+
+ Describe("when used with eventually and a custom matcher", func() {
+ It("should return the matcher's error when a failing value is received on the channel, instead of the must receive something failure", func() {
+ failures := InterceptGomegaFailures(func() {
+ c := make(chan string, 0)
+ Eventually(c, 0.01).Should(Receive(Equal("hello")))
+ })
+ Expect(failures[0]).Should(ContainSubstring("When passed a matcher, ReceiveMatcher's channel *must* receive something."))
+
+ failures = InterceptGomegaFailures(func() {
+ c := make(chan string, 1)
+ c <- "hi"
+ Eventually(c, 0.01).Should(Receive(Equal("hello")))
+ })
+ Expect(failures[0]).Should(ContainSubstring("<string>: hello"))
+ })
+ })
+
+ Describe("Bailing early", func() {
+ It("should bail early when passed a closed channel", func() {
+ c := make(chan bool)
+ close(c)
+
+ t := time.Now()
+ failures := InterceptGomegaFailures(func() {
+ Eventually(c).Should(Receive())
+ })
+ Expect(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond))
+ Expect(failures).Should(HaveLen(1))
+ })
+
+ It("should bail early when passed a non-channel", func() {
+ t := time.Now()
+ failures := InterceptGomegaFailures(func() {
+ Eventually(3).Should(Receive())
+ })
+ Expect(time.Since(t)).Should(BeNumerically("<", 500*time.Millisecond))
+ Expect(failures).Should(HaveLen(1))
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/semi_structured_data_support.go b/vendor/github.com/onsi/gomega/matchers/semi_structured_data_support.go
new file mode 100644
index 000000000..639295684
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/semi_structured_data_support.go
@@ -0,0 +1,92 @@
+package matchers
+
+import (
+ "fmt"
+ "reflect"
+ "strings"
+)
+
+func formattedMessage(comparisonMessage string, failurePath []interface{}) string {
+ var diffMessage string
+ if len(failurePath) == 0 {
+ diffMessage = ""
+ } else {
+ diffMessage = fmt.Sprintf("\n\nfirst mismatched key: %s", formattedFailurePath(failurePath))
+ }
+ return fmt.Sprintf("%s%s", comparisonMessage, diffMessage)
+}
+
+func formattedFailurePath(failurePath []interface{}) string {
+ formattedPaths := []string{}
+ for i := len(failurePath) - 1; i >= 0; i-- {
+ switch p := failurePath[i].(type) {
+ case int:
+ formattedPaths = append(formattedPaths, fmt.Sprintf(`[%d]`, p))
+ default:
+ if i != len(failurePath)-1 {
+ formattedPaths = append(formattedPaths, ".")
+ }
+ formattedPaths = append(formattedPaths, fmt.Sprintf(`"%s"`, p))
+ }
+ }
+ return strings.Join(formattedPaths, "")
+}
+
+func deepEqual(a interface{}, b interface{}) (bool, []interface{}) {
+ var errorPath []interface{}
+ if reflect.TypeOf(a) != reflect.TypeOf(b) {
+ return false, errorPath
+ }
+
+ switch a.(type) {
+ case []interface{}:
+ if len(a.([]interface{})) != len(b.([]interface{})) {
+ return false, errorPath
+ }
+
+ for i, v := range a.([]interface{}) {
+ elementEqual, keyPath := deepEqual(v, b.([]interface{})[i])
+ if !elementEqual {
+ return false, append(keyPath, i)
+ }
+ }
+ return true, errorPath
+
+ case map[interface{}]interface{}:
+ if len(a.(map[interface{}]interface{})) != len(b.(map[interface{}]interface{})) {
+ return false, errorPath
+ }
+
+ for k, v1 := range a.(map[interface{}]interface{}) {
+ v2, ok := b.(map[interface{}]interface{})[k]
+ if !ok {
+ return false, errorPath
+ }
+ elementEqual, keyPath := deepEqual(v1, v2)
+ if !elementEqual {
+ return false, append(keyPath, k)
+ }
+ }
+ return true, errorPath
+
+ case map[string]interface{}:
+ if len(a.(map[string]interface{})) != len(b.(map[string]interface{})) {
+ return false, errorPath
+ }
+
+ for k, v1 := range a.(map[string]interface{}) {
+ v2, ok := b.(map[string]interface{})[k]
+ if !ok {
+ return false, errorPath
+ }
+ elementEqual, keyPath := deepEqual(v1, v2)
+ if !elementEqual {
+ return false, append(keyPath, k)
+ }
+ }
+ return true, errorPath
+
+ default:
+ return a == b, errorPath
+ }
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/succeed_matcher.go b/vendor/github.com/onsi/gomega/matchers/succeed_matcher.go
new file mode 100644
index 000000000..721ed5529
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/succeed_matcher.go
@@ -0,0 +1,33 @@
+package matchers
+
+import (
+ "fmt"
+
+ "github.com/onsi/gomega/format"
+)
+
+type SucceedMatcher struct {
+}
+
+func (matcher *SucceedMatcher) Match(actual interface{}) (success bool, err error) {
+ // is purely nil?
+ if actual == nil {
+ return true, nil
+ }
+
+ // must be an 'error' type
+ if !isError(actual) {
+ return false, fmt.Errorf("Expected an error-type. Got:\n%s", format.Object(actual, 1))
+ }
+
+ // must be nil (or a pointer to a nil)
+ return isNil(actual), nil
+}
+
+func (matcher *SucceedMatcher) FailureMessage(actual interface{}) (message string) {
+ return fmt.Sprintf("Expected success, but got an error:\n%s\n%s", format.Object(actual, 1), format.IndentString(actual.(error).Error(), 1))
+}
+
+func (matcher *SucceedMatcher) NegatedFailureMessage(actual interface{}) (message string) {
+ return "Expected failure, but got no error."
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/succeed_matcher_test.go b/vendor/github.com/onsi/gomega/matchers/succeed_matcher_test.go
new file mode 100644
index 000000000..e42dd8a6e
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/succeed_matcher_test.go
@@ -0,0 +1,72 @@
+package matchers_test
+
+import (
+ "errors"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+ "regexp"
+)
+
+func Erroring() error {
+ return errors.New("bam")
+}
+
+func NotErroring() error {
+ return nil
+}
+
+type AnyType struct{}
+
+func Invalid() *AnyType {
+ return nil
+}
+
+var _ = Describe("Succeed", func() {
+ It("should succeed if the function succeeds", func() {
+ Expect(NotErroring()).Should(Succeed())
+ })
+
+ It("should succeed (in the negated) if the function errored", func() {
+ Expect(Erroring()).ShouldNot(Succeed())
+ })
+
+ It("should not if passed a non-error", func() {
+ success, err := (&SucceedMatcher{}).Match(Invalid())
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(MatchError("Expected an error-type. Got:\n <*matchers_test.AnyType | 0x0>: nil"))
+ })
+
+ It("doesn't support non-error type", func() {
+ success, err := (&SucceedMatcher{}).Match(AnyType{})
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(MatchError("Expected an error-type. Got:\n <matchers_test.AnyType>: {}"))
+ })
+
+ It("doesn't support non-error pointer type", func() {
+ success, err := (&SucceedMatcher{}).Match(&AnyType{})
+ Expect(success).Should(BeFalse())
+ Expect(err).Should(MatchError(MatchRegexp(`Expected an error-type. Got:\n <*matchers_test.AnyType | 0x[[:xdigit:]]+>: {}`)))
+ })
+
+ It("should not succeed with pointer types that conform to error interface", func() {
+ err := &CustomErr{"ohai"}
+ Expect(err).ShouldNot(Succeed())
+ })
+
+ It("should succeed with nil pointers to types that conform to error interface", func() {
+ var err *CustomErr = nil
+ Expect(err).Should(Succeed())
+ })
+
+ It("builds failure message", func() {
+ actual := Succeed().FailureMessage(errors.New("oops"))
+ actual = regexp.MustCompile(" 0x.*>").ReplaceAllString(actual, " 0x00000000>")
+ Expect(actual).To(Equal("Expected success, but got an error:\n <*errors.errorString | 0x00000000>: {s: \"oops\"}\n oops"))
+ })
+
+ It("builds negated failure message", func() {
+ actual := Succeed().NegatedFailureMessage(123)
+ Expect(actual).To(Equal("Expected failure, but got no error."))
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/matchers/support/goraph/MIT.LICENSE b/vendor/github.com/onsi/gomega/matchers/support/goraph/MIT.LICENSE
new file mode 100644
index 000000000..8edd8175a
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/support/goraph/MIT.LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2014 Amit Kumar Gupta
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraph.go b/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraph.go
new file mode 100644
index 000000000..8aaf8759d
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraph.go
@@ -0,0 +1,41 @@
+package bipartitegraph
+
+import "errors"
+import "fmt"
+
+import . "github.com/onsi/gomega/matchers/support/goraph/node"
+import . "github.com/onsi/gomega/matchers/support/goraph/edge"
+
+type BipartiteGraph struct {
+ Left NodeOrderedSet
+ Right NodeOrderedSet
+ Edges EdgeSet
+}
+
+func NewBipartiteGraph(leftValues, rightValues []interface{}, neighbours func(interface{}, interface{}) (bool, error)) (*BipartiteGraph, error) {
+ left := NodeOrderedSet{}
+ for i := range leftValues {
+ left = append(left, Node{Id: i})
+ }
+
+ right := NodeOrderedSet{}
+ for j := range rightValues {
+ right = append(right, Node{Id: j + len(left)})
+ }
+
+ edges := EdgeSet{}
+ for i, leftValue := range leftValues {
+ for j, rightValue := range rightValues {
+ neighbours, err := neighbours(leftValue, rightValue)
+ if err != nil {
+ return nil, errors.New(fmt.Sprintf("error determining adjacency for %v and %v: %s", leftValue, rightValue, err.Error()))
+ }
+
+ if neighbours {
+ edges = append(edges, Edge{Node1: left[i], Node2: right[j]})
+ }
+ }
+ }
+
+ return &BipartiteGraph{left, right, edges}, nil
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraphmatching.go b/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraphmatching.go
new file mode 100644
index 000000000..8181f43a4
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraphmatching.go
@@ -0,0 +1,159 @@
+package bipartitegraph
+
+import . "github.com/onsi/gomega/matchers/support/goraph/node"
+import . "github.com/onsi/gomega/matchers/support/goraph/edge"
+import "github.com/onsi/gomega/matchers/support/goraph/util"
+
+func (bg *BipartiteGraph) LargestMatching() (matching EdgeSet) {
+ paths := bg.maximalDisjointSLAPCollection(matching)
+
+ for len(paths) > 0 {
+ for _, path := range paths {
+ matching = matching.SymmetricDifference(path)
+ }
+ paths = bg.maximalDisjointSLAPCollection(matching)
+ }
+
+ return
+}
+
+func (bg *BipartiteGraph) maximalDisjointSLAPCollection(matching EdgeSet) (result []EdgeSet) {
+ guideLayers := bg.createSLAPGuideLayers(matching)
+ if len(guideLayers) == 0 {
+ return
+ }
+
+ used := make(map[Node]bool)
+
+ for _, u := range guideLayers[len(guideLayers)-1] {
+ slap, found := bg.findDisjointSLAP(u, matching, guideLayers, used)
+ if found {
+ for _, edge := range slap {
+ used[edge.Node1] = true
+ used[edge.Node2] = true
+ }
+ result = append(result, slap)
+ }
+ }
+
+ return
+}
+
+func (bg *BipartiteGraph) findDisjointSLAP(
+ start Node,
+ matching EdgeSet,
+ guideLayers []NodeOrderedSet,
+ used map[Node]bool,
+) ([]Edge, bool) {
+ return bg.findDisjointSLAPHelper(start, EdgeSet{}, len(guideLayers)-1, matching, guideLayers, used)
+}
+
+func (bg *BipartiteGraph) findDisjointSLAPHelper(
+ currentNode Node,
+ currentSLAP EdgeSet,
+ currentLevel int,
+ matching EdgeSet,
+ guideLayers []NodeOrderedSet,
+ used map[Node]bool,
+) (EdgeSet, bool) {
+ used[currentNode] = true
+
+ if currentLevel == 0 {
+ return currentSLAP, true
+ }
+
+ for _, nextNode := range guideLayers[currentLevel-1] {
+ if used[nextNode] {
+ continue
+ }
+
+ edge, found := bg.Edges.FindByNodes(currentNode, nextNode)
+ if !found {
+ continue
+ }
+
+ if matching.Contains(edge) == util.Odd(currentLevel) {
+ continue
+ }
+
+ currentSLAP = append(currentSLAP, edge)
+ slap, found := bg.findDisjointSLAPHelper(nextNode, currentSLAP, currentLevel-1, matching, guideLayers, used)
+ if found {
+ return slap, true
+ }
+ currentSLAP = currentSLAP[:len(currentSLAP)-1]
+ }
+
+ used[currentNode] = false
+ return nil, false
+}
+
+func (bg *BipartiteGraph) createSLAPGuideLayers(matching EdgeSet) (guideLayers []NodeOrderedSet) {
+ used := make(map[Node]bool)
+ currentLayer := NodeOrderedSet{}
+
+ for _, node := range bg.Left {
+ if matching.Free(node) {
+ used[node] = true
+ currentLayer = append(currentLayer, node)
+ }
+ }
+
+ if len(currentLayer) == 0 {
+ return []NodeOrderedSet{}
+ }
+ guideLayers = append(guideLayers, currentLayer)
+
+ done := false
+
+ for !done {
+ lastLayer := currentLayer
+ currentLayer = NodeOrderedSet{}
+
+ if util.Odd(len(guideLayers)) {
+ for _, leftNode := range lastLayer {
+ for _, rightNode := range bg.Right {
+ if used[rightNode] {
+ continue
+ }
+
+ edge, found := bg.Edges.FindByNodes(leftNode, rightNode)
+ if !found || matching.Contains(edge) {
+ continue
+ }
+
+ currentLayer = append(currentLayer, rightNode)
+ used[rightNode] = true
+
+ if matching.Free(rightNode) {
+ done = true
+ }
+ }
+ }
+ } else {
+ for _, rightNode := range lastLayer {
+ for _, leftNode := range bg.Left {
+ if used[leftNode] {
+ continue
+ }
+
+ edge, found := bg.Edges.FindByNodes(leftNode, rightNode)
+ if !found || !matching.Contains(edge) {
+ continue
+ }
+
+ currentLayer = append(currentLayer, leftNode)
+ used[leftNode] = true
+ }
+ }
+
+ }
+
+ if len(currentLayer) == 0 {
+ return []NodeOrderedSet{}
+ }
+ guideLayers = append(guideLayers, currentLayer)
+ }
+
+ return
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/support/goraph/edge/edge.go b/vendor/github.com/onsi/gomega/matchers/support/goraph/edge/edge.go
new file mode 100644
index 000000000..4fd15cc06
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/support/goraph/edge/edge.go
@@ -0,0 +1,61 @@
+package edge
+
+import . "github.com/onsi/gomega/matchers/support/goraph/node"
+
+type Edge struct {
+ Node1 Node
+ Node2 Node
+}
+
+type EdgeSet []Edge
+
+func (ec EdgeSet) Free(node Node) bool {
+ for _, e := range ec {
+ if e.Node1 == node || e.Node2 == node {
+ return false
+ }
+ }
+
+ return true
+}
+
+func (ec EdgeSet) Contains(edge Edge) bool {
+ for _, e := range ec {
+ if e == edge {
+ return true
+ }
+ }
+
+ return false
+}
+
+func (ec EdgeSet) FindByNodes(node1, node2 Node) (Edge, bool) {
+ for _, e := range ec {
+ if (e.Node1 == node1 && e.Node2 == node2) || (e.Node1 == node2 && e.Node2 == node1) {
+ return e, true
+ }
+ }
+
+ return Edge{}, false
+}
+
+func (ec EdgeSet) SymmetricDifference(ec2 EdgeSet) EdgeSet {
+ edgesToInclude := make(map[Edge]bool)
+
+ for _, e := range ec {
+ edgesToInclude[e] = true
+ }
+
+ for _, e := range ec2 {
+ edgesToInclude[e] = !edgesToInclude[e]
+ }
+
+ result := EdgeSet{}
+ for e, include := range edgesToInclude {
+ if include {
+ result = append(result, e)
+ }
+ }
+
+ return result
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/support/goraph/node/node.go b/vendor/github.com/onsi/gomega/matchers/support/goraph/node/node.go
new file mode 100644
index 000000000..800c2ea8c
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/support/goraph/node/node.go
@@ -0,0 +1,7 @@
+package node
+
+type Node struct {
+ Id int
+}
+
+type NodeOrderedSet []Node
diff --git a/vendor/github.com/onsi/gomega/matchers/support/goraph/util/util.go b/vendor/github.com/onsi/gomega/matchers/support/goraph/util/util.go
new file mode 100644
index 000000000..d76a1ee00
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/support/goraph/util/util.go
@@ -0,0 +1,7 @@
+package util
+
+import "math"
+
+func Odd(n int) bool {
+ return math.Mod(float64(n), 2.0) == 1.0
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_01.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_01.xml
new file mode 100644
index 000000000..90f0a1b45
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_01.xml
@@ -0,0 +1,6 @@
+<note>
+ <to>Tove</to>
+ <from>Jani</from>
+ <heading>Reminder</heading>
+ <body>Don't forget me this weekend!</body>
+</note> \ No newline at end of file
diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_02.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_02.xml
new file mode 100644
index 000000000..3863b83c3
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_02.xml
@@ -0,0 +1,9 @@
+
+
+<note>
+ <to>Tove</to>
+ <from>Jani</from>
+ <heading>Reminder</heading>
+ <body>Don't forget me this weekend!</body>
+</note>
+
diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_03.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_03.xml
new file mode 100644
index 000000000..a491c213c
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_03.xml
@@ -0,0 +1 @@
+<note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_04.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_04.xml
new file mode 100644
index 000000000..dcfd3db03
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_04.xml
@@ -0,0 +1,6 @@
+<note>
+ <to>Tove</to>
+ <from>John</from>
+ <heading>Doe</heading>
+ <body>Don't forget me this weekend!</body>
+</note> \ No newline at end of file
diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_05.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_05.xml
new file mode 100644
index 000000000..de15a6a55
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_05.xml
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CATALOG>
+ <CD>
+ <TITLE>Empire Burlesque</TITLE>
+ <ARTIST>Bob Dylan</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>Columbia</COMPANY>
+ <PRICE>10.90</PRICE>
+ <YEAR>1985</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Hide your heart</TITLE>
+ <ARTIST>Bonnie Tyler</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>CBS Records</COMPANY>
+ <PRICE>9.90</PRICE>
+ <YEAR>1988</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Greatest Hits</TITLE>
+ <ARTIST>Dolly Parton</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>RCA</COMPANY>
+ <PRICE>9.90</PRICE>
+ <YEAR>1982</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Still got the blues</TITLE>
+ <ARTIST>Gary Moore</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Virgin records</COMPANY>
+ <PRICE>10.20</PRICE>
+ <YEAR>1990</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Eros</TITLE>
+ <ARTIST>Eros Ramazzotti</ARTIST>
+ <COUNTRY>EU</COUNTRY>
+ <COMPANY>BMG</COMPANY>
+ <PRICE>9.90</PRICE>
+ <YEAR>1997</YEAR>
+ </CD>
+ <CD>
+ <TITLE>One night only</TITLE>
+ <ARTIST>Bee Gees</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Polydor</COMPANY>
+ <PRICE>10.90</PRICE>
+ <YEAR>1998</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Sylvias Mother</TITLE>
+ <ARTIST>Dr.Hook</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>CBS</COMPANY>
+ <PRICE>8.10</PRICE>
+ <YEAR>1973</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Maggie May</TITLE>
+ <ARTIST>Rod Stewart</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Pickwick</COMPANY>
+ <PRICE>8.50</PRICE>
+ <YEAR>1990</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Romanza</TITLE>
+ <ARTIST>Andrea Bocelli</ARTIST>
+ <COUNTRY>EU</COUNTRY>
+ <COMPANY>Polydor</COMPANY>
+ <PRICE>10.80</PRICE>
+ <YEAR>1996</YEAR>
+ </CD>
+ <CD>
+ <TITLE>When a man loves a woman</TITLE>
+ <ARTIST>Percy Sledge</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>Atlantic</COMPANY>
+ <PRICE>8.70</PRICE>
+ <YEAR>1987</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Black angel</TITLE>
+ <ARTIST>Savage Rose</ARTIST>
+ <COUNTRY>EU</COUNTRY>
+ <COMPANY>Mega</COMPANY>
+ <PRICE>10.90</PRICE>
+ <YEAR>1995</YEAR>
+ </CD>
+ <CD>
+ <TITLE>1999 Grammy Nominees</TITLE>
+ <ARTIST>Many</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>Grammy</COMPANY>
+ <PRICE>10.20</PRICE>
+ <YEAR>1999</YEAR>
+ </CD>
+ <CD>
+ <TITLE>For the good times</TITLE>
+ <ARTIST>Kenny Rogers</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Mucik Master</COMPANY>
+ <PRICE>8.70</PRICE>
+ <YEAR>1995</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Big Willie style</TITLE>
+ <ARTIST>Will Smith</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>Columbia</COMPANY>
+ <PRICE>9.90</PRICE>
+ <YEAR>1997</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Tupelo Honey</TITLE>
+ <ARTIST>Van Morrison</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Polydor</COMPANY>
+ <PRICE>8.20</PRICE>
+ <YEAR>1971</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Soulsville</TITLE>
+ <ARTIST>Jorn Hoel</ARTIST>
+ <COUNTRY>Norway</COUNTRY>
+ <COMPANY>WEA</COMPANY>
+ <PRICE>7.90</PRICE>
+ <YEAR>1996</YEAR>
+ </CD>
+ <CD>
+ <TITLE>The very best of</TITLE>
+ <ARTIST>Cat Stevens</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Island</COMPANY>
+ <PRICE>8.90</PRICE>
+ <YEAR>1990</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Stop</TITLE>
+ <ARTIST>Sam Brown</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>A and M</COMPANY>
+ <PRICE>8.90</PRICE>
+ <YEAR>1988</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Bridge of Spies</TITLE>
+ <ARTIST>T'Pau</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Siren</COMPANY>
+ <PRICE>7.90</PRICE>
+ <YEAR>1987</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Private Dancer</TITLE>
+ <ARTIST>Tina Turner</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Capitol</COMPANY>
+ <PRICE>8.90</PRICE>
+ <YEAR>1983</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Midt om natten</TITLE>
+ <ARTIST>Kim Larsen</ARTIST>
+ <COUNTRY>EU</COUNTRY>
+ <COMPANY>Medley</COMPANY>
+ <PRICE>7.80</PRICE>
+ <YEAR>1983</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Pavarotti Gala Concert</TITLE>
+ <ARTIST>Luciano Pavarotti</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>DECCA</COMPANY>
+ <PRICE>9.90</PRICE>
+ <YEAR>1991</YEAR>
+ </CD>
+ <CD>
+ <TITLE>The dock of the bay</TITLE>
+ <ARTIST>Otis Redding</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>Stax Records</COMPANY>
+ <PRICE>7.90</PRICE>
+ <YEAR>1968</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Picture book</TITLE>
+ <ARTIST>Simply Red</ARTIST>
+ <COUNTRY>EU</COUNTRY>
+ <COMPANY>Elektra</COMPANY>
+ <PRICE>7.20</PRICE>
+ <YEAR>1985</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Red</TITLE>
+ <ARTIST>The Communards</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>London</COMPANY>
+ <PRICE>7.80</PRICE>
+ <YEAR>1987</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Unchain my heart</TITLE>
+ <ARTIST>Joe Cocker</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>EMI</COMPANY>
+ <PRICE>8.20</PRICE>
+ <YEAR>1987</YEAR>
+ </CD>
+</CATALOG>
diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_06.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_06.xml
new file mode 100644
index 000000000..4ba90fb97
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_06.xml
@@ -0,0 +1,13 @@
+<root>
+ <table>
+ <tr>
+ <td>Apples</td>
+ <td>Bananas</td>
+ </tr>
+ </table>
+ <table>
+ <name>African Coffee Table</name>
+ <width>80</width>
+ <length>120</length>
+ </table>
+</root> \ No newline at end of file
diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_07.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_07.xml
new file mode 100644
index 000000000..34b9e9775
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_07.xml
@@ -0,0 +1,13 @@
+<root>
+ <h:table xmlns:h="http://www.w3.org/TR/html4/">
+ <h:tr>
+ <h:td>Apples</h:td>
+ <h:td>Bananas</h:td>
+ </h:tr>
+ </h:table>
+ <f:table xmlns:f="https://www.w3schools.com/furniture">
+ <f:name>African Coffee Table</f:name>
+ <f:width>80</f:width>
+ <f:length>120</f:length>
+ </f:table>
+</root> \ No newline at end of file
diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_08.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_08.xml
new file mode 100644
index 000000000..ccaee4e1a
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_08.xml
@@ -0,0 +1,13 @@
+<root>
+ <h:table xmlns:h="http://www.w3.org/TR/html4/">
+ <h:tr>
+ <h:td>Apples</h:td>
+ <h:td>Oranges</h:td>
+ </h:tr>
+ </h:table>
+ <f:table xmlns:f="https://www.w3schools.com/furniture">
+ <f:name>African Coffee Table</f:name>
+ <f:width>80</f:width>
+ <f:length>120</f:length>
+ </f:table>
+</root> \ No newline at end of file
diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_09.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_09.xml
new file mode 100644
index 000000000..531f84d3f
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_09.xml
@@ -0,0 +1,4 @@
+<person gender="female">
+ <firstname>Foo</firstname>
+ <lastname>Bar</lastname>
+</person> \ No newline at end of file
diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_10.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_10.xml
new file mode 100644
index 000000000..b1e1e1fbe
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_10.xml
@@ -0,0 +1,4 @@
+<person gender="male">
+ <firstname>Foo</firstname>
+ <lastname>Bar</lastname>
+</person> \ No newline at end of file
diff --git a/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_11.xml b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_11.xml
new file mode 100644
index 000000000..3132b0f90
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/test_data/xml/sample_11.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
+<note>
+ <to>Tove</to>
+ <from>Jani</from>
+ <heading>Reminder</heading>
+ <body>Don't forget me this weekend!</body>
+</note>
diff --git a/vendor/github.com/onsi/gomega/matchers/type_support.go b/vendor/github.com/onsi/gomega/matchers/type_support.go
new file mode 100644
index 000000000..75afcd844
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/type_support.go
@@ -0,0 +1,179 @@
+/*
+Gomega matchers
+
+This package implements the Gomega matchers and does not typically need to be imported.
+See the docs for Gomega for documentation on the matchers
+
+http://onsi.github.io/gomega/
+*/
+package matchers
+
+import (
+ "encoding/json"
+ "fmt"
+ "reflect"
+)
+
+type omegaMatcher interface {
+ Match(actual interface{}) (success bool, err error)
+ FailureMessage(actual interface{}) (message string)
+ NegatedFailureMessage(actual interface{}) (message string)
+}
+
+func isBool(a interface{}) bool {
+ return reflect.TypeOf(a).Kind() == reflect.Bool
+}
+
+func isNumber(a interface{}) bool {
+ if a == nil {
+ return false
+ }
+ kind := reflect.TypeOf(a).Kind()
+ return reflect.Int <= kind && kind <= reflect.Float64
+}
+
+func isInteger(a interface{}) bool {
+ kind := reflect.TypeOf(a).Kind()
+ return reflect.Int <= kind && kind <= reflect.Int64
+}
+
+func isUnsignedInteger(a interface{}) bool {
+ kind := reflect.TypeOf(a).Kind()
+ return reflect.Uint <= kind && kind <= reflect.Uint64
+}
+
+func isFloat(a interface{}) bool {
+ kind := reflect.TypeOf(a).Kind()
+ return reflect.Float32 <= kind && kind <= reflect.Float64
+}
+
+func toInteger(a interface{}) int64 {
+ if isInteger(a) {
+ return reflect.ValueOf(a).Int()
+ } else if isUnsignedInteger(a) {
+ return int64(reflect.ValueOf(a).Uint())
+ } else if isFloat(a) {
+ return int64(reflect.ValueOf(a).Float())
+ }
+ panic(fmt.Sprintf("Expected a number! Got <%T> %#v", a, a))
+}
+
+func toUnsignedInteger(a interface{}) uint64 {
+ if isInteger(a) {
+ return uint64(reflect.ValueOf(a).Int())
+ } else if isUnsignedInteger(a) {
+ return reflect.ValueOf(a).Uint()
+ } else if isFloat(a) {
+ return uint64(reflect.ValueOf(a).Float())
+ }
+ panic(fmt.Sprintf("Expected a number! Got <%T> %#v", a, a))
+}
+
+func toFloat(a interface{}) float64 {
+ if isInteger(a) {
+ return float64(reflect.ValueOf(a).Int())
+ } else if isUnsignedInteger(a) {
+ return float64(reflect.ValueOf(a).Uint())
+ } else if isFloat(a) {
+ return reflect.ValueOf(a).Float()
+ }
+ panic(fmt.Sprintf("Expected a number! Got <%T> %#v", a, a))
+}
+
+func isError(a interface{}) bool {
+ _, ok := a.(error)
+ return ok
+}
+
+func isChan(a interface{}) bool {
+ if isNil(a) {
+ return false
+ }
+ return reflect.TypeOf(a).Kind() == reflect.Chan
+}
+
+func isMap(a interface{}) bool {
+ if a == nil {
+ return false
+ }
+ return reflect.TypeOf(a).Kind() == reflect.Map
+}
+
+func isArrayOrSlice(a interface{}) bool {
+ if a == nil {
+ return false
+ }
+ switch reflect.TypeOf(a).Kind() {
+ case reflect.Array, reflect.Slice:
+ return true
+ default:
+ return false
+ }
+}
+
+func isString(a interface{}) bool {
+ if a == nil {
+ return false
+ }
+ return reflect.TypeOf(a).Kind() == reflect.String
+}
+
+func toString(a interface{}) (string, bool) {
+ aString, isString := a.(string)
+ if isString {
+ return aString, true
+ }
+
+ aBytes, isBytes := a.([]byte)
+ if isBytes {
+ return string(aBytes), true
+ }
+
+ aStringer, isStringer := a.(fmt.Stringer)
+ if isStringer {
+ return aStringer.String(), true
+ }
+
+ aJSONRawMessage, isJSONRawMessage := a.(json.RawMessage)
+ if isJSONRawMessage {
+ return string(aJSONRawMessage), true
+ }
+
+ return "", false
+}
+
+func lengthOf(a interface{}) (int, bool) {
+ if a == nil {
+ return 0, false
+ }
+ switch reflect.TypeOf(a).Kind() {
+ case reflect.Map, reflect.Array, reflect.String, reflect.Chan, reflect.Slice:
+ return reflect.ValueOf(a).Len(), true
+ default:
+ return 0, false
+ }
+}
+func capOf(a interface{}) (int, bool) {
+ if a == nil {
+ return 0, false
+ }
+ switch reflect.TypeOf(a).Kind() {
+ case reflect.Array, reflect.Chan, reflect.Slice:
+ return reflect.ValueOf(a).Cap(), true
+ default:
+ return 0, false
+ }
+}
+
+func isNil(a interface{}) bool {
+ if a == nil {
+ return true
+ }
+
+ switch reflect.TypeOf(a).Kind() {
+ case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice:
+ return reflect.ValueOf(a).IsNil()
+ }
+
+ return false
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/with_transform.go b/vendor/github.com/onsi/gomega/matchers/with_transform.go
new file mode 100644
index 000000000..8e58d8a0f
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/with_transform.go
@@ -0,0 +1,72 @@
+package matchers
+
+import (
+ "fmt"
+ "reflect"
+
+ "github.com/onsi/gomega/internal/oraclematcher"
+ "github.com/onsi/gomega/types"
+)
+
+type WithTransformMatcher struct {
+ // input
+ Transform interface{} // must be a function of one parameter that returns one value
+ Matcher types.GomegaMatcher
+
+ // cached value
+ transformArgType reflect.Type
+
+ // state
+ transformedValue interface{}
+}
+
+func NewWithTransformMatcher(transform interface{}, matcher types.GomegaMatcher) *WithTransformMatcher {
+ if transform == nil {
+ panic("transform function cannot be nil")
+ }
+ txType := reflect.TypeOf(transform)
+ if txType.NumIn() != 1 {
+ panic("transform function must have 1 argument")
+ }
+ if txType.NumOut() != 1 {
+ panic("transform function must have 1 return value")
+ }
+
+ return &WithTransformMatcher{
+ Transform: transform,
+ Matcher: matcher,
+ transformArgType: reflect.TypeOf(transform).In(0),
+ }
+}
+
+func (m *WithTransformMatcher) Match(actual interface{}) (bool, error) {
+ // return error if actual's type is incompatible with Transform function's argument type
+ actualType := reflect.TypeOf(actual)
+ if !actualType.AssignableTo(m.transformArgType) {
+ return false, fmt.Errorf("Transform function expects '%s' but we have '%s'", m.transformArgType, actualType)
+ }
+
+ // call the Transform function with `actual`
+ fn := reflect.ValueOf(m.Transform)
+ result := fn.Call([]reflect.Value{reflect.ValueOf(actual)})
+ m.transformedValue = result[0].Interface() // expect exactly one value
+
+ return m.Matcher.Match(m.transformedValue)
+}
+
+func (m *WithTransformMatcher) FailureMessage(_ interface{}) (message string) {
+ return m.Matcher.FailureMessage(m.transformedValue)
+}
+
+func (m *WithTransformMatcher) NegatedFailureMessage(_ interface{}) (message string) {
+ return m.Matcher.NegatedFailureMessage(m.transformedValue)
+}
+
+func (m *WithTransformMatcher) MatchMayChangeInTheFuture(_ interface{}) bool {
+ // TODO: Maybe this should always just return true? (Only an issue for non-deterministic transformers.)
+ //
+ // Querying the next matcher is fine if the transformer always will return the same value.
+ // But if the transformer is non-deterministic and returns a different value each time, then there
+ // is no point in querying the next matcher, since it can only comment on the last transformed value.
+ return oraclematcher.MatchMayChangeInTheFuture(m.Matcher, m.transformedValue)
+}
diff --git a/vendor/github.com/onsi/gomega/matchers/with_transform_test.go b/vendor/github.com/onsi/gomega/matchers/with_transform_test.go
new file mode 100644
index 000000000..e52bf8e63
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/matchers/with_transform_test.go
@@ -0,0 +1,102 @@
+package matchers_test
+
+import (
+ "errors"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ . "github.com/onsi/gomega/matchers"
+)
+
+var _ = Describe("WithTransformMatcher", func() {
+
+ var plus1 = func(i int) int { return i + 1 }
+
+ Context("Panic if transform function invalid", func() {
+ panicsWithTransformer := func(transform interface{}) {
+ ExpectWithOffset(1, func() { WithTransform(transform, nil) }).To(Panic())
+ }
+ It("nil", func() {
+ panicsWithTransformer(nil)
+ })
+ Context("Invalid number of args, but correct return value count", func() {
+ It("zero", func() {
+ panicsWithTransformer(func() int { return 5 })
+ })
+ It("two", func() {
+ panicsWithTransformer(func(i, j int) int { return 5 })
+ })
+ })
+ Context("Invalid number of return values, but correct number of arguments", func() {
+ It("zero", func() {
+ panicsWithTransformer(func(i int) {})
+ })
+ It("two", func() {
+ panicsWithTransformer(func(i int) (int, int) { return 5, 6 })
+ })
+ })
+ })
+
+ It("works with positive cases", func() {
+ Expect(1).To(WithTransform(plus1, Equal(2)))
+ Expect(1).To(WithTransform(plus1, WithTransform(plus1, Equal(3))))
+ Expect(1).To(WithTransform(plus1, And(Equal(2), BeNumerically(">", 1))))
+
+ // transform expects custom type
+ type S struct {
+ A int
+ B string
+ }
+ transformer := func(s S) string { return s.B }
+ Expect(S{1, "hi"}).To(WithTransform(transformer, Equal("hi")))
+
+ // transform expects interface
+ errString := func(e error) string { return e.Error() }
+ Expect(errors.New("abc")).To(WithTransform(errString, Equal("abc")))
+ })
+
+ It("works with negative cases", func() {
+ Expect(1).ToNot(WithTransform(plus1, Equal(3)))
+ Expect(1).ToNot(WithTransform(plus1, WithTransform(plus1, Equal(2))))
+ })
+
+ Context("failure messages", func() {
+ Context("when match fails", func() {
+ It("gives a descriptive message", func() {
+ m := WithTransform(plus1, Equal(3))
+ Expect(m.Match(1)).To(BeFalse())
+ Expect(m.FailureMessage(1)).To(Equal("Expected\n <int>: 2\nto equal\n <int>: 3"))
+ })
+ })
+
+ Context("when match succeeds, but expected it to fail", func() {
+ It("gives a descriptive message", func() {
+ m := Not(WithTransform(plus1, Equal(3)))
+ Expect(m.Match(2)).To(BeFalse())
+ Expect(m.FailureMessage(2)).To(Equal("Expected\n <int>: 3\nnot to equal\n <int>: 3"))
+ })
+ })
+
+ Context("actual value is incompatible with transform function's argument type", func() {
+ It("gracefully fails if transform cannot be performed", func() {
+ m := WithTransform(plus1, Equal(3))
+ result, err := m.Match("hi") // give it a string but transform expects int; doesn't panic
+ Expect(result).To(BeFalse())
+ Expect(err).To(MatchError("Transform function expects 'int' but we have 'string'"))
+ })
+ })
+ })
+
+ Context("MatchMayChangeInTheFuture()", func() {
+ It("Propagates value from wrapped matcher on the transformed value", func() {
+ m := WithTransform(plus1, Or()) // empty Or() always returns false, and indicates it cannot change
+ Expect(m.Match(1)).To(BeFalse())
+ Expect(m.(*WithTransformMatcher).MatchMayChangeInTheFuture(1)).To(BeFalse()) // empty Or() indicates cannot change
+ })
+ It("Defaults to true", func() {
+ m := WithTransform(plus1, Equal(2)) // Equal does not have this method
+ Expect(m.Match(1)).To(BeTrue())
+ Expect(m.(*WithTransformMatcher).MatchMayChangeInTheFuture(1)).To(BeTrue()) // defaults to true
+ })
+ })
+})
diff --git a/vendor/github.com/onsi/gomega/types/types.go b/vendor/github.com/onsi/gomega/types/types.go
new file mode 100644
index 000000000..ac59a3a5a
--- /dev/null
+++ b/vendor/github.com/onsi/gomega/types/types.go
@@ -0,0 +1,26 @@
+package types
+
+type TWithHelper interface {
+ Helper()
+}
+
+type GomegaFailHandler func(message string, callerSkip ...int)
+
+type GomegaFailWrapper struct {
+ Fail GomegaFailHandler
+ TWithHelper TWithHelper
+}
+
+//A simple *testing.T interface wrapper
+type GomegaTestingT interface {
+ Fatalf(format string, args ...interface{})
+}
+
+//All Gomega matchers must implement the GomegaMatcher interface
+//
+//For details on writing custom matchers, check out: http://onsi.github.io/gomega/#adding-your-own-matchers
+type GomegaMatcher interface {
+ Match(actual interface{}) (success bool, err error)
+ FailureMessage(actual interface{}) (message string)
+ NegatedFailureMessage(actual interface{}) (message string)
+}
diff --git a/vendor/github.com/urfave/cli/help.go b/vendor/github.com/urfave/cli/help.go
index a0e949f72..65874fa2f 100644
--- a/vendor/github.com/urfave/cli/help.go
+++ b/vendor/github.com/urfave/cli/help.go
@@ -82,7 +82,7 @@ OPTIONS:
var helpCommand = Command{
Name: "help",
Aliases: []string{"h"},
- Usage: "Show a list of commands or help for one command",
+ Usage: "Shows a list of commands or help for one command",
ArgsUsage: "[command]",
Action: func(c *Context) error {
args := c.Args()
diff --git a/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go b/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go
index 6be01f580..98a983c5e 100644
--- a/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go
+++ b/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go
@@ -109,6 +109,36 @@ func generateTemplate(description string) (string, []byte, error) {
b.WriteString("\n\n")
}
+ for _, a := range midl.Errors {
+ writeDocString(&b, a.Doc)
+ b.WriteString("type " + a.Name + " ")
+ writeType(&b, a.Type, true, 0)
+ b.WriteString("\nfunc (e " + a.Name + ") Error() string {\n")
+ b.WriteString("\treturn \"" + midl.Name + "." + a.Name + "\"\n")
+ b.WriteString("}\n\n")
+ }
+
+ b.WriteString("func Dispatch_Error(err error) error {\n")
+ b.WriteString("\tif e, ok := err.(*varlink.Error); ok {\n")
+ b.WriteString("\t\tswitch e.Name {\n")
+ for _, a := range midl.Errors {
+ b.WriteString("\t\tcase \"" + midl.Name + "." + a.Name + "\":\n")
+ b.WriteString("\t\t\terrorRawParameters := e.Parameters.(*json.RawMessage)\n")
+ b.WriteString("\t\t\tif errorRawParameters == nil {\n")
+ b.WriteString("\t\t\t\treturn e\n")
+ b.WriteString("\t\t\t}\n")
+ b.WriteString("\t\t\tvar param " + a.Name + "\n")
+ b.WriteString("\t\t\terr := json.Unmarshal(*errorRawParameters, &param)\n")
+ b.WriteString("\t\t\tif err != nil {\n")
+ b.WriteString("\t\t\t\treturn e\n")
+ b.WriteString("\t\t\t}\n")
+ b.WriteString("\t\t\treturn &param\n")
+ }
+ b.WriteString("\t\t}\n")
+ b.WriteString("\t}\n")
+ b.WriteString("\treturn err\n")
+ b.WriteString("}\n\n")
+
b.WriteString("// Generated client method calls\n\n")
for _, m := range midl.Methods {
@@ -175,9 +205,9 @@ func generateTemplate(description string) (string, []byte, error) {
} else {
b.WriteString("\treceive, err := c.Send(\"" + midl.Name + "." + m.Name + "\", nil, flags)\n")
}
- b.WriteString("if err != nil {\n" +
- "\treturn nil, err\n" +
- "}\n")
+ b.WriteString("\tif err != nil {\n" +
+ "\t\treturn nil, err\n" +
+ "\t}\n")
b.WriteString("\treturn func() (")
for _, field := range m.Out.Fields {
b.WriteString(field.Name + "_out_ ")
@@ -194,6 +224,7 @@ func generateTemplate(description string) (string, []byte, error) {
b.WriteString("\t\tflags, err = receive(nil)\n")
}
b.WriteString("\t\tif err != nil {\n" +
+ "\t\t\terr = Dispatch_Error(err)\n" +
"\t\t\treturn\n" +
"\t\t}\n")
for _, field := range m.Out.Fields {
@@ -242,10 +273,8 @@ func generateTemplate(description string) (string, []byte, error) {
writeType(&b, field.Type, false, 1)
}
b.WriteString(") error {\n")
+ b.WriteString("\tvar out " + e.Name + "\n")
if len(e.Type.Fields) > 0 {
- b.WriteString("\tvar out ")
- writeType(&b, e.Type, true, 1)
- b.WriteString("\n")
for _, field := range e.Type.Fields {
switch field.Type.Kind {
case idl.TypeStruct, idl.TypeArray, idl.TypeMap:
@@ -257,10 +286,8 @@ func generateTemplate(description string) (string, []byte, error) {
b.WriteString("\tout." + strings.Title(field.Name) + " = " + field.Name + "_\n")
}
}
- b.WriteString("\treturn c.ReplyError(\"" + midl.Name + "." + e.Name + "\", &out)\n")
- } else {
- b.WriteString("\treturn c.ReplyError(\"" + midl.Name + "." + e.Name + "\", nil)\n")
}
+ b.WriteString("\treturn c.ReplyError(\"" + midl.Name + "." + e.Name + "\", &out)\n")
b.WriteString("}\n\n")
}
diff --git a/vendor/github.com/varlink/go/cmd/varlink/main.go b/vendor/github.com/varlink/go/cmd/varlink/main.go
index 1de4e1a45..6781dd956 100644
--- a/vendor/github.com/varlink/go/cmd/varlink/main.go
+++ b/vendor/github.com/varlink/go/cmd/varlink/main.go
@@ -12,7 +12,7 @@ import (
)
var bold = color.New(color.Bold)
-var errorBoldRed = bold.Sprint(color.New(color.FgRed).Sprint("Error:"))
+var errorBoldRed string
var bridge string
func ErrPrintf(format string, a ...interface{}) {
@@ -71,7 +71,7 @@ func varlink_call(args []string) {
os.Exit(2)
}
address = "bridge:" + bridge
- methodName = callFlags.Arg(0)
+ methodName = callFlags.Arg(0)
} else {
uri := callFlags.Arg(0)
if uri == "" {
@@ -126,20 +126,18 @@ func varlink_call(args []string) {
f.NullColor = color.New(color.FgMagenta)
if err != nil {
- ErrPrintf("Error calling '%s': %v\n", methodName, err)
- switch e := err.(type) {
- case *varlink.Error:
- println(e.Name)
+ if e, ok := err.(*varlink.Error); ok {
+ ErrPrintf("Call failed with error: %v\n", color.New(color.FgRed).Sprint(e.Name))
errorRawParameters := e.Parameters.(*json.RawMessage)
-
- if errorRawParameters == nil {
- break
+ if errorRawParameters != nil {
+ var param map[string]interface{}
+ _ = json.Unmarshal(*errorRawParameters, &param)
+ c, _ := f.Marshal(param)
+ fmt.Fprintf(os.Stderr, "%v\n", string(c))
}
- var param map[string]interface{}
- _ = json.Unmarshal(*errorRawParameters, &param)
- c, _ := f.Marshal(param)
- ErrPrintf("%v\n", string(c))
+ os.Exit(2)
}
+ ErrPrintf("Error calling '%s': %v\n", methodName, err)
os.Exit(2)
}
c, _ := f.Marshal(retval)
@@ -173,7 +171,7 @@ func varlink_help(args []string) {
os.Exit(2)
}
address = "bridge:" + bridge
- interfaceName = helpFlags.Arg(0)
+ interfaceName = helpFlags.Arg(0)
} else {
uri := helpFlags.Arg(0)
if uri == "" && bridge == "" {
@@ -282,6 +280,8 @@ func main() {
color.NoColor = true // disables colorized output
}
+ errorBoldRed = bold.Sprint(color.New(color.FgRed).Sprint("Error:"))
+
switch flag.Arg(0) {
case "info":
varlink_info(flag.Args()[1:])
diff --git a/vendor/github.com/varlink/go/varlink/varlink_test.go b/vendor/github.com/varlink/go/varlink/varlink_test.go
index eb28c7e45..9dd4ddc63 100644
--- a/vendor/github.com/varlink/go/varlink/varlink_test.go
+++ b/vendor/github.com/varlink/go/varlink/varlink_test.go
@@ -27,27 +27,33 @@ func TestService(t *testing.T) {
)
t.Run("ZeroMessage", func(t *testing.T) {
+ var br bytes.Buffer
+ r := bufio.NewReader(&br)
var b bytes.Buffer
w := bufio.NewWriter(&b)
- if err := service.handleMessage(w, []byte{0}); err == nil {
+ if err := service.handleMessage(r, w, []byte{0}); err == nil {
t.Fatal("HandleMessage returned non-error")
}
})
t.Run("InvalidJson", func(t *testing.T) {
+ var br bytes.Buffer
+ r := bufio.NewReader(&br)
var b bytes.Buffer
w := bufio.NewWriter(&b)
msg := []byte(`{"method":"foo.GetInterfaceDescription" fdgdfg}`)
- if err := service.handleMessage(w, msg); err == nil {
+ if err := service.handleMessage(r, w, msg); err == nil {
t.Fatal("HandleMessage returned no error on invalid json")
}
})
t.Run("WrongInterface", func(t *testing.T) {
+ var br bytes.Buffer
+ r := bufio.NewReader(&br)
var b bytes.Buffer
w := bufio.NewWriter(&b)
msg := []byte(`{"method":"foo.GetInterfaceDescription"}`)
- if err := service.handleMessage(w, msg); err != nil {
+ if err := service.handleMessage(r, w, msg); err != nil {
t.Fatal("HandleMessage returned error on wrong interface")
}
expect(t, `{"parameters":{"interface":"foo"},"error":"org.varlink.service.InterfaceNotFound"}`+"\000",
@@ -55,10 +61,12 @@ func TestService(t *testing.T) {
})
t.Run("InvalidMethod", func(t *testing.T) {
+ var br bytes.Buffer
+ r := bufio.NewReader(&br)
var b bytes.Buffer
w := bufio.NewWriter(&b)
msg := []byte(`{"method":"InvalidMethod"}`)
- if err := service.handleMessage(w, msg); err != nil {
+ if err := service.handleMessage(r, w, msg); err != nil {
t.Fatal("HandleMessage returned error on invalid method")
}
expect(t, `{"parameters":{"parameter":"method"},"error":"org.varlink.service.InvalidParameter"}`+"\000",
@@ -66,10 +74,12 @@ func TestService(t *testing.T) {
})
t.Run("WrongMethod", func(t *testing.T) {
+ var br bytes.Buffer
+ r := bufio.NewReader(&br)
var b bytes.Buffer
w := bufio.NewWriter(&b)
msg := []byte(`{"method":"org.varlink.service.WrongMethod"}`)
- if err := service.handleMessage(w, msg); err != nil {
+ if err := service.handleMessage(r, w, msg); err != nil {
t.Fatal("HandleMessage returned error on wrong method")
}
expect(t, `{"parameters":{"method":"WrongMethod"},"error":"org.varlink.service.MethodNotFound"}`+"\000",
@@ -77,10 +87,12 @@ func TestService(t *testing.T) {
})
t.Run("GetInterfaceDescriptionNullParameters", func(t *testing.T) {
+ var br bytes.Buffer
+ r := bufio.NewReader(&br)
var b bytes.Buffer
w := bufio.NewWriter(&b)
msg := []byte(`{"method":"org.varlink.service.GetInterfaceDescription","parameters": null}`)
- if err := service.handleMessage(w, msg); err != nil {
+ if err := service.handleMessage(r, w, msg); err != nil {
t.Fatalf("HandleMessage returned error: %v", err)
}
expect(t, `{"parameters":{"parameter":"parameters"},"error":"org.varlink.service.InvalidParameter"}`+"\000",
@@ -88,10 +100,12 @@ func TestService(t *testing.T) {
})
t.Run("GetInterfaceDescriptionNoInterface", func(t *testing.T) {
+ var br bytes.Buffer
+ r := bufio.NewReader(&br)
var b bytes.Buffer
w := bufio.NewWriter(&b)
msg := []byte(`{"method":"org.varlink.service.GetInterfaceDescription","parameters":{}}`)
- if err := service.handleMessage(w, msg); err != nil {
+ if err := service.handleMessage(r, w, msg); err != nil {
t.Fatalf("HandleMessage returned error: %v", err)
}
expect(t, `{"parameters":{"parameter":"interface"},"error":"org.varlink.service.InvalidParameter"}`+"\000",
@@ -99,10 +113,12 @@ func TestService(t *testing.T) {
})
t.Run("GetInterfaceDescriptionWrongInterface", func(t *testing.T) {
+ var br bytes.Buffer
+ r := bufio.NewReader(&br)
var b bytes.Buffer
w := bufio.NewWriter(&b)
msg := []byte(`{"method":"org.varlink.service.GetInterfaceDescription","parameters":{"interface":"foo"}}`)
- if err := service.handleMessage(w, msg); err != nil {
+ if err := service.handleMessage(r, w, msg); err != nil {
t.Fatalf("HandleMessage returned error: %v", err)
}
expect(t, `{"parameters":{"parameter":"interface"},"error":"org.varlink.service.InvalidParameter"}`+"\000",
@@ -110,10 +126,12 @@ func TestService(t *testing.T) {
})
t.Run("GetInterfaceDescription", func(t *testing.T) {
+ var br bytes.Buffer
+ r := bufio.NewReader(&br)
var b bytes.Buffer
w := bufio.NewWriter(&b)
msg := []byte(`{"method":"org.varlink.service.GetInterfaceDescription","parameters":{"interface":"org.varlink.service"}}`)
- if err := service.handleMessage(w, msg); err != nil {
+ if err := service.handleMessage(r, w, msg); err != nil {
t.Fatalf("HandleMessage returned error: %v", err)
}
expect(t, `{"parameters":{"description":"# The Varlink Service Interface is provided by every varlink service. It\n# describes the service and the interfaces it implements.\ninterface org.varlink.service\n\n# Get a list of all the interfaces a service provides and information\n# about the implementation.\nmethod GetInfo() -\u003e (\n vendor: string,\n product: string,\n version: string,\n url: string,\n interfaces: []string\n)\n\n# Get the description of an interface that is implemented by this service.\nmethod GetInterfaceDescription(interface: string) -\u003e (description: string)\n\n# The requested interface was not found.\nerror InterfaceNotFound (interface: string)\n\n# The requested method was not found\nerror MethodNotFound (method: string)\n\n# The interface defines the requested method, but the service does not\n# implement it.\nerror MethodNotImplemented (method: string)\n\n# One of the passed parameters is invalid.\nerror InvalidParameter (parameter: string)"}}`+"\000",
@@ -121,10 +139,12 @@ func TestService(t *testing.T) {
})
t.Run("GetInfo", func(t *testing.T) {
+ var br bytes.Buffer
+ r := bufio.NewReader(&br)
var b bytes.Buffer
w := bufio.NewWriter(&b)
msg := []byte(`{"method":"org.varlink.service.GetInfo"}`)
- if err := service.handleMessage(w, msg); err != nil {
+ if err := service.handleMessage(r, w, msg); err != nil {
t.Fatalf("HandleMessage returned error: %v", err)
}
expect(t, `{"parameters":{"vendor":"Varlink","product":"Varlink Test","version":"1","url":"https://github.com/varlink/go/varlink","interfaces":["org.varlink.service"]}}`+"\000",
@@ -199,10 +219,12 @@ func TestMoreService(t *testing.T) {
}
t.Run("MethodNotImplemented", func(t *testing.T) {
+ var br bytes.Buffer
+ r := bufio.NewReader(&br)
var b bytes.Buffer
w := bufio.NewWriter(&b)
msg := []byte(`{"method":"org.example.test.Pingf"}`)
- if err := service.handleMessage(w, msg); err != nil {
+ if err := service.handleMessage(r, w, msg); err != nil {
t.Fatalf("HandleMessage returned error: %v", err)
}
expect(t, `{"parameters":{"method":"Pingf"},"error":"org.varlink.service.MethodNotImplemented"}`+"\000",
@@ -210,20 +232,24 @@ func TestMoreService(t *testing.T) {
})
t.Run("PingError", func(t *testing.T) {
+ var br bytes.Buffer
+ r := bufio.NewReader(&br)
var b bytes.Buffer
w := bufio.NewWriter(&b)
msg := []byte(`{"method":"org.example.test.PingError", "more" : true}`)
- if err := service.handleMessage(w, msg); err != nil {
+ if err := service.handleMessage(r, w, msg); err != nil {
t.Fatalf("HandleMessage returned error: %v", err)
}
expect(t, `{"error":"org.example.test.PingError"}`+"\000",
b.String())
})
t.Run("MoreTest", func(t *testing.T) {
+ var br bytes.Buffer
+ r := bufio.NewReader(&br)
var b bytes.Buffer
w := bufio.NewWriter(&b)
msg := []byte(`{"method":"org.example.test.Ping", "more" : true}`)
- if err := service.handleMessage(w, msg); err != nil {
+ if err := service.handleMessage(r, w, msg); err != nil {
t.Fatalf("HandleMessage returned error: %v", err)
}
expect(t, `{"continues":true}`+"\000"+`{"continues":true}`+"\000"+`{}`+"\000",
diff --git a/vendor/gopkg.in/fsnotify.v1/LICENSE b/vendor/gopkg.in/fsnotify.v1/LICENSE
new file mode 100644
index 000000000..f21e54080
--- /dev/null
+++ b/vendor/gopkg.in/fsnotify.v1/LICENSE
@@ -0,0 +1,28 @@
+Copyright (c) 2012 The Go Authors. All rights reserved.
+Copyright (c) 2012 fsnotify Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/gopkg.in/fsnotify.v1/README.md b/vendor/gopkg.in/fsnotify.v1/README.md
new file mode 100644
index 000000000..3c891e349
--- /dev/null
+++ b/vendor/gopkg.in/fsnotify.v1/README.md
@@ -0,0 +1,50 @@
+# File system notifications for Go
+
+[![GoDoc](https://godoc.org/github.com/fsnotify/fsnotify?status.svg)](https://godoc.org/github.com/fsnotify/fsnotify) [![Go Report Card](https://goreportcard.com/badge/github.com/fsnotify/fsnotify)](https://goreportcard.com/report/github.com/fsnotify/fsnotify)
+
+fsnotify utilizes [golang.org/x/sys](https://godoc.org/golang.org/x/sys) rather than `syscall` from the standard library. Ensure you have the latest version installed by running:
+
+```console
+go get -u golang.org/x/sys/...
+```
+
+Cross platform: Windows, Linux, BSD and OS X.
+
+|Adapter |OS |Status |
+|----------|----------|----------|
+|inotify |Linux 2.6.27 or later, Android\*|Supported [![Build Status](https://travis-ci.org/fsnotify/fsnotify.svg?branch=master)](https://travis-ci.org/fsnotify/fsnotify)|
+|kqueue |BSD, OS X, iOS\*|Supported [![Build Status](https://travis-ci.org/fsnotify/fsnotify.svg?branch=master)](https://travis-ci.org/fsnotify/fsnotify)|
+|ReadDirectoryChangesW|Windows|Supported [![Build status](https://ci.appveyor.com/api/projects/status/ivwjubaih4r0udeh/branch/master?svg=true)](https://ci.appveyor.com/project/NathanYoungman/fsnotify/branch/master)|
+|FSEvents |OS X |[Planned](https://github.com/fsnotify/fsnotify/issues/11)|
+|FEN |Solaris 11 |[In Progress](https://github.com/fsnotify/fsnotify/issues/12)|
+|fanotify |Linux 2.6.37+ | |
+|USN Journals |Windows |[Maybe](https://github.com/fsnotify/fsnotify/issues/53)|
+|Polling |*All* |[Maybe](https://github.com/fsnotify/fsnotify/issues/9)|
+
+\* Android and iOS are untested.
+
+Please see [the documentation](https://godoc.org/github.com/fsnotify/fsnotify) for usage. Consult the [Wiki](https://github.com/fsnotify/fsnotify/wiki) for the FAQ and further information.
+
+## API stability
+
+fsnotify is a fork of [howeyc/fsnotify](https://godoc.org/github.com/howeyc/fsnotify) with a new API as of v1.0. The API is based on [this design document](http://goo.gl/MrYxyA).
+
+All [releases](https://github.com/fsnotify/fsnotify/releases) are tagged based on [Semantic Versioning](http://semver.org/). Further API changes are [planned](https://github.com/fsnotify/fsnotify/milestones), and will be tagged with a new major revision number.
+
+Go 1.6 supports dependencies located in the `vendor/` folder. Unless you are creating a library, it is recommended that you copy fsnotify into `vendor/github.com/fsnotify/fsnotify` within your project, and likewise for `golang.org/x/sys`.
+
+## Contributing
+
+Please refer to [CONTRIBUTING][] before opening an issue or pull request.
+
+## Example
+
+See [example_test.go](https://github.com/fsnotify/fsnotify/blob/master/example_test.go).
+
+[contributing]: https://github.com/fsnotify/fsnotify/blob/master/CONTRIBUTING.md
+
+## Related Projects
+
+* [notify](https://github.com/rjeczalik/notify)
+* [fsevents](https://github.com/fsnotify/fsevents)
+
diff --git a/vendor/gopkg.in/fsnotify.v1/fen.go b/vendor/gopkg.in/fsnotify.v1/fen.go
new file mode 100644
index 000000000..ced39cb88
--- /dev/null
+++ b/vendor/gopkg.in/fsnotify.v1/fen.go
@@ -0,0 +1,37 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build solaris
+
+package fsnotify
+
+import (
+ "errors"
+)
+
+// Watcher watches a set of files, delivering events to a channel.
+type Watcher struct {
+ Events chan Event
+ Errors chan error
+}
+
+// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
+func NewWatcher() (*Watcher, error) {
+ return nil, errors.New("FEN based watcher not yet supported for fsnotify\n")
+}
+
+// Close removes all watches and closes the events channel.
+func (w *Watcher) Close() error {
+ return nil
+}
+
+// Add starts watching the named file or directory (non-recursively).
+func (w *Watcher) Add(name string) error {
+ return nil
+}
+
+// Remove stops watching the the named file or directory (non-recursively).
+func (w *Watcher) Remove(name string) error {
+ return nil
+}
diff --git a/vendor/gopkg.in/fsnotify.v1/fsnotify.go b/vendor/gopkg.in/fsnotify.v1/fsnotify.go
new file mode 100644
index 000000000..e7f55fee7
--- /dev/null
+++ b/vendor/gopkg.in/fsnotify.v1/fsnotify.go
@@ -0,0 +1,62 @@
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !plan9
+
+// Package fsnotify provides a platform-independent interface for file system notifications.
+package fsnotify
+
+import (
+ "bytes"
+ "fmt"
+)
+
+// Event represents a single file system notification.
+type Event struct {
+ Name string // Relative path to the file or directory.
+ Op Op // File operation that triggered the event.
+}
+
+// Op describes a set of file operations.
+type Op uint32
+
+// These are the generalized file operations that can trigger a notification.
+const (
+ Create Op = 1 << iota
+ Write
+ Remove
+ Rename
+ Chmod
+)
+
+func (op Op) String() string {
+ // Use a buffer for efficient string concatenation
+ var buffer bytes.Buffer
+
+ if op&Create == Create {
+ buffer.WriteString("|CREATE")
+ }
+ if op&Remove == Remove {
+ buffer.WriteString("|REMOVE")
+ }
+ if op&Write == Write {
+ buffer.WriteString("|WRITE")
+ }
+ if op&Rename == Rename {
+ buffer.WriteString("|RENAME")
+ }
+ if op&Chmod == Chmod {
+ buffer.WriteString("|CHMOD")
+ }
+ if buffer.Len() == 0 {
+ return ""
+ }
+ return buffer.String()[1:] // Strip leading pipe
+}
+
+// String returns a string representation of the event in the form
+// "file: REMOVE|WRITE|..."
+func (e Event) String() string {
+ return fmt.Sprintf("%q: %s", e.Name, e.Op.String())
+}
diff --git a/vendor/gopkg.in/fsnotify.v1/inotify.go b/vendor/gopkg.in/fsnotify.v1/inotify.go
new file mode 100644
index 000000000..f3b74c51f
--- /dev/null
+++ b/vendor/gopkg.in/fsnotify.v1/inotify.go
@@ -0,0 +1,325 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build linux
+
+package fsnotify
+
+import (
+ "errors"
+ "fmt"
+ "io"
+ "os"
+ "path/filepath"
+ "strings"
+ "sync"
+ "unsafe"
+
+ "golang.org/x/sys/unix"
+)
+
+// Watcher watches a set of files, delivering events to a channel.
+type Watcher struct {
+ Events chan Event
+ Errors chan error
+ mu sync.Mutex // Map access
+ cv *sync.Cond // sync removing on rm_watch with IN_IGNORE
+ fd int
+ poller *fdPoller
+ watches map[string]*watch // Map of inotify watches (key: path)
+ paths map[int]string // Map of watched paths (key: watch descriptor)
+ done chan struct{} // Channel for sending a "quit message" to the reader goroutine
+ doneResp chan struct{} // Channel to respond to Close
+}
+
+// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
+func NewWatcher() (*Watcher, error) {
+ // Create inotify fd
+ fd, errno := unix.InotifyInit1(unix.IN_CLOEXEC)
+ if fd == -1 {
+ return nil, errno
+ }
+ // Create epoll
+ poller, err := newFdPoller(fd)
+ if err != nil {
+ unix.Close(fd)
+ return nil, err
+ }
+ w := &Watcher{
+ fd: fd,
+ poller: poller,
+ watches: make(map[string]*watch),
+ paths: make(map[int]string),
+ Events: make(chan Event),
+ Errors: make(chan error),
+ done: make(chan struct{}),
+ doneResp: make(chan struct{}),
+ }
+ w.cv = sync.NewCond(&w.mu)
+
+ go w.readEvents()
+ return w, nil
+}
+
+func (w *Watcher) isClosed() bool {
+ select {
+ case <-w.done:
+ return true
+ default:
+ return false
+ }
+}
+
+// Close removes all watches and closes the events channel.
+func (w *Watcher) Close() error {
+ if w.isClosed() {
+ return nil
+ }
+
+ // Send 'close' signal to goroutine, and set the Watcher to closed.
+ close(w.done)
+
+ // Wake up goroutine
+ w.poller.wake()
+
+ // Wait for goroutine to close
+ <-w.doneResp
+
+ return nil
+}
+
+// Add starts watching the named file or directory (non-recursively).
+func (w *Watcher) Add(name string) error {
+ name = filepath.Clean(name)
+ if w.isClosed() {
+ return errors.New("inotify instance already closed")
+ }
+
+ const agnosticEvents = unix.IN_MOVED_TO | unix.IN_MOVED_FROM |
+ unix.IN_CREATE | unix.IN_ATTRIB | unix.IN_MODIFY |
+ unix.IN_MOVE_SELF | unix.IN_DELETE | unix.IN_DELETE_SELF
+
+ var flags uint32 = agnosticEvents
+
+ w.mu.Lock()
+ watchEntry, found := w.watches[name]
+ w.mu.Unlock()
+ if found {
+ watchEntry.flags |= flags
+ flags |= unix.IN_MASK_ADD
+ }
+ wd, errno := unix.InotifyAddWatch(w.fd, name, flags)
+ if wd == -1 {
+ return errno
+ }
+
+ w.mu.Lock()
+ w.watches[name] = &watch{wd: uint32(wd), flags: flags}
+ w.paths[wd] = name
+ w.mu.Unlock()
+
+ return nil
+}
+
+// Remove stops watching the named file or directory (non-recursively).
+func (w *Watcher) Remove(name string) error {
+ name = filepath.Clean(name)
+
+ // Fetch the watch.
+ w.mu.Lock()
+ defer w.mu.Unlock()
+ watch, ok := w.watches[name]
+
+ // Remove it from inotify.
+ if !ok {
+ return fmt.Errorf("can't remove non-existent inotify watch for: %s", name)
+ }
+ // inotify_rm_watch will return EINVAL if the file has been deleted;
+ // the inotify will already have been removed.
+ // watches and pathes are deleted in ignoreLinux() implicitly and asynchronously
+ // by calling inotify_rm_watch() below. e.g. readEvents() goroutine receives IN_IGNORE
+ // so that EINVAL means that the wd is being rm_watch()ed or its file removed
+ // by another thread and we have not received IN_IGNORE event.
+ success, errno := unix.InotifyRmWatch(w.fd, watch.wd)
+ if success == -1 {
+ // TODO: Perhaps it's not helpful to return an error here in every case.
+ // the only two possible errors are:
+ // EBADF, which happens when w.fd is not a valid file descriptor of any kind.
+ // EINVAL, which is when fd is not an inotify descriptor or wd is not a valid watch descriptor.
+ // Watch descriptors are invalidated when they are removed explicitly or implicitly;
+ // explicitly by inotify_rm_watch, implicitly when the file they are watching is deleted.
+ return errno
+ }
+
+ // wait until ignoreLinux() deleting maps
+ exists := true
+ for exists {
+ w.cv.Wait()
+ _, exists = w.watches[name]
+ }
+
+ return nil
+}
+
+type watch struct {
+ wd uint32 // Watch descriptor (as returned by the inotify_add_watch() syscall)
+ flags uint32 // inotify flags of this watch (see inotify(7) for the list of valid flags)
+}
+
+// readEvents reads from the inotify file descriptor, converts the
+// received events into Event objects and sends them via the Events channel
+func (w *Watcher) readEvents() {
+ var (
+ buf [unix.SizeofInotifyEvent * 4096]byte // Buffer for a maximum of 4096 raw events
+ n int // Number of bytes read with read()
+ errno error // Syscall errno
+ ok bool // For poller.wait
+ )
+
+ defer close(w.doneResp)
+ defer close(w.Errors)
+ defer close(w.Events)
+ defer unix.Close(w.fd)
+ defer w.poller.close()
+
+ for {
+ // See if we have been closed.
+ if w.isClosed() {
+ return
+ }
+
+ ok, errno = w.poller.wait()
+ if errno != nil {
+ select {
+ case w.Errors <- errno:
+ case <-w.done:
+ return
+ }
+ continue
+ }
+
+ if !ok {
+ continue
+ }
+
+ n, errno = unix.Read(w.fd, buf[:])
+ // If a signal interrupted execution, see if we've been asked to close, and try again.
+ // http://man7.org/linux/man-pages/man7/signal.7.html :
+ // "Before Linux 3.8, reads from an inotify(7) file descriptor were not restartable"
+ if errno == unix.EINTR {
+ continue
+ }
+
+ // unix.Read might have been woken up by Close. If so, we're done.
+ if w.isClosed() {
+ return
+ }
+
+ if n < unix.SizeofInotifyEvent {
+ var err error
+ if n == 0 {
+ // If EOF is received. This should really never happen.
+ err = io.EOF
+ } else if n < 0 {
+ // If an error occurred while reading.
+ err = errno
+ } else {
+ // Read was too short.
+ err = errors.New("notify: short read in readEvents()")
+ }
+ select {
+ case w.Errors <- err:
+ case <-w.done:
+ return
+ }
+ continue
+ }
+
+ var offset uint32
+ // We don't know how many events we just read into the buffer
+ // While the offset points to at least one whole event...
+ for offset <= uint32(n-unix.SizeofInotifyEvent) {
+ // Point "raw" to the event in the buffer
+ raw := (*unix.InotifyEvent)(unsafe.Pointer(&buf[offset]))
+
+ mask := uint32(raw.Mask)
+ nameLen := uint32(raw.Len)
+ // If the event happened to the watched directory or the watched file, the kernel
+ // doesn't append the filename to the event, but we would like to always fill the
+ // the "Name" field with a valid filename. We retrieve the path of the watch from
+ // the "paths" map.
+ w.mu.Lock()
+ name := w.paths[int(raw.Wd)]
+ w.mu.Unlock()
+ if nameLen > 0 {
+ // Point "bytes" at the first byte of the filename
+ bytes := (*[unix.PathMax]byte)(unsafe.Pointer(&buf[offset+unix.SizeofInotifyEvent]))
+ // The filename is padded with NULL bytes. TrimRight() gets rid of those.
+ name += "/" + strings.TrimRight(string(bytes[0:nameLen]), "\000")
+ }
+
+ event := newEvent(name, mask)
+
+ // Send the events that are not ignored on the events channel
+ if !event.ignoreLinux(w, raw.Wd, mask) {
+ select {
+ case w.Events <- event:
+ case <-w.done:
+ return
+ }
+ }
+
+ // Move to the next event in the buffer
+ offset += unix.SizeofInotifyEvent + nameLen
+ }
+ }
+}
+
+// Certain types of events can be "ignored" and not sent over the Events
+// channel. Such as events marked ignore by the kernel, or MODIFY events
+// against files that do not exist.
+func (e *Event) ignoreLinux(w *Watcher, wd int32, mask uint32) bool {
+ // Ignore anything the inotify API says to ignore
+ if mask&unix.IN_IGNORED == unix.IN_IGNORED {
+ w.mu.Lock()
+ defer w.mu.Unlock()
+ name := w.paths[int(wd)]
+ delete(w.paths, int(wd))
+ delete(w.watches, name)
+ w.cv.Broadcast()
+ return true
+ }
+
+ // If the event is not a DELETE or RENAME, the file must exist.
+ // Otherwise the event is ignored.
+ // *Note*: this was put in place because it was seen that a MODIFY
+ // event was sent after the DELETE. This ignores that MODIFY and
+ // assumes a DELETE will come or has come if the file doesn't exist.
+ if !(e.Op&Remove == Remove || e.Op&Rename == Rename) {
+ _, statErr := os.Lstat(e.Name)
+ return os.IsNotExist(statErr)
+ }
+ return false
+}
+
+// newEvent returns an platform-independent Event based on an inotify mask.
+func newEvent(name string, mask uint32) Event {
+ e := Event{Name: name}
+ if mask&unix.IN_CREATE == unix.IN_CREATE || mask&unix.IN_MOVED_TO == unix.IN_MOVED_TO {
+ e.Op |= Create
+ }
+ if mask&unix.IN_DELETE_SELF == unix.IN_DELETE_SELF || mask&unix.IN_DELETE == unix.IN_DELETE {
+ e.Op |= Remove
+ }
+ if mask&unix.IN_MODIFY == unix.IN_MODIFY {
+ e.Op |= Write
+ }
+ if mask&unix.IN_MOVE_SELF == unix.IN_MOVE_SELF || mask&unix.IN_MOVED_FROM == unix.IN_MOVED_FROM {
+ e.Op |= Rename
+ }
+ if mask&unix.IN_ATTRIB == unix.IN_ATTRIB {
+ e.Op |= Chmod
+ }
+ return e
+}
diff --git a/vendor/gopkg.in/fsnotify.v1/inotify_poller.go b/vendor/gopkg.in/fsnotify.v1/inotify_poller.go
new file mode 100644
index 000000000..cc7db4b22
--- /dev/null
+++ b/vendor/gopkg.in/fsnotify.v1/inotify_poller.go
@@ -0,0 +1,187 @@
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build linux
+
+package fsnotify
+
+import (
+ "errors"
+
+ "golang.org/x/sys/unix"
+)
+
+type fdPoller struct {
+ fd int // File descriptor (as returned by the inotify_init() syscall)
+ epfd int // Epoll file descriptor
+ pipe [2]int // Pipe for waking up
+}
+
+func emptyPoller(fd int) *fdPoller {
+ poller := new(fdPoller)
+ poller.fd = fd
+ poller.epfd = -1
+ poller.pipe[0] = -1
+ poller.pipe[1] = -1
+ return poller
+}
+
+// Create a new inotify poller.
+// This creates an inotify handler, and an epoll handler.
+func newFdPoller(fd int) (*fdPoller, error) {
+ var errno error
+ poller := emptyPoller(fd)
+ defer func() {
+ if errno != nil {
+ poller.close()
+ }
+ }()
+ poller.fd = fd
+
+ // Create epoll fd
+ poller.epfd, errno = unix.EpollCreate1(0)
+ if poller.epfd == -1 {
+ return nil, errno
+ }
+ // Create pipe; pipe[0] is the read end, pipe[1] the write end.
+ errno = unix.Pipe2(poller.pipe[:], unix.O_NONBLOCK)
+ if errno != nil {
+ return nil, errno
+ }
+
+ // Register inotify fd with epoll
+ event := unix.EpollEvent{
+ Fd: int32(poller.fd),
+ Events: unix.EPOLLIN,
+ }
+ errno = unix.EpollCtl(poller.epfd, unix.EPOLL_CTL_ADD, poller.fd, &event)
+ if errno != nil {
+ return nil, errno
+ }
+
+ // Register pipe fd with epoll
+ event = unix.EpollEvent{
+ Fd: int32(poller.pipe[0]),
+ Events: unix.EPOLLIN,
+ }
+ errno = unix.EpollCtl(poller.epfd, unix.EPOLL_CTL_ADD, poller.pipe[0], &event)
+ if errno != nil {
+ return nil, errno
+ }
+
+ return poller, nil
+}
+
+// Wait using epoll.
+// Returns true if something is ready to be read,
+// false if there is not.
+func (poller *fdPoller) wait() (bool, error) {
+ // 3 possible events per fd, and 2 fds, makes a maximum of 6 events.
+ // I don't know whether epoll_wait returns the number of events returned,
+ // or the total number of events ready.
+ // I decided to catch both by making the buffer one larger than the maximum.
+ events := make([]unix.EpollEvent, 7)
+ for {
+ n, errno := unix.EpollWait(poller.epfd, events, -1)
+ if n == -1 {
+ if errno == unix.EINTR {
+ continue
+ }
+ return false, errno
+ }
+ if n == 0 {
+ // If there are no events, try again.
+ continue
+ }
+ if n > 6 {
+ // This should never happen. More events were returned than should be possible.
+ return false, errors.New("epoll_wait returned more events than I know what to do with")
+ }
+ ready := events[:n]
+ epollhup := false
+ epollerr := false
+ epollin := false
+ for _, event := range ready {
+ if event.Fd == int32(poller.fd) {
+ if event.Events&unix.EPOLLHUP != 0 {
+ // This should not happen, but if it does, treat it as a wakeup.
+ epollhup = true
+ }
+ if event.Events&unix.EPOLLERR != 0 {
+ // If an error is waiting on the file descriptor, we should pretend
+ // something is ready to read, and let unix.Read pick up the error.
+ epollerr = true
+ }
+ if event.Events&unix.EPOLLIN != 0 {
+ // There is data to read.
+ epollin = true
+ }
+ }
+ if event.Fd == int32(poller.pipe[0]) {
+ if event.Events&unix.EPOLLHUP != 0 {
+ // Write pipe descriptor was closed, by us. This means we're closing down the
+ // watcher, and we should wake up.
+ }
+ if event.Events&unix.EPOLLERR != 0 {
+ // If an error is waiting on the pipe file descriptor.
+ // This is an absolute mystery, and should never ever happen.
+ return false, errors.New("Error on the pipe descriptor.")
+ }
+ if event.Events&unix.EPOLLIN != 0 {
+ // This is a regular wakeup, so we have to clear the buffer.
+ err := poller.clearWake()
+ if err != nil {
+ return false, err
+ }
+ }
+ }
+ }
+
+ if epollhup || epollerr || epollin {
+ return true, nil
+ }
+ return false, nil
+ }
+}
+
+// Close the write end of the poller.
+func (poller *fdPoller) wake() error {
+ buf := make([]byte, 1)
+ n, errno := unix.Write(poller.pipe[1], buf)
+ if n == -1 {
+ if errno == unix.EAGAIN {
+ // Buffer is full, poller will wake.
+ return nil
+ }
+ return errno
+ }
+ return nil
+}
+
+func (poller *fdPoller) clearWake() error {
+ // You have to be woken up a LOT in order to get to 100!
+ buf := make([]byte, 100)
+ n, errno := unix.Read(poller.pipe[0], buf)
+ if n == -1 {
+ if errno == unix.EAGAIN {
+ // Buffer is empty, someone else cleared our wake.
+ return nil
+ }
+ return errno
+ }
+ return nil
+}
+
+// Close all poller file descriptors, but not the one passed to it.
+func (poller *fdPoller) close() {
+ if poller.pipe[1] != -1 {
+ unix.Close(poller.pipe[1])
+ }
+ if poller.pipe[0] != -1 {
+ unix.Close(poller.pipe[0])
+ }
+ if poller.epfd != -1 {
+ unix.Close(poller.epfd)
+ }
+}
diff --git a/vendor/gopkg.in/fsnotify.v1/kqueue.go b/vendor/gopkg.in/fsnotify.v1/kqueue.go
new file mode 100644
index 000000000..c2b4acb18
--- /dev/null
+++ b/vendor/gopkg.in/fsnotify.v1/kqueue.go
@@ -0,0 +1,503 @@
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build freebsd openbsd netbsd dragonfly darwin
+
+package fsnotify
+
+import (
+ "errors"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "sync"
+ "time"
+
+ "golang.org/x/sys/unix"
+)
+
+// Watcher watches a set of files, delivering events to a channel.
+type Watcher struct {
+ Events chan Event
+ Errors chan error
+ done chan bool // Channel for sending a "quit message" to the reader goroutine
+
+ kq int // File descriptor (as returned by the kqueue() syscall).
+
+ mu sync.Mutex // Protects access to watcher data
+ watches map[string]int // Map of watched file descriptors (key: path).
+ externalWatches map[string]bool // Map of watches added by user of the library.
+ dirFlags map[string]uint32 // Map of watched directories to fflags used in kqueue.
+ paths map[int]pathInfo // Map file descriptors to path names for processing kqueue events.
+ fileExists map[string]bool // Keep track of if we know this file exists (to stop duplicate create events).
+ isClosed bool // Set to true when Close() is first called
+}
+
+type pathInfo struct {
+ name string
+ isDir bool
+}
+
+// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
+func NewWatcher() (*Watcher, error) {
+ kq, err := kqueue()
+ if err != nil {
+ return nil, err
+ }
+
+ w := &Watcher{
+ kq: kq,
+ watches: make(map[string]int),
+ dirFlags: make(map[string]uint32),
+ paths: make(map[int]pathInfo),
+ fileExists: make(map[string]bool),
+ externalWatches: make(map[string]bool),
+ Events: make(chan Event),
+ Errors: make(chan error),
+ done: make(chan bool),
+ }
+
+ go w.readEvents()
+ return w, nil
+}
+
+// Close removes all watches and closes the events channel.
+func (w *Watcher) Close() error {
+ w.mu.Lock()
+ if w.isClosed {
+ w.mu.Unlock()
+ return nil
+ }
+ w.isClosed = true
+ w.mu.Unlock()
+
+ // copy paths to remove while locked
+ w.mu.Lock()
+ var pathsToRemove = make([]string, 0, len(w.watches))
+ for name := range w.watches {
+ pathsToRemove = append(pathsToRemove, name)
+ }
+ w.mu.Unlock()
+ // unlock before calling Remove, which also locks
+
+ var err error
+ for _, name := range pathsToRemove {
+ if e := w.Remove(name); e != nil && err == nil {
+ err = e
+ }
+ }
+
+ // Send "quit" message to the reader goroutine:
+ w.done <- true
+
+ return nil
+}
+
+// Add starts watching the named file or directory (non-recursively).
+func (w *Watcher) Add(name string) error {
+ w.mu.Lock()
+ w.externalWatches[name] = true
+ w.mu.Unlock()
+ _, err := w.addWatch(name, noteAllEvents)
+ return err
+}
+
+// Remove stops watching the the named file or directory (non-recursively).
+func (w *Watcher) Remove(name string) error {
+ name = filepath.Clean(name)
+ w.mu.Lock()
+ watchfd, ok := w.watches[name]
+ w.mu.Unlock()
+ if !ok {
+ return fmt.Errorf("can't remove non-existent kevent watch for: %s", name)
+ }
+
+ const registerRemove = unix.EV_DELETE
+ if err := register(w.kq, []int{watchfd}, registerRemove, 0); err != nil {
+ return err
+ }
+
+ unix.Close(watchfd)
+
+ w.mu.Lock()
+ isDir := w.paths[watchfd].isDir
+ delete(w.watches, name)
+ delete(w.paths, watchfd)
+ delete(w.dirFlags, name)
+ w.mu.Unlock()
+
+ // Find all watched paths that are in this directory that are not external.
+ if isDir {
+ var pathsToRemove []string
+ w.mu.Lock()
+ for _, path := range w.paths {
+ wdir, _ := filepath.Split(path.name)
+ if filepath.Clean(wdir) == name {
+ if !w.externalWatches[path.name] {
+ pathsToRemove = append(pathsToRemove, path.name)
+ }
+ }
+ }
+ w.mu.Unlock()
+ for _, name := range pathsToRemove {
+ // Since these are internal, not much sense in propagating error
+ // to the user, as that will just confuse them with an error about
+ // a path they did not explicitly watch themselves.
+ w.Remove(name)
+ }
+ }
+
+ return nil
+}
+
+// Watch all events (except NOTE_EXTEND, NOTE_LINK, NOTE_REVOKE)
+const noteAllEvents = unix.NOTE_DELETE | unix.NOTE_WRITE | unix.NOTE_ATTRIB | unix.NOTE_RENAME
+
+// keventWaitTime to block on each read from kevent
+var keventWaitTime = durationToTimespec(100 * time.Millisecond)
+
+// addWatch adds name to the watched file set.
+// The flags are interpreted as described in kevent(2).
+// Returns the real path to the file which was added, if any, which may be different from the one passed in the case of symlinks.
+func (w *Watcher) addWatch(name string, flags uint32) (string, error) {
+ var isDir bool
+ // Make ./name and name equivalent
+ name = filepath.Clean(name)
+
+ w.mu.Lock()
+ if w.isClosed {
+ w.mu.Unlock()
+ return "", errors.New("kevent instance already closed")
+ }
+ watchfd, alreadyWatching := w.watches[name]
+ // We already have a watch, but we can still override flags.
+ if alreadyWatching {
+ isDir = w.paths[watchfd].isDir
+ }
+ w.mu.Unlock()
+
+ if !alreadyWatching {
+ fi, err := os.Lstat(name)
+ if err != nil {
+ return "", err
+ }
+
+ // Don't watch sockets.
+ if fi.Mode()&os.ModeSocket == os.ModeSocket {
+ return "", nil
+ }
+
+ // Don't watch named pipes.
+ if fi.Mode()&os.ModeNamedPipe == os.ModeNamedPipe {
+ return "", nil
+ }
+
+ // Follow Symlinks
+ // Unfortunately, Linux can add bogus symlinks to watch list without
+ // issue, and Windows can't do symlinks period (AFAIK). To maintain
+ // consistency, we will act like everything is fine. There will simply
+ // be no file events for broken symlinks.
+ // Hence the returns of nil on errors.
+ if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
+ name, err = filepath.EvalSymlinks(name)
+ if err != nil {
+ return "", nil
+ }
+
+ w.mu.Lock()
+ _, alreadyWatching = w.watches[name]
+ w.mu.Unlock()
+
+ if alreadyWatching {
+ return name, nil
+ }
+
+ fi, err = os.Lstat(name)
+ if err != nil {
+ return "", nil
+ }
+ }
+
+ watchfd, err = unix.Open(name, openMode, 0700)
+ if watchfd == -1 {
+ return "", err
+ }
+
+ isDir = fi.IsDir()
+ }
+
+ const registerAdd = unix.EV_ADD | unix.EV_CLEAR | unix.EV_ENABLE
+ if err := register(w.kq, []int{watchfd}, registerAdd, flags); err != nil {
+ unix.Close(watchfd)
+ return "", err
+ }
+
+ if !alreadyWatching {
+ w.mu.Lock()
+ w.watches[name] = watchfd
+ w.paths[watchfd] = pathInfo{name: name, isDir: isDir}
+ w.mu.Unlock()
+ }
+
+ if isDir {
+ // Watch the directory if it has not been watched before,
+ // or if it was watched before, but perhaps only a NOTE_DELETE (watchDirectoryFiles)
+ w.mu.Lock()
+
+ watchDir := (flags&unix.NOTE_WRITE) == unix.NOTE_WRITE &&
+ (!alreadyWatching || (w.dirFlags[name]&unix.NOTE_WRITE) != unix.NOTE_WRITE)
+ // Store flags so this watch can be updated later
+ w.dirFlags[name] = flags
+ w.mu.Unlock()
+
+ if watchDir {
+ if err := w.watchDirectoryFiles(name); err != nil {
+ return "", err
+ }
+ }
+ }
+ return name, nil
+}
+
+// readEvents reads from kqueue and converts the received kevents into
+// Event values that it sends down the Events channel.
+func (w *Watcher) readEvents() {
+ eventBuffer := make([]unix.Kevent_t, 10)
+
+ for {
+ // See if there is a message on the "done" channel
+ select {
+ case <-w.done:
+ err := unix.Close(w.kq)
+ if err != nil {
+ w.Errors <- err
+ }
+ close(w.Events)
+ close(w.Errors)
+ return
+ default:
+ }
+
+ // Get new events
+ kevents, err := read(w.kq, eventBuffer, &keventWaitTime)
+ // EINTR is okay, the syscall was interrupted before timeout expired.
+ if err != nil && err != unix.EINTR {
+ w.Errors <- err
+ continue
+ }
+
+ // Flush the events we received to the Events channel
+ for len(kevents) > 0 {
+ kevent := &kevents[0]
+ watchfd := int(kevent.Ident)
+ mask := uint32(kevent.Fflags)
+ w.mu.Lock()
+ path := w.paths[watchfd]
+ w.mu.Unlock()
+ event := newEvent(path.name, mask)
+
+ if path.isDir && !(event.Op&Remove == Remove) {
+ // Double check to make sure the directory exists. This can happen when
+ // we do a rm -fr on a recursively watched folders and we receive a
+ // modification event first but the folder has been deleted and later
+ // receive the delete event
+ if _, err := os.Lstat(event.Name); os.IsNotExist(err) {
+ // mark is as delete event
+ event.Op |= Remove
+ }
+ }
+
+ if event.Op&Rename == Rename || event.Op&Remove == Remove {
+ w.Remove(event.Name)
+ w.mu.Lock()
+ delete(w.fileExists, event.Name)
+ w.mu.Unlock()
+ }
+
+ if path.isDir && event.Op&Write == Write && !(event.Op&Remove == Remove) {
+ w.sendDirectoryChangeEvents(event.Name)
+ } else {
+ // Send the event on the Events channel
+ w.Events <- event
+ }
+
+ if event.Op&Remove == Remove {
+ // Look for a file that may have overwritten this.
+ // For example, mv f1 f2 will delete f2, then create f2.
+ if path.isDir {
+ fileDir := filepath.Clean(event.Name)
+ w.mu.Lock()
+ _, found := w.watches[fileDir]
+ w.mu.Unlock()
+ if found {
+ // make sure the directory exists before we watch for changes. When we
+ // do a recursive watch and perform rm -fr, the parent directory might
+ // have gone missing, ignore the missing directory and let the
+ // upcoming delete event remove the watch from the parent directory.
+ if _, err := os.Lstat(fileDir); err == nil {
+ w.sendDirectoryChangeEvents(fileDir)
+ }
+ }
+ } else {
+ filePath := filepath.Clean(event.Name)
+ if fileInfo, err := os.Lstat(filePath); err == nil {
+ w.sendFileCreatedEventIfNew(filePath, fileInfo)
+ }
+ }
+ }
+
+ // Move to next event
+ kevents = kevents[1:]
+ }
+ }
+}
+
+// newEvent returns an platform-independent Event based on kqueue Fflags.
+func newEvent(name string, mask uint32) Event {
+ e := Event{Name: name}
+ if mask&unix.NOTE_DELETE == unix.NOTE_DELETE {
+ e.Op |= Remove
+ }
+ if mask&unix.NOTE_WRITE == unix.NOTE_WRITE {
+ e.Op |= Write
+ }
+ if mask&unix.NOTE_RENAME == unix.NOTE_RENAME {
+ e.Op |= Rename
+ }
+ if mask&unix.NOTE_ATTRIB == unix.NOTE_ATTRIB {
+ e.Op |= Chmod
+ }
+ return e
+}
+
+func newCreateEvent(name string) Event {
+ return Event{Name: name, Op: Create}
+}
+
+// watchDirectoryFiles to mimic inotify when adding a watch on a directory
+func (w *Watcher) watchDirectoryFiles(dirPath string) error {
+ // Get all files
+ files, err := ioutil.ReadDir(dirPath)
+ if err != nil {
+ return err
+ }
+
+ for _, fileInfo := range files {
+ filePath := filepath.Join(dirPath, fileInfo.Name())
+ filePath, err = w.internalWatch(filePath, fileInfo)
+ if err != nil {
+ return err
+ }
+
+ w.mu.Lock()
+ w.fileExists[filePath] = true
+ w.mu.Unlock()
+ }
+
+ return nil
+}
+
+// sendDirectoryEvents searches the directory for newly created files
+// and sends them over the event channel. This functionality is to have
+// the BSD version of fsnotify match Linux inotify which provides a
+// create event for files created in a watched directory.
+func (w *Watcher) sendDirectoryChangeEvents(dirPath string) {
+ // Get all files
+ files, err := ioutil.ReadDir(dirPath)
+ if err != nil {
+ w.Errors <- err
+ }
+
+ // Search for new files
+ for _, fileInfo := range files {
+ filePath := filepath.Join(dirPath, fileInfo.Name())
+ err := w.sendFileCreatedEventIfNew(filePath, fileInfo)
+
+ if err != nil {
+ return
+ }
+ }
+}
+
+// sendFileCreatedEvent sends a create event if the file isn't already being tracked.
+func (w *Watcher) sendFileCreatedEventIfNew(filePath string, fileInfo os.FileInfo) (err error) {
+ w.mu.Lock()
+ _, doesExist := w.fileExists[filePath]
+ w.mu.Unlock()
+ if !doesExist {
+ // Send create event
+ w.Events <- newCreateEvent(filePath)
+ }
+
+ // like watchDirectoryFiles (but without doing another ReadDir)
+ filePath, err = w.internalWatch(filePath, fileInfo)
+ if err != nil {
+ return err
+ }
+
+ w.mu.Lock()
+ w.fileExists[filePath] = true
+ w.mu.Unlock()
+
+ return nil
+}
+
+func (w *Watcher) internalWatch(name string, fileInfo os.FileInfo) (string, error) {
+ if fileInfo.IsDir() {
+ // mimic Linux providing delete events for subdirectories
+ // but preserve the flags used if currently watching subdirectory
+ w.mu.Lock()
+ flags := w.dirFlags[name]
+ w.mu.Unlock()
+
+ flags |= unix.NOTE_DELETE | unix.NOTE_RENAME
+ return w.addWatch(name, flags)
+ }
+
+ // watch file to mimic Linux inotify
+ return w.addWatch(name, noteAllEvents)
+}
+
+// kqueue creates a new kernel event queue and returns a descriptor.
+func kqueue() (kq int, err error) {
+ kq, err = unix.Kqueue()
+ if kq == -1 {
+ return kq, err
+ }
+ return kq, nil
+}
+
+// register events with the queue
+func register(kq int, fds []int, flags int, fflags uint32) error {
+ changes := make([]unix.Kevent_t, len(fds))
+
+ for i, fd := range fds {
+ // SetKevent converts int to the platform-specific types:
+ unix.SetKevent(&changes[i], fd, unix.EVFILT_VNODE, flags)
+ changes[i].Fflags = fflags
+ }
+
+ // register the events
+ success, err := unix.Kevent(kq, changes, nil, nil)
+ if success == -1 {
+ return err
+ }
+ return nil
+}
+
+// read retrieves pending events, or waits until an event occurs.
+// A timeout of nil blocks indefinitely, while 0 polls the queue.
+func read(kq int, events []unix.Kevent_t, timeout *unix.Timespec) ([]unix.Kevent_t, error) {
+ n, err := unix.Kevent(kq, nil, events, timeout)
+ if err != nil {
+ return nil, err
+ }
+ return events[0:n], nil
+}
+
+// durationToTimespec prepares a timeout value
+func durationToTimespec(d time.Duration) unix.Timespec {
+ return unix.NsecToTimespec(d.Nanoseconds())
+}
diff --git a/vendor/gopkg.in/fsnotify.v1/open_mode_bsd.go b/vendor/gopkg.in/fsnotify.v1/open_mode_bsd.go
new file mode 100644
index 000000000..7d8de1451
--- /dev/null
+++ b/vendor/gopkg.in/fsnotify.v1/open_mode_bsd.go
@@ -0,0 +1,11 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build freebsd openbsd netbsd dragonfly
+
+package fsnotify
+
+import "golang.org/x/sys/unix"
+
+const openMode = unix.O_NONBLOCK | unix.O_RDONLY
diff --git a/vendor/gopkg.in/fsnotify.v1/open_mode_darwin.go b/vendor/gopkg.in/fsnotify.v1/open_mode_darwin.go
new file mode 100644
index 000000000..9139e1716
--- /dev/null
+++ b/vendor/gopkg.in/fsnotify.v1/open_mode_darwin.go
@@ -0,0 +1,12 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build darwin
+
+package fsnotify
+
+import "golang.org/x/sys/unix"
+
+// note: this constant is not defined on BSD
+const openMode = unix.O_EVTONLY
diff --git a/vendor/gopkg.in/fsnotify.v1/windows.go b/vendor/gopkg.in/fsnotify.v1/windows.go
new file mode 100644
index 000000000..09436f31d
--- /dev/null
+++ b/vendor/gopkg.in/fsnotify.v1/windows.go
@@ -0,0 +1,561 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build windows
+
+package fsnotify
+
+import (
+ "errors"
+ "fmt"
+ "os"
+ "path/filepath"
+ "runtime"
+ "sync"
+ "syscall"
+ "unsafe"
+)
+
+// Watcher watches a set of files, delivering events to a channel.
+type Watcher struct {
+ Events chan Event
+ Errors chan error
+ isClosed bool // Set to true when Close() is first called
+ mu sync.Mutex // Map access
+ port syscall.Handle // Handle to completion port
+ watches watchMap // Map of watches (key: i-number)
+ input chan *input // Inputs to the reader are sent on this channel
+ quit chan chan<- error
+}
+
+// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
+func NewWatcher() (*Watcher, error) {
+ port, e := syscall.CreateIoCompletionPort(syscall.InvalidHandle, 0, 0, 0)
+ if e != nil {
+ return nil, os.NewSyscallError("CreateIoCompletionPort", e)
+ }
+ w := &Watcher{
+ port: port,
+ watches: make(watchMap),
+ input: make(chan *input, 1),
+ Events: make(chan Event, 50),
+ Errors: make(chan error),
+ quit: make(chan chan<- error, 1),
+ }
+ go w.readEvents()
+ return w, nil
+}
+
+// Close removes all watches and closes the events channel.
+func (w *Watcher) Close() error {
+ if w.isClosed {
+ return nil
+ }
+ w.isClosed = true
+
+ // Send "quit" message to the reader goroutine
+ ch := make(chan error)
+ w.quit <- ch
+ if err := w.wakeupReader(); err != nil {
+ return err
+ }
+ return <-ch
+}
+
+// Add starts watching the named file or directory (non-recursively).
+func (w *Watcher) Add(name string) error {
+ if w.isClosed {
+ return errors.New("watcher already closed")
+ }
+ in := &input{
+ op: opAddWatch,
+ path: filepath.Clean(name),
+ flags: sysFSALLEVENTS,
+ reply: make(chan error),
+ }
+ w.input <- in
+ if err := w.wakeupReader(); err != nil {
+ return err
+ }
+ return <-in.reply
+}
+
+// Remove stops watching the the named file or directory (non-recursively).
+func (w *Watcher) Remove(name string) error {
+ in := &input{
+ op: opRemoveWatch,
+ path: filepath.Clean(name),
+ reply: make(chan error),
+ }
+ w.input <- in
+ if err := w.wakeupReader(); err != nil {
+ return err
+ }
+ return <-in.reply
+}
+
+const (
+ // Options for AddWatch
+ sysFSONESHOT = 0x80000000
+ sysFSONLYDIR = 0x1000000
+
+ // Events
+ sysFSACCESS = 0x1
+ sysFSALLEVENTS = 0xfff
+ sysFSATTRIB = 0x4
+ sysFSCLOSE = 0x18
+ sysFSCREATE = 0x100
+ sysFSDELETE = 0x200
+ sysFSDELETESELF = 0x400
+ sysFSMODIFY = 0x2
+ sysFSMOVE = 0xc0
+ sysFSMOVEDFROM = 0x40
+ sysFSMOVEDTO = 0x80
+ sysFSMOVESELF = 0x800
+
+ // Special events
+ sysFSIGNORED = 0x8000
+ sysFSQOVERFLOW = 0x4000
+)
+
+func newEvent(name string, mask uint32) Event {
+ e := Event{Name: name}
+ if mask&sysFSCREATE == sysFSCREATE || mask&sysFSMOVEDTO == sysFSMOVEDTO {
+ e.Op |= Create
+ }
+ if mask&sysFSDELETE == sysFSDELETE || mask&sysFSDELETESELF == sysFSDELETESELF {
+ e.Op |= Remove
+ }
+ if mask&sysFSMODIFY == sysFSMODIFY {
+ e.Op |= Write
+ }
+ if mask&sysFSMOVE == sysFSMOVE || mask&sysFSMOVESELF == sysFSMOVESELF || mask&sysFSMOVEDFROM == sysFSMOVEDFROM {
+ e.Op |= Rename
+ }
+ if mask&sysFSATTRIB == sysFSATTRIB {
+ e.Op |= Chmod
+ }
+ return e
+}
+
+const (
+ opAddWatch = iota
+ opRemoveWatch
+)
+
+const (
+ provisional uint64 = 1 << (32 + iota)
+)
+
+type input struct {
+ op int
+ path string
+ flags uint32
+ reply chan error
+}
+
+type inode struct {
+ handle syscall.Handle
+ volume uint32
+ index uint64
+}
+
+type watch struct {
+ ov syscall.Overlapped
+ ino *inode // i-number
+ path string // Directory path
+ mask uint64 // Directory itself is being watched with these notify flags
+ names map[string]uint64 // Map of names being watched and their notify flags
+ rename string // Remembers the old name while renaming a file
+ buf [4096]byte
+}
+
+type indexMap map[uint64]*watch
+type watchMap map[uint32]indexMap
+
+func (w *Watcher) wakeupReader() error {
+ e := syscall.PostQueuedCompletionStatus(w.port, 0, 0, nil)
+ if e != nil {
+ return os.NewSyscallError("PostQueuedCompletionStatus", e)
+ }
+ return nil
+}
+
+func getDir(pathname string) (dir string, err error) {
+ attr, e := syscall.GetFileAttributes(syscall.StringToUTF16Ptr(pathname))
+ if e != nil {
+ return "", os.NewSyscallError("GetFileAttributes", e)
+ }
+ if attr&syscall.FILE_ATTRIBUTE_DIRECTORY != 0 {
+ dir = pathname
+ } else {
+ dir, _ = filepath.Split(pathname)
+ dir = filepath.Clean(dir)
+ }
+ return
+}
+
+func getIno(path string) (ino *inode, err error) {
+ h, e := syscall.CreateFile(syscall.StringToUTF16Ptr(path),
+ syscall.FILE_LIST_DIRECTORY,
+ syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE,
+ nil, syscall.OPEN_EXISTING,
+ syscall.FILE_FLAG_BACKUP_SEMANTICS|syscall.FILE_FLAG_OVERLAPPED, 0)
+ if e != nil {
+ return nil, os.NewSyscallError("CreateFile", e)
+ }
+ var fi syscall.ByHandleFileInformation
+ if e = syscall.GetFileInformationByHandle(h, &fi); e != nil {
+ syscall.CloseHandle(h)
+ return nil, os.NewSyscallError("GetFileInformationByHandle", e)
+ }
+ ino = &inode{
+ handle: h,
+ volume: fi.VolumeSerialNumber,
+ index: uint64(fi.FileIndexHigh)<<32 | uint64(fi.FileIndexLow),
+ }
+ return ino, nil
+}
+
+// Must run within the I/O thread.
+func (m watchMap) get(ino *inode) *watch {
+ if i := m[ino.volume]; i != nil {
+ return i[ino.index]
+ }
+ return nil
+}
+
+// Must run within the I/O thread.
+func (m watchMap) set(ino *inode, watch *watch) {
+ i := m[ino.volume]
+ if i == nil {
+ i = make(indexMap)
+ m[ino.volume] = i
+ }
+ i[ino.index] = watch
+}
+
+// Must run within the I/O thread.
+func (w *Watcher) addWatch(pathname string, flags uint64) error {
+ dir, err := getDir(pathname)
+ if err != nil {
+ return err
+ }
+ if flags&sysFSONLYDIR != 0 && pathname != dir {
+ return nil
+ }
+ ino, err := getIno(dir)
+ if err != nil {
+ return err
+ }
+ w.mu.Lock()
+ watchEntry := w.watches.get(ino)
+ w.mu.Unlock()
+ if watchEntry == nil {
+ if _, e := syscall.CreateIoCompletionPort(ino.handle, w.port, 0, 0); e != nil {
+ syscall.CloseHandle(ino.handle)
+ return os.NewSyscallError("CreateIoCompletionPort", e)
+ }
+ watchEntry = &watch{
+ ino: ino,
+ path: dir,
+ names: make(map[string]uint64),
+ }
+ w.mu.Lock()
+ w.watches.set(ino, watchEntry)
+ w.mu.Unlock()
+ flags |= provisional
+ } else {
+ syscall.CloseHandle(ino.handle)
+ }
+ if pathname == dir {
+ watchEntry.mask |= flags
+ } else {
+ watchEntry.names[filepath.Base(pathname)] |= flags
+ }
+ if err = w.startRead(watchEntry); err != nil {
+ return err
+ }
+ if pathname == dir {
+ watchEntry.mask &= ^provisional
+ } else {
+ watchEntry.names[filepath.Base(pathname)] &= ^provisional
+ }
+ return nil
+}
+
+// Must run within the I/O thread.
+func (w *Watcher) remWatch(pathname string) error {
+ dir, err := getDir(pathname)
+ if err != nil {
+ return err
+ }
+ ino, err := getIno(dir)
+ if err != nil {
+ return err
+ }
+ w.mu.Lock()
+ watch := w.watches.get(ino)
+ w.mu.Unlock()
+ if watch == nil {
+ return fmt.Errorf("can't remove non-existent watch for: %s", pathname)
+ }
+ if pathname == dir {
+ w.sendEvent(watch.path, watch.mask&sysFSIGNORED)
+ watch.mask = 0
+ } else {
+ name := filepath.Base(pathname)
+ w.sendEvent(filepath.Join(watch.path, name), watch.names[name]&sysFSIGNORED)
+ delete(watch.names, name)
+ }
+ return w.startRead(watch)
+}
+
+// Must run within the I/O thread.
+func (w *Watcher) deleteWatch(watch *watch) {
+ for name, mask := range watch.names {
+ if mask&provisional == 0 {
+ w.sendEvent(filepath.Join(watch.path, name), mask&sysFSIGNORED)
+ }
+ delete(watch.names, name)
+ }
+ if watch.mask != 0 {
+ if watch.mask&provisional == 0 {
+ w.sendEvent(watch.path, watch.mask&sysFSIGNORED)
+ }
+ watch.mask = 0
+ }
+}
+
+// Must run within the I/O thread.
+func (w *Watcher) startRead(watch *watch) error {
+ if e := syscall.CancelIo(watch.ino.handle); e != nil {
+ w.Errors <- os.NewSyscallError("CancelIo", e)
+ w.deleteWatch(watch)
+ }
+ mask := toWindowsFlags(watch.mask)
+ for _, m := range watch.names {
+ mask |= toWindowsFlags(m)
+ }
+ if mask == 0 {
+ if e := syscall.CloseHandle(watch.ino.handle); e != nil {
+ w.Errors <- os.NewSyscallError("CloseHandle", e)
+ }
+ w.mu.Lock()
+ delete(w.watches[watch.ino.volume], watch.ino.index)
+ w.mu.Unlock()
+ return nil
+ }
+ e := syscall.ReadDirectoryChanges(watch.ino.handle, &watch.buf[0],
+ uint32(unsafe.Sizeof(watch.buf)), false, mask, nil, &watch.ov, 0)
+ if e != nil {
+ err := os.NewSyscallError("ReadDirectoryChanges", e)
+ if e == syscall.ERROR_ACCESS_DENIED && watch.mask&provisional == 0 {
+ // Watched directory was probably removed
+ if w.sendEvent(watch.path, watch.mask&sysFSDELETESELF) {
+ if watch.mask&sysFSONESHOT != 0 {
+ watch.mask = 0
+ }
+ }
+ err = nil
+ }
+ w.deleteWatch(watch)
+ w.startRead(watch)
+ return err
+ }
+ return nil
+}
+
+// readEvents reads from the I/O completion port, converts the
+// received events into Event objects and sends them via the Events channel.
+// Entry point to the I/O thread.
+func (w *Watcher) readEvents() {
+ var (
+ n, key uint32
+ ov *syscall.Overlapped
+ )
+ runtime.LockOSThread()
+
+ for {
+ e := syscall.GetQueuedCompletionStatus(w.port, &n, &key, &ov, syscall.INFINITE)
+ watch := (*watch)(unsafe.Pointer(ov))
+
+ if watch == nil {
+ select {
+ case ch := <-w.quit:
+ w.mu.Lock()
+ var indexes []indexMap
+ for _, index := range w.watches {
+ indexes = append(indexes, index)
+ }
+ w.mu.Unlock()
+ for _, index := range indexes {
+ for _, watch := range index {
+ w.deleteWatch(watch)
+ w.startRead(watch)
+ }
+ }
+ var err error
+ if e := syscall.CloseHandle(w.port); e != nil {
+ err = os.NewSyscallError("CloseHandle", e)
+ }
+ close(w.Events)
+ close(w.Errors)
+ ch <- err
+ return
+ case in := <-w.input:
+ switch in.op {
+ case opAddWatch:
+ in.reply <- w.addWatch(in.path, uint64(in.flags))
+ case opRemoveWatch:
+ in.reply <- w.remWatch(in.path)
+ }
+ default:
+ }
+ continue
+ }
+
+ switch e {
+ case syscall.ERROR_MORE_DATA:
+ if watch == nil {
+ w.Errors <- errors.New("ERROR_MORE_DATA has unexpectedly null lpOverlapped buffer")
+ } else {
+ // The i/o succeeded but the buffer is full.
+ // In theory we should be building up a full packet.
+ // In practice we can get away with just carrying on.
+ n = uint32(unsafe.Sizeof(watch.buf))
+ }
+ case syscall.ERROR_ACCESS_DENIED:
+ // Watched directory was probably removed
+ w.sendEvent(watch.path, watch.mask&sysFSDELETESELF)
+ w.deleteWatch(watch)
+ w.startRead(watch)
+ continue
+ case syscall.ERROR_OPERATION_ABORTED:
+ // CancelIo was called on this handle
+ continue
+ default:
+ w.Errors <- os.NewSyscallError("GetQueuedCompletionPort", e)
+ continue
+ case nil:
+ }
+
+ var offset uint32
+ for {
+ if n == 0 {
+ w.Events <- newEvent("", sysFSQOVERFLOW)
+ w.Errors <- errors.New("short read in readEvents()")
+ break
+ }
+
+ // Point "raw" to the event in the buffer
+ raw := (*syscall.FileNotifyInformation)(unsafe.Pointer(&watch.buf[offset]))
+ buf := (*[syscall.MAX_PATH]uint16)(unsafe.Pointer(&raw.FileName))
+ name := syscall.UTF16ToString(buf[:raw.FileNameLength/2])
+ fullname := filepath.Join(watch.path, name)
+
+ var mask uint64
+ switch raw.Action {
+ case syscall.FILE_ACTION_REMOVED:
+ mask = sysFSDELETESELF
+ case syscall.FILE_ACTION_MODIFIED:
+ mask = sysFSMODIFY
+ case syscall.FILE_ACTION_RENAMED_OLD_NAME:
+ watch.rename = name
+ case syscall.FILE_ACTION_RENAMED_NEW_NAME:
+ if watch.names[watch.rename] != 0 {
+ watch.names[name] |= watch.names[watch.rename]
+ delete(watch.names, watch.rename)
+ mask = sysFSMOVESELF
+ }
+ }
+
+ sendNameEvent := func() {
+ if w.sendEvent(fullname, watch.names[name]&mask) {
+ if watch.names[name]&sysFSONESHOT != 0 {
+ delete(watch.names, name)
+ }
+ }
+ }
+ if raw.Action != syscall.FILE_ACTION_RENAMED_NEW_NAME {
+ sendNameEvent()
+ }
+ if raw.Action == syscall.FILE_ACTION_REMOVED {
+ w.sendEvent(fullname, watch.names[name]&sysFSIGNORED)
+ delete(watch.names, name)
+ }
+ if w.sendEvent(fullname, watch.mask&toFSnotifyFlags(raw.Action)) {
+ if watch.mask&sysFSONESHOT != 0 {
+ watch.mask = 0
+ }
+ }
+ if raw.Action == syscall.FILE_ACTION_RENAMED_NEW_NAME {
+ fullname = filepath.Join(watch.path, watch.rename)
+ sendNameEvent()
+ }
+
+ // Move to the next event in the buffer
+ if raw.NextEntryOffset == 0 {
+ break
+ }
+ offset += raw.NextEntryOffset
+
+ // Error!
+ if offset >= n {
+ w.Errors <- errors.New("Windows system assumed buffer larger than it is, events have likely been missed.")
+ break
+ }
+ }
+
+ if err := w.startRead(watch); err != nil {
+ w.Errors <- err
+ }
+ }
+}
+
+func (w *Watcher) sendEvent(name string, mask uint64) bool {
+ if mask == 0 {
+ return false
+ }
+ event := newEvent(name, uint32(mask))
+ select {
+ case ch := <-w.quit:
+ w.quit <- ch
+ case w.Events <- event:
+ }
+ return true
+}
+
+func toWindowsFlags(mask uint64) uint32 {
+ var m uint32
+ if mask&sysFSACCESS != 0 {
+ m |= syscall.FILE_NOTIFY_CHANGE_LAST_ACCESS
+ }
+ if mask&sysFSMODIFY != 0 {
+ m |= syscall.FILE_NOTIFY_CHANGE_LAST_WRITE
+ }
+ if mask&sysFSATTRIB != 0 {
+ m |= syscall.FILE_NOTIFY_CHANGE_ATTRIBUTES
+ }
+ if mask&(sysFSMOVE|sysFSCREATE|sysFSDELETE) != 0 {
+ m |= syscall.FILE_NOTIFY_CHANGE_FILE_NAME | syscall.FILE_NOTIFY_CHANGE_DIR_NAME
+ }
+ return m
+}
+
+func toFSnotifyFlags(action uint32) uint64 {
+ switch action {
+ case syscall.FILE_ACTION_ADDED:
+ return sysFSCREATE
+ case syscall.FILE_ACTION_REMOVED:
+ return sysFSDELETE
+ case syscall.FILE_ACTION_MODIFIED:
+ return sysFSMODIFY
+ case syscall.FILE_ACTION_RENAMED_OLD_NAME:
+ return sysFSMOVEDFROM
+ case syscall.FILE_ACTION_RENAMED_NEW_NAME:
+ return sysFSMOVEDTO
+ }
+ return 0
+}
diff --git a/vendor/gopkg.in/tomb.v1/LICENSE b/vendor/gopkg.in/tomb.v1/LICENSE
new file mode 100644
index 000000000..a4249bb31
--- /dev/null
+++ b/vendor/gopkg.in/tomb.v1/LICENSE
@@ -0,0 +1,29 @@
+tomb - support for clean goroutine termination in Go.
+
+Copyright (c) 2010-2011 - Gustavo Niemeyer <gustavo@niemeyer.net>
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/gopkg.in/tomb.v1/README.md b/vendor/gopkg.in/tomb.v1/README.md
new file mode 100644
index 000000000..3ae8788e8
--- /dev/null
+++ b/vendor/gopkg.in/tomb.v1/README.md
@@ -0,0 +1,4 @@
+Installation and usage
+----------------------
+
+See [gopkg.in/tomb.v1](https://gopkg.in/tomb.v1) for documentation and usage details.
diff --git a/vendor/gopkg.in/tomb.v1/tomb.go b/vendor/gopkg.in/tomb.v1/tomb.go
new file mode 100644
index 000000000..9aec56d82
--- /dev/null
+++ b/vendor/gopkg.in/tomb.v1/tomb.go
@@ -0,0 +1,176 @@
+// Copyright (c) 2011 - Gustavo Niemeyer <gustavo@niemeyer.net>
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+// * Neither the name of the copyright holder nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The tomb package offers a conventional API for clean goroutine termination.
+//
+// A Tomb tracks the lifecycle of a goroutine as alive, dying or dead,
+// and the reason for its death.
+//
+// The zero value of a Tomb assumes that a goroutine is about to be
+// created or already alive. Once Kill or Killf is called with an
+// argument that informs the reason for death, the goroutine is in
+// a dying state and is expected to terminate soon. Right before the
+// goroutine function or method returns, Done must be called to inform
+// that the goroutine is indeed dead and about to stop running.
+//
+// A Tomb exposes Dying and Dead channels. These channels are closed
+// when the Tomb state changes in the respective way. They enable
+// explicit blocking until the state changes, and also to selectively
+// unblock select statements accordingly.
+//
+// When the tomb state changes to dying and there's still logic going
+// on within the goroutine, nested functions and methods may choose to
+// return ErrDying as their error value, as this error won't alter the
+// tomb state if provided to the Kill method. This is a convenient way to
+// follow standard Go practices in the context of a dying tomb.
+//
+// For background and a detailed example, see the following blog post:
+//
+// http://blog.labix.org/2011/10/09/death-of-goroutines-under-control
+//
+// For a more complex code snippet demonstrating the use of multiple
+// goroutines with a single Tomb, see:
+//
+// http://play.golang.org/p/Xh7qWsDPZP
+//
+package tomb
+
+import (
+ "errors"
+ "fmt"
+ "sync"
+)
+
+// A Tomb tracks the lifecycle of a goroutine as alive, dying or dead,
+// and the reason for its death.
+//
+// See the package documentation for details.
+type Tomb struct {
+ m sync.Mutex
+ dying chan struct{}
+ dead chan struct{}
+ reason error
+}
+
+var (
+ ErrStillAlive = errors.New("tomb: still alive")
+ ErrDying = errors.New("tomb: dying")
+)
+
+func (t *Tomb) init() {
+ t.m.Lock()
+ if t.dead == nil {
+ t.dead = make(chan struct{})
+ t.dying = make(chan struct{})
+ t.reason = ErrStillAlive
+ }
+ t.m.Unlock()
+}
+
+// Dead returns the channel that can be used to wait
+// until t.Done has been called.
+func (t *Tomb) Dead() <-chan struct{} {
+ t.init()
+ return t.dead
+}
+
+// Dying returns the channel that can be used to wait
+// until t.Kill or t.Done has been called.
+func (t *Tomb) Dying() <-chan struct{} {
+ t.init()
+ return t.dying
+}
+
+// Wait blocks until the goroutine is in a dead state and returns the
+// reason for its death.
+func (t *Tomb) Wait() error {
+ t.init()
+ <-t.dead
+ t.m.Lock()
+ reason := t.reason
+ t.m.Unlock()
+ return reason
+}
+
+// Done flags the goroutine as dead, and should be called a single time
+// right before the goroutine function or method returns.
+// If the goroutine was not already in a dying state before Done is
+// called, it will be flagged as dying and dead at once with no
+// error.
+func (t *Tomb) Done() {
+ t.Kill(nil)
+ close(t.dead)
+}
+
+// Kill flags the goroutine as dying for the given reason.
+// Kill may be called multiple times, but only the first
+// non-nil error is recorded as the reason for termination.
+//
+// If reason is ErrDying, the previous reason isn't replaced
+// even if it is nil. It's a runtime error to call Kill with
+// ErrDying if t is not in a dying state.
+func (t *Tomb) Kill(reason error) {
+ t.init()
+ t.m.Lock()
+ defer t.m.Unlock()
+ if reason == ErrDying {
+ if t.reason == ErrStillAlive {
+ panic("tomb: Kill with ErrDying while still alive")
+ }
+ return
+ }
+ if t.reason == nil || t.reason == ErrStillAlive {
+ t.reason = reason
+ }
+ // If the receive on t.dying succeeds, then
+ // it can only be because we have already closed it.
+ // If it blocks, then we know that it needs to be closed.
+ select {
+ case <-t.dying:
+ default:
+ close(t.dying)
+ }
+}
+
+// Killf works like Kill, but builds the reason providing the received
+// arguments to fmt.Errorf. The generated error is also returned.
+func (t *Tomb) Killf(f string, a ...interface{}) error {
+ err := fmt.Errorf(f, a...)
+ t.Kill(err)
+ return err
+}
+
+// Err returns the reason for the goroutine death provided via Kill
+// or Killf, or ErrStillAlive when the goroutine is still alive.
+func (t *Tomb) Err() (reason error) {
+ t.init()
+ t.m.Lock()
+ reason = t.reason
+ t.m.Unlock()
+ return
+}