Skip to content

Commit

Permalink
[wip] multifile test
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Bylicki <[email protected]>
  • Loading branch information
jbylicki committed Jun 20, 2023
1 parent dbdcbba commit 1356df9
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions verilog/tools/ls/verilog-language-server_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,8 @@ TEST_F(VerilogLanguageServerSymbolTableTest, RenameTestSymbolSingleFile) {
EXPECT_EQ(diagnostics["method"], "textDocument/publishDiagnostics")
<< "textDocument/publishDiagnostics not received";

EXPECT_EQ(diagnostics["params"]["uri"], PathToLSPUri(verible::lsp::LSPUriToPath(file_uri)))
<< "Diagnostics for invalid file";
EXPECT_EQ(diagnostics["params"]["diagnostics"].size(), 0)
<< "The test file has errors";
std::string request = RenameRequest(params);
Expand All @@ -1553,6 +1555,60 @@ TEST_F(VerilogLanguageServerSymbolTableTest, RenameTestSymbolSingleFile) {
<< "Invalid result size for id: ";
}

TEST_F(VerilogLanguageServerSymbolTableTest, RenameTestSymbolMultipleFiles) {
// Create sample file and make sure diagnostics do not have errors
std::string file_uri =
PathToLSPUri(absl::string_view(root_dir + "/top.sv"));
verible::lsp::RenameParams params;
params.position.line = 2;
params.position.character = 10;
params.textDocument.uri = file_uri;
params.newName = "foobaz";
std::string foosv =
"package foo;\n"
" class foobar;\n"
" endclass;\n"
"endpackage;\n";
std::string topsv =
"import foo::*;\n"
"module top;\n"
" foo::foobar bar;\n"
"endmodule;\n";
absl::string_view filelist_content = "foo.sv\ntop.sv\n";

const verible::file::testing::ScopedTestFile filelist(
root_dir, filelist_content, "verible.filelist");
const verible::file::testing::ScopedTestFile module_foo(root_dir, foosv,
"foo.sv");

const verible::file::testing::ScopedTestFile module_top(root_dir, topsv,
"top.sv");
const std::string foo_request=
DidOpenRequest("file://" + module_foo.filename(), foosv);
ASSERT_OK(SendRequest(foo_request));
const std::string top_request=
DidOpenRequest("file://" + module_top.filename(), topsv);
ASSERT_OK(SendRequest(foo_request));

const json diagnostics = json::parse(GetResponse());
EXPECT_EQ(diagnostics["method"], "textDocument/publishDiagnostics")
<< "textDocument/publishDiagnostics not received";
EXPECT_EQ(diagnostics["params"]["uri"], PathToLSPUri(verible::lsp::LSPUriToPath(file_uri)))
<< "Diagnostics for invalid file";

// Complaints about package and file names
EXPECT_EQ(diagnostics["params"]["diagnostics"].size(), 0)
<< "The test file has errors";
std::string request = RenameRequest(params);
ASSERT_OK(SendRequest(request));

const json response = json::parse(GetResponse());
EXPECT_EQ(response["result"]["changes"].size(), 1)
<< "Invalid result size for id: ";
EXPECT_EQ(response["result"]["changes"][file_uri].size(), 2)
<< "Invalid result size for id: ";
}

TEST_F(VerilogLanguageServerSymbolTableTest, RenameTestPackageDistinction) {
// Create sample file and make sure diagnostics do not have errors
std::string file_uri =
Expand Down Expand Up @@ -1587,6 +1643,8 @@ TEST_F(VerilogLanguageServerSymbolTableTest, RenameTestPackageDistinction) {
const json diagnostics = json::parse(GetResponse());
EXPECT_EQ(diagnostics["method"], "textDocument/publishDiagnostics")
<< "textDocument/publishDiagnostics not received";
EXPECT_EQ(diagnostics["params"]["uri"], PathToLSPUri(verible::lsp::LSPUriToPath(file_uri)))
<< "Diagnostics for invalid file";

// Complaints about package and file names
EXPECT_EQ(diagnostics["params"]["diagnostics"].size(), 2)
Expand Down

0 comments on commit 1356df9

Please sign in to comment.