diff --git a/clients/vscode-hlasmplugin/CHANGELOG.md b/clients/vscode-hlasmplugin/CHANGELOG.md index 314b9a806..f0b5339f4 100644 --- a/clients/vscode-hlasmplugin/CHANGELOG.md +++ b/clients/vscode-hlasmplugin/CHANGELOG.md @@ -13,6 +13,7 @@ - "Diagnostics suppressed" informational message may be incorrectly generated - Auto-select WebAssembly image on platforms without native support - Querying current directory fails on Windows (WASM) +- Implicit workspaces should not attempt reading configuration files ## [1.9.0](https://github.com/eclipse-che4z/che-che4z-lsp-for-hlasm/compare/1.8.0...1.9.0) (2023-08-03) diff --git a/parser_library/src/workspace_manager.cpp b/parser_library/src/workspace_manager.cpp index 632cffc63..4a9f76bf2 100644 --- a/parser_library/src/workspace_manager.cpp +++ b/parser_library/src/workspace_manager.cpp @@ -71,11 +71,11 @@ class workspace_manager_impl final : public workspace_manager, struct opened_workspace { opened_workspace(const resource_location& location, - const std::string& name, + const std::string&, workspaces::file_manager& file_manager, const lib_config& global_config, external_configuration_requests* ecr) - : ws(location, name, file_manager, global_config, settings, ecr) + : ws(location, file_manager, global_config, settings, ecr) {} opened_workspace(workspaces::file_manager& file_manager, const lib_config& global_config) : ws(file_manager, global_config, settings) diff --git a/parser_library/src/workspaces/workspace.cpp b/parser_library/src/workspaces/workspace.cpp index 8d90dfc19..0615aa86d 100644 --- a/parser_library/src/workspaces/workspace.cpp +++ b/parser_library/src/workspaces/workspace.cpp @@ -264,13 +264,11 @@ struct workspace_parse_lib_provider final : public parse_lib_provider }; workspace::workspace(const resource_location& location, - const std::string& name, file_manager& file_manager, const lib_config& global_config, const shared_json& global_settings, external_configuration_requests* ecr) - : name_(name) - , location_(location.lexically_normal()) + : location_(location.lexically_normal()) , file_manager_(file_manager) , fm_vfm_(file_manager_, location) , implicit_proc_grp("pg_implicit", {}, {}) @@ -284,7 +282,7 @@ workspace::workspace(file_manager& file_manager, const shared_json& global_settings, std::shared_ptr implicit_library, external_configuration_requests* ecr) - : workspace(resource_location(""), "", file_manager, global_config, global_settings, ecr) + : workspace(resource_location(), file_manager, global_config, global_settings, ecr) { opened_ = true; if (implicit_library) diff --git a/parser_library/src/workspaces/workspace.h b/parser_library/src/workspaces/workspace.h index a452c6fbe..ea842416b 100644 --- a/parser_library/src/workspaces/workspace.h +++ b/parser_library/src/workspaces/workspace.h @@ -74,7 +74,6 @@ class workspace : public diagnosable_impl std::shared_ptr implicit_library = nullptr, external_configuration_requests* ecr = nullptr); workspace(const resource_location& location, - const std::string& name, file_manager& file_manager, const lib_config& global_config, const shared_json& global_settings, @@ -142,7 +141,6 @@ class workspace : public diagnosable_impl void invalidate_external_configuration(const resource_location& url); private: - std::string name_; resource_location location_; file_manager& file_manager_; file_manager_vfm fm_vfm_; diff --git a/parser_library/src/workspaces/workspace_configuration.cpp b/parser_library/src/workspaces/workspace_configuration.cpp index 18a9ba8e9..17fad0334 100644 --- a/parser_library/src/workspaces/workspace_configuration.cpp +++ b/parser_library/src/workspaces/workspace_configuration.cpp @@ -245,7 +245,7 @@ workspace_configuration::~workspace_configuration() = default; bool workspace_configuration::is_configuration_file(const utils::resource::resource_location& file) const { - return is_config_file(file) || is_b4g_config_file(file); + return !m_location.empty() && (is_config_file(file) || is_b4g_config_file(file)); } template @@ -553,7 +553,7 @@ bool workspace_configuration::settings_updated() const } utils::value_task workspace_configuration::parse_b4g_config_file( - const utils::resource::resource_location& cfg_file_rl) + utils::resource::resource_location cfg_file_rl) { // keep in sync with try_loading_alternative_configuration const auto alternative_root = @@ -737,13 +737,16 @@ void workspace_configuration::produce_diagnostics( utils::value_task workspace_configuration::parse_configuration_file( std::optional file) { - if (!file.has_value() || is_config_file(*file)) - co_return co_await load_and_process_config(m_config_diags); + if (!m_location.empty()) + { + if (!file.has_value() || is_config_file(*file)) + return load_and_process_config(m_config_diags); - if (is_b4g_config_file(*file)) - co_return co_await parse_b4g_config_file(*file); + if (is_b4g_config_file(*file)) + return parse_b4g_config_file(std::move(*file)); + } - co_return parse_config_file_result::not_found; + return utils::value_task::from_value(parse_config_file_result::not_found); } utils::value_task>> workspace_configuration::refresh_libraries( @@ -958,7 +961,7 @@ utils::value_task workspace_configuration::l } } - if (affiliation == regex_pgm) + if (affiliation == regex_pgm || m_location.empty()) co_return empty_alternative_cfg_root; auto configuration_url = utils::resource::resource_location::replace_filename(rl, B4G_CONF_FILE); diff --git a/parser_library/src/workspaces/workspace_configuration.h b/parser_library/src/workspaces/workspace_configuration.h index a02e64148..e8144f015 100644 --- a/parser_library/src/workspaces/workspace_configuration.h +++ b/parser_library/src/workspaces/workspace_configuration.h @@ -238,7 +238,7 @@ class workspace_configuration bool is_b4g_config_file(const utils::resource::resource_location& file) const; [[nodiscard]] utils::value_task parse_b4g_config_file( - const utils::resource::resource_location& cfg_file_rl); + utils::resource::resource_location cfg_file_rl); [[nodiscard]] utils::value_task load_and_process_config(std::vector& diags); diff --git a/parser_library/test/workspace/b4g_integration_test.cpp b/parser_library/test/workspace/b4g_integration_test.cpp index aea1b61a9..5910272f7 100644 --- a/parser_library/test/workspace/b4g_integration_test.cpp +++ b/parser_library/test/workspace/b4g_integration_test.cpp @@ -31,15 +31,15 @@ using namespace hlasm_plugin::parser_library::workspaces; using hlasm_plugin::utils::resource::resource_location; namespace { -constexpr auto prepend_ws_loc = [](std::string path) { +constexpr auto prepend_ws_loc = [](std::string_view path) { static const resource_location rl("scheme://ws/"); return resource_location::join(rl, path).lexically_normal(); }; const std::string empty_b4g_conf(R"({})"); const auto ws_rl = prepend_ws_loc(""); -const auto proc_grps_rl = prepend_ws_loc(proc_grps_name.get_uri()); -const auto pgm_conf_rl = prepend_ws_loc(pgm_conf_name.get_uri()); +const auto proc_grps_rl = prepend_ws_loc(proc_grps_name); +const auto pgm_conf_rl = prepend_ws_loc(pgm_conf_name); const auto b4g_conf_rl = prepend_ws_loc("SYS/SUB/ASMPGM/.bridge.json"); const auto pgm_a = prepend_ws_loc("SYS/SUB/ASMPGM/A"); const auto pgm_b = prepend_ws_loc("SYS/SUB/ASMPGM/B"); @@ -136,7 +136,7 @@ class workspace_test : public workspace { public: workspace_test(file_manager& fm) - : workspace(ws_rl, "workspace_name", fm, m_config, m_global_settings) + : workspace(ws_rl, fm, m_config, m_global_settings) { open().run(); } @@ -200,7 +200,7 @@ class pgm_conf_preference_helper file_manager_impl_test fm; lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws = workspace(ws_rl, "workspace_name", fm, config, global_settings); + workspace ws = workspace(ws_rl, fm, config, global_settings); pgm_conf_preference_helper() { diff --git a/parser_library/test/workspace/diags_suppress_test.cpp b/parser_library/test/workspace/diags_suppress_test.cpp index ca21cb0fa..1b8e812dd 100644 --- a/parser_library/test/workspace/diags_suppress_test.cpp +++ b/parser_library/test/workspace/diags_suppress_test.cpp @@ -45,8 +45,8 @@ const auto file_loc = resource_location("a_file"); TEST(diags_suppress, no_suppress) { file_manager_impl fm; - fm.did_open_file(pgm_conf_name, 0, empty_pgm_conf); - fm.did_open_file(proc_grps_name, 0, one_proc_grps); + fm.did_open_file(empty_pgm_conf_name, 0, empty_pgm_conf); + fm.did_open_file(empty_proc_grps_name, 0, one_proc_grps); fm.did_open_file(file_loc, 0, R"( LR 1, @@ -60,7 +60,7 @@ TEST(diags_suppress, no_suppress) lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(file_loc)); parse_all_files(ws); @@ -76,8 +76,8 @@ TEST(diags_suppress, do_suppress) shared_json global_settings = make_empty_shared_json(); file_manager_impl fm; - fm.did_open_file(pgm_conf_name, 0, empty_pgm_conf); - fm.did_open_file(proc_grps_name, 0, one_proc_grps); + fm.did_open_file(empty_pgm_conf_name, 0, empty_pgm_conf); + fm.did_open_file(empty_proc_grps_name, 0, one_proc_grps); fm.did_open_file(file_loc, 0, R"( LR 1, @@ -90,7 +90,7 @@ TEST(diags_suppress, do_suppress) message_consumer_mock msg_consumer; - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); ws.set_message_consumer(&msg_consumer); ws.open().run(); run_if_valid(ws.did_open_file(file_loc)); @@ -105,8 +105,8 @@ TEST(diags_suppress, do_suppress) TEST(diags_suppress, pgm_supress_limit_changed) { file_manager_impl fm; - fm.did_open_file(pgm_conf_name, 0, empty_pgm_conf); - fm.did_open_file(proc_grps_name, 0, one_proc_grps); + fm.did_open_file(empty_pgm_conf_name, 0, empty_pgm_conf); + fm.did_open_file(empty_proc_grps_name, 0, one_proc_grps); fm.did_open_file(file_loc, 0, R"( LR 1, @@ -120,7 +120,7 @@ TEST(diags_suppress, pgm_supress_limit_changed) lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(file_loc)); parse_all_files(ws); @@ -131,8 +131,8 @@ TEST(diags_suppress, pgm_supress_limit_changed) std::string new_limit_str = R"("diagnosticsSuppressLimit":5,)"; document_change ch(range({ 0, 1 }, { 0, 1 }), new_limit_str.c_str(), new_limit_str.size()); - fm.did_change_file(pgm_conf_name, 1, &ch, 1); - run_if_valid(ws.did_change_file(pgm_conf_name, file_content_state::changed_content)); + fm.did_change_file(empty_pgm_conf_name, 1, &ch, 1); + run_if_valid(ws.did_change_file(empty_pgm_conf_name, file_content_state::changed_content)); parse_all_files(ws); run_if_valid(ws.did_change_file(file_loc, file_content_state::changed_content)); @@ -146,8 +146,8 @@ TEST(diags_suppress, pgm_supress_limit_changed) TEST(diags_suppress, mark_for_parsing_only) { file_manager_impl fm; - fm.did_open_file(pgm_conf_name, 0, empty_pgm_conf); - fm.did_open_file(proc_grps_name, 0, one_proc_grps); + fm.did_open_file(empty_pgm_conf_name, 0, empty_pgm_conf); + fm.did_open_file(empty_proc_grps_name, 0, one_proc_grps); fm.did_open_file(file_loc, 0, R"( LR 1, @@ -161,7 +161,7 @@ TEST(diags_suppress, mark_for_parsing_only) auto config = lib_config::load_from_json(R"({"diagnosticsSuppressLimit":5})"_json); shared_json global_settings = make_empty_shared_json(); - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(file_loc)); // parsing not done yet diff --git a/parser_library/test/workspace/empty_configs.h b/parser_library/test/workspace/empty_configs.h index 1c9762541..2a1faad1f 100644 --- a/parser_library/test/workspace/empty_configs.h +++ b/parser_library/test/workspace/empty_configs.h @@ -17,13 +17,17 @@ #include #include +#include #include "nlohmann/json_fwd.hpp" #include "utils/path.h" #include "utils/resource_location.h" -inline const auto pgm_conf_name = hlasm_plugin::utils::resource::resource_location(".hlasmplugin/pgm_conf.json"); -inline const auto proc_grps_name = hlasm_plugin::utils::resource::resource_location(".hlasmplugin/proc_grps.json"); +constexpr const std::string_view pgm_conf_name(".hlasmplugin/pgm_conf.json"); +constexpr const std::string_view proc_grps_name(".hlasmplugin/proc_grps.json"); +inline const hlasm_plugin::utils::resource::resource_location empty_ws("ews:/"); +inline const hlasm_plugin::utils::resource::resource_location empty_pgm_conf_name("ews:/.hlasmplugin/pgm_conf.json"); +inline const hlasm_plugin::utils::resource::resource_location empty_proc_grps_name("ews:/.hlasmplugin/proc_grps.json"); inline const std::string empty_pgm_conf = R"({ "pgms": []})"; inline const std::string empty_proc_grps = R"({ "pgroups": []})"; diff --git a/parser_library/test/workspace/external_configuration_requests_mock.h b/parser_library/test/workspace/external_configuration_requests_mock.h new file mode 100644 index 000000000..86ebfaf8f --- /dev/null +++ b/parser_library/test/workspace/external_configuration_requests_mock.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023 Broadcom. + * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Broadcom, Inc. - initial API and implementation + */ + +#include +#include + +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include "external_configuration_requests.h" + +namespace { +class external_configuration_requests_mock : public hlasm_plugin::parser_library::external_configuration_requests +{ +public: + MOCK_METHOD(void, + read_external_configuration, + (hlasm_plugin::parser_library::sequence url, + hlasm_plugin::parser_library::workspace_manager_response> + content), + (override)); +}; +} // namespace diff --git a/parser_library/test/workspace/instruction_sets_test.cpp b/parser_library/test/workspace/instruction_sets_test.cpp index 5b8e2993d..385a3e337 100644 --- a/parser_library/test/workspace/instruction_sets_test.cpp +++ b/parser_library/test/workspace/instruction_sets_test.cpp @@ -97,12 +97,11 @@ std::string sam31_macro = R"( MACRO &VAR SETA 2 MEND)"; -const char* sam31_macro_path = is_windows() ? "lib\\SAM31" : "lib/SAM31"; -const std::string hlasmplugin_folder = ".hlasmplugin"; - -const resource_location proc_grps_loc(hlasmplugin_folder + "/proc_grps.json"); -const resource_location pgm_conf_loc(hlasmplugin_folder + "/pgm_conf.json"); -const resource_location source_loc("source"); +const resource_location ws_loc("ws:/"); +const resource_location proc_grps_loc("ws:/.hlasmplugin/proc_grps.json"); +const resource_location pgm_conf_loc("ws:/.hlasmplugin/pgm_conf.json"); +const resource_location source_loc("ws:/source"); +const resource_location sam31_macro_loc("ws:/lib/SAM31"); enum class file_manager_opt_variant { @@ -127,8 +126,6 @@ class file_manager_opt : public file_manager_impl public: file_manager_opt(file_manager_opt_variant variant) { - resource_location sam31_macro_loc(sam31_macro_path); - did_open_file(proc_grps_loc, 1, get_proc_grp(variant)); did_open_file(pgm_conf_loc, 1, pgmconf_file); did_open_file(source_loc, 1, source); @@ -139,10 +136,10 @@ class file_manager_opt : public file_manager_impl const hlasm_plugin::utils::resource::resource_location& location) const override { using hlasm_plugin::utils::value_task; - if (location == resource_location("lib/")) + if (location == resource_location("ws:/lib/")) return value_task::from_value({ { - { "SAM31", resource_location(sam31_macro_path) }, + { "SAM31", sam31_macro_loc }, }, hlasm_plugin::utils::path::list_directory_rc::done, }); @@ -171,7 +168,7 @@ TEST_F(workspace_instruction_sets_test, changed_instr_set_370_Z10) file_manager_opt file_manager(file_manager_opt_variant::optable_370); lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(source_loc)); @@ -190,7 +187,7 @@ TEST_F(workspace_instruction_sets_test, changed_instr_set_Z10_370) file_manager_opt file_manager(file_manager_opt_variant::optable_Z10); lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(source_loc)); diff --git a/parser_library/test/workspace/load_config_test.cpp b/parser_library/test/workspace/load_config_test.cpp index a966d7078..73e86a570 100644 --- a/parser_library/test/workspace/load_config_test.cpp +++ b/parser_library/test/workspace/load_config_test.cpp @@ -187,7 +187,7 @@ TEST(workspace, load_config_synthetic) file_manager_proc_grps_test file_manager; lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(ws_loc, "test_proc_grps_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); @@ -262,12 +262,12 @@ TEST(workspace, load_config_synthetic) TEST(workspace, pgm_conf_malformed) { file_manager_impl fm; - fm.did_open_file(pgm_conf_name, 0, R"({ "pgms": [})"); - fm.did_open_file(proc_grps_name, 0, empty_proc_grps); + fm.did_open_file(empty_pgm_conf_name, 0, R"({ "pgms": [})"); + fm.did_open_file(empty_proc_grps_name, 0, empty_proc_grps); lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); ws.open().run(); ws.collect_diags(); @@ -278,12 +278,12 @@ TEST(workspace, proc_grps_malformed) { file_manager_impl fm; - fm.did_open_file(pgm_conf_name, 0, empty_pgm_conf); - fm.did_open_file(proc_grps_name, 0, R"({ "pgroups" []})"); + fm.did_open_file(empty_pgm_conf_name, 0, empty_pgm_conf); + fm.did_open_file(empty_proc_grps_name, 0, R"({ "pgroups" []})"); lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); ws.open().run(); ws.collect_diags(); @@ -293,11 +293,11 @@ TEST(workspace, proc_grps_malformed) TEST(workspace, pgm_conf_missing) { file_manager_impl fm; - fm.did_open_file(proc_grps_name, 0, empty_proc_grps); + fm.did_open_file(empty_proc_grps_name, 0, empty_proc_grps); lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); ws.open().run(); ws.collect_diags(); @@ -307,11 +307,11 @@ TEST(workspace, pgm_conf_missing) TEST(workspace, proc_grps_missing) { file_manager_impl fm; - fm.did_open_file(pgm_conf_name, 0, empty_pgm_conf); + fm.did_open_file(empty_pgm_conf_name, 0, empty_pgm_conf); lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); ws.open().run(); ws.collect_diags(); @@ -321,7 +321,7 @@ TEST(workspace, proc_grps_missing) TEST(workspace, pgm_conf_noproc_proc_group) { file_manager_impl fm; - fm.did_open_file(pgm_conf_name, 0, R"({ + fm.did_open_file(empty_pgm_conf_name, 0, R"({ "pgms": [ { "program": "temp.hlasm", @@ -329,14 +329,15 @@ TEST(workspace, pgm_conf_noproc_proc_group) } ] })"); - fm.did_open_file(proc_grps_name, 0, empty_proc_grps); - fm.did_open_file(resource_location("temp.hlasm"), 1, ""); + fm.did_open_file(empty_proc_grps_name, 0, empty_proc_grps); + const auto temp_hlasm = resource_location::join(empty_ws, "temp.hlasm"); + fm.did_open_file(temp_hlasm, 1, ""); lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); ws.open().run(); - run_if_valid(ws.did_open_file(resource_location("temp.hlasm"))); + run_if_valid(ws.did_open_file(temp_hlasm)); parse_all_files(ws); ws.collect_diags(); @@ -346,7 +347,7 @@ TEST(workspace, pgm_conf_noproc_proc_group) TEST(workspace, pgm_conf_unknown_proc_group) { file_manager_impl fm; - fm.did_open_file(pgm_conf_name, 0, R"({ + fm.did_open_file(empty_pgm_conf_name, 0, R"({ "pgms": [ { "program": "temp.hlasm", @@ -354,14 +355,15 @@ TEST(workspace, pgm_conf_unknown_proc_group) } ] })"); - fm.did_open_file(proc_grps_name, 0, empty_proc_grps); - fm.did_open_file(resource_location("temp.hlasm"), 1, ""); + fm.did_open_file(empty_proc_grps_name, 0, empty_proc_grps); + const auto temp_hlasm = resource_location::join(empty_ws, "temp.hlasm"); + fm.did_open_file(temp_hlasm, 1, ""); lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); ws.open().run(); - run_if_valid(ws.did_open_file(resource_location("temp.hlasm"))); + run_if_valid(ws.did_open_file(temp_hlasm)); parse_all_files(ws); ws.collect_diags(); @@ -371,8 +373,8 @@ TEST(workspace, pgm_conf_unknown_proc_group) TEST(workspace, missing_proc_group_diags) { file_manager_impl fm; - const auto pgm_conf_ws_loc = resource_location::join(ws_loc, pgm_conf_name.get_uri()); - const auto proc_grps_ws_loc = resource_location::join(ws_loc, proc_grps_name.get_uri()); + const auto pgm_conf_ws_loc = resource_location::join(ws_loc, pgm_conf_name); + const auto proc_grps_ws_loc = resource_location::join(ws_loc, proc_grps_name); const auto pgm1_wildcard_loc = resource_location::join(ws_loc, "pgms/pgm1"); const auto pgm1_different_loc = resource_location::join(ws_loc, "different/pgm1"); fm.did_open_file(pgm_conf_ws_loc, 0, file_pgm_conf_content); @@ -383,7 +385,7 @@ TEST(workspace, missing_proc_group_diags) lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(ws_loc, "test_ws", fm, config, global_settings); + workspace ws(ws_loc, fm, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(pgm1_loc)); parse_all_files(ws); @@ -425,8 +427,8 @@ TEST(workspace, missing_proc_group_diags) TEST(workspace, missing_proc_group_diags_wildcards) { file_manager_impl fm; - const auto pgm_conf_ws_loc = resource_location::join(ws_loc, pgm_conf_name.get_uri()); - const auto proc_grps_ws_loc = resource_location::join(ws_loc, proc_grps_name.get_uri()); + const auto pgm_conf_ws_loc = resource_location::join(ws_loc, pgm_conf_name); + const auto proc_grps_ws_loc = resource_location::join(ws_loc, proc_grps_name); const auto pgm1_wildcard_loc = resource_location::join(ws_loc, "pgms/pgm1"); const auto pgm1_different_loc = resource_location::join(ws_loc, "different/pgm1"); fm.did_open_file( @@ -438,7 +440,7 @@ TEST(workspace, missing_proc_group_diags_wildcards) lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(ws_loc, "test_ws", fm, config, global_settings); + workspace ws(ws_loc, fm, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(pgm1_loc)); parse_all_files(ws); @@ -460,8 +462,8 @@ TEST(workspace, missing_proc_group_diags_wildcards) TEST(workspace, missing_proc_group_diags_wildcards_noproc) { file_manager_impl fm; - const auto pgm_conf_ws_loc = resource_location::join(ws_loc, pgm_conf_name.get_uri()); - const auto proc_grps_ws_loc = resource_location::join(ws_loc, proc_grps_name.get_uri()); + const auto pgm_conf_ws_loc = resource_location::join(ws_loc, pgm_conf_name); + const auto proc_grps_ws_loc = resource_location::join(ws_loc, proc_grps_name); const auto pgm1_wildcard_loc = resource_location::join(ws_loc, "pgms/pgm1"); const auto pgm1_different_loc = resource_location::join(ws_loc, "different/pgm1"); fm.did_open_file(pgm_conf_ws_loc, @@ -474,7 +476,7 @@ TEST(workspace, missing_proc_group_diags_wildcards_noproc) lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(ws_loc, "test_ws", fm, config, global_settings); + workspace ws(ws_loc, fm, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(pgm1_loc)); parse_all_files(ws); @@ -508,12 +510,12 @@ TEST(workspace, asm_options_invalid) ] })"; file_manager_impl fm; - fm.did_open_file(pgm_conf_name, 0, empty_pgm_conf); - fm.did_open_file(proc_grps_name, 0, proc_file); + fm.did_open_file(empty_pgm_conf_name, 0, empty_pgm_conf); + fm.did_open_file(empty_proc_grps_name, 0, proc_file); lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); ws.open().run(); ws.collect_diags(); @@ -549,7 +551,7 @@ TEST(workspace, asm_options_goff_xobject_redefinition) file_manager_asm_test file_manager; lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(ws_loc, "test_proc_grps_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); @@ -561,14 +563,15 @@ TEST(workspace, proc_grps_with_substitutions) { file_manager_impl fm; - fm.did_open_file(pgm_conf_name, 0, empty_pgm_conf); - fm.did_open_file( - proc_grps_name, 0, R"({ "pgroups":[{"name":"a${config:name}b","libs":["${config:lib1}","${config:lib2}"]}]})"); + fm.did_open_file(empty_pgm_conf_name, 0, empty_pgm_conf); + fm.did_open_file(empty_proc_grps_name, + 0, + R"({ "pgroups":[{"name":"a${config:name}b","libs":["${config:lib1}","${config:lib2}"]}]})"); lib_config config; shared_json global_settings = std::make_shared( nlohmann::json::parse(R"({"name":"proc_group","lib1":"library1","lib2":"library2"})")); - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); ws.open().run(); ws.collect_diags(); @@ -580,24 +583,25 @@ TEST(workspace, proc_grps_with_substitutions) ASSERT_EQ(pg.libraries().size(), 2); EXPECT_EQ(dynamic_cast(pg.libraries()[0].get())->get_location(), - resource_location::join(resource_location("library1"), "")); + resource_location::join(empty_ws, "library1/")); EXPECT_EQ(dynamic_cast(pg.libraries()[1].get())->get_location(), - resource_location::join(resource_location("library2"), "")); + resource_location::join(empty_ws, "library2/")); } TEST(workspace, pgm_conf_with_substitutions) { file_manager_impl fm; - fm.did_open_file(pgm_conf_name, + fm.did_open_file(empty_pgm_conf_name, 0, R"({"pgms":[{"program":"test/${config:pgm_mask.0}","pgroup":"P1","asm_options":{"SYSPARM":"${config:sysparm}${config:sysparm}"}}]})"); - fm.did_open_file(proc_grps_name, 0, R"({"pgroups":[{"name": "P1","libs":[]}]})"); + fm.did_open_file(empty_proc_grps_name, 0, R"({"pgroups":[{"name": "P1","libs":[]}]})"); lib_config config; shared_json global_settings = std::make_shared( nlohmann::json::parse(R"({"pgm_mask":["file_name"],"sysparm":"DEBUG"})")); - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); + const auto test_loc = resource_location::join(empty_ws, "test"); ws.open().run(); ws.collect_diags(); @@ -605,7 +609,7 @@ TEST(workspace, pgm_conf_with_substitutions) using hlasm_plugin::utils::resource::resource_location; - const auto& opts = ws.get_asm_options(resource_location::join(resource_location("test"), "file_name")); + const auto& opts = ws.get_asm_options(resource_location::join(test_loc, "file_name")); EXPECT_EQ(opts.sysparm, "DEBUGDEBUG"); } @@ -614,12 +618,12 @@ TEST(workspace, missing_substitutions) { file_manager_impl fm; - fm.did_open_file(pgm_conf_name, 0, R"({"pgms":[{"program":"test/${config:pgm_mask}","pgroup":"P1"}]})"); - fm.did_open_file(proc_grps_name, 0, R"({"pgroups":[{"name":"P1","libs":["${config:lib}"]}]})"); + fm.did_open_file(empty_pgm_conf_name, 0, R"({"pgms":[{"program":"test/${config:pgm_mask}","pgroup":"P1"}]})"); + fm.did_open_file(empty_proc_grps_name, 0, R"({"pgroups":[{"name":"P1","libs":["${config:lib}"]}]})"); lib_config config; shared_json global_settings = std::make_shared(nlohmann::json::object()); - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); ws.open().run(); ws.collect_diags(); @@ -630,15 +634,16 @@ TEST(workspace, refresh_settings) { file_manager_impl fm; - fm.did_open_file(pgm_conf_name, + fm.did_open_file(empty_pgm_conf_name, 0, R"({"pgms":[{"program":"test/${config:pgm_mask.0}","pgroup":"P1","asm_options":{"SYSPARM":"${config:sysparm}${config:sysparm}"}}]})"); - fm.did_open_file(proc_grps_name, 0, R"({"pgroups":[{"name": "P1","libs":[]}]})"); + fm.did_open_file(empty_proc_grps_name, 0, R"({"pgroups":[{"name": "P1","libs":[]}]})"); lib_config config; shared_json global_settings = std::make_shared( nlohmann::json::parse(R"({"pgm_mask":["file_name"],"sysparm":"DEBUG"})")); - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); + const auto test_loc = resource_location::join(empty_ws, "test"); ws.open().run(); ws.collect_diags(); @@ -646,29 +651,27 @@ TEST(workspace, refresh_settings) using hlasm_plugin::utils::resource::resource_location; - EXPECT_EQ( - ws.get_asm_options(resource_location::join(resource_location("test"), "file_name")).sysparm, "DEBUGDEBUG"); + EXPECT_EQ(ws.get_asm_options(resource_location::join(test_loc, "file_name")).sysparm, "DEBUGDEBUG"); EXPECT_FALSE(ws.settings_updated().run().value()); global_settings = std::make_shared( nlohmann::json::parse(R"({"pgm_mask":["different_file"],"sysparm":"RELEASE"})")); EXPECT_TRUE(ws.settings_updated().run().value()); - EXPECT_EQ(ws.get_asm_options(resource_location::join(resource_location("test"), "file_name")).sysparm, ""); - EXPECT_EQ(ws.get_asm_options(resource_location::join(resource_location("test"), "different_file")).sysparm, - "RELEASERELEASE"); + EXPECT_EQ(ws.get_asm_options(resource_location::join(test_loc, "file_name")).sysparm, ""); + EXPECT_EQ(ws.get_asm_options(resource_location::join(test_loc, "different_file")).sysparm, "RELEASERELEASE"); } TEST(workspace, opcode_suggestions) { file_manager_impl fm; - fm.did_open_file(pgm_conf_name, 0, R"({"pgms":[{"program":"pgm","pgroup":"P1"}]})"); - fm.did_open_file(proc_grps_name, 0, R"({"pgroups":[{"name": "P1","libs":[]}]})"); + fm.did_open_file(empty_pgm_conf_name, 0, R"({"pgms":[{"program":"pgm","pgroup":"P1"}]})"); + fm.did_open_file(empty_proc_grps_name, 0, R"({"pgroups":[{"name": "P1","libs":[]}]})"); lib_config config; shared_json global_settings = make_empty_shared_json(); - workspace ws(fm, config, global_settings); + workspace ws(empty_ws, fm, config, global_settings); ws.open().run(); ws.collect_diags(); @@ -677,8 +680,8 @@ TEST(workspace, opcode_suggestions) using hlasm_plugin::utils::resource::resource_location; std::vector> expected { { "LHI", 3 } }; - EXPECT_EQ(ws.make_opcode_suggestion(resource_location("pgm"), "LHIXXX", false), expected); - EXPECT_EQ(ws.make_opcode_suggestion(resource_location("pgm_implicit"), "LHIXXX", false), expected); + EXPECT_EQ(ws.make_opcode_suggestion(resource_location::join(empty_ws, "pgm"), "LHIXXX", false), expected); + EXPECT_EQ(ws.make_opcode_suggestion(resource_location::join(empty_ws, "pgm_implicit"), "LHIXXX", false), expected); } TEST(workspace, lsp_file_not_processed_yet) diff --git a/parser_library/test/workspace/workspace_configuration_test.cpp b/parser_library/test/workspace/workspace_configuration_test.cpp index 26621cadf..2d8afc282 100644 --- a/parser_library/test/workspace/workspace_configuration_test.cpp +++ b/parser_library/test/workspace/workspace_configuration_test.cpp @@ -23,6 +23,7 @@ #include "../common_testing.h" #include "empty_configs.h" #include "external_configuration_requests.h" +#include "external_configuration_requests_mock.h" #include "file_manager_mock.h" #include "utils/resource_location.h" #include "utils/task.h" @@ -106,19 +107,6 @@ TEST(workspace_configuration, refresh_needed_configs) EXPECT_FALSE(cfg.refresh_libraries({ resource_location("test://workspace/something/else") }).run().value()); } -namespace { -class external_configuration_requests_mock : public hlasm_plugin::parser_library::external_configuration_requests -{ -public: - MOCK_METHOD(void, - read_external_configuration, - (hlasm_plugin::parser_library::sequence url, - hlasm_plugin::parser_library::workspace_manager_response> - content), - (override)); -}; -} // namespace - TEST(workspace_configuration, external_configurations_group_name) { NiceMock fm; diff --git a/parser_library/test/workspace/workspace_fade_test.cpp b/parser_library/test/workspace/workspace_fade_test.cpp index c8879c204..c196f75b6 100644 --- a/parser_library/test/workspace/workspace_fade_test.cpp +++ b/parser_library/test/workspace/workspace_fade_test.cpp @@ -36,12 +36,13 @@ using namespace hlasm_plugin::utils::resource; using namespace hlasm_plugin::utils; namespace { -const resource_location src1_loc("src1.hlasm"); -const resource_location src2_loc("src2.hlasm"); -const resource_location pgm_conf_loc(".hlasmplugin/pgm_conf.json"); -const resource_location proc_grps_loc(".hlasmplugin/proc_grps.json"); -const resource_location cpybook_loc("libs/CPYBOOK"); -const resource_location mac_loc("libs/mac"); +const resource_location fade_loc("fade:/"); +const resource_location src1_loc("fade:/src1.hlasm"); +const resource_location src2_loc("fade:/src2.hlasm"); +const resource_location pgm_conf_loc("fade:/.hlasmplugin/pgm_conf.json"); +const resource_location proc_grps_loc("fade:/.hlasmplugin/proc_grps.json"); +const resource_location cpybook_loc("fade:/libs/CPYBOOK"); +const resource_location mac_loc("fade:/libs/mac"); class file_manager_extended : public file_manager_impl { @@ -78,7 +79,7 @@ class fade_fixture_base : public diagnosable_impl, public ::testing::TestWithPar std::vector fms; fade_fixture_base() - : ws(workspace(file_manager, config, global_settings)) + : ws(workspace(fade_loc, file_manager, config, global_settings)) {} void SetUp() override @@ -153,7 +154,7 @@ INSTANTIATE_TEST_SUITE_P(fade, test_params { { "1" }, { - fade_message_s::inactive_statement("src1.hlasm", range(position(3, 0), position(5, 80))), + fade_message_s::inactive_statement("fade:/src1.hlasm", range(position(3, 0), position(5, 80))), }, })); @@ -193,13 +194,13 @@ INSTANTIATE_TEST_SUITE_P(fade, test_params { { " MAC 1" }, { - fade_message_s::inactive_statement("src1.hlasm", range(position(5, 0), position(5, 80))), + fade_message_s::inactive_statement("fade:/src1.hlasm", range(position(5, 0), position(5, 80))), }, }, test_params { { "* MAC 1" }, { - fade_message_s::unused_macro("src1.hlasm", range(position(3, 0), position(3, 80))), + fade_message_s::unused_macro("fade:/src1.hlasm", range(position(3, 0), position(3, 80))), }, })); } // namespace @@ -257,9 +258,9 @@ INSTANTIATE_TEST_SUITE_P(fade, ::testing::Values(test_params { {}, { - fade_message_s::inactive_statement("src1.hlasm", range(position(3, 0), position(3, 80))), - fade_message_s::inactive_statement("src1.hlasm", range(position(5, 0), position(5, 80))), - fade_message_s::inactive_statement("src1.hlasm", range(position(7, 0), position(7, 80))), + fade_message_s::inactive_statement("fade:/src1.hlasm", range(position(3, 0), position(3, 80))), + fade_message_s::inactive_statement("fade:/src1.hlasm", range(position(5, 0), position(5, 80))), + fade_message_s::inactive_statement("fade:/src1.hlasm", range(position(7, 0), position(7, 80))), }, })); } // namespace @@ -301,14 +302,14 @@ INSTANTIATE_TEST_SUITE_P(fade, test_params { { " MAC 1" }, { - fade_message_s::unused_macro("src1.hlasm", range(position(5, 0), position(5, 80))), - fade_message_s::inactive_statement("src1.hlasm", range(position(9, 0), position(9, 80))), + fade_message_s::unused_macro("fade:/src1.hlasm", range(position(5, 0), position(5, 80))), + fade_message_s::inactive_statement("fade:/src1.hlasm", range(position(9, 0), position(9, 80))), }, }, test_params { { "* MAC 1" }, { - fade_message_s::unused_macro("src1.hlasm", range(position(3, 0), position(3, 80))), + fade_message_s::unused_macro("fade:/src1.hlasm", range(position(3, 0), position(3, 80))), }, })); } // namespace @@ -354,7 +355,7 @@ INSTANTIATE_TEST_SUITE_P(fade, INNER)", }, { - fade_message_s::unused_macro("src1.hlasm", range(position(10, 0), position(10, 80))), + fade_message_s::unused_macro("fade:/src1.hlasm", range(position(10, 0), position(10, 80))), }, }, test_params { @@ -364,7 +365,7 @@ INSTANTIATE_TEST_SUITE_P(fade, INNER)", }, { - fade_message_s::unused_macro("src1.hlasm", range(position(2, 0), position(2, 80))), + fade_message_s::unused_macro("fade:/src1.hlasm", range(position(2, 0), position(2, 80))), }, }, test_params { @@ -374,8 +375,8 @@ INSTANTIATE_TEST_SUITE_P(fade, * INNER)", }, { - fade_message_s::unused_macro("src1.hlasm", range(position(4, 0), position(4, 80))), - fade_message_s::unused_macro("src1.hlasm", range(position(10, 0), position(10, 80))), + fade_message_s::unused_macro("fade:/src1.hlasm", range(position(4, 0), position(4, 80))), + fade_message_s::unused_macro("fade:/src1.hlasm", range(position(10, 0), position(10, 80))), }, }, test_params { @@ -385,8 +386,8 @@ INSTANTIATE_TEST_SUITE_P(fade, * INNER)", }, { - fade_message_s::unused_macro("src1.hlasm", range(position(2, 0), position(2, 80))), - fade_message_s::unused_macro("src1.hlasm", range(position(10, 0), position(10, 80))), + fade_message_s::unused_macro("fade:/src1.hlasm", range(position(2, 0), position(2, 80))), + fade_message_s::unused_macro("fade:/src1.hlasm", range(position(10, 0), position(10, 80))), }, })); } // namespace @@ -433,7 +434,7 @@ INSTANTIATE_TEST_SUITE_P(fade, test_params { { " MAC 1" }, { - fade_message_s::inactive_statement("libs/mac", range(position(3, 0), position(3, 80))), + fade_message_s::inactive_statement("fade:/libs/mac", range(position(3, 0), position(3, 80))), }, }, test_params { @@ -488,7 +489,7 @@ INSTANTIATE_TEST_SUITE_P(fade, " MAC 1", }, { - fade_message_s::inactive_statement("libs/mac", range(position(3, 0), position(3, 80))), + fade_message_s::inactive_statement("fade:/libs/mac", range(position(3, 0), position(3, 80))), }, }, test_params { @@ -497,7 +498,7 @@ INSTANTIATE_TEST_SUITE_P(fade, " MAC 0", }, { - fade_message_s::unused_macro("libs/mac", range(position(7, 0), position(7, 80))), + fade_message_s::unused_macro("fade:/libs/mac", range(position(7, 0), position(7, 80))), }, }, test_params { @@ -506,8 +507,8 @@ INSTANTIATE_TEST_SUITE_P(fade, " MAC 1", }, { - fade_message_s::inactive_statement("libs/mac", range(position(3, 0), position(3, 80))), - fade_message_s::unused_macro("libs/mac", range(position(7, 0), position(7, 80))), + fade_message_s::inactive_statement("fade:/libs/mac", range(position(3, 0), position(3, 80))), + fade_message_s::unused_macro("fade:/libs/mac", range(position(7, 0), position(7, 80))), }, }, test_params { @@ -573,8 +574,8 @@ INSTANTIATE_TEST_SUITE_P(fade, "* MAC3 0", }, { - fade_message_s::unused_macro("libs/CPYBOOK", range(position(10, 0), position(10, 80))), - fade_message_s::unused_macro("libs/CPYBOOK", range(position(20, 0), position(20, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(10, 0), position(10, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(20, 0), position(20, 80))), }, }, test_params { @@ -583,9 +584,9 @@ INSTANTIATE_TEST_SUITE_P(fade, "* MAC3 1", }, { - fade_message_s::inactive_statement("libs/CPYBOOK", range(position(3, 0), position(3, 80))), - fade_message_s::unused_macro("libs/CPYBOOK", range(position(10, 0), position(10, 80))), - fade_message_s::unused_macro("libs/CPYBOOK", range(position(20, 0), position(20, 80))), + fade_message_s::inactive_statement("fade:/libs/CPYBOOK", range(position(3, 0), position(3, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(10, 0), position(10, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(20, 0), position(20, 80))), }, }, test_params { @@ -594,8 +595,8 @@ INSTANTIATE_TEST_SUITE_P(fade, " MAC3 0", }, { - fade_message_s::unused_macro("libs/CPYBOOK", range(position(1, 0), position(1, 80))), - fade_message_s::unused_macro("libs/CPYBOOK", range(position(10, 0), position(10, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(1, 0), position(1, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(10, 0), position(10, 80))), }, }, test_params { @@ -604,9 +605,9 @@ INSTANTIATE_TEST_SUITE_P(fade, " MAC3 1", }, { - fade_message_s::unused_macro("libs/CPYBOOK", range(position(1, 0), position(1, 80))), - fade_message_s::unused_macro("libs/CPYBOOK", range(position(10, 0), position(10, 80))), - fade_message_s::inactive_statement("libs/CPYBOOK", range(position(22, 0), position(22, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(1, 0), position(1, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(10, 0), position(10, 80))), + fade_message_s::inactive_statement("fade:/libs/CPYBOOK", range(position(22, 0), position(22, 80))), }, }, test_params { @@ -615,7 +616,7 @@ INSTANTIATE_TEST_SUITE_P(fade, " MAC3 0", }, { - fade_message_s::unused_macro("libs/CPYBOOK", range(position(10, 0), position(10, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(10, 0), position(10, 80))), }, }, test_params { @@ -624,8 +625,8 @@ INSTANTIATE_TEST_SUITE_P(fade, " MAC3 0", }, { - fade_message_s::inactive_statement("libs/CPYBOOK", range(position(3, 0), position(3, 80))), - fade_message_s::unused_macro("libs/CPYBOOK", range(position(10, 0), position(10, 80))), + fade_message_s::inactive_statement("fade:/libs/CPYBOOK", range(position(3, 0), position(3, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(10, 0), position(10, 80))), }, }, test_params { @@ -634,8 +635,8 @@ INSTANTIATE_TEST_SUITE_P(fade, " MAC3 1", }, { - fade_message_s::unused_macro("libs/CPYBOOK", range(position(10, 0), position(10, 80))), - fade_message_s::inactive_statement("libs/CPYBOOK", range(position(22, 0), position(22, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(10, 0), position(10, 80))), + fade_message_s::inactive_statement("fade:/libs/CPYBOOK", range(position(22, 0), position(22, 80))), }, }, test_params { @@ -644,9 +645,9 @@ INSTANTIATE_TEST_SUITE_P(fade, " MAC3 1", }, { - fade_message_s::inactive_statement("libs/CPYBOOK", range(position(3, 0), position(3, 80))), - fade_message_s::unused_macro("libs/CPYBOOK", range(position(10, 0), position(10, 80))), - fade_message_s::inactive_statement("libs/CPYBOOK", range(position(22, 0), position(22, 80))), + fade_message_s::inactive_statement("fade:/libs/CPYBOOK", range(position(3, 0), position(3, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(10, 0), position(10, 80))), + fade_message_s::inactive_statement("fade:/libs/CPYBOOK", range(position(22, 0), position(22, 80))), }, }, test_params { @@ -655,8 +656,8 @@ INSTANTIATE_TEST_SUITE_P(fade, " MAC3 0", }, { - fade_message_s::unused_macro("libs/CPYBOOK", range(position(1, 0), position(1, 80))), - fade_message_s::unused_macro("libs/CPYBOOK", range(position(10, 0), position(10, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(1, 0), position(1, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(10, 0), position(10, 80))), }, }, test_params { @@ -665,8 +666,8 @@ INSTANTIATE_TEST_SUITE_P(fade, " MAC3 0", }, { - fade_message_s::unused_macro("libs/CPYBOOK", range(position(1, 0), position(1, 80))), - fade_message_s::unused_macro("libs/CPYBOOK", range(position(10, 0), position(10, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(1, 0), position(1, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(10, 0), position(10, 80))), }, }, test_params { @@ -675,8 +676,8 @@ INSTANTIATE_TEST_SUITE_P(fade, " MAC3 1", }, { - fade_message_s::unused_macro("libs/CPYBOOK", range(position(1, 0), position(1, 80))), - fade_message_s::unused_macro("libs/CPYBOOK", range(position(10, 0), position(10, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(1, 0), position(1, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(10, 0), position(10, 80))), }, }, test_params { @@ -685,9 +686,9 @@ INSTANTIATE_TEST_SUITE_P(fade, " MAC3 1", }, { - fade_message_s::unused_macro("libs/CPYBOOK", range(position(1, 0), position(1, 80))), - fade_message_s::unused_macro("libs/CPYBOOK", range(position(10, 0), position(10, 80))), - fade_message_s::inactive_statement("libs/CPYBOOK", range(position(22, 0), position(22, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(1, 0), position(1, 80))), + fade_message_s::unused_macro("fade:/libs/CPYBOOK", range(position(10, 0), position(10, 80))), + fade_message_s::inactive_statement("fade:/libs/CPYBOOK", range(position(22, 0), position(22, 80))), }, })); } // namespace @@ -759,7 +760,7 @@ INSTANTIATE_TEST_SUITE_P(fade, }, test_params { { "1", "1" }, - { fade_message_s::inactive_statement("libs/CPYBOOK", range(position(2, 0), position(2, 80))) }, + { fade_message_s::inactive_statement("fade:/libs/CPYBOOK", range(position(2, 0), position(2, 80))) }, })); } // namespace @@ -800,22 +801,22 @@ INSTANTIATE_TEST_SUITE_P(fade, test_params { { " MAC 0,1" }, { - fade_message_s::inactive_statement("libs/CPYBOOK", range(position(2, 0), position(2, 80))), - fade_message_s::inactive_statement("libs/mac", range(position(4, 0), position(4, 80))), + fade_message_s::inactive_statement("fade:/libs/CPYBOOK", range(position(2, 0), position(2, 80))), + fade_message_s::inactive_statement("fade:/libs/mac", range(position(4, 0), position(4, 80))), }, }, test_params { { " MAC 1,0" }, { - fade_message_s::inactive_statement("libs/CPYBOOK", range(position(1, 0), position(2, 80))), - fade_message_s::inactive_statement("libs/mac", range(position(3, 0), position(3, 80))), + fade_message_s::inactive_statement("fade:/libs/CPYBOOK", range(position(1, 0), position(2, 80))), + fade_message_s::inactive_statement("fade:/libs/mac", range(position(3, 0), position(3, 80))), }, }, test_params { { " MAC 1,1" }, { - fade_message_s::inactive_statement("libs/CPYBOOK", range(position(1, 0), position(2, 80))), - fade_message_s::inactive_statement("libs/mac", range(position(3, 0), position(3, 80))), + fade_message_s::inactive_statement("fade:/libs/CPYBOOK", range(position(1, 0), position(2, 80))), + fade_message_s::inactive_statement("fade:/libs/mac", range(position(3, 0), position(3, 80))), }, }, test_params { @@ -944,15 +945,15 @@ INSTANTIATE_TEST_SUITE_P(fade, test_params { { "0" }, { - fade_message_s::inactive_statement("src1.hlasm", range(position(4, 0), position(4, 80))), - fade_message_s::inactive_statement("src1.hlasm", range(position(6, 0), position(6, 80))), + fade_message_s::inactive_statement("fade:/src1.hlasm", range(position(4, 0), position(4, 80))), + fade_message_s::inactive_statement("fade:/src1.hlasm", range(position(6, 0), position(6, 80))), }, }, test_params { { "1" }, { - fade_message_s::inactive_statement("src1.hlasm", range(position(4, 0), position(4, 80))), - fade_message_s::inactive_statement("libs/mac", range(position(4, 0), position(5, 80))), + fade_message_s::inactive_statement("fade:/src1.hlasm", range(position(4, 0), position(4, 80))), + fade_message_s::inactive_statement("fade:/libs/mac", range(position(4, 0), position(5, 80))), }, })); } // namespace @@ -999,7 +1000,7 @@ INSTANTIATE_TEST_SUITE_P(fade, ::testing::Values(test_params { {}, { - fade_message_s::inactive_statement("src1.hlasm", range(position(17, 0), position(17, 80))), + fade_message_s::inactive_statement("fade:/src1.hlasm", range(position(17, 0), position(17, 80))), }, })); } // namespace @@ -1174,16 +1175,16 @@ class fade_helper file_manager_impl_test m_fm; const lib_config m_empty_config; const shared_json m_global_settings = make_empty_shared_json(); - workspace ws = workspace(m_fm, m_empty_config, m_global_settings); + workspace ws = workspace(resource_location("fade:/"), m_fm, m_empty_config, m_global_settings); std::vector m_fmsgs; }; } // namespace TEST(fade, cpybook_as_pgm) { - static const resource_location srcA_loc("A.hlasm"); - static const resource_location srcB_loc("B.hlasm"); - static const resource_location srcC_loc("C.hlasm"); + static const resource_location srcA_loc("fade:/A.hlasm"); + static const resource_location srcB_loc("fade:/B.hlasm"); + static const resource_location srcC_loc("fade:/C.hlasm"); fade_helper fh(std::vector({ fade_helper::files_details { srcA_loc, false, workspaces::file_content_state::changed_content }, @@ -1193,41 +1194,41 @@ TEST(fade, cpybook_as_pgm) EXPECT_TRUE(matches_fade_messages(fh.fade_messages(), std::vector({ - fade_message_s::inactive_statement("C.hlasm", range(position(3, 0), position(3, 80))), - fade_message_s::inactive_statement("C.hlasm", range(position(8, 0), position(8, 80))), - fade_message_s::inactive_statement("C.hlasm", range(position(15, 0), position(15, 80))), + fade_message_s::inactive_statement("fade:/C.hlasm", range(position(3, 0), position(3, 80))), + fade_message_s::inactive_statement("fade:/C.hlasm", range(position(8, 0), position(8, 80))), + fade_message_s::inactive_statement("fade:/C.hlasm", range(position(15, 0), position(15, 80))), }))); // Toggle open and close of a file a few times fh.did_close_file(srcA_loc); EXPECT_TRUE(matches_fade_messages(fh.fade_messages(), std::vector({ - fade_message_s::inactive_statement("C.hlasm", range(position(3, 0), position(3, 80))), - fade_message_s::inactive_statement("C.hlasm", range(position(8, 0), position(11, 80))), - fade_message_s::inactive_statement("C.hlasm", range(position(15, 0), position(15, 80))), + fade_message_s::inactive_statement("fade:/C.hlasm", range(position(3, 0), position(3, 80))), + fade_message_s::inactive_statement("fade:/C.hlasm", range(position(8, 0), position(11, 80))), + fade_message_s::inactive_statement("fade:/C.hlasm", range(position(15, 0), position(15, 80))), }))); fh.did_open_file(srcA_loc); EXPECT_TRUE(matches_fade_messages(fh.fade_messages(), std::vector({ - fade_message_s::inactive_statement("C.hlasm", range(position(3, 0), position(3, 80))), - fade_message_s::inactive_statement("C.hlasm", range(position(8, 0), position(8, 80))), - fade_message_s::inactive_statement("C.hlasm", range(position(15, 0), position(15, 80))), + fade_message_s::inactive_statement("fade:/C.hlasm", range(position(3, 0), position(3, 80))), + fade_message_s::inactive_statement("fade:/C.hlasm", range(position(8, 0), position(8, 80))), + fade_message_s::inactive_statement("fade:/C.hlasm", range(position(15, 0), position(15, 80))), }))); fh.did_close_file(srcA_loc); EXPECT_TRUE(matches_fade_messages(fh.fade_messages(), std::vector({ - fade_message_s::inactive_statement("C.hlasm", range(position(3, 0), position(3, 80))), - fade_message_s::inactive_statement("C.hlasm", range(position(8, 0), position(11, 80))), - fade_message_s::inactive_statement("C.hlasm", range(position(15, 0), position(15, 80))), + fade_message_s::inactive_statement("fade:/C.hlasm", range(position(3, 0), position(3, 80))), + fade_message_s::inactive_statement("fade:/C.hlasm", range(position(8, 0), position(11, 80))), + fade_message_s::inactive_statement("fade:/C.hlasm", range(position(15, 0), position(15, 80))), }))); fh.did_close_file(srcB_loc); EXPECT_TRUE(matches_fade_messages(fh.fade_messages(), std::vector({ - fade_message_s::inactive_statement("C.hlasm", range(position(3, 0), position(3, 80))), - fade_message_s::inactive_statement("C.hlasm", range(position(8, 0), position(15, 80))), + fade_message_s::inactive_statement("fade:/C.hlasm", range(position(3, 0), position(3, 80))), + fade_message_s::inactive_statement("fade:/C.hlasm", range(position(8, 0), position(15, 80))), }))); fh.did_close_file(srcC_loc); diff --git a/parser_library/test/workspace/workspace_pattern_test.cpp b/parser_library/test/workspace/workspace_pattern_test.cpp index b45c65676..f6a2cbf22 100644 --- a/parser_library/test/workspace/workspace_pattern_test.cpp +++ b/parser_library/test/workspace/workspace_pattern_test.cpp @@ -459,7 +459,7 @@ struct test_variables_lib_pattern : file_manager(pgroup_variant, pgmconf_variant) , config() , global_settings(make_empty_shared_json()) - , ws(ws_loc, "workspace_name", file_manager, config, global_settings) + , ws(ws_loc, file_manager, config, global_settings) { ws.open().run(); }; @@ -930,7 +930,7 @@ void verify_infinit_loop(pgroup_symlinks_variants pgroup_variant, pgmconf_varian co_return { {}, hlasm_plugin::utils::path::list_directory_rc::done }; })); - workspace ws(ws_loc, "workspace_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(pattern_test_source_loc)); parse_all_files(ws); diff --git a/parser_library/test/workspace/workspace_test.cpp b/parser_library/test/workspace/workspace_test.cpp index 5f20c296c..07c35a0a4 100644 --- a/parser_library/test/workspace/workspace_test.cpp +++ b/parser_library/test/workspace/workspace_test.cpp @@ -19,6 +19,7 @@ #include "../common_testing.h" #include "empty_configs.h" +#include "external_configuration_requests_mock.h" #include "external_file_reader_mock.h" #include "utils/path.h" #include "utils/platform.h" @@ -248,20 +249,19 @@ std::string source_using_macro_file_no_error = R"( CORRECT)"; std::string source_using_macro_with_dep = R"( CORDEP)"; -const std::string hlasmplugin_folder = ".hlasmplugin"; - -const resource_location empty_loc = resource_location(""); - -const resource_location proc_grps_loc(hlasmplugin_folder + "/proc_grps.json"); -const resource_location pgm_conf_loc(hlasmplugin_folder + "/pgm_conf.json"); -const resource_location source1_loc("source1"); -const resource_location source2_loc("source2"); -const resource_location source3_loc("source3"); -const resource_location source4_loc("source4"); -const resource_location faulty_macro_loc("lib/ERROR"); -const resource_location correct_macro_loc("lib/CORRECT"); -const resource_location cordep_macro_loc("lib/CORDEP"); -const resource_location dep_macro_loc("lib/DEP"); +const resource_location ws_loc("ws:/"); +const resource_location lib_loc("ws:/lib/"); + +const resource_location proc_grps_loc("ws:/.hlasmplugin/proc_grps.json"); +const resource_location pgm_conf_loc("ws:/.hlasmplugin/pgm_conf.json"); +const resource_location source1_loc("ws:/source1"); +const resource_location source2_loc("ws:/source2"); +const resource_location source3_loc("ws:/source3"); +const resource_location source4_loc("ws:/source4"); +const resource_location faulty_macro_loc("ws:/lib/ERROR"); +const resource_location correct_macro_loc("ws:/lib/CORRECT"); +const resource_location cordep_macro_loc("ws:/lib/CORDEP"); +const resource_location dep_macro_loc("ws:/lib/DEP"); } // namespace class file_manager_extended : public file_manager_impl, public external_file_reader @@ -379,7 +379,7 @@ class file_manager_opt : public file_manager_impl hlasm_plugin::utils::value_task list_directory_files( const hlasm_plugin::utils::resource::resource_location& location) const override { - if (location == resource_location("lib/")) + if (location == lib_loc) return hlasm_plugin::utils::value_task::from_value({ { { "CORRECT", correct_macro_loc }, @@ -398,7 +398,7 @@ class file_manager_opt : public file_manager_impl TEST_F(workspace_test, did_close_file) { file_manager_extended file_manager; - workspace ws(empty_loc, "workspace_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); // 3 files are open @@ -444,7 +444,7 @@ TEST_F(workspace_test, did_close_file) TEST_F(workspace_test, did_close_file_without_save) { file_manager_extended file_manager; - workspace ws(empty_loc, "workspace_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); @@ -476,7 +476,7 @@ TEST_F(workspace_test, did_close_file_without_save) TEST_F(workspace_test, did_change_watched_files) { file_manager_extended file_manager; - workspace ws(empty_loc, "workspace_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(source3_loc)); @@ -499,7 +499,7 @@ TEST_F(workspace_test, did_change_watched_files) TEST_F(workspace_test, did_change_watched_files_not_opened_file) { file_manager_extended file_manager; - workspace ws(empty_loc, "workspace_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(source3_loc)); @@ -514,7 +514,7 @@ TEST_F(workspace_test, did_change_watched_files_not_opened_file) TEST_F(workspace_test, diagnostics_recollection) { file_manager_opt file_manager(file_manager_opt_variant::required); - workspace ws(empty_loc, "workspace_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(source1_loc)); @@ -535,7 +535,7 @@ TEST_F(workspace_test, missing_library_required) file_manager_opt_variant::required }) { file_manager_opt file_manager(type); - workspace ws(empty_loc, "workspace_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(source1_loc)); @@ -548,7 +548,7 @@ TEST_F(workspace_test, missing_library_required) TEST_F(workspace_test, missing_library_optional) { file_manager_opt file_manager(file_manager_opt_variant::optional); - workspace ws(empty_loc, "workspace_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(source1_loc)); @@ -559,7 +559,7 @@ TEST_F(workspace_test, missing_library_optional) TEST_F(workspace_test, invalid_assembler_options) { file_manager_opt file_manager(file_manager_opt_variant::invalid_assembler_options); - workspace ws(empty_loc, "workspace_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); EXPECT_GE(collect_and_get_diags_size(ws), (size_t)1); @@ -569,7 +569,7 @@ TEST_F(workspace_test, invalid_assembler_options) TEST_F(workspace_test, invalid_assembler_options_in_pgm_conf) { file_manager_opt file_manager(file_manager_opt_variant::invalid_assembler_options_in_pgm_conf); - workspace ws(empty_loc, "workspace_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); EXPECT_GE(collect_and_get_diags_size(ws), (size_t)1); @@ -579,7 +579,7 @@ TEST_F(workspace_test, invalid_assembler_options_in_pgm_conf) TEST_F(workspace_test, invalid_preprocessor_options) { file_manager_opt file_manager(file_manager_opt_variant::invalid_preprocessor_options); - workspace ws(empty_loc, "workspace_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); EXPECT_GE(collect_and_get_diags_size(ws), (size_t)1); @@ -596,7 +596,7 @@ class file_manager_list_dir_failed : public file_manager_opt hlasm_plugin::utils::value_task list_directory_files( const hlasm_plugin::utils::resource::resource_location& location) const override { - if (location == resource_location("lib/")) + if (location == lib_loc) return hlasm_plugin::utils::value_task::from_value({ {}, hlasm_plugin::utils::path::list_directory_rc::other_failure, @@ -612,7 +612,7 @@ class file_manager_list_dir_failed : public file_manager_opt TEST_F(workspace_test, library_list_failure) { file_manager_list_dir_failed file_manager; - workspace ws(empty_loc, "workspace_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(source1_loc)); @@ -624,7 +624,7 @@ TEST_F(workspace_test, library_list_failure) TEST_F(workspace_test, did_change_watched_files_added_missing) { file_manager_extended file_manager; - workspace ws(empty_loc, "workspace_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); file_manager.insert_correct_macro = false; @@ -662,10 +662,11 @@ TEST_F(workspace_test, use_external_library) })"); fm.did_open_file(source1_loc, 1, ""); - workspace ws(empty_loc, "workspace_name", fm, config, global_settings); + workspace ws(ws_loc, fm, config, global_settings); ws.open().run(); - EXPECT_CALL(external_files, list_directory_files(resource_location("hlasm-external:///DATASET/REMOTE.DATASET"))) + EXPECT_CALL( + external_files, list_directory_files(resource_location("hlasm-external://hhhddkcp/DATASET/REMOTE.DATASET"))) .WillOnce(Invoke([]() { return value_task::from_value({ {}, path::list_directory_rc::done }); })); @@ -680,7 +681,7 @@ TEST_F(workspace_test, track_nested_dependencies) { file_manager_extended file_manager; config.diag_supress_limit = 0; - workspace ws(empty_loc, "workspace_name", file_manager, config, global_settings); + workspace ws(ws_loc, file_manager, config, global_settings); ws.open().run(); run_if_valid(ws.did_open_file(source4_loc));