Skip to content

Commit

Permalink
configuration/main: Set content hash filename for bash in a single place
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonKagstrom committed Jul 9, 2024
1 parent 0f11044 commit c3f7618
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
23 changes: 18 additions & 5 deletions src/configuration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -493,11 +493,26 @@ class Configuration : public IConfiguration
setKey("binary-path", tmp.first);
binaryName = tmp.second;

setKey("binary-name", binaryName);

if (!keyAsInt("cobertura-only"))
{
setKey("target-directory",
fmt("%s/%s.%08zx", outDirectory.c_str(), binaryName.c_str(),
(size_t)hash_file(get_real_path(binaryPath))));
IFileParser *parser = IParserManager::getInstance().matchParser(binaryPath);

if (parser && (parser->getParserType() == "bash" ||
parser->getParserType() == "python"))
{
// Use the path as the hash for non-compiled languages
setKey("target-directory",
fmt("%s/%s.%08zx", keyAsString("out-directory").c_str(), keyAsString("binary-name").c_str(),
std::hash<std::string>()(keyAsString("binary-name").c_str())));
}
else
{
setKey("target-directory",
fmt("%s/%s.%08zx", outDirectory.c_str(), binaryName.c_str(),
(size_t)hash_file(get_real_path(binaryPath))));
}
}
else
{
Expand All @@ -511,8 +526,6 @@ class Configuration : public IConfiguration
return usage();
}

setKey("binary-name", binaryName);

if (keyAsString("command-name") == "")
setKey("command-name", binaryName);
}
Expand Down
10 changes: 0 additions & 10 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,6 @@ static int runKcov(IConfiguration::RunMode_t runningMode)
return 1;
}

if ((parser->getParserType() == "bash" ||
parser->getParserType() == "python") &&
!conf.keyAsInt("cobertura-only"))
{
// Use the path as the hash for non-compiled languages
conf.setKey("target-directory",
fmt("%s/%s.%08zx", conf.keyAsString("out-directory").c_str(), conf.keyAsString("binary-name").c_str(),
std::hash<std::string>()(conf.keyAsString("binary-name").c_str())));
}

// Match and create an engine
IEngineFactory::IEngineCreator &engineCreator =
IEngineFactory::getInstance().matchEngine(file);
Expand Down

0 comments on commit c3f7618

Please sign in to comment.