├── .gitallowed ├── .github ├── ISSUE_TEMPLATE │ ├── 1-PUB_SITE.md │ ├── 2-BUG.md │ └── 3-FEATURE.md ├── dependabot.yml └── workflows │ ├── no-response.yml │ └── test.yaml ├── .gitignore ├── .status ├── .test_config ├── AUTHORS ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── bin ├── dependency_services.dart └── pub.dart ├── dart_test.yaml ├── doc ├── cache_layout.md ├── dart_tool_layout.md ├── repository-spec-v2.md └── solver.md ├── lib ├── pub.dart └── src │ ├── ascii_tree.dart │ ├── authentication │ ├── client.dart │ ├── credential.dart │ └── token_store.dart │ ├── command.dart │ ├── command │ ├── add.dart │ ├── bump.dart │ ├── cache.dart │ ├── cache_add.dart │ ├── cache_clean.dart │ ├── cache_list.dart │ ├── cache_preload.dart │ ├── cache_repair.dart │ ├── dependency_services.dart │ ├── deps.dart │ ├── downgrade.dart │ ├── get.dart │ ├── global.dart │ ├── global_activate.dart │ ├── global_deactivate.dart │ ├── global_list.dart │ ├── global_run.dart │ ├── lish.dart │ ├── login.dart │ ├── logout.dart │ ├── outdated.dart │ ├── remove.dart │ ├── run.dart │ ├── token.dart │ ├── token_add.dart │ ├── token_list.dart │ ├── token_remove.dart │ ├── unpack.dart │ ├── upgrade.dart │ ├── uploader.dart │ ├── version.dart │ ├── workspace.dart │ └── workspace_list.dart │ ├── command_runner.dart │ ├── crc32c.dart │ ├── dart.dart │ ├── entrypoint.dart │ ├── error_group.dart │ ├── exceptions.dart │ ├── executable.dart │ ├── exit_codes.dart │ ├── flutter_releases.dart │ ├── git.dart │ ├── global_packages.dart │ ├── http.dart │ ├── ignore.dart │ ├── io.dart │ ├── isolate.dart │ ├── language_version.dart │ ├── levenshtein.dart │ ├── lock_file.dart │ ├── log.dart │ ├── oauth2.dart │ ├── package.dart │ ├── package_config.dart │ ├── package_graph.dart │ ├── package_name.dart │ ├── progress.dart │ ├── pub_embeddable_command.dart │ ├── pubspec.dart │ ├── pubspec_parse.dart │ ├── pubspec_utils.dart │ ├── rate_limited_scheduler.dart │ ├── sdk.dart │ ├── sdk │ ├── dart.dart │ ├── flutter.dart │ ├── fuchsia.dart │ └── sdk_package_config.dart │ ├── solver.dart │ ├── solver │ ├── assignment.dart │ ├── failure.dart │ ├── incompatibility.dart │ ├── incompatibility_cause.dart │ ├── package_lister.dart │ ├── partial_solution.dart │ ├── reformat_ranges.dart │ ├── report.dart │ ├── result.dart │ ├── set_relation.dart │ ├── solve_suggestions.dart │ ├── term.dart │ ├── type.dart │ └── version_solver.dart │ ├── source.dart │ ├── source │ ├── cached.dart │ ├── git.dart │ ├── hosted.dart │ ├── path.dart │ ├── root.dart │ ├── sdk.dart │ └── unknown.dart │ ├── system_cache.dart │ ├── transcript.dart │ ├── utils.dart │ ├── validator.dart │ └── validator │ ├── analyze.dart │ ├── changelog.dart │ ├── compiled_dartdoc.dart │ ├── dependency.dart │ ├── dependency_override.dart │ ├── deprecated_fields.dart │ ├── devtools_extension.dart │ ├── directory.dart │ ├── executable.dart │ ├── file_case.dart │ ├── flutter_constraint.dart │ ├── flutter_plugin_format.dart │ ├── git_status.dart │ ├── gitignore.dart │ ├── leak_detection.dart │ ├── license.dart │ ├── name.dart │ ├── pubspec.dart │ ├── pubspec_field.dart │ ├── pubspec_typo.dart │ ├── readme.dart │ ├── relative_version_numbering.dart │ ├── sdk_constraint.dart │ ├── size.dart │ └── strict_dependencies.dart ├── pubspec.lock ├── pubspec.yaml ├── test ├── add │ ├── common │ │ ├── add_test.dart │ │ ├── invalid_options.dart │ │ ├── version_constraint_test.dart │ │ └── version_resolution_test.dart │ ├── git │ │ ├── git_test.dart │ │ ├── ref_test.dart │ │ └── subdir_test.dart │ ├── hosted │ │ └── non_default_pub_server_test.dart │ ├── path │ │ ├── absolute_path_test.dart │ │ └── relative_path_test.dart │ └── sdk │ │ └── sdk_test.dart ├── ascii_tree_test.dart ├── bump_test.dart ├── cache │ ├── add │ │ ├── adds_latest_matching_version_test.dart │ │ ├── adds_latest_version_test.dart │ │ ├── all_adds_all_matching_versions_test.dart │ │ ├── all_with_some_versions_present_test.dart │ │ ├── already_cached_test.dart │ │ ├── bad_version_test.dart │ │ ├── missing_package_arg_test.dart │ │ ├── no_matching_version_test.dart │ │ ├── package_not_found_test.dart │ │ └── unexpected_arguments_test.dart │ ├── clean_test.dart │ ├── create_readme_test.dart │ ├── detect_deprecated_dir_test.dart │ ├── gc_test.dart │ ├── list_test.dart │ ├── preload_test.dart │ └── repair │ │ ├── empty_cache_test.dart │ │ ├── git_test.dart │ │ ├── handles_corrupted_binstub_test.dart │ │ ├── handles_corrupted_global_lockfile_test.dart │ │ ├── handles_failure_test.dart │ │ ├── handles_orphaned_binstub_test.dart │ │ ├── hosted.dart │ │ ├── recompiles_snapshots_test.dart │ │ └── updates_binstubs_test.dart ├── content_hash_test.dart ├── dart3_sdk_constraint_hack_test.dart ├── dependency_name_validation_test.dart ├── dependency_override_test.dart ├── dependency_services │ └── dependency_services_test.dart ├── deps │ └── executables_test.dart ├── deps_test.dart ├── descriptor.dart ├── descriptor │ ├── git.dart │ ├── link_descriptor.dart │ ├── package_config.dart │ ├── tar.dart │ └── yaml.dart ├── dev_dependency_test.dart ├── directory_option_test.dart ├── downgrade │ ├── does_not_show_other_versions_test.dart │ ├── doesnt_change_git_dependencies_test.dart │ ├── dry_run_does_not_apply_changes_test.dart │ ├── tighten_test.dart │ ├── unlock_if_necessary_test.dart │ └── unlock_single_package_test.dart ├── embedding │ ├── embedding_test.dart │ ├── ensure_pubspec_resolved.dart │ └── get_executable_for_command.dart ├── error_group_test.dart ├── get │ ├── dry_run_does_not_apply_changes_test.dart │ ├── enforce_lockfile_test.dart │ ├── flutter_constraint_upper_bound_ignored_test.dart │ ├── get_inside_cache_fails_test.dart │ ├── gets_in_example_folder_test.dart │ ├── git │ │ ├── check_out_and_upgrade_test.dart │ │ ├── check_out_branch_test.dart │ │ ├── check_out_revision_test.dart │ │ ├── check_out_test.dart │ │ ├── check_out_transitive_test.dart │ │ ├── check_out_twice_test.dart │ │ ├── check_out_unfetched_revision_of_cached_repo_test.dart │ │ ├── check_out_with_trailing_slash_test.dart │ │ ├── clean_invalid_git_repo_cache_test.dart │ │ ├── dependency_name_match_pubspec_test.dart │ │ ├── different_repo_name_test.dart │ │ ├── doesnt_fetch_if_nothing_changes_test.dart │ │ ├── get_test.dart │ │ ├── git_not_installed_test.dart │ │ ├── lock_version_test.dart │ │ ├── locked_revision_without_repo_test.dart │ │ ├── path_test.dart │ │ ├── require_pubspec_name_test.dart │ │ ├── require_pubspec_test.dart │ │ ├── ssh_url_test.dart │ │ ├── stay_locked_if_compatible_test.dart │ │ ├── tag_pattern_test.dart │ │ └── unlock_if_incompatible_test.dart │ ├── hosted │ │ ├── advisory_test.dart │ │ ├── avoid_network_requests_test.dart │ │ ├── cached_pubspec_test.dart │ │ ├── do_not_upgrade_on_removed_constraints_test.dart │ │ ├── does_no_network_requests_when_possible_test.dart │ │ ├── explain_bad_hosted_url_test.dart │ │ ├── get_stress_test.dart │ │ ├── get_test.dart │ │ ├── get_transitive_test.dart │ │ ├── gets_a_package_with_busted_dev_dependencies_test.dart │ │ ├── resolve_constraints_test.dart │ │ ├── resolve_with_retracted_package_versions_test.dart │ │ ├── stay_locked_if_compatible_test.dart │ │ ├── stay_locked_if_new_is_satisfied_test.dart │ │ ├── stay_locked_test.dart │ │ ├── unlock_if_incompatible_test.dart │ │ ├── unlock_if_new_is_unsatisfied_test.dart │ │ ├── unlock_if_version_doesnt_exist_test.dart │ │ ├── warn_about_discontinued_test.dart │ │ └── warn_about_retracted_package_test.dart │ ├── package_name_test.dart │ ├── path │ │ ├── absolute_path_test.dart │ │ ├── absolute_symlink_test.dart │ │ ├── empty_pubspec_test.dart │ │ ├── no_pubspec_test.dart │ │ ├── nonexistent_dir_test.dart │ │ ├── path_is_file_test.dart │ │ ├── relative_path_test.dart │ │ ├── relative_symlink_test.dart │ │ ├── shared_dependency_symlink_test.dart │ │ └── shared_dependency_test.dart │ ├── preserve_lock_file_line_endings_test.dart │ ├── sdk_constraint_required_test.dart │ ├── summary_only_environment_test.dart │ ├── switch_source_test.dart │ ├── unknown_sdk_test.dart │ └── with_empty_environment_test.dart ├── git_test.dart ├── global │ ├── activate │ │ ├── activate_casing_test.dart │ │ ├── activate_git_after_hosted_test.dart │ │ ├── activate_hosted_after_git_test.dart │ │ ├── activate_hosted_after_path_test.dart │ │ ├── activate_hosted_test.dart │ │ ├── activate_hosted_twice_test.dart │ │ ├── activate_package_from_workspace.dart │ │ ├── activate_path_after_hosted_test.dart │ │ ├── bad_version_test.dart │ │ ├── cached_package_test.dart │ │ ├── constraint_test.dart │ │ ├── constraint_with_path_test.dart │ │ ├── custom_hosted_url_test.dart │ │ ├── different_version_test.dart │ │ ├── doesnt_snapshot_path_executables_test.dart │ │ ├── empty_constraint_test.dart │ │ ├── fails_when_active_package_is_corrupt_test.dart │ │ ├── feature_test.dart │ │ ├── git_package_test.dart │ │ ├── ignores_active_version_test.dart │ │ ├── installs_dependencies_for_git_test.dart │ │ ├── installs_dependencies_for_path_test.dart │ │ ├── installs_dependencies_test.dart │ │ ├── missing_git_repo_test.dart │ │ ├── missing_package_arg_test.dart │ │ ├── outdated_binstub_test.dart │ │ ├── path_package_test.dart │ │ ├── reactivating_git_upgrades_test.dart │ │ ├── snapshots_git_executables_test.dart │ │ ├── snapshots_hosted_executables_test.dart │ │ ├── supports_version_solver_backtracking_test.dart │ │ ├── uncached_package_test.dart │ │ ├── unexpected_arguments_test.dart │ │ └── unknown_package_test.dart │ ├── binstubs │ │ ├── binstub_runs_executable_test.dart │ │ ├── binstub_runs_global_run_if_no_snapshot_test.dart │ │ ├── binstub_runs_precompiled_snapshot_test.dart │ │ ├── creates_executables_in_pubspec_test.dart │ │ ├── does_not_warn_if_no_executables_test.dart │ │ ├── does_not_warn_if_on_path_test.dart │ │ ├── explicit_and_no_executables_options_test.dart │ │ ├── explicit_executables_test.dart │ │ ├── missing_script_test.dart │ │ ├── name_collision_test.dart │ │ ├── name_collision_with_overwrite_test.dart │ │ ├── no_executables_flag_test.dart │ │ ├── outdated_binstub_runs_pub_global_test.dart │ │ ├── outdated_snapshot_test.dart │ │ ├── path_package_test.dart │ │ ├── reactivate_removes_old_executables_test.dart │ │ ├── removes_even_if_not_in_pubspec_test.dart │ │ ├── removes_when_deactivated_test.dart │ │ ├── runs_once_even_when_dart_is_batch_test.dart │ │ ├── unknown_explicit_executable_test.dart │ │ ├── utils.dart │ │ └── warns_if_not_on_path_test.dart │ ├── deactivate │ │ ├── deactivate_and_reactivate_package_test.dart │ │ ├── git_package_test.dart │ │ ├── hosted_package_test.dart │ │ ├── missing_package_arg_test.dart │ │ ├── path_package_test.dart │ │ ├── removes_precompiled_snapshots_test.dart │ │ ├── unexpected_arguments_test.dart │ │ └── unknown_package_test.dart │ ├── list_test.dart │ └── run │ │ ├── errors_if_outside_bin_test.dart │ │ ├── fails_if_sdk_constraint_is_unmet_test.dart │ │ ├── implicit_executable_name_test.dart │ │ ├── missing_executable_arg_test.dart │ │ ├── missing_path_package_test.dart │ │ ├── nonexistent_script_test.dart │ │ ├── package_api_test.dart │ │ ├── recompiles_if_snapshot_is_out_of_date_test.dart │ │ ├── reflects_changes_to_local_package_test.dart │ │ ├── runs_git_script_test.dart │ │ ├── runs_path_script_test.dart │ │ ├── runs_script_in_checked_mode_test.dart │ │ ├── runs_script_in_unchecked_mode_test.dart │ │ ├── runs_script_test.dart │ │ └── unknown_package_test.dart ├── golden_file.dart ├── help_test.dart ├── hosted │ ├── fail_gracefully_on_bad_version_listing_response_test.dart │ ├── fail_gracefully_on_invalid_url_test.dart │ ├── fail_gracefully_on_missing_package_test.dart │ ├── fail_gracefully_on_url_resolve_test.dart │ ├── fail_gracefully_with_hint_test.dart │ ├── metadata_test.dart │ ├── offline_test.dart │ ├── remove_removed_dependency_test.dart │ ├── remove_removed_transitive_dependency_test.dart │ ├── short_syntax_test.dart │ ├── version_negotiation_test.dart │ └── will_normalize_hosted_url_test.dart ├── ignore_test.dart ├── io_test.dart ├── levenshtein_test.dart ├── lish │ ├── archive_contents_test.dart │ ├── archives_and_uploads_a_package_test.dart │ ├── cloud_storage_upload_doesnt_redirect_test.dart │ ├── cloud_storage_upload_provides_an_error_test.dart │ ├── does_not_include_dot_file.dart │ ├── does_not_include_pubspec_overrides_file.dart │ ├── does_not_publish_if_private_test.dart │ ├── does_not_publish_if_private_with_server_arg_test.dart │ ├── dot_folder_name_test.dart │ ├── dry_run_package_validation_has_a_warning_test.dart │ ├── dry_run_package_validation_has_no_warnings_test.dart │ ├── dry_run_warns_about_server_checks.dart │ ├── force_cannot_be_combined_with_dry_run_test.dart │ ├── force_does_not_publish_if_private_test.dart │ ├── force_does_not_publish_if_there_are_errors_test.dart │ ├── force_publishes_if_tests_are_no_warnings_or_errors_test.dart │ ├── force_publishes_if_there_are_warnings_test.dart │ ├── many_files_test.dart │ ├── package_creation_provides_a_malformed_error_test.dart │ ├── package_creation_provides_a_malformed_success_test.dart │ ├── package_creation_provides_an_error_test.dart │ ├── package_creation_provides_invalid_json_test.dart │ ├── package_validation_has_a_warning_and_continues_test.dart │ ├── package_validation_has_a_warning_and_is_canceled_test.dart │ ├── package_validation_has_an_error_test.dart │ ├── publishing_to_and_from_archive_test.dart │ ├── requires_resolution_before_publishing_test.dart │ ├── server_arg_does_not_override_private_test.dart │ ├── server_arg_overrides_publish_to_url_test.dart │ ├── skip_validation_test.dart │ ├── symlinks_test.dart │ ├── unicode_file_names_test.dart │ ├── upload_form_fields_has_a_non_string_value_test.dart │ ├── upload_form_fields_is_not_a_map_test.dart │ ├── upload_form_is_missing_fields_test.dart │ ├── upload_form_is_missing_url_test.dart │ ├── upload_form_provides_an_error_test.dart │ ├── upload_form_provides_invalid_json_test.dart │ ├── upload_form_url_is_not_a_string_test.dart │ ├── uses_publish_to_url_test.dart │ └── utils.dart ├── lock_file_test.dart ├── log_test.dart ├── no_packages_dir_test.dart ├── oauth2 │ ├── logout_test.dart │ ├── utils.dart │ ├── with_a_malformed_credentials_authenticates_again_test.dart │ ├── with_a_pre_existing_credentials_does_not_authenticate_test.dart │ ├── with_a_server_rejected_refresh_token_authenticates_again_test.dart │ ├── with_an_expired_credentials_refreshes_and_saves_test.dart │ ├── with_an_expired_credentials_without_a_refresh_token_authenticates_again_test.dart │ ├── with_no_credentials_authenticates_and_saves_credentials_test.dart │ └── with_server_rejected_credentials_authenticates_again_test.dart ├── outdated │ └── outdated_test.dart ├── package_config_file_test.dart ├── package_graph_file_test.dart ├── package_list_files_test.dart ├── package_server.dart ├── pinned_dependency_hint_test.dart ├── precompilation_test.dart ├── pub_get_and_upgrade_test.dart ├── pub_uploader_test.dart ├── pubspec_overrides_test.dart ├── pubspec_test.dart ├── pubspec_utils_test.dart ├── rate_limited_scheduler_test.dart ├── reformat_ranges_test.dart ├── remove │ └── remove_test.dart ├── run │ ├── allows_dart_extension_test.dart │ ├── app_can_read_from_stdin_test.dart │ ├── errors_if_no_executable_is_given_test.dart │ ├── errors_if_only_transitive_dependency_test.dart │ ├── errors_if_path_in_dependency_test.dart │ ├── forwards_signal_posix_test.dart │ ├── includes_parent_directories_of_entrypoint_test.dart │ ├── loads_package_imports_in_a_dependency_test.dart │ ├── nonexistent_dependency_test.dart │ ├── nonexistent_script_in_dependency_test.dart │ ├── nonexistent_script_test.dart │ ├── package_api_test.dart │ ├── passes_along_arguments_test.dart │ ├── precompile_test.dart │ ├── runs_app_in_directory_in_entrypoint_test.dart │ ├── runs_app_in_entrypoint_test.dart │ ├── runs_from_a_dependency_override_after_dependency_test.dart │ ├── runs_named_app_in_dependency_test.dart │ ├── runs_named_app_in_dev_dependency_test.dart │ ├── runs_shorthand_app_in_dependency_test.dart │ ├── runs_the_script_in_checked_mode_test.dart │ └── runs_the_script_in_unchecked_mode_test.dart ├── sdk_test.dart ├── snapshot_test.dart ├── solve_suggestions_test.dart ├── test_pub.dart ├── testdata │ ├── README.md │ └── goldens │ │ ├── ascii_tree_test │ │ ├── tree.fromFiles a complex example.ans │ │ └── tree.fromMap a complex example.ans │ │ ├── dependency_services │ │ └── dependency_services_test │ │ │ ├── Adding transitive.txt │ │ │ ├── Can update a git package.txt │ │ │ ├── Compatible.txt │ │ │ ├── Finds smallest possible upgrade.txt │ │ │ ├── Ignoring version.txt │ │ │ ├── No pubspec.lock.txt │ │ │ ├── Preserves no content-hashes.txt │ │ │ ├── Preserves pub.dartlang.org as hosted url.txt │ │ │ ├── Relative paths are allowed.txt │ │ │ ├── Removing transitive.txt │ │ │ ├── Smallest possible upgrade can upgrade beyond breaking.txt │ │ │ ├── Smallest possible upgrade can upgrade other packages if needed.txt │ │ │ ├── can upgrade workspaces.txt │ │ │ └── multibreaking.txt │ │ ├── deps │ │ └── executables_test │ │ │ ├── applies formatting before printing executables.txt │ │ │ ├── dev dependencies.txt │ │ │ ├── lists Dart executables, without entrypoints.txt │ │ │ ├── lists executables from a dependency.txt │ │ │ ├── lists executables only from immediate dependencies.txt │ │ │ ├── overriden dependencies executables.txt │ │ │ ├── skips executables in sub directories.txt │ │ │ └── skips non-Dart executables.txt │ │ ├── directory_option_test │ │ └── commands taking a --directory~-C parameter work.txt │ │ ├── embedding │ │ └── embedding_test │ │ │ ├── --color forces colors.txt │ │ │ ├── --help.txt │ │ │ ├── Compilation errors are only printed once.txt │ │ │ ├── logfile is written with --verbose and on unexpected exceptions.txt │ │ │ └── run works, though hidden.txt │ │ ├── get │ │ └── hosted │ │ │ └── advisory_test │ │ │ ├── do not show ignored advisories - aliases.txt │ │ │ ├── do not show ignored advisories.txt │ │ │ ├── no advisories to show - a single advisory with no pub packages.txt │ │ │ ├── no advisories to show.txt │ │ │ ├── no advisory available from pub.dev.txt │ │ │ ├── no advisory available.txt │ │ │ ├── several advisories, one of which has no pub packages.txt │ │ │ ├── show advisories.txt │ │ │ ├── show advisory - newer version available.txt │ │ │ ├── show advisory - same package mentioned twice.txt │ │ │ ├── show advisory.txt │ │ │ ├── show id if no display url is present.txt │ │ │ └── show max 5 advisories.txt │ │ ├── help_test │ │ ├── pub add --help.txt │ │ ├── pub bump --help.txt │ │ ├── pub bump breaking --help.txt │ │ ├── pub bump major --help.txt │ │ ├── pub bump minor --help.txt │ │ ├── pub bump patch --help.txt │ │ ├── pub cache --help.txt │ │ ├── pub cache add --help.txt │ │ ├── pub cache clean --help.txt │ │ ├── pub cache repair --help.txt │ │ ├── pub deps --help.txt │ │ ├── pub downgrade --help.txt │ │ ├── pub get --help.txt │ │ ├── pub global --help.txt │ │ ├── pub global activate --help.txt │ │ ├── pub global deactivate --help.txt │ │ ├── pub global list --help.txt │ │ ├── pub global run --help.txt │ │ ├── pub login --help.txt │ │ ├── pub logout --help.txt │ │ ├── pub outdated --help.txt │ │ ├── pub publish --help.txt │ │ ├── pub remove --help.txt │ │ ├── pub run --help.txt │ │ ├── pub token --help.txt │ │ ├── pub token add --help.txt │ │ ├── pub token list --help.txt │ │ ├── pub token remove --help.txt │ │ ├── pub unpack --help.txt │ │ ├── pub upgrade --help.txt │ │ ├── pub version --help.txt │ │ ├── pub workspace --help.txt │ │ └── pub workspace list --help.txt │ │ ├── hosted │ │ ├── fail_gracefully_on_bad_version_listing_response_test │ │ │ ├── 401-with-message.txt │ │ │ ├── 401.txt │ │ │ ├── 403-with-message.txt │ │ │ ├── 403.txt │ │ │ └── bad_json.txt │ │ └── fail_gracefully_with_hint_test │ │ │ └── supports two hints.txt │ │ ├── lish │ │ └── many_files_test │ │ │ └── displays all files.txt │ │ ├── outdated │ │ └── outdated_test │ │ │ ├── Handles SDK dependencies.txt │ │ │ ├── Handles packages that are not found on server.txt │ │ │ ├── circular dependency on root.txt │ │ │ ├── do not report ignored advisories.txt │ │ │ ├── do not show advisories if no version is affected.txt │ │ │ ├── does not allow arguments - handles bad flags.txt │ │ │ ├── don't show retracted.txt │ │ │ ├── latest version reported while locked on a prerelease can be a prerelease.txt │ │ │ ├── mutually incompatible newer versions.txt │ │ │ ├── newer versions available.txt │ │ │ ├── no dependencies.txt │ │ │ ├── no lockfile.txt │ │ │ ├── no pubspec.txt │ │ │ ├── only report unignored advisory.txt │ │ │ ├── overridden dependencies - no resolution.txt │ │ │ ├── overridden dependencies with retraction- no resolution .txt │ │ │ ├── overridden dependencies.txt │ │ │ ├── reports dependencies from all of workspace.txt │ │ │ ├── show advisory - all versions.txt │ │ │ ├── show advisory - current also retracted.txt │ │ │ ├── show advisory - current, same package mentioned twice.txt │ │ │ ├── show advisory - current.txt │ │ │ ├── show advisory - latest also discontinued.txt │ │ │ ├── show advisory - latest.txt │ │ │ ├── show advisory - several advisories.txt │ │ │ ├── show discontinued and retracted.txt │ │ │ ├── show discontinued with no latest version.txt │ │ │ ├── show discontinued.txt │ │ │ └── show retracted.txt │ │ ├── upgrade │ │ └── example_warns_about_major_versions_test │ │ │ ├── pub upgrade --major-versions does not update major versions in example~.txt │ │ │ └── pub upgrade --null-safety does not update null-safety of dependencies in example~.txt │ │ └── validator │ │ └── validations_output_test │ │ └── Layout of publication warnings.txt ├── token │ ├── add_token_test.dart │ ├── error_message_test.dart │ ├── remove_token_test.dart │ ├── token_authentication_test.dart │ ├── when_receives_401_removes_token_test.dart │ └── when_receives_403_persists_saved_token_test.dart ├── transcript_test.dart ├── unknown_properties_in_description_test.dart ├── unknown_source_test.dart ├── unpack_test.dart ├── upgrade │ ├── dry_run_does_not_apply_changes_test.dart │ ├── example_warns_about_major_versions_test.dart │ ├── git │ │ ├── do_not_upgrade_if_unneeded_test.dart │ │ ├── upgrade_locked_test.dart │ │ ├── upgrade_one_locked_test.dart │ │ ├── upgrade_to_incompatible_pubspec_test.dart │ │ └── upgrade_to_nonexistent_pubspec_test.dart │ ├── hosted │ │ ├── unlock_if_necessary_test.dart │ │ ├── unlock_single_package_test.dart │ │ ├── upgrade_removed_constraints_test.dart │ │ └── warn_about_discontinued_test.dart │ ├── renamed_package_circular_dependency.dart │ ├── report │ │ ├── describes_change_test.dart │ │ ├── does_not_show_newer_versions_for_locked_packages_test.dart │ │ ├── highlights_overrides_test.dart │ │ ├── leading_character_shows_change_test.dart │ │ ├── shows_newer_available_versions_test.dart │ │ ├── shows_number_of_changed_dependencies_test.dart │ │ └── shows_pub_outdated_test.dart │ ├── upgrade_major_versions_test.dart │ ├── upgrade_tighten_test.dart │ └── upgrade_transitive_test.dart ├── utils_test.dart ├── validator │ ├── analyze_test.dart │ ├── changelog_test.dart │ ├── compiled_dartdoc_test.dart │ ├── dependency_override_test.dart │ ├── dependency_test.dart │ ├── deprecated_fields_test.dart │ ├── devtools_extension_test.dart │ ├── directory_test.dart │ ├── executable_test.dart │ ├── file_case_test.dart │ ├── flutter_constraint_test.dart │ ├── flutter_plugin_format_test.dart │ ├── git_status_test.dart │ ├── gitignore_test.dart │ ├── language_version_test.dart │ ├── leak_detection_test.dart │ ├── license_test.dart │ ├── name_test.dart │ ├── pubspec_field_test.dart │ ├── pubspec_test.dart │ ├── pubspec_typo_test.dart │ ├── readme_test.dart │ ├── relative_version_numbering_test.dart │ ├── sdk_constraint_test.dart │ ├── size_test.dart │ ├── strict_dependencies_test.dart │ ├── utils.dart │ └── validations_output_test.dart ├── version_solver_test.dart └── workspace_test.dart └── tool ├── extract_all_pub_dev.dart ├── test-bin ├── pub ├── pub.bat └── pub_command_runner.dart └── test.dart /.gitallowed: -------------------------------------------------------------------------------- 1 | # Allow file for git-secrets, see: 2 | # https://github.com/awslabs/git-secrets#ignoring-false-positives 3 | 4 | # Ignore secrets from leak detection, these secrets have all been revoked and 5 | # are only used for testing the detection logic. 6 | lib/src/validator/leak_detection.dart 7 | test/validator/leak_detection_test.dart 8 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/1-PUB_SITE.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: There is a problem with pub.dev 3 | about: A `dart pub get` or `flutter pub get` fails because of an outage at `pub.dev`, the site 4 | cannot be loaded, or there is an issue with a particular package such as a 5 | request to have a published package removed. 6 | 7 | --- 8 | 9 | ********************************************************** 10 | **This is not the repository you want to file issues in!** 11 | ********************************************************** 12 | 13 | For any issues with the `pub.dev` repository, file issues at 14 | https://github.com/dart-lang/pub-dartlang-dart/issues 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/3-FEATURE.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: I'd like a new feature to be supported by the pub client. 4 | 5 | --- 6 | 7 | 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | enable-beta-ecosystems: true 3 | updates: 4 | - package-ecosystem: "pub" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | 9 | - package-ecosystem: github-actions 10 | directory: / 11 | schedule: 12 | interval: monthly 13 | labels: 14 | - autosubmit 15 | groups: 16 | github-actions: 17 | patterns: 18 | - "*" 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .buildlog 2 | .DS_Store 3 | .idea 4 | .vscode 5 | .dart_tool/ 6 | .settings/ 7 | /build/ 8 | packages 9 | /bin/pub.dart.snapshot 10 | -------------------------------------------------------------------------------- /.test_config: -------------------------------------------------------------------------------- 1 | { 2 | "test_package": { 3 | "platforms": ["vm"] 4 | } 5 | } -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # Below is a list of people and organizations that have contributed 2 | # to the project. Names should be added to the list like so: 3 | # 4 | # Name/Organization 5 | 6 | Google Inc. 7 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:dart_flutter_team_lints/analysis_options.yaml 2 | 3 | analyzer: 4 | errors: 5 | todo: ignore 6 | exclude: 7 | - lib/src/third_party/** 8 | 9 | language: 10 | strict-casts: true 11 | strict-inference: true 12 | 13 | linter: 14 | rules: 15 | - avoid_print 16 | - avoid_private_typedef_functions 17 | - avoid_redundant_argument_values 18 | - avoid_unused_constructor_parameters 19 | - avoid_void_async 20 | - cancel_subscriptions 21 | - missing_code_block_language_in_doc_comment 22 | - missing_whitespace_between_adjacent_strings 23 | - no_adjacent_strings_in_list 24 | - no_runtimeType_toString 25 | - prefer_const_declarations 26 | - prefer_final_locals 27 | - unawaited_futures 28 | - unreachable_from_main 29 | - use_enums 30 | -------------------------------------------------------------------------------- /bin/pub.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/command_runner.dart'; 6 | import 'package:pub/src/io.dart'; 7 | 8 | Future main(List arguments) async { 9 | await flushThenExit(await PubCommandRunner().run(arguments)); 10 | } 11 | -------------------------------------------------------------------------------- /dart_test.yaml: -------------------------------------------------------------------------------- 1 | presets: 2 | ci: 3 | timeout: 3x 4 | 5 | # Pub has a huge number of small suites, which means test is frequently 6 | # loading new ones. Keeping concurrency low helps limit load timeouts. 7 | concurrency: 1 8 | -------------------------------------------------------------------------------- /lib/src/command/cache.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import '../command.dart'; 6 | import 'cache_add.dart'; 7 | import 'cache_clean.dart'; 8 | import 'cache_list.dart'; 9 | import 'cache_preload.dart'; 10 | import 'cache_repair.dart'; 11 | 12 | /// Handles the `cache` pub command. 13 | class CacheCommand extends PubCommand { 14 | @override 15 | String get name => 'cache'; 16 | @override 17 | String get description => 'Work with the system cache.'; 18 | @override 19 | String get docUrl => 'https://dart.dev/tools/pub/cmd/pub-cache'; 20 | 21 | CacheCommand() { 22 | addSubcommand(CacheAddCommand()); 23 | addSubcommand(CacheListCommand()); 24 | addSubcommand(CacheCleanCommand()); 25 | addSubcommand(CacheRepairCommand()); 26 | addSubcommand(CachePreloadCommand()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/src/command/global.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import '../command.dart'; 6 | import 'global_activate.dart'; 7 | import 'global_deactivate.dart'; 8 | import 'global_list.dart'; 9 | import 'global_run.dart'; 10 | 11 | /// Handles the `global` pub command. 12 | class GlobalCommand extends PubCommand { 13 | @override 14 | String get name => 'global'; 15 | @override 16 | String get description => 'Work with global packages.'; 17 | @override 18 | String get docUrl => 'https://dart.dev/tools/pub/cmd/pub-global'; 19 | 20 | GlobalCommand({bool alwaysUseSubprocess = false}) { 21 | addSubcommand(GlobalActivateCommand()); 22 | addSubcommand(GlobalDeactivateCommand()); 23 | addSubcommand(GlobalListCommand()); 24 | addSubcommand(GlobalRunCommand(alwaysUseSubprocess: alwaysUseSubprocess)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/src/command/global_list.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import '../command.dart'; 6 | 7 | /// Handles the `global list` pub command. 8 | class GlobalListCommand extends PubCommand { 9 | @override 10 | String get name => 'list'; 11 | @override 12 | String get description => 'List globally activated packages.'; 13 | @override 14 | bool get allowTrailingOptions => false; 15 | @override 16 | bool get takesArguments => false; 17 | 18 | @override 19 | Future runProtected() async { 20 | globals.listActivePackages(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/src/command/logout.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import '../command.dart'; 8 | import '../oauth2.dart' as oauth2; 9 | 10 | /// Handles the `logout` pub command. 11 | class LogoutCommand extends PubCommand { 12 | @override 13 | String get name => 'logout'; 14 | @override 15 | String get description => 'Log out of pub.dev.'; 16 | @override 17 | bool get takesArguments => false; 18 | 19 | LogoutCommand(); 20 | 21 | @override 22 | Future runProtected() async { 23 | oauth2.logout(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /lib/src/command/token.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import '../command.dart'; 6 | import '../command_runner.dart'; 7 | import 'token_add.dart'; 8 | import 'token_list.dart'; 9 | import 'token_remove.dart'; 10 | 11 | /// Handles the `token` command. 12 | class TokenCommand extends PubCommand { 13 | @override 14 | String get name => 'token'; 15 | @override 16 | String get description => ''' 17 | Manage authentication tokens for hosted pub repositories. 18 | 19 | The tokens will be used for authorizing both when retrieving dependencies and 20 | for publishing. 21 | 22 | Tokens are stored in `${tokenStore.tokensFile}`. 23 | 24 | For interactive authorization against pub.dev, use `$topLevelProgram pub login`.'''; 25 | @override 26 | String get docUrl => 'https://dart.dev/tools/pub/cmd/pub-token'; 27 | 28 | TokenCommand() { 29 | addSubcommand(TokenListCommand()); 30 | addSubcommand(TokenAddCommand()); 31 | addSubcommand(TokenRemoveCommand()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/src/command/token_list.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import '../command.dart'; 6 | import '../log.dart' as log; 7 | 8 | /// Handles the `token list` pub command. 9 | class TokenListCommand extends PubCommand { 10 | @override 11 | String get name => 'list'; 12 | @override 13 | String get description => 'List servers for which a token exists.'; 14 | @override 15 | String get docUrl => 'https://dart.dev/tools/pub/cmd/pub-token'; 16 | 17 | @override 18 | Future runProtected() async { 19 | if (cache.tokenStore.credentials.isNotEmpty) { 20 | log.message( 21 | 'You have secret tokens for ${cache.tokenStore.credentials.length} ' 22 | 'package repositories:', 23 | ); 24 | for (final token in cache.tokenStore.credentials) { 25 | log.message(token.url.toString()); 26 | } 27 | } else { 28 | log.message( 29 | 'You do not have any secret tokens for package repositories.\n' 30 | 'However you can add new tokens using the command below:\n' 31 | '\n pub token add [hosted-url]', 32 | ); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/src/command/version.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import '../command.dart'; 6 | import '../log.dart' as log; 7 | import '../sdk.dart'; 8 | 9 | /// Handles the `version` pub command. 10 | class VersionCommand extends PubCommand { 11 | @override 12 | String get name => 'version'; 13 | @override 14 | String get description => 'Print pub version.'; 15 | @override 16 | String get argumentsDescription => ''; 17 | 18 | @override 19 | Future runProtected() async { 20 | log.message('Pub ${sdk.version}'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/src/command/workspace.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import '../command.dart'; 6 | import 'workspace_list.dart'; 7 | 8 | class WorkspaceCommand extends PubCommand { 9 | @override 10 | String get description => 'Work with the pub workspace.'; 11 | 12 | @override 13 | String get name => 'workspace'; 14 | 15 | WorkspaceCommand() { 16 | addSubcommand(WorkspaceListCommand()); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/src/solver/set_relation.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// An enum of possible relationships between two sets. 6 | enum SetRelation { 7 | /// The second set contains all elements of the first, as well as possibly 8 | /// more. 9 | subset('subset'), 10 | 11 | /// Neither set contains any elements of the other. 12 | disjoint('disjoint'), 13 | 14 | /// The sets have elements in common, but the first is not a superset of the 15 | /// second. 16 | /// 17 | /// This is also used when the first set is a superset of the first, but in 18 | /// practice we don't need to distinguish that from overlapping sets. 19 | overlapping('overlapping'); 20 | 21 | final String _name; 22 | 23 | const SetRelation(this._name); 24 | 25 | @override 26 | String toString() => _name; 27 | } 28 | -------------------------------------------------------------------------------- /lib/src/solver/type.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | /// An enum for types of version resolution. 6 | enum SolveType { 7 | /// As few changes to the lockfile as possible to be consistent with the 8 | /// pubspec. 9 | get('get'), 10 | 11 | /// Upgrade all packages or specific packages to the highest versions 12 | /// possible, regardless of the lockfile. 13 | upgrade('upgrade'), 14 | 15 | /// Downgrade all packages or specific packages to the lowest versions 16 | /// possible, regardless of the lockfile. 17 | downgrade('downgrade'); 18 | 19 | final String _name; 20 | 21 | const SolveType(this._name); 22 | 23 | @override 24 | String toString() => _name; 25 | } 26 | -------------------------------------------------------------------------------- /lib/src/validator/executable.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import 'package:path/path.dart' as p; 8 | 9 | import '../validator.dart'; 10 | 11 | /// Validates that a package's pubspec doesn't contain executables that 12 | /// reference non-existent scripts. 13 | class ExecutableValidator extends Validator { 14 | @override 15 | Future validate() async { 16 | final binFiles = filesBeneath( 17 | 'bin', 18 | recursive: false, 19 | ).map(package.relative); 20 | 21 | package.pubspec.executables.forEach((executable, script) { 22 | final scriptPath = p.join('bin', '$script.dart'); 23 | if (binFiles.contains(scriptPath)) return; 24 | 25 | warnings.add( 26 | 'Your pubspec.yaml lists an executable "$executable" that ' 27 | 'points to a script "$scriptPath" that does not exist.', 28 | ); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/src/validator/file_case.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import 'package:collection/collection.dart'; 8 | 9 | import '../validator.dart'; 10 | 11 | /// Validates that a package files all are unique even after case-normalization. 12 | class FileCaseValidator extends Validator { 13 | @override 14 | Future validate() async { 15 | final lowerCaseToFile = {}; 16 | for (final file in files.sorted()) { 17 | final lowerCase = file.toLowerCase(); 18 | final existing = lowerCaseToFile[lowerCase]; 19 | if (existing != null) { 20 | errors.add(''' 21 | The file $file and $existing only differ in capitalization. 22 | 23 | This is not supported across platforms. 24 | 25 | Try renaming one of them. 26 | '''); 27 | break; 28 | } 29 | lowerCaseToFile[lowerCase] = file; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/src/validator/pubspec.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:async'; 6 | 7 | import 'package:path/path.dart' as p; 8 | 9 | import '../validator.dart'; 10 | 11 | /// Validates that a package's pubspec exists. 12 | /// 13 | /// In most cases this is clearly true, since pub can't run without a pubspec, 14 | /// but it's possible that the pubspec is gitignored. 15 | class PubspecValidator extends Validator { 16 | @override 17 | Future validate() async { 18 | if (!filesBeneath( 19 | '.', 20 | recursive: false, 21 | ).any((file) => p.basename(file) == 'pubspec.yaml')) { 22 | errors.add('The pubspec is hidden, probably by .gitignore or pubignore.'); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: pub 2 | 3 | environment: 4 | sdk: ^3.7.0 5 | 6 | dependencies: 7 | analyzer: 7.3.0 8 | args: ^2.7.0 9 | async: ^2.11.0 10 | cli_util: ^0.4.1 11 | collection: ^1.18.0 12 | convert: ^3.1.2 13 | crypto: ^3.0.6 14 | frontend_server_client: ^4.0.0 15 | graphs: ^2.3.1 16 | http: ^1.1.2 17 | http_multi_server: ^3.2.1 18 | http_parser: ^4.1.1 19 | meta: ^1.16.0 20 | path: ^1.9.1 21 | pool: ^1.5.1 22 | pub_semver: ^2.2.0 23 | shelf: ^1.4.1 24 | source_span: ^1.10.1 25 | stack_trace: ^1.11.1 26 | tar: ^2.0.0 27 | typed_data: ^1.4.0 28 | yaml: ^3.1.3 29 | yaml_edit: ^2.2.1 30 | 31 | dev_dependencies: 32 | checks: ^0.3.0 33 | dart_flutter_team_lints: ^3.5.1 34 | shelf_test_handler: ^2.0.2 35 | test: ^1.25.14 36 | test_descriptor: ^2.0.2 37 | test_process: ^2.1.0 38 | -------------------------------------------------------------------------------- /test/cache/add/adds_latest_version_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('adds the latest stable version of the package', () async { 12 | await servePackages() 13 | ..serve('foo', '1.2.2') 14 | ..serve('foo', '1.2.3') 15 | ..serve('foo', '1.2.4-dev'); 16 | 17 | await runPub( 18 | args: ['cache', 'add', 'foo'], 19 | silent: contains('Downloading foo 1.2.3...'), 20 | ); 21 | 22 | await d.cacheDir({'foo': '1.2.3'}).validate(); 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /test/cache/add/all_adds_all_matching_versions_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('"--all" adds all matching versions of the package', () async { 12 | await servePackages() 13 | ..serve('foo', '1.2.2') 14 | ..serve('foo', '1.2.3-dev') 15 | ..serve('foo', '1.2.3') 16 | ..serve('foo', '2.0.0'); 17 | 18 | await runPub( 19 | args: ['cache', 'add', 'foo', '-v', '>=1.0.0 <2.0.0', '--all'], 20 | silent: allOf([ 21 | contains('Downloading foo 1.2.2...'), 22 | contains('Downloading foo 1.2.3-dev...'), 23 | contains('Downloading foo 1.2.3...'), 24 | ]), 25 | ); 26 | 27 | await d.cacheDir({'foo': '1.2.2'}).validate(); 28 | await d.cacheDir({'foo': '1.2.3-dev'}).validate(); 29 | await d.cacheDir({'foo': '1.2.3'}).validate(); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/cache/add/already_cached_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('does nothing if the package is already cached', () async { 12 | final server = await servePackages(); 13 | server.serve('foo', '1.2.3'); 14 | 15 | // Run once to put it in the cache. 16 | await runPub( 17 | args: ['cache', 'add', 'foo'], 18 | silent: contains('Downloading foo 1.2.3...'), 19 | ); 20 | 21 | // Should be in the cache now. 22 | await runPub( 23 | args: ['cache', 'add', 'foo'], 24 | output: 'Already cached foo 1.2.3.', 25 | ); 26 | 27 | await d.cacheDir({'foo': '1.2.3'}).validate(); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /test/cache/add/bad_version_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('fails if the version constraint cannot be parsed', () { 12 | return runPub( 13 | args: ['cache', 'add', 'foo', '-v', '1.0'], 14 | error: contains('Could not parse version "1.0". Unknown text at "1.0".'), 15 | exitCode: exit_codes.USAGE, 16 | ); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /test/cache/add/missing_package_arg_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('fails if no package was given', () { 12 | return runPub( 13 | args: ['cache', 'add'], 14 | error: contains('No package to add given.'), 15 | exitCode: exit_codes.USAGE, 16 | ); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /test/cache/add/no_matching_version_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../test_pub.dart'; 8 | 9 | void main() { 10 | test('fails if no version matches the version constraint', () async { 11 | await servePackages() 12 | ..serve('foo', '1.2.2') 13 | ..serve('foo', '1.2.3'); 14 | 15 | await runPub( 16 | args: ['cache', 'add', 'foo', '-v', '>2.0.0'], 17 | error: 'Package foo has no versions that match >2.0.0.', 18 | exitCode: 1, 19 | ); 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/cache/add/package_not_found_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('fails if the package could not be found on the source', () async { 12 | await servePackages(); 13 | 14 | await runPub( 15 | args: ['cache', 'add', 'foo'], 16 | error: RegExp( 17 | r'Package not available \(could not find package foo at http://.*\)\.', 18 | ), 19 | exitCode: exit_codes.UNAVAILABLE, 20 | ); 21 | }); 22 | } 23 | -------------------------------------------------------------------------------- /test/cache/add/unexpected_arguments_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('fails if there are extra arguments', () { 12 | return runPub( 13 | args: ['cache', 'add', 'foo', 'bar', 'baz'], 14 | error: contains('Unexpected arguments "bar" and "baz".'), 15 | exitCode: exit_codes.USAGE, 16 | ); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /test/cache/detect_deprecated_dir_test.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:path/path.dart' as p; 4 | import 'package:test/test.dart'; 5 | import 'package:test_descriptor/test_descriptor.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() async { 11 | test( 12 | 'Detects and warns about old cache dir', 13 | skip: !Platform.isWindows, 14 | () async { 15 | await d.dir('APPDATA', [ 16 | d.dir('Pub', [d.dir('Cache')]), 17 | ]).create(); 18 | final server = await servePackages(); 19 | server.serve('foo', '1.0.0'); 20 | await d.appDir(dependencies: {'foo': '^1.0.0'}).create(); 21 | await pubGet( 22 | warning: contains('Found a legacy Pub cache at'), 23 | environment: {'APPDATA': d.path('APPDATA')}, 24 | ); 25 | expect( 26 | File( 27 | p.join(sandbox, 'APPDATA', 'Pub', 'Cache', 'DEPRECATED.md'), 28 | ).existsSync(), 29 | isTrue, 30 | ); 31 | server.serve('foo', '2.0.0'); 32 | await d.appDir(dependencies: {'foo': '^2.0.0'}).create(); 33 | await pubGet(warning: isNot(contains('Found a legacy Pub cache'))); 34 | }, 35 | ); 36 | } 37 | -------------------------------------------------------------------------------- /test/cache/repair/empty_cache_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../test_pub.dart'; 8 | 9 | void main() { 10 | test('does nothing if the cache is empty', () { 11 | // Repair them. 12 | return runPub( 13 | args: ['cache', 'repair'], 14 | output: 'No packages in cache, so nothing to repair.', 15 | ); 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /test/cache/repair/handles_corrupted_binstub_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('handles a corrupted binstub script', () async { 12 | final server = await servePackages(); 13 | server.serve( 14 | 'foo', 15 | '1.0.0', 16 | contents: [ 17 | d.dir('bin', [d.file('script.dart', "main(args) => print('ok');")]), 18 | ], 19 | ); 20 | 21 | await runPub(args: ['global', 'activate', 'foo']); 22 | 23 | await d.dir(cachePath, [ 24 | d.dir('bin', [d.file(binStubName('script'), 'junk')]), 25 | ]).create(); 26 | 27 | await runPub( 28 | args: ['cache', 'repair'], 29 | error: contains('Error reading binstub for "script":'), 30 | ); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /test/cache/repair/handles_corrupted_global_lockfile_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../descriptor.dart' as d; 9 | import '../../test_pub.dart'; 10 | 11 | void main() { 12 | test('handles a corrupted global lockfile', () async { 13 | await d.dir(cachePath, [ 14 | d.dir('global_packages/foo', [d.file('pubspec.lock', 'junk')]), 15 | ]).create(); 16 | 17 | await runPub( 18 | args: ['cache', 'repair'], 19 | error: contains('Failed to reactivate foo:'), 20 | output: contains( 21 | 'Failed to reactivate 1 package:\n' 22 | '- foo', 23 | ), 24 | exitCode: exit_codes.UNAVAILABLE, 25 | ); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /test/cache/repair/handles_orphaned_binstub_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | const _orphanedBinstub = ''' 11 | #!/usr/bin/env sh 12 | # This file was created by pub v0.1.2-3. 13 | # Package: foo 14 | # Version: 1.0.0 15 | # Executable: foo-script 16 | # Script: script 17 | dart "/path/to/.pub-cache/global_packages/foo/bin/script.dart.snapshot" "\$@" 18 | '''; 19 | 20 | void main() { 21 | test('handles an orphaned binstub script', () async { 22 | await d.dir(cachePath, [ 23 | d.dir('bin', [d.file(binStubName('script'), _orphanedBinstub)]), 24 | ]).create(); 25 | 26 | await runPub( 27 | args: ['cache', 'repair'], 28 | error: allOf([ 29 | contains('Binstubs exist for non-activated packages:'), 30 | contains('From foo: foo-script'), 31 | ]), 32 | ); 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test/dependency_name_validation_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart'; 6 | import 'package:test/test.dart'; 7 | 8 | import 'descriptor.dart'; 9 | import 'test_pub.dart'; 10 | 11 | void main() { 12 | test('Dependency names have to be valid package names', () async { 13 | await appDir(dependencies: {'abc def': '1.0.0'}).create(); 14 | await pubGet(error: contains('Not a valid package name.'), exitCode: DATA); 15 | }); 16 | 17 | test('Dev-dependency names have to be valid package names', () async { 18 | await appDir( 19 | pubspec: { 20 | 'dev_dependencies': {'abc def': '1.0.0'}, 21 | }, 22 | ).create(); 23 | await pubGet(error: contains('Not a valid package name.'), exitCode: DATA); 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /test/downgrade/does_not_show_other_versions_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() { 11 | test('does not show how many other versions are available', () async { 12 | await servePackages() 13 | ..serve('downgraded', '1.0.0') 14 | ..serve('downgraded', '2.0.0') 15 | ..serve('downgraded', '3.0.0-dev'); 16 | 17 | await d.appDir(dependencies: {'downgraded': '3.0.0-dev'}).create(); 18 | 19 | await pubGet(); 20 | 21 | // Loosen the constraints. 22 | await d.appDir(dependencies: {'downgraded': '>=2.0.0'}).create(); 23 | 24 | await pubDowngrade(output: contains('downgraded 2.0.0 (was 3.0.0-dev)')); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /test/downgrade/doesnt_change_git_dependencies_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() { 11 | test("doesn't change git dependencies", () async { 12 | ensureGit(); 13 | 14 | await d.git('foo.git', [ 15 | d.libDir('foo'), 16 | d.libPubspec('foo', '1.0.0'), 17 | ]).create(); 18 | 19 | await d 20 | .appDir( 21 | dependencies: { 22 | 'foo': {'git': '../foo.git'}, 23 | }, 24 | ) 25 | .create(); 26 | 27 | await pubGet(); 28 | 29 | final originalFooSpec = packageSpec('foo'); 30 | 31 | await d.git('foo.git', [ 32 | d.libDir('foo', 'foo 2'), 33 | d.libPubspec('foo', '1.0.0'), 34 | ]).commit(); 35 | 36 | await pubDowngrade(); 37 | 38 | expect(packageSpec('foo'), originalFooSpec); 39 | }); 40 | } 41 | -------------------------------------------------------------------------------- /test/get/dry_run_does_not_apply_changes_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() { 11 | test('--dry-run shows but does not apply changes', () async { 12 | final server = await servePackages(); 13 | server.serve('foo', '1.0.0'); 14 | 15 | await d.appDir(dependencies: {'foo': '1.0.0'}).create(); 16 | 17 | await pubGet( 18 | args: ['--dry-run'], 19 | output: allOf([ 20 | contains('+ foo 1.0.0'), 21 | contains('Would change 1 dependency.'), 22 | ]), 23 | ); 24 | 25 | await d.dir(appPath, [ 26 | d.nothing('pubspec.lock'), 27 | d.nothing('.dart_tool/package_config.json'), 28 | ]).validate(); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /test/get/flutter_constraint_upper_bound_ignored_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('pub get succeeds despite of "invalid" flutter upper bound', () async { 13 | final fakeFlutterRoot = d.dir('fake_flutter_root', [ 14 | d.flutterVersion('1.23.0'), 15 | ]); 16 | await fakeFlutterRoot.create(); 17 | await d.dir(appPath, [ 18 | d.pubspec({ 19 | 'name': 'myapp', 20 | 'environment': {'flutter': '>=0.5.0 <1.0.0'}, 21 | }), 22 | ]).create(); 23 | 24 | await pubGet( 25 | exitCode: exit_codes.SUCCESS, 26 | environment: {'FLUTTER_ROOT': fakeFlutterRoot.io.path}, 27 | ); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /test/get/get_inside_cache_fails_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('`pub get` inside the cache fails gracefully', () async { 13 | final server = await servePackages(); 14 | server.serve('foo', '1.0.0'); 15 | await d.appDir(dependencies: {'foo': 'any'}).create(); 16 | 17 | await pubGet(); 18 | 19 | await pubGet( 20 | workingDirectory: p.join(d.sandbox, d.hostedCachePath(), 'foo-1.0.0'), 21 | error: 'Cannot operate on packages inside the cache.', 22 | ); 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /test/get/git/check_out_twice_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('checks out a package from Git twice', () async { 12 | ensureGit(); 13 | 14 | await d.git('foo.git', [ 15 | d.libDir('foo'), 16 | d.libPubspec('foo', '1.0.0'), 17 | ]).create(); 18 | 19 | await d 20 | .appDir( 21 | dependencies: { 22 | 'foo': {'git': '../foo.git'}, 23 | }, 24 | ) 25 | .create(); 26 | 27 | await pubGet(); 28 | 29 | await d.dir(cachePath, [ 30 | d.dir('git', [ 31 | d.dir('cache', [d.gitPackageRepoCacheDir('foo')]), 32 | d.gitPackageRevisionCacheDir('foo'), 33 | ]), 34 | ]).validate(); 35 | 36 | expect(packageSpec('foo'), isNotNull); 37 | 38 | // Verify that nothing breaks if we get a Git revision that's already 39 | // in the cache. 40 | await pubUpgrade(); 41 | }); 42 | } 43 | -------------------------------------------------------------------------------- /test/get/git/dependency_name_match_pubspec_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../descriptor.dart' as d; 9 | import '../../test_pub.dart'; 10 | 11 | void main() { 12 | test('requires the dependency name to match the remote pubspec ' 13 | 'name', () async { 14 | ensureGit(); 15 | 16 | await d.git('foo.git', [ 17 | d.libDir('foo'), 18 | d.libPubspec('foo', '1.0.0'), 19 | ]).create(); 20 | 21 | await d.dir(appPath, [ 22 | d.appPubspec( 23 | dependencies: { 24 | 'weirdname': {'git': '../foo.git'}, 25 | }, 26 | ), 27 | ]).create(); 28 | 29 | await pubGet( 30 | error: contains( 31 | '"name" field doesn\'t match expected name ' 32 | '"weirdname".', 33 | ), 34 | exitCode: exit_codes.DATA, 35 | ); 36 | }); 37 | } 38 | -------------------------------------------------------------------------------- /test/get/git/different_repo_name_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('doesn\'t require the repository name to match the name in the ' 12 | 'pubspec', () async { 13 | ensureGit(); 14 | 15 | await d.git('foo.git', [ 16 | d.libDir('weirdname'), 17 | d.libPubspec('weirdname', '1.0.0'), 18 | ]).create(); 19 | 20 | await d.dir(appPath, [ 21 | d.appPubspec( 22 | dependencies: { 23 | 'weirdname': {'git': '../foo.git'}, 24 | }, 25 | ), 26 | ]).create(); 27 | 28 | await pubGet(); 29 | 30 | expect(packageSpec('weirdname')['rootUri'], contains('foo')); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /test/get/git/doesnt_fetch_if_nothing_changes_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:pub/src/io.dart'; 7 | import 'package:test/test.dart'; 8 | 9 | import '../../descriptor.dart' as d; 10 | import '../../test_pub.dart'; 11 | 12 | void main() { 13 | test("doesn't re-fetch a repository if nothing changes", () async { 14 | ensureGit(); 15 | 16 | await d.git('foo.git', [ 17 | d.libDir('foo'), 18 | d.libPubspec('foo', '1.0.0'), 19 | ]).create(); 20 | 21 | await d 22 | .appDir( 23 | dependencies: { 24 | 'foo': { 25 | 'git': {'url': '../foo.git'}, 26 | }, 27 | }, 28 | ) 29 | .create(); 30 | 31 | await pubGet(); 32 | 33 | final originalFooSpec = packageSpec('foo'); 34 | 35 | // Delete the repo. This will cause "pub get" to fail if it tries to 36 | // re-fetch. 37 | deleteEntry(p.join(d.sandbox, 'foo.git')); 38 | 39 | await pubGet(); 40 | 41 | expect(packageSpec('foo'), originalFooSpec); 42 | }); 43 | } 44 | -------------------------------------------------------------------------------- /test/get/git/require_pubspec_name_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../descriptor.dart' as d; 9 | import '../../test_pub.dart'; 10 | 11 | void main() { 12 | test('requires the dependency to have a pubspec with a name ' 13 | 'field', () async { 14 | ensureGit(); 15 | 16 | await d.git('foo.git', [d.libDir('foo'), d.pubspec({})]).create(); 17 | 18 | await d 19 | .appDir( 20 | dependencies: { 21 | 'foo': {'git': '../foo.git'}, 22 | }, 23 | ) 24 | .create(); 25 | 26 | await pubGet( 27 | error: contains('Missing the required "name" field.'), 28 | exitCode: exit_codes.DATA, 29 | ); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/get/git/require_pubspec_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('requires the dependency to have a pubspec', () async { 12 | ensureGit(); 13 | 14 | await d.git('foo.git', [d.libDir('foo')]).create(); 15 | 16 | await d 17 | .appDir( 18 | dependencies: { 19 | 'foo': {'git': '../foo.git'}, 20 | }, 21 | ) 22 | .create(); 23 | 24 | await pubGet( 25 | error: RegExp( 26 | r'Could not find a file named "pubspec\.yaml" ' 27 | r'in [^\n]\.', 28 | ), 29 | ); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/get/hosted/get_stress_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('gets more than 16 packages from a pub server', () async { 12 | final server = await servePackages(); 13 | server.serve('foo', '1.2.3'); 14 | for (var i = 0; i < 20; i++) { 15 | server.serve('pkg$i', '1.$i.0'); 16 | } 17 | 18 | await d 19 | .appDir( 20 | dependencies: { 21 | 'foo': '1.2.3', 22 | for (var i = 0; i < 20; i++) 'pkg$i': '^1.$i.0', 23 | }, 24 | ) 25 | .create(); 26 | 27 | await pubGet(); 28 | 29 | await d.cacheDir({ 30 | 'foo': '1.2.3', 31 | for (var i = 0; i < 20; i++) 'pkg$i': '1.$i.0', 32 | }).validate(); 33 | await d.appPackageConfigFile([ 34 | d.packageConfigEntry(name: 'foo', version: '1.2.3'), 35 | for (var i = 0; i < 20; i++) 36 | d.packageConfigEntry(name: 'pkg$i', version: '1.$i.0'), 37 | ]).validate(); 38 | }); 39 | } 40 | -------------------------------------------------------------------------------- /test/get/hosted/get_transitive_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('gets packages transitively from a pub server', () async { 12 | await servePackages() 13 | ..serve('foo', '1.2.3', deps: {'bar': '2.0.4'}) 14 | ..serve('bar', '2.0.3') 15 | ..serve('bar', '2.0.4') 16 | ..serve('bar', '2.0.5'); 17 | 18 | await d.appDir(dependencies: {'foo': '1.2.3'}).create(); 19 | 20 | await pubGet(); 21 | 22 | await d.cacheDir({'foo': '1.2.3', 'bar': '2.0.4'}).validate(); 23 | await d.appPackageConfigFile([ 24 | d.packageConfigEntry(name: 'foo', version: '1.2.3'), 25 | d.packageConfigEntry(name: 'bar', version: '2.0.4'), 26 | ]).validate(); 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /test/get/hosted/gets_a_package_with_busted_dev_dependencies_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | // Regression test for issue 22194. 12 | test('gets a dependency with broken dev dependencies from a pub ' 13 | 'server', () async { 14 | final server = await servePackages(); 15 | server.serve( 16 | 'foo', 17 | '1.2.3', 18 | pubspec: { 19 | 'dev_dependencies': { 20 | 'busted': {'not a real source': null}, 21 | }, 22 | }, 23 | ); 24 | 25 | await d.appDir(dependencies: {'foo': '1.2.3'}).create(); 26 | 27 | await pubGet(); 28 | 29 | await d.cacheDir({'foo': '1.2.3'}).validate(); 30 | await d.appPackageConfigFile([ 31 | d.packageConfigEntry(name: 'foo', version: '1.2.3'), 32 | ]).validate(); 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test/get/hosted/resolve_constraints_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('resolves version constraints from a pub server', () async { 12 | await servePackages() 13 | ..serve('foo', '1.2.3', deps: {'baz': '>=2.0.0'}) 14 | ..serve('bar', '2.3.4', deps: {'baz': '<3.0.0'}) 15 | ..serve('baz', '2.0.3') 16 | ..serve('baz', '2.0.4') 17 | ..serve('baz', '3.0.1'); 18 | 19 | await d.appDir(dependencies: {'foo': 'any', 'bar': 'any'}).create(); 20 | 21 | await pubGet(); 22 | 23 | await d.cacheDir({ 24 | 'foo': '1.2.3', 25 | 'bar': '2.3.4', 26 | 'baz': '2.0.4', 27 | }).validate(); 28 | await d.appPackageConfigFile([ 29 | d.packageConfigEntry(name: 'foo', version: '1.2.3'), 30 | d.packageConfigEntry(name: 'bar', version: '2.3.4'), 31 | d.packageConfigEntry(name: 'baz', version: '2.0.4'), 32 | ]).validate(); 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test/get/hosted/stay_locked_if_compatible_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test("doesn't upgrade a locked pub server package with a new " 12 | 'compatible constraint', () async { 13 | final server = await servePackages(); 14 | server.serve('foo', '1.0.0'); 15 | 16 | await d.appDir(dependencies: {'foo': 'any'}).create(); 17 | 18 | await pubGet(); 19 | await d.appPackageConfigFile([ 20 | d.packageConfigEntry(name: 'foo', version: '1.0.0'), 21 | ]).validate(); 22 | 23 | server.serve('foo', '1.0.1'); 24 | 25 | await d.appDir(dependencies: {'foo': '>=1.0.0'}).create(); 26 | 27 | await pubGet(); 28 | 29 | await d.appPackageConfigFile([ 30 | d.packageConfigEntry(name: 'foo', version: '1.0.0'), 31 | ]).validate(); 32 | }); 33 | } 34 | -------------------------------------------------------------------------------- /test/get/hosted/unlock_if_incompatible_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('upgrades a locked pub server package with a new incompatible ' 12 | 'constraint', () async { 13 | final server = await servePackages(); 14 | server.serve('foo', '1.0.0'); 15 | 16 | await d.appDir(dependencies: {'foo': 'any'}).create(); 17 | 18 | await pubGet(); 19 | 20 | await d.appPackageConfigFile([ 21 | d.packageConfigEntry(name: 'foo', version: '1.0.0'), 22 | ]).validate(); 23 | server.serve('foo', '1.0.1'); 24 | await d.appDir(dependencies: {'foo': '>1.0.0'}).create(); 25 | 26 | await pubGet(); 27 | 28 | await d.appPackageConfigFile([ 29 | d.packageConfigEntry(name: 'foo', version: '1.0.1'), 30 | ]).validate(); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /test/get/hosted/unlock_if_version_doesnt_exist_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:pub/src/io.dart'; 7 | import 'package:test/test.dart'; 8 | 9 | import '../../descriptor.dart' as d; 10 | import '../../test_pub.dart'; 11 | 12 | void main() { 13 | test( 14 | 'upgrades a locked pub server package with a nonexistent version', 15 | () async { 16 | final server = await servePackages(); 17 | server.serve('foo', '1.0.0'); 18 | 19 | await d.appDir(dependencies: {'foo': 'any'}).create(); 20 | await pubGet(); 21 | await d.appPackageConfigFile([ 22 | d.packageConfigEntry(name: 'foo', version: '1.0.0'), 23 | ]).validate(); 24 | 25 | deleteEntry(p.join(d.sandbox, cachePath)); 26 | 27 | server.clearPackages(); 28 | server.serve('foo', '1.0.1'); 29 | 30 | await pubGet(); 31 | await d.appPackageConfigFile([ 32 | d.packageConfigEntry(name: 'foo', version: '1.0.1'), 33 | ]).validate(); 34 | }, 35 | ); 36 | } 37 | -------------------------------------------------------------------------------- /test/get/path/absolute_path_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../descriptor.dart' as d; 9 | import '../../test_pub.dart'; 10 | 11 | void main() { 12 | test('path dependency with absolute path', () async { 13 | await d.dir('foo', [ 14 | d.libDir('foo'), 15 | d.libPubspec('foo', '0.0.1'), 16 | ]).create(); 17 | 18 | await d.dir(appPath, [ 19 | d.appPubspec( 20 | dependencies: { 21 | 'foo': {'path': p.join(d.sandbox, 'foo')}, 22 | }, 23 | ), 24 | ]).create(); 25 | 26 | await pubGet(); 27 | 28 | await d.appPackageConfigFile([ 29 | d.packageConfigEntry(name: 'foo', path: p.join(d.sandbox, 'foo')), 30 | ]).validate(); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /test/get/path/empty_pubspec_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:pub/src/exit_codes.dart' as exit_codes; 7 | import 'package:test/test.dart'; 8 | 9 | import '../../descriptor.dart' as d; 10 | import '../../test_pub.dart'; 11 | 12 | void main() { 13 | // Regression test for issue 20103. 14 | test('path dependency to an empty pubspec', () async { 15 | await d.dir('foo', [d.libDir('foo'), d.file('pubspec.yaml', '')]).create(); 16 | 17 | await d.dir(appPath, [ 18 | d.appPubspec( 19 | dependencies: { 20 | 'foo': {'path': '../foo'}, 21 | }, 22 | ), 23 | ]).create(); 24 | 25 | await pubGet( 26 | exitCode: exit_codes.DATA, 27 | error: 28 | 'Error on line 1, column 1 of ' 29 | '${p.join('..', 'foo', 'pubspec.yaml')}: ' 30 | 'Missing the required "name" field.', 31 | ); 32 | }); 33 | } 34 | -------------------------------------------------------------------------------- /test/get/path/no_pubspec_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:pub/src/exit_codes.dart' as exit_codes; 7 | import 'package:test/test.dart'; 8 | 9 | import '../../descriptor.dart' as d; 10 | import '../../test_pub.dart'; 11 | 12 | void main() { 13 | test('path dependency to non-package directory', () async { 14 | // Make an empty directory. 15 | await d.dir('foo').create(); 16 | final fooPath = p.join(d.sandbox, 'foo'); 17 | 18 | await d.dir(appPath, [ 19 | d.appPubspec( 20 | dependencies: { 21 | 'foo': {'path': fooPath}, 22 | }, 23 | ), 24 | ]).create(); 25 | 26 | await pubGet( 27 | error: 28 | 'Because myapp depends on foo from path which doesn\'t exist ' 29 | '(No pubspec.yaml found for package foo in $fooPath.), ' 30 | 'version solving failed.', 31 | exitCode: exit_codes.NO_INPUT, 32 | ); 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test/get/path/nonexistent_dir_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:pub/src/exit_codes.dart' as exit_codes; 7 | import 'package:test/test.dart'; 8 | 9 | import '../../descriptor.dart' as d; 10 | import '../../test_pub.dart'; 11 | 12 | void main() { 13 | test('path dependency to non-existent directory', () async { 14 | final badPath = p.join(d.sandbox, 'bad_path'); 15 | 16 | await d.dir(appPath, [ 17 | d.appPubspec( 18 | dependencies: { 19 | 'foo': {'path': badPath}, 20 | }, 21 | ), 22 | ]).create(); 23 | 24 | await pubGet( 25 | error: 26 | 'Because myapp depends on foo from path which doesn\'t exist ' 27 | '(could not find package foo at "$badPath"), version solving failed.', 28 | exitCode: exit_codes.NO_INPUT, 29 | ); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/get/path/path_is_file_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:pub/src/exit_codes.dart' as exit_codes; 7 | import 'package:test/test.dart'; 8 | 9 | import '../../descriptor.dart' as d; 10 | import '../../test_pub.dart'; 11 | 12 | void main() { 13 | test('path dependency when path is a file', () async { 14 | await d.dir('foo', [ 15 | d.libDir('foo'), 16 | d.libPubspec('foo', '0.0.1'), 17 | ]).create(); 18 | 19 | await d.file('dummy.txt', '').create(); 20 | final dummyPath = p.join(d.sandbox, 'dummy.txt'); 21 | 22 | await d.dir(appPath, [ 23 | d.appPubspec( 24 | dependencies: { 25 | 'foo': {'path': dummyPath}, 26 | }, 27 | ), 28 | ]).create(); 29 | 30 | await pubGet( 31 | error: 32 | 'Because myapp depends on foo from path which doesn\'t exist ' 33 | '(Path dependency for package foo must refer to a directory, ' 34 | 'not a file. Was "$dummyPath".), version solving failed.', 35 | exitCode: exit_codes.NO_INPUT, 36 | ); 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /test/get/summary_only_environment_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() { 11 | test('pub get with PUB_SUMMARY_ONLY will only print a summary', () async { 12 | (await servePackages()).serve('foo', '1.0.0'); 13 | await d.appDir(dependencies: {'foo': 'any'}).create(); 14 | 15 | await pubGet( 16 | output: 17 | 'Resolving dependencies...\n' 18 | 'Downloading packages...\n' 19 | 'Got dependencies.', 20 | silent: contains('+ foo 1.0.0'), 21 | environment: {'PUB_SUMMARY_ONLY': '1'}, 22 | ); 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /test/get/switch_source_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() { 11 | test('re-gets a package if its source has changed', () async { 12 | final server = await servePackages(); 13 | server.serve('foo', '1.2.3'); 14 | 15 | await d.dir('foo', [ 16 | d.libDir('foo', 'foo 0.0.1'), 17 | d.libPubspec('foo', '0.0.1'), 18 | ]).create(); 19 | 20 | await d 21 | .appDir( 22 | dependencies: { 23 | 'foo': {'path': '../foo'}, 24 | }, 25 | ) 26 | .create(); 27 | 28 | await pubGet(); 29 | 30 | await d.appPackageConfigFile([ 31 | d.packageConfigEntry(name: 'foo', path: '../foo'), 32 | ]).validate(); 33 | await d.appDir(dependencies: {'foo': 'any'}).create(); 34 | 35 | await pubGet(); 36 | 37 | await d.appPackageConfigFile([ 38 | d.packageConfigEntry(name: 'foo', version: '1.2.3'), 39 | ]).validate(); 40 | }); 41 | } 42 | -------------------------------------------------------------------------------- /test/get/unknown_sdk_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('pub get barks at unknown sdk', () async { 13 | await d.dir(appPath, [ 14 | d.pubspec({ 15 | 'environment': {'foo': '>=1.2.4 <2.0.0'}, 16 | }), 17 | ]).create(); 18 | 19 | await pubGet( 20 | error: contains( 21 | 'Error on line 1, column 32 of pubspec.yaml: ' 22 | "pubspec.yaml refers to an unknown sdk 'foo'.", 23 | ), 24 | exitCode: exit_codes.DATA, 25 | ); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /test/get/with_empty_environment_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() { 11 | test(r'runs even with an empty environment (eg. no $HOME)', () async { 12 | final server = await servePackages(); 13 | server.serve('foo', '1.2.3'); 14 | 15 | await d.appDir(dependencies: {'foo': 'any'}).create(); 16 | 17 | await pubGet( 18 | environment: {'_PUB_TEST_CONFIG_DIR': null}, 19 | includeParentHomeAndPath: false, 20 | ); 21 | }); 22 | } 23 | -------------------------------------------------------------------------------- /test/global/activate/activate_hosted_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart'; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../descriptor.dart'; 9 | import '../../test_pub.dart'; 10 | 11 | void main() { 12 | test('activating an invalid package name fails nicely', () async { 13 | await appDir().create(); 14 | await runPub( 15 | args: ['global', 'activate', '.'], 16 | error: allOf( 17 | contains('Not a valid package name: "."'), 18 | contains('Did you mean `dart pub global activate --source path .'), 19 | ), 20 | exitCode: USAGE, 21 | ); 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /test/global/activate/bad_version_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('fails if the version constraint cannot be parsed', () { 12 | return runPub( 13 | args: ['global', 'activate', 'foo', '1.0'], 14 | error: contains('Could not parse version "1.0". Unknown text at "1.0".'), 15 | exitCode: exit_codes.USAGE, 16 | ); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /test/global/activate/constraint_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('chooses the highest version that matches the constraint', () async { 12 | await servePackages() 13 | ..serve('foo', '1.0.0') 14 | ..serve('foo', '1.0.1') 15 | ..serve('foo', '1.1.0') 16 | ..serve('foo', '1.2.3'); 17 | 18 | await runPub(args: ['global', 'activate', 'foo', '<1.1.0']); 19 | 20 | await d.dir(cachePath, [ 21 | d.dir('global_packages', [ 22 | d.dir('foo', [d.file('pubspec.lock', contains('1.0.1'))]), 23 | ]), 24 | ]).validate(); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /test/global/activate/constraint_with_path_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('fails if a version is passed with the path source', () { 12 | return runPub( 13 | args: ['global', 'activate', '-spath', 'foo', '1.2.3'], 14 | error: contains('Unexpected argument "1.2.3".'), 15 | exitCode: exit_codes.USAGE, 16 | ); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /test/global/activate/doesnt_snapshot_path_executables_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test("doesn't snapshots the executables for a path package", () async { 12 | await d.dir('foo', [ 13 | d.libPubspec('foo', '1.0.0'), 14 | d.dir('bin', [d.file('hello.dart', "void main() => print('hello!');")]), 15 | ]).create(); 16 | 17 | await runPub( 18 | args: ['global', 'activate', '-spath', '../foo'], 19 | output: isNot(contains('Built foo:hello.')), 20 | ); 21 | 22 | await d.dir(cachePath, [ 23 | d.dir('global_packages', [ 24 | d.dir('foo', [ 25 | d.file('pubspec.lock', contains('1.0.0')), 26 | d.nothing('bin'), 27 | ]), 28 | ]), 29 | ]).validate(); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/global/activate/empty_constraint_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('errors if the constraint matches no versions', () async { 12 | await servePackages() 13 | ..serve('foo', '1.0.0') 14 | ..serve('foo', '1.0.1'); 15 | 16 | await runPub( 17 | args: ['global', 'activate', 'foo', '>1.1.0'], 18 | error: equalsIgnoringWhitespace(""" 19 | Because pub global activate depends on foo >1.1.0 which doesn't match 20 | any versions, version solving failed. 21 | """), 22 | exitCode: exit_codes.DATA, 23 | ); 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /test/global/activate/installs_dependencies_for_git_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('activating a Git package installs its dependencies', () async { 12 | await servePackages() 13 | ..serve('bar', '1.0.0', deps: {'baz': 'any'}) 14 | ..serve('baz', '1.0.0'); 15 | 16 | await d.git('foo.git', [ 17 | d.libPubspec('foo', '1.0.0', deps: {'bar': 'any'}), 18 | d.dir('bin', [d.file('foo.dart', "main() => print('ok');")]), 19 | ]).create(); 20 | 21 | await runPub( 22 | args: ['global', 'activate', '-sgit', '../foo.git'], 23 | silent: allOf([ 24 | contains('Downloading bar 1.0.0...'), 25 | contains('Downloading baz 1.0.0...'), 26 | ]), 27 | ); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /test/global/activate/installs_dependencies_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../test_pub.dart'; 8 | 9 | void main() { 10 | test('activating a package installs its dependencies', () async { 11 | await servePackages() 12 | ..serve('foo', '1.0.0', deps: {'bar': 'any'}) 13 | ..serve('bar', '1.0.0', deps: {'baz': 'any'}) 14 | ..serve('baz', '1.0.0'); 15 | 16 | await runPub( 17 | args: ['global', 'activate', 'foo'], 18 | silent: allOf([ 19 | contains('Downloading bar 1.0.0...'), 20 | contains('Downloading baz 1.0.0...'), 21 | ]), 22 | ); 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /test/global/activate/missing_git_repo_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('fails if the Git repo does not exist', () async { 12 | ensureGit(); 13 | 14 | await runPub( 15 | args: ['global', 'activate', '-sgit', '../nope.git'], 16 | error: contains("/nope.git' does not appear to be a git repository"), 17 | exitCode: exit_codes.UNAVAILABLE, 18 | ); 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /test/global/activate/missing_package_arg_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('fails if no package was given', () { 12 | return runPub( 13 | args: ['global', 'activate'], 14 | error: contains('No package to activate given.'), 15 | exitCode: exit_codes.USAGE, 16 | ); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /test/global/activate/supports_version_solver_backtracking_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('performs version solver backtracking if necessary', () async { 12 | await servePackages() 13 | ..serve( 14 | 'foo', 15 | '1.1.0', 16 | pubspec: { 17 | 'environment': {'sdk': defaultSdkConstraint}, 18 | }, 19 | ) 20 | ..serve( 21 | 'foo', 22 | '1.2.0', 23 | pubspec: { 24 | 'environment': {'sdk': '^3.1.3'}, 25 | }, 26 | ); 27 | 28 | await runPub(args: ['global', 'activate', 'foo']); 29 | 30 | // foo 1.2.0 won't be picked because its SDK constraint conflicts with the 31 | // dummy SDK version 3.1.2+3. 32 | await d.dir(cachePath, [ 33 | d.dir('global_packages', [ 34 | d.dir('foo', [d.file('pubspec.lock', contains('1.1.0'))]), 35 | ]), 36 | ]).validate(); 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /test/global/activate/unexpected_arguments_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('fails if there are extra arguments', () { 12 | return runPub( 13 | args: ['global', 'activate', 'foo', '1.0.0', 'bar', 'baz'], 14 | error: contains('Unexpected arguments "bar" and "baz".'), 15 | exitCode: exit_codes.USAGE, 16 | ); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /test/global/activate/unknown_package_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('errors if the package could not be found', () async { 12 | await servePackages(); 13 | 14 | await runPub( 15 | args: ['global', 'activate', 'foo'], 16 | error: allOf([ 17 | contains( 18 | "Because pub global activate depends on foo any which doesn't " 19 | 'exist (could not find package foo at http://localhost:', 20 | ), 21 | contains('), version solving failed.'), 22 | ]), 23 | exitCode: exit_codes.UNAVAILABLE, 24 | ); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /test/global/binstubs/binstub_runs_precompiled_snapshot_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('the binstubs runs a built snapshot if present', () async { 12 | final server = await servePackages(); 13 | server.serve( 14 | 'foo', 15 | '1.0.0', 16 | pubspec: { 17 | 'executables': {'foo-script': 'script'}, 18 | }, 19 | contents: [ 20 | d.dir('bin', [d.file('script.dart', "main(args) => print('ok');")]), 21 | ], 22 | ); 23 | 24 | await runPub(args: ['global', 'activate', 'foo']); 25 | 26 | await d.dir(cachePath, [ 27 | d.dir('bin', [ 28 | d.file( 29 | binStubName('foo-script'), 30 | contains('script.dart-$versionSuffix.snapshot'), 31 | ), 32 | ]), 33 | ]).validate(); 34 | }); 35 | } 36 | -------------------------------------------------------------------------------- /test/global/binstubs/does_not_warn_if_no_executables_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('does not warn if the package has no executables', () async { 12 | final server = await servePackages(); 13 | server.serve( 14 | 'foo', 15 | '1.0.0', 16 | contents: [ 17 | d.dir('bin', [ 18 | d.file('script.dart', "main(args) => print('ok \$args');"), 19 | ]), 20 | ], 21 | ); 22 | 23 | await runPub( 24 | args: ['global', 'activate', 'foo'], 25 | output: isNot(contains('is not on your path')), 26 | ); 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /test/global/binstubs/explicit_and_no_executables_options_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../descriptor.dart' as d; 9 | import '../../test_pub.dart'; 10 | 11 | void main() { 12 | test('errors if -x and --no-executables are both passed', () async { 13 | await d.dir('foo', [d.libPubspec('foo', '1.0.0')]).create(); 14 | 15 | await runPub( 16 | args: [ 17 | 'global', 18 | 'activate', 19 | '--source', 20 | 'path', 21 | '../foo', 22 | '-x', 23 | 'anything', 24 | '--no-executables', 25 | ], 26 | error: contains('Cannot pass both --no-executables and --executable.'), 27 | exitCode: exit_codes.USAGE, 28 | ); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /test/global/binstubs/missing_script_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../descriptor.dart' as d; 9 | import '../../test_pub.dart'; 10 | 11 | void main() { 12 | test("errors if an executable's script can't be found", () async { 13 | await d.dir('foo', [ 14 | d.pubspec({ 15 | 'name': 'foo', 16 | 'executables': {'missing': 'not_here', 'nope': null}, 17 | }), 18 | ]).create(); 19 | 20 | final pub = await startPub( 21 | args: ['global', 'activate', '-spath', '../foo'], 22 | ); 23 | 24 | expect( 25 | pub.stderr, 26 | emits( 27 | 'Warning: Executable "missing" runs ' 28 | '"${p.join('bin', 'not_here.dart')}", which was not found in foo.', 29 | ), 30 | ); 31 | expect( 32 | pub.stderr, 33 | emits( 34 | 'Warning: Executable "nope" runs ' 35 | '"${p.join('bin', 'nope.dart')}", which was not found in foo.', 36 | ), 37 | ); 38 | await pub.shouldExit(); 39 | }); 40 | } 41 | -------------------------------------------------------------------------------- /test/global/binstubs/no_executables_flag_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('does not create binstubs if --no-executables is passed', () async { 12 | await d.dir('foo', [ 13 | d.pubspec({ 14 | 'name': 'foo', 15 | 'executables': {'one': null}, 16 | }), 17 | d.dir('bin', [d.file('one.dart', "main() => print('ok');")]), 18 | ]).create(); 19 | 20 | await runPub(args: ['global', 'activate', '--source', 'path', '../foo']); 21 | 22 | await runPub( 23 | args: [ 24 | 'global', 25 | 'activate', 26 | '--source', 27 | 'path', 28 | '../foo', 29 | '--no-executables', 30 | ], 31 | ); 32 | 33 | // Should still delete old one. 34 | await d.dir(cachePath, [ 35 | d.dir('bin', [d.nothing(binStubName('one'))]), 36 | ]).validate(); 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /test/global/binstubs/path_package_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('creates binstubs when activating a path package', () async { 12 | await d.dir('foo', [ 13 | d.pubspec({ 14 | 'name': 'foo', 15 | 'executables': {'foo': null}, 16 | }), 17 | d.dir('bin', [d.file('foo.dart', "main() => print('ok');")]), 18 | ]).create(); 19 | 20 | await runPub( 21 | args: ['global', 'activate', '--source', 'path', '../foo'], 22 | output: contains('Installed executable foo.'), 23 | ); 24 | 25 | await d.dir(cachePath, [ 26 | d.dir('bin', [ 27 | d.file(binStubName('foo'), contains('global run foo:foo')), 28 | ]), 29 | ]).validate(); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/global/binstubs/removes_even_if_not_in_pubspec_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('removes all binstubs for package', () async { 12 | await d.dir('foo', [ 13 | d.pubspec({ 14 | 'name': 'foo', 15 | 'executables': {'foo': null}, 16 | }), 17 | d.dir('bin', [d.file('foo.dart', "main() => print('ok');")]), 18 | ]).create(); 19 | 20 | // Create the binstub for foo. 21 | await runPub(args: ['global', 'activate', '--source', 'path', '../foo']); 22 | 23 | // Remove it from the pubspec. 24 | await d.dir('foo', [ 25 | d.pubspec({'name': 'foo'}), 26 | ]).create(); 27 | 28 | // Deactivate. 29 | await runPub(args: ['global', 'deactivate', 'foo']); 30 | 31 | // It should still be deleted. 32 | await d.dir(cachePath, [ 33 | d.dir('bin', [d.nothing(binStubName('foo'))]), 34 | ]).validate(); 35 | }); 36 | } 37 | -------------------------------------------------------------------------------- /test/global/binstubs/removes_when_deactivated_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('removes binstubs when the package is deactivated', () async { 12 | final server = await servePackages(); 13 | server.serve( 14 | 'foo', 15 | '1.0.0', 16 | pubspec: { 17 | 'executables': {'one': null, 'two': null}, 18 | }, 19 | contents: [ 20 | d.dir('bin', [ 21 | d.file('one.dart', "main(args) => print('one');"), 22 | d.file('two.dart', "main(args) => print('two');"), 23 | ]), 24 | ], 25 | ); 26 | 27 | await runPub(args: ['global', 'activate', 'foo']); 28 | await runPub(args: ['global', 'deactivate', 'foo']); 29 | 30 | await d.dir(cachePath, [ 31 | d.dir('bin', [ 32 | d.nothing(binStubName('one')), 33 | d.nothing(binStubName('two')), 34 | ]), 35 | ]).validate(); 36 | }); 37 | } 38 | -------------------------------------------------------------------------------- /test/global/binstubs/unknown_explicit_executable_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../descriptor.dart' as d; 9 | import '../../test_pub.dart'; 10 | 11 | void main() { 12 | test('errors on an unknown explicit executable', () async { 13 | await d.dir('foo', [ 14 | d.pubspec({ 15 | 'name': 'foo', 16 | 'executables': {'one': 'one'}, 17 | }), 18 | d.dir('bin', [d.file('one.dart', "main() => print('ok');")]), 19 | ]).create(); 20 | 21 | final pub = await startPub( 22 | args: [ 23 | 'global', 'activate', '--source', 'path', '../foo', // 24 | '-x', 'who', '-x', 'one', '--executable', 'wat', 25 | ], 26 | ); 27 | 28 | expect(pub.stdout, emitsThrough('Installed executable one.')); 29 | expect(pub.stderr, emits('Unknown executables wat and who.')); 30 | await pub.shouldExit(exit_codes.DATA); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /test/global/binstubs/utils.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:io'; 6 | 7 | import 'package:path/path.dart' as p; 8 | 9 | import '../../test_pub.dart'; 10 | 11 | /// The buildbots do not have the Dart SDK (containing "dart" and "pub") on 12 | /// their PATH, so we need to spawn the binstub process with a PATH that 13 | /// explicitly includes it. 14 | /// 15 | /// The `pub`/`pub.bat` command on the PATH will be the one in tool/test-bin not 16 | /// the one from the sdk. 17 | Map getEnvironment() { 18 | final binDir = p.dirname(Platform.resolvedExecutable); 19 | final separator = Platform.isWindows ? ';' : ':'; 20 | final pubBin = p.absolute('tool', 'test-bin'); 21 | final path = 22 | "$pubBin$separator${Platform.environment["PATH"]}$separator$binDir"; 23 | 24 | final environment = getPubTestEnvironment(); 25 | environment['PATH'] = path; 26 | return environment; 27 | } 28 | -------------------------------------------------------------------------------- /test/global/binstubs/warns_if_not_on_path_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('warns if the binstub directory is not on the path', () async { 12 | final server = await servePackages(); 13 | server.serve( 14 | 'foo', 15 | '1.0.0', 16 | pubspec: { 17 | 'executables': {'some-dart-script': 'script'}, 18 | }, 19 | contents: [ 20 | d.dir('bin', [ 21 | d.file('script.dart', "main(args) => print('ok \$args');"), 22 | ]), 23 | ], 24 | ); 25 | 26 | await runPub( 27 | args: ['global', 'activate', 'foo'], 28 | error: contains('is not on your path'), 29 | ); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/global/deactivate/deactivate_and_reactivate_package_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../test_pub.dart'; 8 | 9 | void main() { 10 | test('activates a different version after deactivating', () async { 11 | await servePackages() 12 | ..serve('foo', '1.0.0') 13 | ..serve('foo', '2.0.0'); 14 | 15 | // Activate an old version. 16 | await runPub(args: ['global', 'activate', 'foo', '1.0.0']); 17 | 18 | await runPub( 19 | args: ['global', 'deactivate', 'foo'], 20 | output: 'Deactivated package foo 1.0.0.', 21 | ); 22 | 23 | // Activating again should forget the old version. 24 | await runPub( 25 | args: ['global', 'activate', 'foo'], 26 | silent: contains('Downloading foo 2.0.0...'), 27 | output: ''' 28 | Resolving dependencies... 29 | Downloading packages... 30 | + foo 2.0.0 31 | Activated foo 2.0.0.''', 32 | ); 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test/global/deactivate/git_package_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart'; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../descriptor.dart' as d; 9 | import '../../test_pub.dart'; 10 | 11 | void main() { 12 | test('deactivates an active Git package', () async { 13 | ensureGit(); 14 | 15 | await d.git('foo.git', [ 16 | d.libPubspec('foo', '1.0.0'), 17 | d.dir('bin', [d.file('foo.dart', "main() => print('ok');")]), 18 | ]).create(); 19 | 20 | await runPub(args: ['global', 'activate', '-sgit', '../foo.git']); 21 | 22 | await runPub( 23 | args: ['global', 'deactivate', 'foo'], 24 | output: 25 | 'Deactivated package foo 1.0.0 from Git repository ' 26 | '"..${separator}foo.git".', 27 | ); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /test/global/deactivate/hosted_package_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../test_pub.dart'; 8 | 9 | void main() { 10 | test('deactivates an active hosted package', () async { 11 | final server = await servePackages(); 12 | server.serve('foo', '1.0.0'); 13 | 14 | await runPub(args: ['global', 'activate', 'foo']); 15 | 16 | await runPub( 17 | args: ['global', 'deactivate', 'foo'], 18 | output: 'Deactivated package foo 1.0.0.', 19 | ); 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/global/deactivate/missing_package_arg_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('fails if no package was given', () { 12 | return runPub( 13 | args: ['global', 'deactivate'], 14 | error: contains('No package to deactivate given.'), 15 | exitCode: exit_codes.USAGE, 16 | ); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /test/global/deactivate/path_package_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:pub/src/io.dart'; 7 | import 'package:test/test.dart'; 8 | 9 | import '../../descriptor.dart' as d; 10 | import '../../test_pub.dart'; 11 | 12 | void main() { 13 | test('deactivates an active path package', () async { 14 | await d.dir('foo', [ 15 | d.libPubspec('foo', '1.0.0'), 16 | d.dir('bin', [d.file('foo.dart', "main() => print('ok');")]), 17 | ]).create(); 18 | 19 | await runPub(args: ['global', 'activate', '--source', 'path', '../foo']); 20 | 21 | final path = canonicalize(p.join(d.sandbox, 'foo')); 22 | await runPub( 23 | args: ['global', 'deactivate', 'foo'], 24 | output: 'Deactivated package foo 1.0.0 at path "$path".', 25 | ); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /test/global/deactivate/removes_precompiled_snapshots_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('removes built snapshots', () async { 12 | final server = await servePackages(); 13 | server.serve('foo', '1.0.0'); 14 | 15 | await runPub(args: ['global', 'activate', 'foo']); 16 | 17 | await runPub( 18 | args: ['global', 'deactivate', 'foo'], 19 | output: 'Deactivated package foo 1.0.0.', 20 | ); 21 | 22 | await d.dir(cachePath, [ 23 | d.dir('global_packages', [d.nothing('foo')]), 24 | ]).validate(); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /test/global/deactivate/unexpected_arguments_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('fails if there are extra arguments', () { 12 | return runPub( 13 | args: ['global', 'deactivate', 'foo', 'bar', 'baz'], 14 | error: contains('Unexpected arguments "bar" and "baz".'), 15 | exitCode: exit_codes.USAGE, 16 | ); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /test/global/deactivate/unknown_package_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('errors if the package is not activated', () async { 12 | await servePackages(); 13 | 14 | await runPub( 15 | args: ['global', 'deactivate', 'foo'], 16 | error: 'No active package foo.', 17 | exitCode: exit_codes.DATA, 18 | ); 19 | }); 20 | 21 | test('errors if the package exists with another casing', () async { 22 | final server = await servePackages(); 23 | server.serve('foo', '1.0.0'); 24 | await runPub(args: ['global', 'activate', 'foo']); 25 | await runPub( 26 | args: ['global', 'deactivate', 'Foo'], 27 | error: 'No active package Foo.', 28 | exitCode: exit_codes.DATA, 29 | ); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/global/run/errors_if_outside_bin_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../descriptor.dart' as d; 9 | import '../../test_pub.dart'; 10 | 11 | void main() { 12 | test('errors if the script is in a subdirectory.', () async { 13 | final server = await servePackages(); 14 | server.serve( 15 | 'foo', 16 | '1.0.0', 17 | contents: [ 18 | d.dir('example', [d.file('script.dart', "main(args) => print('ok');")]), 19 | ], 20 | ); 21 | 22 | await runPub(args: ['global', 'activate', 'foo']); 23 | await runPub( 24 | args: ['global', 'run', 'foo:example/script'], 25 | error: contains( 26 | 'Cannot run an executable in a subdirectory of a global package.', 27 | ), 28 | exitCode: exit_codes.USAGE, 29 | ); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/global/run/implicit_executable_name_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('defaults to the package name if the script is omitted', () async { 12 | final server = await servePackages(); 13 | server.serve( 14 | 'foo', 15 | '1.0.0', 16 | contents: [ 17 | d.dir('bin', [d.file('foo.dart', "main(args) => print('foo');")]), 18 | ], 19 | ); 20 | 21 | await runPub(args: ['global', 'activate', 'foo']); 22 | 23 | final pub = await pubRun(global: true, args: ['foo']); 24 | expect(pub.stdout, emits('foo')); 25 | await pub.shouldExit(); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /test/global/run/missing_executable_arg_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('fails if no executable was given', () { 12 | return runPub( 13 | args: ['global', 'run'], 14 | error: contains('Must specify an executable to run.'), 15 | exitCode: exit_codes.USAGE, 16 | ); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /test/global/run/missing_path_package_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:pub/src/io.dart'; 7 | import 'package:test/test.dart'; 8 | 9 | import '../../descriptor.dart' as d; 10 | import '../../test_pub.dart'; 11 | 12 | void main() { 13 | test('errors if the local package does not exist', () async { 14 | await d.dir('foo', [ 15 | d.libPubspec('foo', '1.0.0'), 16 | d.dir('bin', [d.file('foo.dart', "main() => print('ok');")]), 17 | ]).create(); 18 | 19 | await runPub(args: ['global', 'activate', '--source', 'path', '../foo']); 20 | 21 | deleteEntry(p.join(d.sandbox, 'foo')); 22 | 23 | final pub = await pubRun(global: true, args: ['foo']); 24 | expect( 25 | pub.stderr, 26 | emits('The directory `${d.path('foo')}` does not exist.'), 27 | ); 28 | await pub.shouldExit(1); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /test/global/run/nonexistent_script_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:pub/src/exit_codes.dart' as exit_codes; 7 | import 'package:test/test.dart'; 8 | 9 | import '../../test_pub.dart'; 10 | 11 | void main() { 12 | test('errors if the script does not exist.', () async { 13 | final server = await servePackages(); 14 | server.serve( 15 | 'foo', 16 | '1.0.0', 17 | pubspec: { 18 | 'dev_dependencies': {'bar': '1.0.0'}, 19 | }, 20 | ); 21 | 22 | await runPub(args: ['global', 'activate', 'foo']); 23 | 24 | final pub = await pubRun(global: true, args: ['foo:script']); 25 | expect( 26 | pub.stderr, 27 | emits("Could not find ${p.join("bin", "script.dart")} in package foo."), 28 | ); 29 | await pub.shouldExit(exit_codes.NO_INPUT); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/global/run/reflects_changes_to_local_package_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('changes in a path package are immediately reflected', () async { 12 | await d.dir('foo', [ 13 | d.libPubspec('foo', '1.0.0'), 14 | d.dir('bin', [d.file('foo.dart', "main() => print('ok');")]), 15 | ]).create(); 16 | 17 | await runPub(args: ['global', 'activate', '--source', 'path', '../foo']); 18 | 19 | await d.file('foo/bin/foo.dart', "main() => print('changed');").create(); 20 | 21 | final pub = await pubRun(global: true, args: ['foo']); 22 | expect(pub.stdout, emitsThrough('changed')); 23 | await pub.shouldExit(); 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /test/global/run/runs_git_script_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('runs a script in a git package', () async { 12 | ensureGit(); 13 | 14 | await d.git('foo.git', [ 15 | d.libPubspec('foo', '1.0.0'), 16 | d.dir('bin', [d.file('foo.dart', "main() => print('ok');")]), 17 | ]).create(); 18 | 19 | await runPub(args: ['global', 'activate', '-sgit', '../foo.git']); 20 | 21 | final pub = await pubRun(global: true, args: ['foo']); 22 | expect(pub.stdout, emits('ok')); 23 | await pub.shouldExit(); 24 | }); 25 | } 26 | -------------------------------------------------------------------------------- /test/global/run/runs_script_in_checked_mode_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('runs a script with assertions enabled', () async { 12 | final server = await servePackages(); 13 | server.serve( 14 | 'foo', 15 | '1.0.0', 16 | contents: [ 17 | d.dir('bin', [d.file('script.dart', 'main() { assert(false); }')]), 18 | ], 19 | ); 20 | 21 | await runPub(args: ['global', 'activate', 'foo']); 22 | 23 | final pub = await pubRun( 24 | global: true, 25 | args: ['--enable-asserts', 'foo:script'], 26 | ); 27 | expect(pub.stderr, emitsThrough(contains('Failed assertion'))); 28 | await pub.shouldExit(255); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /test/global/run/runs_script_in_unchecked_mode_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | const _script = ''' 11 | main() { 12 | assert(false); 13 | print("no checks"); 14 | } 15 | '''; 16 | 17 | void main() { 18 | test('runs a script in unchecked mode by default', () async { 19 | final server = await servePackages(); 20 | server.serve( 21 | 'foo', 22 | '1.0.0', 23 | contents: [ 24 | d.dir('bin', [d.file('script.dart', _script)]), 25 | ], 26 | ); 27 | 28 | await runPub(args: ['global', 'activate', 'foo']); 29 | 30 | final pub = await pubRun(global: true, args: ['foo:script']); 31 | expect(pub.stdout, emits('no checks')); 32 | await pub.shouldExit(); 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test/global/run/runs_script_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('runs a script in an activated package', () async { 12 | final server = await servePackages(); 13 | server.serve( 14 | 'foo', 15 | '1.0.0', 16 | contents: [ 17 | d.dir('bin', [d.file('script.dart', "main(args) => print('ok');")]), 18 | ], 19 | ); 20 | 21 | await runPub(args: ['global', 'activate', 'foo']); 22 | 23 | final pub = await pubRun(global: true, args: ['foo:script']); 24 | expect(pub.stdout, emits('ok')); 25 | await pub.shouldExit(); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /test/global/run/unknown_package_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('errors if the package is not activated', () async { 12 | await servePackages(); 13 | 14 | await runPub( 15 | args: ['global', 'run', 'foo:bar'], 16 | error: startsWith('No active package foo.'), 17 | exitCode: exit_codes.DATA, 18 | ); 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /test/hosted/fail_gracefully_on_url_resolve_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | forBothPubGetAndUpgrade((command) { 13 | test('fails gracefully if the url does not resolve', () async { 14 | await d.dir(appPath, [ 15 | d.appPubspec( 16 | dependencies: { 17 | 'foo': { 18 | 'hosted': {'name': 'foo', 'url': 'https://invalid-url.foo'}, 19 | }, 20 | }, 21 | ), 22 | ]).create(); 23 | 24 | await pubCommand( 25 | command, 26 | error: 27 | 'Got socket error trying to find package foo at ' 28 | 'https://invalid-url.foo.', 29 | exitCode: exit_codes.UNAVAILABLE, 30 | environment: {'PUB_MAX_HTTP_RETRIES': '2'}, 31 | ); 32 | }); 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test/hosted/remove_removed_dependency_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() { 11 | forBothPubGetAndUpgrade((command) { 12 | test("removes a dependency that's removed from the pubspec", () async { 13 | await servePackages() 14 | ..serve('foo', '1.0.0') 15 | ..serve('bar', '1.0.0'); 16 | 17 | await d.appDir(dependencies: {'foo': 'any', 'bar': 'any'}).create(); 18 | 19 | await pubCommand(command); 20 | await d.appPackageConfigFile([ 21 | d.packageConfigEntry(name: 'foo', version: '1.0.0'), 22 | d.packageConfigEntry(name: 'bar', version: '1.0.0'), 23 | ]).validate(); 24 | 25 | await d.appDir(dependencies: {'foo': 'any'}).create(); 26 | 27 | await pubCommand(command); 28 | 29 | await d.appPackageConfigFile([ 30 | d.packageConfigEntry(name: 'foo', version: '1.0.0'), 31 | ]).validate(); 32 | }); 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test/lish/cloud_storage_upload_doesnt_redirect_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:shelf/shelf.dart' as shelf; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | import 'utils.dart'; 11 | 12 | void main() { 13 | test("cloud storage upload doesn't redirect", () async { 14 | await servePackages(); 15 | await d.validPackage().create(); 16 | await d.credentialsFile(globalServer, 'access-token').create(); 17 | final pub = await startPublish(globalServer); 18 | 19 | await confirmPublish(pub); 20 | handleUploadForm(globalServer); 21 | 22 | globalServer.expect('POST', '/upload', (request) async { 23 | await request.read().drain(); 24 | return shelf.Response(200); 25 | }); 26 | 27 | expect(pub.stderr, emits('Failed to upload the package.')); 28 | await pub.shouldExit(1); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /test/lish/does_not_publish_if_private_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('does not publish if the package is private', () async { 13 | await d.validPackage(pubspecExtras: {'publish_to': 'none'}).create(); 14 | 15 | await runPub( 16 | args: ['lish'], 17 | error: contains('A private package cannot be published.'), 18 | exitCode: exit_codes.DATA, 19 | ); 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/lish/does_not_publish_if_private_with_server_arg_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('does not publish if the package is private even if a server ' 13 | 'argument is provided', () async { 14 | await d.validPackage(pubspecExtras: {'publish_to': 'none'}).create(); 15 | 16 | await runPub( 17 | args: ['lish'], 18 | error: contains('A private package cannot be published.'), 19 | environment: {'PUB_HOSTED_URL': 'http://example.com'}, 20 | exitCode: exit_codes.DATA, 21 | ); 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /test/lish/dot_folder_name_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('Can publish files in a .folder', () async { 13 | await d.git(appPath).create(); 14 | await d.validPackage().create(); 15 | await d.dir(appPath, [ 16 | d.dir('.vscode', [d.file('a')]), 17 | d.file('.pubignore', '!.vscode/'), 18 | ]).create(); 19 | await runPub( 20 | args: ['lish', '--dry-run'], 21 | output: contains(''' 22 | ├── .vscode 23 | │ └── a'''), 24 | exitCode: exit_codes.SUCCESS, 25 | ); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /test/lish/dry_run_package_validation_has_a_warning_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | 7 | import 'package:test/test.dart'; 8 | 9 | import '../descriptor.dart' as d; 10 | import '../test_pub.dart'; 11 | 12 | void main() { 13 | test('dry-run package validation gives a warning', () async { 14 | (await servePackages()).serve('foo', '1.0.0'); 15 | await d.validPackage().create(); 16 | 17 | final pkg = packageMap('test_pkg', '1.0.0', null, null, { 18 | 'sdk': defaultSdkConstraint, 19 | }); 20 | pkg['dependencies'] = {'foo': 'any'}; 21 | await d.dir(appPath, [d.pubspec(pkg)]).create(); 22 | 23 | final pub = await startPublish(globalServer, args: ['--dry-run']); 24 | 25 | await pub.shouldExit(exit_codes.DATA); 26 | expect(pub.stdout, emitsThrough('Package has 1 warning.')); 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /test/lish/dry_run_package_validation_has_no_warnings_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | 7 | import 'package:test/test.dart'; 8 | 9 | import '../descriptor.dart' as d; 10 | import '../test_pub.dart'; 11 | 12 | void main() { 13 | test( 14 | '--dry-run package validation on valid package has no warnings', 15 | () async { 16 | await d.validPackage().create(); 17 | 18 | await servePackages(); 19 | final pub = await startPublish(globalServer, args: ['--dry-run']); 20 | 21 | await pub.shouldExit(exit_codes.SUCCESS); 22 | expect(pub.stdout, emitsThrough('Package has 0 warnings.')); 23 | }, 24 | ); 25 | } 26 | -------------------------------------------------------------------------------- /test/lish/dry_run_warns_about_server_checks.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() { 11 | test('--dry-run mentions that checks are not exhaustive', () async { 12 | await d.validPackage().create(); 13 | await runPub( 14 | args: ['publish', '--dry-run'], 15 | output: contains('The server may enforce additional checks.'), 16 | ); 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /test/lish/force_cannot_be_combined_with_dry_run_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('--force cannot be combined with --dry-run', () async { 13 | await d.validPackage().create(); 14 | 15 | await runPub( 16 | args: ['lish', '--force', '--dry-run'], 17 | error: contains('Cannot use both --force and --dry-run.'), 18 | exitCode: exit_codes.USAGE, 19 | ); 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/lish/force_does_not_publish_if_private_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('force does not publish if the package is private', () async { 13 | await d.validPackage(pubspecExtras: {'publish_to': 'none'}).create(); 14 | 15 | await runPub( 16 | args: ['lish', '--force'], 17 | error: contains('A private package cannot be published.'), 18 | exitCode: exit_codes.DATA, 19 | ); 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/lish/force_does_not_publish_if_there_are_errors_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:io'; 6 | 7 | import 'package:path/path.dart' as p; 8 | import 'package:pub/src/exit_codes.dart' as exit_codes; 9 | import 'package:test/test.dart'; 10 | 11 | import '../descriptor.dart' as d; 12 | import '../test_pub.dart'; 13 | 14 | void main() { 15 | test('--force does not publish if there are errors', () async { 16 | await servePackages(); 17 | await d.validPackage().create(); 18 | // It is an error to publish without a LICENSE file. 19 | File(d.path(p.join(appPath, 'LICENSE'))).deleteSync(); 20 | 21 | await servePackages(); 22 | final pub = await startPublish(globalServer, args: ['--force']); 23 | 24 | await pub.shouldExit(exit_codes.DATA); 25 | expect( 26 | pub.stderr, 27 | emitsThrough( 28 | 'Sorry, your package is missing a requirement ' 29 | "and can't be published yet.", 30 | ), 31 | ); 32 | }); 33 | } 34 | -------------------------------------------------------------------------------- /test/lish/package_creation_provides_a_malformed_error_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | 7 | import 'package:shelf/shelf.dart' as shelf; 8 | import 'package:test/test.dart'; 9 | 10 | import '../descriptor.dart' as d; 11 | import '../test_pub.dart'; 12 | import 'utils.dart'; 13 | 14 | void main() { 15 | test('package creation provides a malformed error', () async { 16 | await servePackages(); 17 | await d.validPackage().create(); 18 | await d.credentialsFile(globalServer, 'access-token').create(); 19 | final pub = await startPublish(globalServer); 20 | 21 | await confirmPublish(pub); 22 | handleUploadForm(globalServer); 23 | handleUpload(globalServer); 24 | 25 | final body = {'error': 'Your package was too boring.'}; 26 | globalServer.expect('GET', '/create', (request) { 27 | return shelf.Response.notFound(jsonEncode(body)); 28 | }); 29 | 30 | expect(pub.stderr, emits('Invalid server response:')); 31 | expect(pub.stderr, emits(jsonEncode(body))); 32 | await pub.shouldExit(1); 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test/lish/package_creation_provides_a_malformed_success_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | 7 | import 'package:shelf/shelf.dart' as shelf; 8 | import 'package:test/test.dart'; 9 | 10 | import '../descriptor.dart' as d; 11 | import '../test_pub.dart'; 12 | import 'utils.dart'; 13 | 14 | void main() { 15 | test('package creation provides a malformed success', () async { 16 | await servePackages(); 17 | await d.validPackage().create(); 18 | await d.credentialsFile(globalServer, 'access-token').create(); 19 | final pub = await startPublish(globalServer); 20 | 21 | await confirmPublish(pub); 22 | handleUploadForm(globalServer); 23 | handleUpload(globalServer); 24 | 25 | final body = {'success': 'Your package was awesome.'}; 26 | globalServer.expect('GET', '/create', (request) { 27 | return shelf.Response.ok(jsonEncode(body)); 28 | }); 29 | 30 | expect(pub.stderr, emits('Invalid server response:')); 31 | expect(pub.stderr, emits(jsonEncode(body))); 32 | await pub.shouldExit(1); 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test/lish/package_creation_provides_an_error_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | 7 | import 'package:shelf/shelf.dart' as shelf; 8 | import 'package:test/test.dart'; 9 | 10 | import '../descriptor.dart' as d; 11 | import '../test_pub.dart'; 12 | import 'utils.dart'; 13 | 14 | void main() { 15 | test('package creation provides an error', () async { 16 | await servePackages(); 17 | await d.validPackage().create(); 18 | await d.credentialsFile(globalServer, 'access-token').create(); 19 | final pub = await startPublish(globalServer); 20 | 21 | await confirmPublish(pub); 22 | handleUploadForm(globalServer); 23 | handleUpload(globalServer); 24 | 25 | globalServer.expect('GET', '/create', (request) { 26 | return shelf.Response.notFound( 27 | jsonEncode({ 28 | 'error': {'message': 'Your package was too boring.'}, 29 | }), 30 | ); 31 | }); 32 | 33 | expect( 34 | pub.stderr, 35 | emits('Message from server: Your package was too boring.'), 36 | ); 37 | await pub.shouldExit(1); 38 | }); 39 | } 40 | -------------------------------------------------------------------------------- /test/lish/package_creation_provides_invalid_json_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:shelf/shelf.dart' as shelf; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | import 'utils.dart'; 11 | 12 | void main() { 13 | test('package creation provides invalid JSON', () async { 14 | await servePackages(); 15 | await d.validPackage().create(); 16 | await d.credentialsFile(globalServer, 'access-token').create(); 17 | final pub = await startPublish(globalServer); 18 | 19 | await confirmPublish(pub); 20 | handleUploadForm(globalServer); 21 | handleUpload(globalServer); 22 | 23 | globalServer.expect('GET', '/create', (request) { 24 | return shelf.Response.ok('{not json'); 25 | }); 26 | 27 | expect( 28 | pub.stderr, 29 | emitsLines( 30 | 'Invalid server response:\n' 31 | '{not json', 32 | ), 33 | ); 34 | await pub.shouldExit(1); 35 | }); 36 | } 37 | -------------------------------------------------------------------------------- /test/lish/package_validation_has_a_warning_and_is_canceled_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('package validation has a warning and is canceled', () async { 13 | await d.validPackage().create(); 14 | final pkg = packageMap('test_pkg', '1.0.0', null, null, { 15 | 'sdk': defaultSdkConstraint, 16 | }); 17 | pkg['author'] = 'Natalie Weizenbaum'; 18 | await d.dir(appPath, [d.pubspec(pkg)]).create(); 19 | 20 | await servePackages(); 21 | final pub = await startPublish(globalServer); 22 | 23 | pub.stdin.writeln('n'); 24 | await pub.shouldExit(exit_codes.DATA); 25 | expect(pub.stderr, emitsThrough('Package upload canceled.')); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /test/lish/package_validation_has_an_error_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('package validation has an error', () async { 13 | await d.dir(appPath, [ 14 | d.rawPubspec({ 15 | 'name': 'test_pkg', 16 | 'homepage': 'https://pub.dev', 17 | 'version': '1.0.0', 18 | 'environment': {'sdk': defaultSdkConstraint}, 19 | }), 20 | ]).create(); 21 | 22 | await servePackages(); 23 | final pub = await startPublish(globalServer); 24 | 25 | await pub.shouldExit(exit_codes.DATA); 26 | expect( 27 | pub.stderr, 28 | emitsThrough( 29 | 'Sorry, your package is missing some ' 30 | "requirements and can't be published yet.", 31 | ), 32 | ); 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test/lish/requires_resolution_before_publishing_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('does not publish if no resolution can be found', () async { 13 | await servePackages(); // No packages. 14 | await d.validPackage().create(); 15 | await d.appDir(dependencies: {'foo': '1.0.0'}).create(); 16 | await runPub( 17 | args: ['lish'], 18 | error: contains("Because myapp depends on foo any which doesn't exist"), 19 | exitCode: exit_codes.UNAVAILABLE, 20 | ); 21 | }); 22 | } 23 | -------------------------------------------------------------------------------- /test/lish/server_arg_does_not_override_private_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | 7 | import 'package:test/test.dart'; 8 | 9 | import '../descriptor.dart' as d; 10 | import '../test_pub.dart'; 11 | 12 | void main() { 13 | test('an explicit --server argument does not override privacy', () async { 14 | await d.validPackage(pubspecExtras: {'publish_to': 'none'}).create(); 15 | 16 | await runPub( 17 | args: ['lish', '--server', 'http://arg.com'], 18 | error: contains('A private package cannot be published.'), 19 | exitCode: exit_codes.DATA, 20 | ); 21 | }); 22 | } 23 | -------------------------------------------------------------------------------- /test/lish/server_arg_overrides_publish_to_url_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | 7 | import 'package:test/test.dart'; 8 | 9 | import '../descriptor.dart' as d; 10 | import '../test_pub.dart'; 11 | 12 | void main() { 13 | test('an explicit --server argument overrides a "publish_to" url', () async { 14 | // Create a real server that can reject requests because validators will 15 | // try to ping it, and will use multiple retries when doing so. 16 | final packageServer = await startPackageServer(); 17 | 18 | final pkg = packageMap('test_pkg', '1.0.0'); 19 | pkg['publish_to'] = 'http://pubspec.com'; 20 | await d.dir(appPath, [d.pubspec(pkg)]).create(); 21 | await runPub( 22 | args: ['lish', '--dry-run', '--server', packageServer.url], 23 | output: contains(packageServer.url), 24 | exitCode: exit_codes.DATA, 25 | ); 26 | 27 | await packageServer.close(); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /test/lish/upload_form_fields_has_a_non_string_value_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | 7 | import 'package:test/test.dart'; 8 | 9 | import '../descriptor.dart' as d; 10 | import '../test_pub.dart'; 11 | import 'utils.dart'; 12 | 13 | void main() { 14 | test('upload form fields has a non-string value', () async { 15 | await servePackages(); 16 | await d.validPackage().create(); 17 | await d.credentialsFile(globalServer, 'access-token').create(); 18 | final pub = await startPublish(globalServer); 19 | 20 | await confirmPublish(pub); 21 | 22 | final body = { 23 | 'url': 'http://example.com/upload', 24 | 'fields': {'field': 12}, 25 | }; 26 | handleUploadForm(globalServer, body: body); 27 | expect(pub.stderr, emits('Invalid server response:')); 28 | expect(pub.stderr, emits(jsonEncode(body))); 29 | await pub.shouldExit(1); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/lish/upload_form_fields_is_not_a_map_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | 7 | import 'package:test/test.dart'; 8 | 9 | import '../descriptor.dart' as d; 10 | import '../test_pub.dart'; 11 | import 'utils.dart'; 12 | 13 | void main() { 14 | test('upload form fields is not a map', () async { 15 | await servePackages(); 16 | await d.validPackage().create(); 17 | await d.credentialsFile(globalServer, 'access-token').create(); 18 | final pub = await startPublish(globalServer); 19 | 20 | await confirmPublish(pub); 21 | 22 | final body = {'url': 'http://example.com/upload', 'fields': 12}; 23 | handleUploadForm(globalServer, body: body); 24 | expect(pub.stderr, emits('Invalid server response:')); 25 | expect(pub.stderr, emits(jsonEncode(body))); 26 | await pub.shouldExit(1); 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /test/lish/upload_form_is_missing_fields_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | 7 | import 'package:test/test.dart'; 8 | 9 | import '../descriptor.dart' as d; 10 | import '../test_pub.dart'; 11 | import 'utils.dart'; 12 | 13 | void main() { 14 | test('upload form is missing fields', () async { 15 | await servePackages(); 16 | await d.validPackage().create(); 17 | await d.credentialsFile(globalServer, 'access-token').create(); 18 | final pub = await startPublish(globalServer); 19 | 20 | await confirmPublish(pub); 21 | 22 | final body = {'url': 'http://example.com/upload'}; 23 | handleUploadForm(globalServer, body: body); 24 | expect(pub.stderr, emits('Invalid server response:')); 25 | expect(pub.stderr, emits(jsonEncode(body))); 26 | await pub.shouldExit(1); 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /test/lish/upload_form_is_missing_url_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | 7 | import 'package:test/test.dart'; 8 | 9 | import '../descriptor.dart' as d; 10 | import '../test_pub.dart'; 11 | import 'utils.dart'; 12 | 13 | void main() { 14 | test('upload form is missing url', () async { 15 | await servePackages(); 16 | await d.validPackage().create(); 17 | await d.credentialsFile(globalServer, 'access-token').create(); 18 | final pub = await startPublish(globalServer); 19 | 20 | await confirmPublish(pub); 21 | 22 | final body = { 23 | 'fields': {'field1': 'value1', 'field2': 'value2'}, 24 | }; 25 | 26 | handleUploadForm(globalServer, body: body); 27 | expect(pub.stderr, emits('Invalid server response:')); 28 | expect(pub.stderr, emits(jsonEncode(body))); 29 | await pub.shouldExit(1); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/lish/upload_form_provides_an_error_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | 7 | import 'package:shelf/shelf.dart' as shelf; 8 | import 'package:test/test.dart'; 9 | 10 | import '../descriptor.dart' as d; 11 | import '../test_pub.dart'; 12 | 13 | void main() { 14 | test('upload form provides an error, that is sanitized', () async { 15 | await servePackages(); 16 | await d.validPackage().create(); 17 | await d.credentialsFile(globalServer, 'access-token').create(); 18 | final pub = await startPublish(globalServer); 19 | 20 | await confirmPublish(pub); 21 | 22 | globalServer.expect('GET', '/api/packages/versions/new', (request) async { 23 | return shelf.Response.notFound( 24 | jsonEncode({ 25 | 'error': { 26 | 'message': 'your request\u0000sucked', 27 | }, // The \u0000 should be sanitized to a space. 28 | }), 29 | ); 30 | }); 31 | 32 | expect(pub.stderr, emits('Message from server: your request sucked')); 33 | await pub.shouldExit(1); 34 | }); 35 | } 36 | -------------------------------------------------------------------------------- /test/lish/upload_form_provides_invalid_json_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:shelf/shelf.dart' as shelf; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('upload form provides invalid JSON', () async { 13 | await servePackages(); 14 | await d.validPackage().create(); 15 | await servePackages(); 16 | await d.credentialsFile(globalServer, 'access-token').create(); 17 | final pub = await startPublish(globalServer); 18 | 19 | await confirmPublish(pub); 20 | 21 | globalServer.expect( 22 | 'GET', 23 | '/api/packages/versions/new', 24 | (request) => shelf.Response.ok('{not json'), 25 | ); 26 | 27 | expect( 28 | pub.stderr, 29 | emitsLines( 30 | 'Invalid server response:\n' 31 | '{not json', 32 | ), 33 | ); 34 | await pub.shouldExit(1); 35 | }); 36 | } 37 | -------------------------------------------------------------------------------- /test/lish/upload_form_url_is_not_a_string_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'dart:convert'; 6 | 7 | import 'package:test/test.dart'; 8 | 9 | import '../descriptor.dart' as d; 10 | import '../test_pub.dart'; 11 | import 'utils.dart'; 12 | 13 | void main() { 14 | test('upload form url is not a string', () async { 15 | await servePackages(); 16 | await d.validPackage().create(); 17 | await d.credentialsFile(globalServer, 'access-token').create(); 18 | final pub = await startPublish(globalServer); 19 | 20 | await confirmPublish(pub); 21 | 22 | final body = { 23 | 'url': 12, 24 | 'fields': {'field1': 'value1', 'field2': 'value2'}, 25 | }; 26 | 27 | handleUploadForm(globalServer, body: body); 28 | expect(pub.stderr, emits('Invalid server response:')); 29 | expect(pub.stderr, emits(jsonEncode(body))); 30 | await pub.shouldExit(1); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /test/lish/uses_publish_to_url_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | 7 | import 'package:test/test.dart'; 8 | 9 | import '../descriptor.dart' as d; 10 | import '../test_pub.dart'; 11 | 12 | void main() { 13 | test('uses the publish_to URL', () async { 14 | final server = await servePackages(); 15 | final pkg = packageMap('test_pkg', '1.0.0'); 16 | pkg['publish_to'] = server.url; 17 | await d.dir(appPath, [d.pubspec(pkg)]).create(); 18 | await runPub( 19 | args: ['lish', '--dry-run'], 20 | output: contains('Publishing test_pkg 1.0.0 to ${server.url}'), 21 | exitCode: exit_codes.DATA, 22 | ); 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /test/log_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/log.dart'; 6 | import 'package:test/test.dart'; 7 | 8 | void main() { 9 | test('limitLength', () { 10 | expect(limitLength('', 7), ''); 11 | expect(limitLength('x', 7), 'x'); 12 | expect(limitLength('x' * 7, 7), 'x' * 7); 13 | expect(limitLength('x' * 8, 7), 'x[...]x'); 14 | expect(limitLength('x' * 1000, 7), 'x[...]x'); 15 | expect(limitLength('', 8), ''); 16 | expect(limitLength('x', 8), 'x'); 17 | expect(limitLength('x' * 8, 8), 'x' * 8); 18 | expect(limitLength('x' * 9, 8), 'xx[...]x'); 19 | expect(limitLength('x' * 1000, 8), 'xx[...]x'); 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/no_packages_dir_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import 'descriptor.dart' as d; 8 | import 'test_pub.dart'; 9 | 10 | void main() { 11 | forBothPubGetAndUpgrade((command) { 12 | test('does not touch directories named "packages"', () async { 13 | await d.dir(appPath, [ 14 | d.appPubspec(), 15 | d.dir('packages'), 16 | d.dir('bin/packages'), 17 | d.dir('bin/subdir/packages'), 18 | d.dir('lib/packages'), 19 | ]).create(); 20 | 21 | await pubCommand(command); 22 | 23 | await d.dir(appPath, [ 24 | d.dir('packages'), 25 | d.dir('bin/packages'), 26 | d.dir('bin/subdir/packages'), 27 | d.dir('lib/packages'), 28 | ]).validate(); 29 | }); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/oauth2/logout_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() { 11 | test('with an existing credentials file, deletes it.', () async { 12 | await servePackages(); 13 | await d 14 | .credentialsFile( 15 | globalServer, 16 | 'access-token', 17 | refreshToken: 'refresh token', 18 | expiration: DateTime.now().add(const Duration(hours: 1)), 19 | ) 20 | .create(); 21 | 22 | await runPub(args: ['logout'], output: contains('Logging out of pub.dev.')); 23 | 24 | await configDir([d.nothing('pub-credentials.json')]).validate(); 25 | }); 26 | 27 | test('with no existing credentials.json, notifies.', () async { 28 | await d.dir(configPath, [d.nothing('pub-credentials.json')]).create(); 29 | await runPub( 30 | args: ['logout'], 31 | output: contains('No existing credentials file'), 32 | ); 33 | 34 | await d.dir(configPath, [d.nothing('pub-credentials.json')]).validate(); 35 | }); 36 | } 37 | -------------------------------------------------------------------------------- /test/oauth2/with_a_pre_existing_credentials_does_not_authenticate_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() { 11 | test('with a pre-existing credentials.json does not authenticate', () async { 12 | await d.validPackage().create(); 13 | 14 | await servePackages(); 15 | await d.credentialsFile(globalServer, 'access-token').create(); 16 | final pub = await startPublish(globalServer); 17 | 18 | await confirmPublish(pub); 19 | 20 | await pub.kill(); 21 | }); 22 | } 23 | -------------------------------------------------------------------------------- /test/pub_uploader_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import 'descriptor.dart' as d; 8 | import 'test_pub.dart'; 9 | 10 | void main() { 11 | test('displays deprecation notice', () async { 12 | await runPub( 13 | args: ['uploader', 'add'], 14 | error: ''' 15 | Package uploaders are no longer managed from the command line. 16 | Manage uploaders from: 17 | 18 | https://pub.dev/packages//admin 19 | ''', 20 | exitCode: 1, 21 | ); 22 | 23 | await d.appDir().create(); 24 | await runPub( 25 | args: ['uploader', 'add'], 26 | error: ''' 27 | Package uploaders are no longer managed from the command line. 28 | Manage uploaders from: 29 | 30 | https://pub.dev/packages/myapp/admin 31 | ''', 32 | exitCode: 1, 33 | ); 34 | }); 35 | } 36 | -------------------------------------------------------------------------------- /test/run/allows_dart_extension_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | const _script = """ 11 | import 'dart:io'; 12 | 13 | main() { 14 | stdout.writeln("stdout output"); 15 | stderr.writeln("stderr output"); 16 | exitCode = 123; 17 | } 18 | """; 19 | 20 | void main() { 21 | test('allows a ".dart" extension on the argument', () async { 22 | await d.dir(appPath, [ 23 | d.appPubspec(), 24 | d.dir('bin', [d.file('script.dart', _script)]), 25 | ]).create(); 26 | 27 | await pubGet(); 28 | final pub = await pubRun(args: ['script.dart']); 29 | expect(pub.stdout, emitsThrough('stdout output')); 30 | expect(pub.stderr, emitsThrough('stderr output')); 31 | await pub.shouldExit(123); 32 | }); 33 | } 34 | -------------------------------------------------------------------------------- /test/run/errors_if_no_executable_is_given_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('Errors if the executable does not exist.', () async { 13 | await d.dir(appPath, [d.appPubspec()]).create(); 14 | 15 | await runPub( 16 | args: ['run'], 17 | error: contains('Must specify an executable to run.'), 18 | exitCode: exit_codes.USAGE, 19 | ); 20 | }); 21 | } 22 | -------------------------------------------------------------------------------- /test/run/errors_if_path_in_dependency_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('Errors if the executable is in a subdirectory in a ' 13 | 'dependency.', () async { 14 | await d.dir('foo', [d.libPubspec('foo', '1.0.0')]).create(); 15 | 16 | await d.dir(appPath, [ 17 | d.appPubspec( 18 | dependencies: { 19 | 'foo': {'path': '../foo'}, 20 | }, 21 | ), 22 | ]).create(); 23 | 24 | await runPub( 25 | args: ['run', 'foo:sub/dir'], 26 | error: contains( 27 | 'Cannot run an executable in a subdirectory of a dependency.', 28 | ), 29 | exitCode: exit_codes.USAGE, 30 | ); 31 | }); 32 | } 33 | -------------------------------------------------------------------------------- /test/run/includes_parent_directories_of_entrypoint_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | const _script = r""" 12 | import '../../a.dart'; 13 | import '../b.dart'; 14 | main() { 15 | print("$a $b"); 16 | } 17 | """; 18 | 19 | void main() { 20 | test('allows assets in parent directories of the entrypoint to be ' 21 | 'accessed', () async { 22 | await d.dir(appPath, [ 23 | d.appPubspec(), 24 | d.dir('tool', [ 25 | d.file('a.dart', "var a = 'a';"), 26 | d.dir('a', [ 27 | d.file('b.dart', "var b = 'b';"), 28 | d.dir('b', [d.file('app.dart', _script)]), 29 | ]), 30 | ]), 31 | ]).create(); 32 | 33 | await pubGet(); 34 | final pub = await pubRun(args: [p.join('tool', 'a', 'b', 'app')]); 35 | expect(pub.stdout, emitsThrough('a b')); 36 | await pub.shouldExit(); 37 | }); 38 | } 39 | -------------------------------------------------------------------------------- /test/run/loads_package_imports_in_a_dependency_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() { 11 | test('loads package imports in a dependency', () async { 12 | await d.dir('foo', [ 13 | d.libPubspec('foo', '1.0.0'), 14 | d.dir('lib', [d.file('foo.dart', "final value = 'foobar';")]), 15 | d.dir('bin', [ 16 | d.file('bar.dart', ''' 17 | import "package:foo/foo.dart"; 18 | 19 | main() => print(value); 20 | '''), 21 | ]), 22 | ]).create(); 23 | 24 | await d.dir(appPath, [ 25 | d.appPubspec( 26 | dependencies: { 27 | 'foo': {'path': '../foo'}, 28 | }, 29 | ), 30 | ]).create(); 31 | 32 | await pubGet(); 33 | final pub = await pubRun(args: ['foo:bar']); 34 | expect(pub.stdout, emitsThrough('foobar')); 35 | await pub.shouldExit(); 36 | }); 37 | } 38 | -------------------------------------------------------------------------------- /test/run/nonexistent_dependency_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/exit_codes.dart' as exit_codes; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('Errors if the script is in an unknown package.', () async { 13 | await d.dir(appPath, [d.appPubspec()]).create(); 14 | 15 | await pubGet(); 16 | final pub = await pubRun(args: ['foo:script']); 17 | expect( 18 | pub.stderr, 19 | emits( 20 | 'Could not find package "foo". Did you forget to add a ' 21 | 'dependency?', 22 | ), 23 | ); 24 | await pub.shouldExit(exit_codes.DATA); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /test/run/nonexistent_script_in_dependency_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:pub/src/exit_codes.dart' as exit_codes; 7 | import 'package:test/test.dart'; 8 | 9 | import '../descriptor.dart' as d; 10 | import '../test_pub.dart'; 11 | 12 | void main() { 13 | test('Errors if the script in a dependency does not exist.', () async { 14 | await d.dir('foo', [d.libPubspec('foo', '1.0.0')]).create(); 15 | 16 | await d.dir(appPath, [ 17 | d.appPubspec( 18 | dependencies: { 19 | 'foo': {'path': '../foo'}, 20 | }, 21 | ), 22 | ]).create(); 23 | 24 | await pubGet(); 25 | 26 | final pub = await pubRun(args: ['foo:script']); 27 | expect( 28 | pub.stderr, 29 | emits("Could not find ${p.join("bin", "script.dart")} in package foo."), 30 | ); 31 | await pub.shouldExit(exit_codes.NO_INPUT); 32 | }); 33 | } 34 | -------------------------------------------------------------------------------- /test/run/nonexistent_script_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:pub/src/exit_codes.dart' as exit_codes; 7 | import 'package:test/test.dart'; 8 | 9 | import '../descriptor.dart' as d; 10 | import '../test_pub.dart'; 11 | 12 | void main() { 13 | test('Errors if the script does not exist.', () async { 14 | await d.dir(appPath, [d.appPubspec()]).create(); 15 | 16 | await pubGet(); 17 | final pub = await pubRun(args: [p.join('bin', 'script')]); 18 | expect( 19 | pub.stderr, 20 | emits("Could not find ${p.join("bin", "script.dart")}."), 21 | ); 22 | await pub.shouldExit(exit_codes.NO_INPUT); 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /test/run/passes_along_arguments_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | const _script = ''' 11 | main(List args) { 12 | print(args.join(" ")); 13 | } 14 | '''; 15 | 16 | void main() { 17 | test('passes arguments to the spawned script', () async { 18 | await d.dir(appPath, [ 19 | d.appPubspec(), 20 | d.dir('bin', [d.file('args.dart', _script)]), 21 | ]).create(); 22 | 23 | await pubGet(); 24 | 25 | // Use some args that would trip up pub's arg parser to ensure that it 26 | // isn't trying to look at them. 27 | final pub = await pubRun( 28 | args: ['bin/args', '--verbose', '-m', '--', 'help'], 29 | ); 30 | 31 | expect(pub.stdout, emitsThrough('--verbose -m -- help')); 32 | await pub.shouldExit(); 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /test/run/runs_app_in_directory_in_entrypoint_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:path/path.dart' as p; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('runs a Dart application in the entrypoint package', () async { 13 | await d.dir(appPath, [ 14 | d.appPubspec(), 15 | d.dir('tool', [ 16 | d.file('app.dart', "main() => print('tool');"), 17 | d.dir('sub', [d.file('app.dart', "main() => print('sub');")]), 18 | ]), 19 | ]).create(); 20 | 21 | await pubGet(); 22 | var pub = await pubRun(args: [p.join('tool', 'app')]); 23 | expect(pub.stdout, emitsThrough('tool')); 24 | await pub.shouldExit(); 25 | 26 | pub = await pubRun(args: [p.join('tool', 'sub', 'app')]); 27 | expect(pub.stdout, emitsThrough('sub')); 28 | await pub.shouldExit(); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /test/run/runs_app_in_entrypoint_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | const _script = """ 11 | import 'dart:io'; 12 | 13 | main() { 14 | stdout.writeln("stdout output"); 15 | stderr.writeln("stderr output"); 16 | exitCode = 123; 17 | } 18 | """; 19 | 20 | void main() { 21 | test('runs a Dart application in the entrypoint package', () async { 22 | await d.dir(appPath, [ 23 | d.appPubspec(), 24 | d.dir('bin', [d.file('script.dart', _script)]), 25 | ]).create(); 26 | 27 | await pubGet(); 28 | final pub = await pubRun(args: ['bin/script']); 29 | expect(pub.stdout, emitsThrough('stdout output')); 30 | expect(pub.stderr, emits('stderr output')); 31 | await pub.shouldExit(123); 32 | }); 33 | } 34 | -------------------------------------------------------------------------------- /test/run/runs_named_app_in_dependency_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() { 11 | test('runs a named Dart application in a dependency', () async { 12 | await d.dir('foo', [ 13 | d.libPubspec('foo', '1.0.0'), 14 | d.dir('bin', [d.file('bar.dart', "main() => print('foobar');")]), 15 | ]).create(); 16 | 17 | await d.dir(appPath, [ 18 | d.appPubspec( 19 | dependencies: { 20 | 'foo': {'path': '../foo'}, 21 | }, 22 | ), 23 | ]).create(); 24 | 25 | await pubGet(); 26 | final pub = await pubRun(args: ['foo:bar']); 27 | expect(pub.stdout, emitsThrough('foobar')); 28 | await pub.shouldExit(); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /test/run/runs_named_app_in_dev_dependency_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() { 11 | test('runs a named Dart application in a dev dependency', () async { 12 | await d.dir('foo', [ 13 | d.libPubspec('foo', '1.0.0'), 14 | d.dir('bin', [d.file('bar.dart', "main() => print('foobar');")]), 15 | ]).create(); 16 | 17 | await d.dir(appPath, [ 18 | d.pubspec({ 19 | 'name': 'myapp', 20 | 'dev_dependencies': { 21 | 'foo': {'path': '../foo'}, 22 | }, 23 | }), 24 | ]).create(); 25 | 26 | await pubGet(); 27 | final pub = await pubRun(args: ['foo:bar']); 28 | expect(pub.stdout, emitsThrough('foobar')); 29 | await pub.shouldExit(); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/run/runs_shorthand_app_in_dependency_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() { 11 | test('runs a shorthand Dart application in a dependency', () async { 12 | await d.dir('foo', [ 13 | d.libPubspec('foo', '1.0.0'), 14 | d.dir('bin', [d.file('foo.dart', "main() => print('foo');")]), 15 | ]).create(); 16 | 17 | await d.dir(appPath, [ 18 | d.pubspec({ 19 | 'name': 'myapp', 20 | 'dependencies': { 21 | 'foo': {'path': '../foo'}, 22 | }, 23 | }), 24 | ]).create(); 25 | 26 | await pubGet(); 27 | final pub = await pubRun(args: ['foo']); 28 | expect(pub.stdout, emitsThrough('foo')); 29 | await pub.shouldExit(); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/run/runs_the_script_in_checked_mode_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | void main() { 11 | test('runs the script with assertions enabled', () async { 12 | await d.dir(appPath, [ 13 | d.appPubspec(), 14 | d.dir('bin', [d.file('script.dart', 'main() { assert(false); }')]), 15 | ]).create(); 16 | 17 | await pubGet(); 18 | await runPub( 19 | args: ['run', '--enable-asserts', 'bin/script'], 20 | error: contains('Failed assertion'), 21 | exitCode: 255, 22 | ); 23 | }); 24 | } 25 | -------------------------------------------------------------------------------- /test/run/runs_the_script_in_unchecked_mode_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../descriptor.dart' as d; 8 | import '../test_pub.dart'; 9 | 10 | const _script = ''' 11 | main() { 12 | assert(false); 13 | print("no checks"); 14 | } 15 | '''; 16 | 17 | void main() { 18 | test('runs the script without assertions by default', () async { 19 | await d.dir(appPath, [ 20 | d.appPubspec(), 21 | d.dir('bin', [d.file('script.dart', _script)]), 22 | ]).create(); 23 | 24 | await pubGet(); 25 | await runPub(args: ['run', 'bin/script'], output: contains('no checks')); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /test/testdata/README.md: -------------------------------------------------------------------------------- 1 | # Test Data 2 | 3 | Data used in tests is called _test data_ and is located in this folder, or 4 | sub-folders thereof. This is not for test files, this folder should not contain 5 | test code, only data used in tests. 6 | 7 | ## Golden Test 8 | 9 | The `test` wrapper `testWithGolden('', (ctx) async {` will register a 10 | test case, and create a file: 11 | `test/testdata/goldens/path/to/myfile_test/.txt` 12 | , where `path/to/myfile_test.dart` is the name of the file containing the test 13 | case, and `` is the name of the test case. 14 | 15 | Any calls to `ctx.run` will run `pub` and compare the output to a section in the 16 | golden file. If the file does not exist, it is created and the 17 | test is marked as skipped. 18 | Thus, it is safe to delete all files in `test/testdata/goldens` and recreate 19 | them -- just carefully review the changes before committing. 20 | 21 | **Maintaining goldens**: 22 | 1. Delete `test/testdata/goldens/`. 23 | 2. Re-run tests to re-create files in `test/testdata/goldens/`. 24 | 3. Compare changes, using `git diff test/testdata/goldens/`. 25 | 26 | -------------------------------------------------------------------------------- /test/testdata/goldens/ascii_tree_test/tree.fromMap a complex example.ans: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/ascii_tree_test.dart 2 | 3 | ├── .gitignore 4 | ├── README.md 5 | ├── TODO 6 | ├── example 7 | │ ├── console_example.dart 8 | │ ├── main.dart 9 | │ └── web copy 10 | │  └── web_example.dart 11 | ├── lib 12 | │ └── path.dart 13 | ├── pubspec.yaml 14 | └── test 15 | ├── absolute_test.dart 16 | ├── basename_test.dart 17 | ├── dirname_test.dart 18 | ├── extension_test.dart 19 | ├── is_absolute_test.dart 20 | ├── is_relative_test.dart 21 | ├── join_test.dart 22 | ├── normalize_test.dart 23 | ├── relative_test.dart 24 | └── split_test.dart 25 | -------------------------------------------------------------------------------- /test/testdata/goldens/deps/executables_test/lists Dart executables, without entrypoints.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/deps/executables_test.dart 2 | 3 | ## Section 0 4 | $ tree 5 | └── myapp 6 | ├── bin 7 | │ ├── bar.dart 8 | │ └── foo.dart 9 | ├── pubspec.lock 10 | └── pubspec.yaml 11 | 12 | -------------------------------- END OF OUTPUT --------------------------------- 13 | 14 | ## Section 1 15 | $ pub deps --executables 16 | myapp: bar, foo 17 | 18 | -------------------------------- END OF OUTPUT --------------------------------- 19 | 20 | ## Section 2 21 | $ pub deps --executables --dev 22 | myapp: bar, foo 23 | 24 | -------------------------------- END OF OUTPUT --------------------------------- 25 | 26 | ## Section 3 27 | $ pub deps --json 28 | { 29 | "root": "myapp", 30 | "packages": [ 31 | { 32 | "name": "myapp", 33 | "version": "0.0.0", 34 | "kind": "root", 35 | "source": "root", 36 | "dependencies": [], 37 | "directDependencies": [], 38 | "devDependencies": [] 39 | } 40 | ], 41 | "sdks": [ 42 | { 43 | "name": "Dart", 44 | "version": "3.1.2+3" 45 | } 46 | ], 47 | "executables": [ 48 | ":bar", 49 | ":foo" 50 | ] 51 | } 52 | 53 | -------------------------------------------------------------------------------- /test/testdata/goldens/deps/executables_test/skips executables in sub directories.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/deps/executables_test.dart 2 | 3 | ## Section 0 4 | $ tree 5 | └── myapp 6 | ├── bin 7 | │ ├── foo.dart 8 | │ └── sub 9 | │ └── bar.dart 10 | ├── pubspec.lock 11 | └── pubspec.yaml 12 | 13 | -------------------------------- END OF OUTPUT --------------------------------- 14 | 15 | ## Section 1 16 | $ pub deps --executables 17 | myapp:foo 18 | 19 | -------------------------------- END OF OUTPUT --------------------------------- 20 | 21 | ## Section 2 22 | $ pub deps --executables --dev 23 | myapp:foo 24 | 25 | -------------------------------- END OF OUTPUT --------------------------------- 26 | 27 | ## Section 3 28 | $ pub deps --json 29 | { 30 | "root": "myapp", 31 | "packages": [ 32 | { 33 | "name": "myapp", 34 | "version": "0.0.0", 35 | "kind": "root", 36 | "source": "root", 37 | "dependencies": [], 38 | "directDependencies": [], 39 | "devDependencies": [] 40 | } 41 | ], 42 | "sdks": [ 43 | { 44 | "name": "Dart", 45 | "version": "3.1.2+3" 46 | } 47 | ], 48 | "executables": [ 49 | ":foo" 50 | ] 51 | } 52 | 53 | -------------------------------------------------------------------------------- /test/testdata/goldens/deps/executables_test/skips non-Dart executables.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/deps/executables_test.dart 2 | 3 | ## Section 0 4 | $ tree 5 | └── myapp 6 | ├── bin 7 | │ ├── bar.sh 8 | │ └── foo.py 9 | ├── pubspec.lock 10 | └── pubspec.yaml 11 | 12 | -------------------------------- END OF OUTPUT --------------------------------- 13 | 14 | ## Section 1 15 | $ pub deps --executables 16 | 17 | -------------------------------- END OF OUTPUT --------------------------------- 18 | 19 | ## Section 2 20 | $ pub deps --executables --dev 21 | 22 | -------------------------------- END OF OUTPUT --------------------------------- 23 | 24 | ## Section 3 25 | $ pub deps --json 26 | { 27 | "root": "myapp", 28 | "packages": [ 29 | { 30 | "name": "myapp", 31 | "version": "0.0.0", 32 | "kind": "root", 33 | "source": "root", 34 | "dependencies": [], 35 | "directDependencies": [], 36 | "devDependencies": [] 37 | } 38 | ], 39 | "sdks": [ 40 | { 41 | "name": "Dart", 42 | "version": "3.1.2+3" 43 | } 44 | ], 45 | "executables": [] 46 | } 47 | 48 | -------------------------------------------------------------------------------- /test/testdata/goldens/embedding/embedding_test/--color forces colors.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/embedding/embedding_test.dart 2 | 3 | $ tool/test-bin/pub_command_runner.dart pub --no-color get 4 | Resolving dependencies... 5 | Downloading packages... 6 | + foo 1.0.0 (2.0.0 available) 7 | Changed 1 dependency! 8 | 1 package has newer versions incompatible with dependency constraints. 9 | Try `dart pub outdated` for more information. 10 | 11 | -------------------------------- END OF OUTPUT --------------------------------- 12 | 13 | $ tool/test-bin/pub_command_runner.dart pub --color get 14 | Resolving dependencies... 15 | Downloading packages... 16 | foo 1.0.0 (2.0.0 available) 17 | Got dependencies! 18 | 1 package has newer versions incompatible with dependency constraints. 19 | Try `dart pub outdated` for more information. 20 | 21 | -------------------------------------------------------------------------------- /test/testdata/goldens/embedding/embedding_test/Compilation errors are only printed once.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/embedding/embedding_test.dart 2 | 3 | $ tool/test-bin/pub_command_runner.dart run :syntax_error 4 | [E] Failed to build myapp:syntax_error: 5 | [E] bin/syntax_error.dart:1:21: Error: Expected ';' after this. 6 | [E] main() => print("hi") 7 | [E] ^ 8 | [E] bin/syntax_error.dart:1:22: Error: Unexpected token ''. 9 | [E] main() => print("hi") 10 | [E] ^... 11 | 12 | -------------------------------------------------------------------------------- /test/testdata/goldens/embedding/embedding_test/run works, though hidden.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/embedding/embedding_test.dart 2 | 3 | $ tool/test-bin/pub_command_runner.dart pub get 4 | Resolving dependencies... 5 | Downloading packages... 6 | Got dependencies! 7 | 8 | -------------------------------- END OF OUTPUT --------------------------------- 9 | 10 | $ tool/test-bin/pub_command_runner.dart pub run bin/main.dart 11 | Hi 12 | 13 | -------------------------------------------------------------------------------- /test/testdata/goldens/get/hosted/advisory_test/do not show ignored advisories - aliases.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/get/hosted/advisory_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | Downloading packages... 7 | + baz 1.0.0 8 | + foo 1.2.3 (affected by advisory: [^0], 2.0.0 available) 9 | Changed 2 dependencies! 10 | Dependencies are affected by security advisories: 11 | [^0]: https://github.com/advisories/456 12 | 1 package has newer versions incompatible with dependency constraints. 13 | Try `dart pub outdated` for more information. 14 | 15 | -------------------------------------------------------------------------------- /test/testdata/goldens/get/hosted/advisory_test/do not show ignored advisories.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/get/hosted/advisory_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | Downloading packages... 7 | + baz 1.0.0 8 | + foo 1.2.3 (affected by advisory: [^0], 2.0.0 available) 9 | Changed 2 dependencies! 10 | Dependencies are affected by security advisories: 11 | [^0]: https://github.com/advisories/456 12 | 1 package has newer versions incompatible with dependency constraints. 13 | Try `dart pub outdated` for more information. 14 | 15 | -------------------------------------------------------------------------------- /test/testdata/goldens/get/hosted/advisory_test/no advisories to show - a single advisory with no pub packages.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/get/hosted/advisory_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | Downloading packages... 7 | + baz 1.0.0 8 | + foo 1.2.3 9 | Changed 2 dependencies! 10 | 11 | -------------------------------------------------------------------------------- /test/testdata/goldens/get/hosted/advisory_test/no advisories to show.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/get/hosted/advisory_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | Downloading packages... 7 | + baz 1.0.0 8 | + foo 1.2.3 9 | Changed 2 dependencies! 10 | 11 | -------------------------------------------------------------------------------- /test/testdata/goldens/get/hosted/advisory_test/no advisory available from pub.dev.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/get/hosted/advisory_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | Downloading packages... 7 | [STDERR] Failed to fetch advisories for "no_advisory_pkg" from "http://localhost:$PORT". 8 | [EXIT CODE] 69 9 | 10 | -------------------------------------------------------------------------------- /test/testdata/goldens/get/hosted/advisory_test/no advisory available.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/get/hosted/advisory_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | Downloading packages... 7 | + foo 1.0.0 (affected by advisory: [^0]) 8 | + no_advisory_pkg 1.0.0 9 | Changed 2 dependencies! 10 | Dependencies are affected by security advisories: 11 | [^0]: https://github.com/advisories/123 12 | [STDERR] Warning: Unable to fetch advisories for "no_advisory_pkg" from "http://localhost:$PORT". 13 | 14 | -------------------------------------------------------------------------------- /test/testdata/goldens/get/hosted/advisory_test/several advisories, one of which has no pub packages.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/get/hosted/advisory_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | Downloading packages... 7 | + baz 1.0.0 8 | + foo 1.2.3 (affected by advisory: [^0]) 9 | Changed 2 dependencies! 10 | Dependencies are affected by security advisories: 11 | [^0]: https://github.com/advisories/123 12 | 13 | -------------------------------------------------------------------------------- /test/testdata/goldens/get/hosted/advisory_test/show advisories.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/get/hosted/advisory_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | Downloading packages... 7 | + baz 1.0.0 8 | + foo 1.2.3 (affected by advisories: [^0], [^1]) 9 | Changed 2 dependencies! 10 | Dependencies are affected by security advisories: 11 | [^0]: https://github.com/advisories/123 12 | [^1]: https://github.com/advisories/456 13 | 14 | -------------------------------------------------------------------------------- /test/testdata/goldens/get/hosted/advisory_test/show advisory - newer version available.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/get/hosted/advisory_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | Downloading packages... 7 | + baz 1.0.0 8 | + foo 1.2.3 (affected by advisory: [^0], 2.0.0 available) 9 | Changed 2 dependencies! 10 | Dependencies are affected by security advisories: 11 | [^0]: https://github.com/advisories/123 12 | 1 package has newer versions incompatible with dependency constraints. 13 | Try `dart pub outdated` for more information. 14 | 15 | -------------------------------------------------------------------------------- /test/testdata/goldens/get/hosted/advisory_test/show advisory - same package mentioned twice.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/get/hosted/advisory_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | Downloading packages... 7 | + baz 1.0.0 8 | + foo 1.2.3 (affected by advisory: [^0]) 9 | Changed 2 dependencies! 10 | Dependencies are affected by security advisories: 11 | [^0]: https://github.com/advisories/123 12 | 13 | -------------------------------------------------------------------------------- /test/testdata/goldens/get/hosted/advisory_test/show advisory.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/get/hosted/advisory_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | Downloading packages... 7 | + baz 1.0.0 8 | + foo 1.2.3 (affected by advisory: [^0]) 9 | Changed 2 dependencies! 10 | Dependencies are affected by security advisories: 11 | [^0]: https://github.com/advisories/123 12 | 13 | -------------------------------------------------------------------------------- /test/testdata/goldens/get/hosted/advisory_test/show id if no display url is present.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/get/hosted/advisory_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | Downloading packages... 7 | + baz 1.0.0 8 | + foo 1.2.3 (affected by advisories: [^0], [^1]) 9 | Changed 2 dependencies! 10 | Dependencies are affected by security advisories: 11 | [^0]: ABCD-1234-5678-9101 12 | [^1]: https://github.com/advisories/VXYZ-1234-5678-9101 13 | 14 | -------------------------------------------------------------------------------- /test/testdata/goldens/get/hosted/advisory_test/show max 5 advisories.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/get/hosted/advisory_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | Downloading packages... 7 | + baz 1.0.0 8 | + foo 1.2.3 (affected by advisories: [^0], [^1], [^2], [^3], [^4], ...) 9 | Changed 2 dependencies! 10 | Dependencies are affected by security advisories: 11 | [^0]: https://github.com/advisories/000 12 | [^1]: https://github.com/advisories/111 13 | [^2]: https://github.com/advisories/222 14 | [^3]: https://github.com/advisories/333 15 | [^4]: https://github.com/advisories/444 16 | 17 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub bump --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub bump --help 5 | Increases the version number of the current package. 6 | 7 | 8 | Usage: pub bump [arguments...] 9 | -h, --help Print this usage information. 10 | 11 | Available subcommands: 12 | breaking Increment to the next breaking version (eg. 0.1.2 -> 0.2.0) 13 | major Increment the major version number (eg. 3.1.2 -> 4.0.0) 14 | minor Increment the minor version number (eg. 3.1.2 -> 3.2.0) 15 | patch Increment the patch version number (eg. 3.1.2 -> 3.1.3) 16 | 17 | Run "pub help" to see global options. 18 | 19 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub bump breaking --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub bump breaking --help 5 | Increment to the next breaking version (eg. 0.1.2 -> 0.2.0) 6 | 7 | Usage: pub bump breaking [arguments...] 8 | -h, --help Print this usage information. 9 | -n, --dry-run Report what would change, but don't change anything. 10 | 11 | Run "pub help" to see global options. 12 | 13 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub bump major --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub bump major --help 5 | Increment the major version number (eg. 3.1.2 -> 4.0.0) 6 | 7 | Usage: pub bump major [arguments...] 8 | -h, --help Print this usage information. 9 | -n, --dry-run Report what would change, but don't change anything. 10 | 11 | Run "pub help" to see global options. 12 | 13 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub bump minor --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub bump minor --help 5 | Increment the minor version number (eg. 3.1.2 -> 3.2.0) 6 | 7 | Usage: pub bump minor [arguments...] 8 | -h, --help Print this usage information. 9 | -n, --dry-run Report what would change, but don't change anything. 10 | 11 | Run "pub help" to see global options. 12 | 13 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub bump patch --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub bump patch --help 5 | Increment the patch version number (eg. 3.1.2 -> 3.1.3) 6 | 7 | Usage: pub bump patch [arguments...] 8 | -h, --help Print this usage information. 9 | -n, --dry-run Report what would change, but don't change anything. 10 | 11 | Run "pub help" to see global options. 12 | 13 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub cache --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub cache --help 5 | Work with the system cache. 6 | 7 | Usage: pub cache [arguments...] 8 | -h, --help Print this usage information. 9 | 10 | Available subcommands: 11 | add Install a package. 12 | clean Clears the global PUB_CACHE. 13 | repair Reinstall cached packages. 14 | 15 | Run "pub help" to see global options. 16 | See https://dart.dev/tools/pub/cmd/pub-cache for detailed documentation. 17 | 18 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub cache add --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub cache add --help 5 | Install a package. 6 | 7 | Usage: pub cache add [--version ] [--all] 8 | -h, --help Print this usage information. 9 | --all Install all matching versions. 10 | -v, --version Version constraint. 11 | 12 | Run "pub help" to see global options. 13 | See https://dart.dev/tools/pub/cmd/pub-cache for detailed documentation. 14 | 15 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub cache clean --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub cache clean --help 5 | Clears the global PUB_CACHE. 6 | 7 | Usage: pub cache clean [arguments...] 8 | -h, --help Print this usage information. 9 | -f, --force Don't ask for confirmation. 10 | 11 | Run "pub help" to see global options. 12 | 13 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub cache repair --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub cache repair --help 5 | Reinstall cached packages. 6 | 7 | Usage: pub cache repair [arguments...] 8 | -h, --help Print this usage information. 9 | 10 | Run "pub help" to see global options. 11 | See https://dart.dev/tools/pub/cmd/pub-cache for detailed documentation. 12 | 13 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub deps --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub deps --help 5 | Print package dependencies. 6 | 7 | Usage: pub deps [arguments...] 8 | -h, --help Print this usage information. 9 | -s, --style How output should be displayed. 10 | [compact, tree (default), list] 11 | --[no-]dev Whether to include dev dependencies. 12 | (defaults to on) 13 | --executables List all available executables. 14 | --json Output dependency information in a json format. 15 | -C, --directory= Run this in the directory . 16 | 17 | Run "pub help" to see global options. 18 | See https://dart.dev/tools/pub/cmd/pub-deps for detailed documentation. 19 | 20 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub downgrade --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub downgrade --help 5 | Downgrade the current package's dependencies to oldest versions. 6 | 7 | 8 | 9 | Usage: pub downgrade [dependencies...] 10 | -h, --help Print this usage information. 11 | --[no-]offline Use cached packages instead of accessing the network. 12 | -n, --dry-run Report what dependencies would change but don't change any. 13 | -C, --directory= Run this in the directory . 14 | --tighten Updates lower bounds in pubspec.yaml to match the resolved version. 15 | 16 | Run "pub help" to see global options. 17 | See https://dart.dev/tools/pub/cmd/pub-downgrade for detailed documentation. 18 | 19 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub get --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub get --help 5 | Get the current package's dependencies. 6 | 7 | Usage: pub get 8 | -h, --help Print this usage information. 9 | --[no-]offline Use cached packages instead of accessing the network. 10 | -n, --dry-run Report what dependencies would change but don't change any. 11 | --enforce-lockfile Enforce pubspec.lock. Fail `pub get` if the current `pubspec.lock` does not exactly specify a valid resolution of `pubspec.yaml` or if any content hash of a hosted package 12 | has changed. 13 | Useful for CI or deploying to production. 14 | --[no-]precompile Build executables in immediate dependencies. 15 | -C, --directory= Run this in the directory . 16 | 17 | Run "pub help" to see global options. 18 | See https://dart.dev/tools/pub/cmd/pub-get for detailed documentation. 19 | 20 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub global --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub global --help 5 | Work with global packages. 6 | 7 | Usage: pub global [arguments...] 8 | -h, --help Print this usage information. 9 | 10 | Available subcommands: 11 | activate Make a package's executables globally available. 12 | deactivate Remove a previously activated package. 13 | list List globally activated packages. 14 | run Run an executable from a globally activated package. 15 | 16 | Run "pub help" to see global options. 17 | See https://dart.dev/tools/pub/cmd/pub-global for detailed documentation. 18 | 19 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub global activate --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub global activate --help 5 | Make a package's executables globally available. 6 | 7 | Usage: pub global activate [version-constraint] 8 | -h, --help Print this usage information. 9 | -s, --source The source used to find the package. 10 | [git, hosted (default), path] 11 | --git-path Path of git package in repository 12 | --git-ref Git branch or commit to be retrieved 13 | --no-executables Do not put executables on PATH. 14 | -x, --executable Executable(s) to place on PATH. 15 | --overwrite Overwrite executables from other packages with the same name. 16 | -u, --hosted-url A custom pub server URL for the package. Only applies when using the `hosted` source. 17 | 18 | Run "pub help" to see global options. 19 | 20 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub global deactivate --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub global deactivate --help 5 | Remove a previously activated package. 6 | 7 | Usage: pub global deactivate 8 | -h, --help Print this usage information. 9 | 10 | Run "pub help" to see global options. 11 | 12 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub global list --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub global list --help 5 | List globally activated packages. 6 | 7 | Usage: pub global list [arguments...] 8 | -h, --help Print this usage information. 9 | 10 | Run "pub help" to see global options. 11 | 12 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub global run --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub global run --help 5 | Run an executable from a globally activated package. 6 | 7 | Usage: pub global run : [args...] 8 | -h, --help Print this usage information. 9 | --[no-]enable-asserts Enable assert statements. 10 | --enable-experiment= Runs the executable in a VM with the given experiments enabled. (Will disable snapshotting, resulting in slower startup). 11 | 12 | Run "pub help" to see global options. 13 | 14 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub login --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub login --help 5 | Log into pub.dev. 6 | 7 | Usage: pub login 8 | -h, --help Print this usage information. 9 | 10 | Run "pub help" to see global options. 11 | 12 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub logout --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub logout --help 5 | Log out of pub.dev. 6 | 7 | Usage: pub logout [arguments...] 8 | -h, --help Print this usage information. 9 | 10 | Run "pub help" to see global options. 11 | 12 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub outdated --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub outdated --help 5 | Analyze your dependencies to find which ones can be upgraded. 6 | 7 | Usage: pub outdated [options] 8 | -h, --help Print this usage information. 9 | --[no-]dependency-overrides Show resolutions with `dependency_overrides`. 10 | (defaults to on) 11 | --[no-]dev-dependencies Take dev dependencies into account. 12 | (defaults to on) 13 | --json Output the results using a json format. 14 | --[no-]prereleases Include prereleases in latest version. 15 | --[no-]show-all Include dependencies that are already fulfilling --mode. 16 | --[no-]transitive Show transitive dependencies. 17 | (defaults to on) 18 | -C, --directory= Run this in the directory . 19 | 20 | Run "pub help" to see global options. 21 | See https://dart.dev/tools/pub/cmd/pub-outdated for detailed documentation. 22 | 23 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub publish --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub publish --help 5 | Publish the current package to pub.dev. 6 | 7 | Usage: pub publish [options] 8 | -h, --help Print this usage information. 9 | -n, --dry-run Validate but do not publish the package. 10 | -f, --force Publish without confirmation if there are no errors. 11 | --skip-validation Publish without validation and resolution (this will ignore errors). 12 | -C, --directory= Run this in the directory . 13 | 14 | Run "pub help" to see global options. 15 | See https://dart.dev/tools/pub/cmd/pub-lish for detailed documentation. 16 | 17 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub remove --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub remove --help 5 | Removes dependencies from `pubspec.yaml`. 6 | 7 | Invoking `dart pub remove foo bar` will remove `foo` and `bar` from either 8 | `dependencies` or `dev_dependencies` in `pubspec.yaml`. 9 | 10 | To remove a dependency override of a package prefix the package name with 11 | 'override:'. 12 | 13 | 14 | Usage: pub remove [...] 15 | -h, --help Print this usage information. 16 | --[no-]offline Use cached packages instead of accessing the network. 17 | -n, --dry-run Report what dependencies would change but don't change any. 18 | --[no-]precompile Precompile executables in immediate dependencies. 19 | -C, --directory= Run this in the directory . 20 | 21 | Run "pub help" to see global options. 22 | See https://dart.dev/tools/pub/cmd/pub-remove for detailed documentation. 23 | 24 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub run --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub run --help 5 | Run an executable from a package. 6 | 7 | Usage: pub run [arguments...] 8 | -h, --help Print this usage information. 9 | --[no-]enable-asserts Enable assert statements. 10 | --enable-experiment= Runs the executable in a VM with the given experiments enabled. 11 | (Will disable snapshotting, resulting in slower startup). 12 | -C, --directory= Run this in the directory . 13 | 14 | Run "pub help" to see global options. 15 | See https://dart.dev/tools/pub/cmd/pub-run for detailed documentation. 16 | 17 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub token --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub token --help 5 | Manage authentication tokens for hosted pub repositories. 6 | 7 | The tokens will be used for authorizing both when retrieving dependencies and 8 | for publishing. 9 | 10 | Tokens are stored in `$SANDBOX/.config/dart/pub-tokens.json`. 11 | 12 | For interactive authorization against pub.dev, use `dart pub login`. 13 | 14 | Usage: pub token [arguments...] 15 | -h, --help Print this usage information. 16 | 17 | Available subcommands: 18 | add Add an authentication token for a package repository. 19 | list List servers for which a token exists. 20 | remove Remove secret token for package repository at . 21 | 22 | Run "pub help" to see global options. 23 | See https://dart.dev/tools/pub/cmd/pub-token for detailed documentation. 24 | 25 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub token add --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub token add --help 5 | Add an authentication token for a package repository. 6 | 7 | The token will be used for authorizing against both when 8 | retrieving dependencies and for publishing. 9 | 10 | Tokens are stored in $SANDBOX/.config/dart/pub-tokens.json. 11 | 12 | This command will prompt for the secret token over stdin. 13 | (Unless `--env-var` is used). 14 | 15 | For interactive authorization against pub.dev, use `dart pub login`. 16 | 17 | Usage: pub token add [options] 18 | -h, --help Print this usage information. 19 | --env-var= Read the secret token from this environment variable when making requests. 20 | 21 | Run "pub help" to see global options. 22 | See https://dart.dev/tools/pub/cmd/pub-token for detailed documentation. 23 | 24 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub token list --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub token list --help 5 | List servers for which a token exists. 6 | 7 | Usage: pub token list [arguments...] 8 | -h, --help Print this usage information. 9 | 10 | Run "pub help" to see global options. 11 | See https://dart.dev/tools/pub/cmd/pub-token for detailed documentation. 12 | 13 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub token remove --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub token remove --help 5 | Remove secret token for package repository at . 6 | 7 | Usage: pub token remove | --all 8 | -h, --help Print this usage information. 9 | --all Remove all secret tokens. 10 | 11 | Run "pub help" to see global options. 12 | See https://dart.dev/tools/pub/cmd/pub-token for detailed documentation. 13 | 14 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub upgrade --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub upgrade --help 5 | Upgrade the current package's dependencies to latest versions. 6 | 7 | Usage: pub upgrade [dependencies...] 8 | -h, --help Print this usage information. 9 | --[no-]offline Use cached packages instead of accessing the network. 10 | -n, --dry-run Report what dependencies would change but don't change any. 11 | --[no-]precompile Precompile executables in immediate dependencies. 12 | --tighten Updates lower bounds in pubspec.yaml to match the resolved version. 13 | --unlock-transitive Also upgrades the transitive dependencies of the listed [dependencies] 14 | --major-versions Upgrades packages to their latest resolvable versions, and updates pubspec.yaml. 15 | -C, --directory= Run this in the directory . 16 | 17 | Run "pub help" to see global options. 18 | See https://dart.dev/tools/pub/cmd/pub-upgrade for detailed documentation. 19 | 20 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub version --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub version --help 5 | Print pub version. 6 | 7 | Usage: pub version 8 | -h, --help Print this usage information. 9 | 10 | Run "pub help" to see global options. 11 | 12 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub workspace --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub workspace --help 5 | Work with the pub workspace. 6 | 7 | Usage: pub workspace [arguments...] 8 | -h, --help Print this usage information. 9 | 10 | Available subcommands: 11 | list List all packages in the workspace, and their directory 12 | 13 | Run "pub help" to see global options. 14 | 15 | -------------------------------------------------------------------------------- /test/testdata/goldens/help_test/pub workspace list --help.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/help_test.dart 2 | 3 | ## Section 0 4 | $ pub workspace list --help 5 | List all packages in the workspace, and their directory 6 | 7 | Usage: pub workspace list [arguments...] 8 | -h, --help Print this usage information. 9 | --json output information in a json format 10 | 11 | Run "pub help" to see global options. 12 | 13 | -------------------------------------------------------------------------------- /test/testdata/goldens/hosted/fail_gracefully_on_bad_version_listing_response_test/401-with-message.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/hosted/fail_gracefully_on_bad_version_listing_response_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | [STDERR] Because myapp depends on foo any which doesn't exist (authentication failed), version solving failed. 7 | [STDERR] 8 | [STDERR] http://localhost:$PORT package repository requested authentication! 9 | [STDERR] You can provide credentials using: 10 | [STDERR] dart pub token add http://localhost:$PORT 11 | [STDERR] 12 | [EXIT CODE] 69 13 | 14 | -------------------------------------------------------------------------------- /test/testdata/goldens/hosted/fail_gracefully_on_bad_version_listing_response_test/401.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/hosted/fail_gracefully_on_bad_version_listing_response_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | [STDERR] Because myapp depends on foo any which doesn't exist (authentication failed), version solving failed. 7 | [STDERR] 8 | [STDERR] http://localhost:$PORT package repository requested authentication! 9 | [STDERR] You can provide credentials using: 10 | [STDERR] dart pub token add http://localhost:$PORT 11 | [EXIT CODE] 69 12 | 13 | -------------------------------------------------------------------------------- /test/testdata/goldens/hosted/fail_gracefully_on_bad_version_listing_response_test/403-with-message.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/hosted/fail_gracefully_on_bad_version_listing_response_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | [STDERR] Because myapp depends on foo any which doesn't exist (authorization failed), version solving failed. 7 | [STDERR] 8 | [STDERR] Insufficient permissions to the resource at the http://localhost:$PORT package repository. 9 | [STDERR] You can modify credentials using: 10 | [STDERR] dart pub token add http://localhost:$PORT 11 | [STDERR] 12 | [EXIT CODE] 69 13 | 14 | -------------------------------------------------------------------------------- /test/testdata/goldens/hosted/fail_gracefully_on_bad_version_listing_response_test/403.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/hosted/fail_gracefully_on_bad_version_listing_response_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | [STDERR] Because myapp depends on foo any which doesn't exist (authorization failed), version solving failed. 7 | [STDERR] 8 | [STDERR] Insufficient permissions to the resource at the http://localhost:$PORT package repository. 9 | [STDERR] You can modify credentials using: 10 | [STDERR] dart pub token add http://localhost:$PORT 11 | [EXIT CODE] 69 12 | 13 | -------------------------------------------------------------------------------- /test/testdata/goldens/hosted/fail_gracefully_on_bad_version_listing_response_test/bad_json.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/hosted/fail_gracefully_on_bad_version_listing_response_test.dart 2 | 3 | ## Section 0 4 | $ pub get 5 | Resolving dependencies... 6 | [STDERR] Because myapp depends on foo any which doesn't exist (Got badly formatted response trying to find package foo at http://localhost:$PORT), version solving failed. 7 | [STDERR] 8 | [STDERR] Check that "http://localhost:$PORT" is a valid package repository. 9 | [EXIT CODE] 65 10 | 11 | -------------------------------------------------------------------------------- /test/testdata/goldens/hosted/fail_gracefully_with_hint_test/supports two hints.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/hosted/fail_gracefully_with_hint_test.dart 2 | 3 | ## Section 0 4 | $ pub get --offline 5 | Resolving dependencies... 6 | [STDERR] Because foo <1.2.4 requires the Flutter SDK and foo >=1.2.4 depends on bar any, every version of foo requires bar any. 7 | [STDERR] So, because bar doesn't exist (could not find package bar in cache) and myapp depends on foo any, version solving failed. 8 | [STDERR] 9 | [STDERR] Flutter users should use `flutter pub` instead of `dart pub`. 10 | [STDERR] 11 | [STDERR] Try again without --offline! 12 | [EXIT CODE] 69 13 | 14 | -------------------------------------------------------------------------------- /test/testdata/goldens/outdated/outdated_test/Handles packages that are not found on server.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/outdated/outdated_test.dart 2 | 3 | ## Section 0 4 | $ pub outdated 5 | Showing outdated packages. 6 | [*] indicates versions that are not the latest available. 7 | 8 | Package Name Current Upgradable Resolvable Latest 9 | 10 | direct dependencies: 11 | foo - 1.0.0 (overridden) 1.0.0 (overridden) 1.0.0 (overridden) 12 | 13 | No pubspec.lock found. There are no Current versions. 14 | Run `dart pub get` to create a pubspec.lock with versions matching your pubspec.yaml. 15 | 16 | -------------------------------------------------------------------------------- /test/testdata/goldens/outdated/outdated_test/no pubspec.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/outdated/outdated_test.dart 2 | 3 | ## Section 0 4 | $ pub outdated 5 | [STDERR] Found no `pubspec.yaml` file in `$SANDBOX/myapp` or parent directories 6 | [EXIT CODE] 66 7 | 8 | -------------------------------------------------------------------------------- /test/testdata/goldens/upgrade/example_warns_about_major_versions_test/pub upgrade --major-versions does not update major versions in example~.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/upgrade/example_warns_about_major_versions_test.dart 2 | 3 | ## Section 0 4 | $ pub upgrade --major-versions --example 5 | 6 | Changed 1 constraint in pubspec.yaml: 7 | bar: ^1.0.0 -> ^2.0.0 8 | Resolving dependencies... 9 | Downloading packages... 10 | + bar 2.0.0 11 | Changed 1 dependency! 12 | Resolving dependencies in `./example`... 13 | Downloading packages... 14 | Got dependencies in `./example`. 15 | [STDERR] Running `upgrade --major-versions` only in `.`. Run `dart pub upgrade --major-versions --directory example/` separately. 16 | 17 | -------------------------------- END OF OUTPUT --------------------------------- 18 | 19 | ## Section 1 20 | $ pub upgrade --major-versions --directory example 21 | 22 | Changed 1 constraint in pubspec.yaml: 23 | foo: ^1.0.0 -> ^2.0.0 24 | Resolving dependencies in `example`... 25 | Downloading packages... 26 | > foo 2.0.0 (was 1.0.0) 27 | Changed 1 dependency in `example`! 28 | 29 | -------------------------------------------------------------------------------- /test/testdata/goldens/upgrade/example_warns_about_major_versions_test/pub upgrade --null-safety does not update null-safety of dependencies in example~.txt: -------------------------------------------------------------------------------- 1 | # GENERATED BY: test/upgrade/example_warns_about_major_versions_test.dart 2 | 3 | ## Section 0 4 | $ pub upgrade --null-safety --example 5 | [STDERR] The `--null-safety` flag is no longer supported. 6 | [STDERR] Consider using the Dart 2.19 sdk to migrate to null safety. 7 | [EXIT CODE] 65 8 | 9 | -------------------------------- END OF OUTPUT --------------------------------- 10 | 11 | ## Section 1 12 | $ pub upgrade --null-safety --directory example 13 | [STDERR] The `--null-safety` flag is no longer supported. 14 | [STDERR] Consider using the Dart 2.19 sdk to migrate to null safety. 15 | [EXIT CODE] 65 16 | 17 | -------------------------------------------------------------------------------- /test/token/when_receives_401_removes_token_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:shelf/shelf.dart' as shelf; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('when receives 401 response removes saved token', () async { 13 | final server = await servePackages(); 14 | await d.validPackage().create(); 15 | await d.tokensFile({ 16 | 'version': 1, 17 | 'hosted': [ 18 | {'url': server.url, 'token': 'access-token'}, 19 | ], 20 | }).create(); 21 | final pub = await startPublish(server, overrideDefaultHostedServer: false); 22 | await confirmPublish(pub); 23 | 24 | server.expect('GET', '/api/packages/versions/new', (request) { 25 | return shelf.Response(401); 26 | }); 27 | 28 | await pub.shouldExit(65); 29 | 30 | await d.tokensFile({ 31 | 'version': 1, 32 | 'hosted': >[], 33 | }).validate(); 34 | }); 35 | } 36 | -------------------------------------------------------------------------------- /test/token/when_receives_403_persists_saved_token_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:shelf/shelf.dart' as shelf; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | 11 | void main() { 12 | test('when receives 403 response persists saved token', () async { 13 | await d.validPackage().create(); 14 | final server = await servePackages(); 15 | await d.tokensFile({ 16 | 'version': 1, 17 | 'hosted': [ 18 | {'url': server.url, 'token': 'access-token'}, 19 | ], 20 | }).create(); 21 | final pub = await startPublish(server, overrideDefaultHostedServer: false); 22 | await confirmPublish(pub); 23 | 24 | server.expect('GET', '/api/packages/versions/new', (request) { 25 | return shelf.Response(403); 26 | }); 27 | 28 | await pub.shouldExit(65); 29 | 30 | await d.tokensFile({ 31 | 'version': 1, 32 | 'hosted': [ 33 | {'url': server.url, 'token': 'access-token'}, 34 | ], 35 | }).validate(); 36 | }); 37 | } 38 | -------------------------------------------------------------------------------- /test/upgrade/git/upgrade_to_nonexistent_pubspec_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('upgrades Git packages to a nonexistent pubspec', () async { 12 | ensureGit(); 13 | 14 | final repo = d.git('foo.git', [ 15 | d.libDir('foo'), 16 | d.libPubspec('foo', '1.0.0'), 17 | ]); 18 | await repo.create(); 19 | 20 | await d 21 | .appDir( 22 | dependencies: { 23 | 'foo': {'git': '../foo.git'}, 24 | }, 25 | ) 26 | .create(); 27 | 28 | await pubGet(); 29 | 30 | final originalFooSpec = packageSpec('foo'); 31 | 32 | await repo.runGit(['rm', 'pubspec.yaml']); 33 | await repo.runGit(['commit', '-m', 'delete']); 34 | 35 | await pubUpgrade( 36 | error: RegExp( 37 | r'Could not find a file named "pubspec.yaml" ' 38 | r'in [^\n]*\.', 39 | ), 40 | ); 41 | 42 | expect(packageSpec('foo'), originalFooSpec); 43 | }); 44 | } 45 | -------------------------------------------------------------------------------- /test/upgrade/renamed_package_circular_dependency.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | import '../descriptor.dart' as d; 7 | import '../test_pub.dart'; 8 | 9 | void main() { 10 | test('The upgrade report handles a package becoming root', () async { 11 | await servePackages() 12 | ..serve('foo', '1.0.0', deps: {'myapp': 'any'}) 13 | ..serve('myapp', '1.0.0', deps: {'foo': 'any'}); 14 | 15 | await d.dir(appPath, [ 16 | d.pubspec({ 17 | 'name': 'myappx', 18 | 'version': '1.0.0', 19 | 'dependencies': {'foo': 'any'}, 20 | }), 21 | ]).create(); 22 | 23 | await pubGet(); 24 | 25 | // Rename the package 26 | await d.dir(appPath, [ 27 | d.pubspec({ 28 | 'name': 'myapp', 29 | 'version': '1.0.1', 30 | 'dependencies': {'foo': 'any'}, 31 | }), 32 | ]).create(); 33 | await pubUpgrade(); 34 | }); 35 | } 36 | -------------------------------------------------------------------------------- /test/upgrade/report/highlights_overrides_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('highlights overridden packages', () async { 12 | final server = await servePackages(); 13 | server.serve('overridden', '1.0.0'); 14 | 15 | await d.dir(appPath, [ 16 | d.pubspec({ 17 | 'name': 'myapp', 18 | 'dependency_overrides': {'overridden': 'any'}, 19 | }), 20 | ]).create(); 21 | 22 | // Upgrade everything. 23 | await pubUpgrade( 24 | output: RegExp(r''' 25 | Resolving dependencies\.\.\..* 26 | Downloading packages\.\.\..* 27 | ! overridden 1\.0\.0 \(overridden\) 28 | ''', multiLine: true), 29 | ); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/upgrade/report/shows_number_of_changed_dependencies_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:test/test.dart'; 6 | 7 | import '../../descriptor.dart' as d; 8 | import '../../test_pub.dart'; 9 | 10 | void main() { 11 | test('does not show how many newer versions are available for ' 12 | 'packages that are locked and not being upgraded', () async { 13 | await servePackages() 14 | ..serve('a', '1.0.0') 15 | ..serve('b', '1.0.0') 16 | ..serve('c', '2.0.0'); 17 | 18 | await d.appDir(dependencies: {'a': 'any'}).create(); 19 | 20 | // One dependency changed. 21 | await pubUpgrade(output: RegExp(r'Changed 1 dependency!$')); 22 | 23 | // Remove one and add two. 24 | await d.appDir(dependencies: {'b': 'any', 'c': 'any'}).create(); 25 | 26 | await pubUpgrade(output: RegExp(r'Changed 3 dependencies!$')); 27 | 28 | // Don't change anything. 29 | await pubUpgrade(output: RegExp(r'No dependencies changed.$')); 30 | }); 31 | } 32 | -------------------------------------------------------------------------------- /test/validator/pubspec_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import 'package:pub/src/validator/pubspec.dart'; 6 | import 'package:test/test.dart'; 7 | 8 | import '../descriptor.dart' as d; 9 | import '../test_pub.dart'; 10 | import 'utils.dart'; 11 | 12 | void main() { 13 | test('should consider a package valid if it has a pubspec', () async { 14 | await d.validPackage().create(); 15 | 16 | await expectValidationDeprecated(PubspecValidator.new); 17 | }); 18 | 19 | test( 20 | 'should consider a package invalid if it has a .gitignored pubspec', 21 | () async { 22 | final repo = d.git(appPath, [d.file('.gitignore', 'pubspec.yaml')]); 23 | await d.validPackage().create(); 24 | await repo.create(); 25 | 26 | await expectValidationDeprecated( 27 | PubspecValidator.new, 28 | errors: isNotEmpty, 29 | ); 30 | }, 31 | ); 32 | } 33 | -------------------------------------------------------------------------------- /test/validator/validations_output_test.dart: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file 2 | // for details. All rights reserved. Use of this source code is governed by a 3 | // BSD-style license that can be found in the LICENSE file. 4 | 5 | import '../descriptor.dart'; 6 | import '../golden_file.dart'; 7 | import '../test_pub.dart'; 8 | 9 | Future main() async { 10 | testWithGolden('Layout of publication warnings', (ctx) async { 11 | final server = await servePackages(); 12 | server.serve('foo', '1.0.0'); 13 | server.serve('bar', '1.0.0'); 14 | 15 | await dir(appPath, [ 16 | pubspec({ 17 | 'name': 'myapp', 18 | 'dev_dependencies': {'foo': '1.0.0'}, 19 | 'dependencies': {'bar': null}, 20 | 'dependency_overrides': {'bar': '1.0.0'}, 21 | }), 22 | dir('bin', [ 23 | file('main.dart', ''' 24 | import 'package:foo/foo.dart'; 25 | '''), 26 | ]), 27 | ]).create(); 28 | await ctx.run( 29 | ['publish', '--dry-run'], 30 | environment: { 31 | // Use more columns to avoid unintended line breaking. 32 | '_PUB_TEST_TERMINAL_COLUMNS': '200', 33 | }, 34 | ); 35 | }); 36 | } 37 | -------------------------------------------------------------------------------- /tool/test-bin/pub: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file 3 | # for details. All rights reserved. Use of this source code is governed by a 4 | # BSD-style license that can be found in the LICENSE file. 5 | 6 | # Runs bin/pub.dart with dart from PATH (or the snapshot if present). 7 | 8 | if [ -n "$_PUB_TEST_SNAPSHOT" ]; then 9 | dart $_PUB_TEST_SNAPSHOT $* 10 | else 11 | dart `dirname "$0"`/../../bin/pub.dart $* 12 | fi 13 | -------------------------------------------------------------------------------- /tool/test-bin/pub.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file 3 | rem for details. All rights reserved. Use of this source code is governed by a 4 | rem BSD-style license that can be found in the LICENSE file. 5 | 6 | rem Runs bin/pub.dart with dart from PATH (or the snapshot if present). 7 | 8 | if "%_PUB_TEST_SNAPSHOT%"=="" ( 9 | dart %~p0\..\..\..\bin\pub.dart %* 10 | ) else ( 11 | dart %_PUB_TEST_SNAPSHOT% %* 12 | ) 13 | --------------------------------------------------------------------------------