mirror of
https://github.com/NixOS/nix
synced 2025-06-25 10:41:16 +02:00
Merge pull request #12989 from NixOS/mergify/bp/2.28-maintenance/pr-12986
Fix another machine config parsing bug (backport #12986)
This commit is contained in:
commit
4d990f1459
2 changed files with 19 additions and 4 deletions
|
@ -85,6 +85,20 @@ TEST(machines, getMachinesWithCommentsAndSemicolonSeparator) {
|
||||||
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, AuthorityMatches("nix@scabby.labs.cs.uu.nl"))));
|
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, AuthorityMatches("nix@scabby.labs.cs.uu.nl"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(machines, getMachinesWithFunnyWhitespace) {
|
||||||
|
auto actual = Machine::parseConfig({},
|
||||||
|
" # commment ; comment\n"
|
||||||
|
" nix@scratchy.labs.cs.uu.nl ; nix@itchy.labs.cs.uu.nl \n"
|
||||||
|
"\n \n"
|
||||||
|
"\n ;;; \n"
|
||||||
|
"\n ; ; \n"
|
||||||
|
"nix@scabby.labs.cs.uu.nl\n\n");
|
||||||
|
EXPECT_THAT(actual, SizeIs(3));
|
||||||
|
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, AuthorityMatches("nix@scratchy.labs.cs.uu.nl"))));
|
||||||
|
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, AuthorityMatches("nix@itchy.labs.cs.uu.nl"))));
|
||||||
|
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, AuthorityMatches("nix@scabby.labs.cs.uu.nl"))));
|
||||||
|
}
|
||||||
|
|
||||||
TEST(machines, getMachinesWithCorrectCompleteSingleBuilder) {
|
TEST(machines, getMachinesWithCorrectCompleteSingleBuilder) {
|
||||||
auto actual = Machine::parseConfig({},
|
auto actual = Machine::parseConfig({},
|
||||||
"nix@scratchy.labs.cs.uu.nl i686-linux "
|
"nix@scratchy.labs.cs.uu.nl i686-linux "
|
||||||
|
|
|
@ -106,13 +106,14 @@ static std::vector<std::string> expandBuilderLines(const std::string & builders)
|
||||||
{
|
{
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto line : tokenizeString<std::vector<std::string>>(builders, "\n")) {
|
for (auto line : tokenizeString<std::vector<std::string>>(builders, "\n")) {
|
||||||
trim(line);
|
|
||||||
line.erase(std::find(line.begin(), line.end(), '#'), line.end());
|
line.erase(std::find(line.begin(), line.end(), '#'), line.end());
|
||||||
for (auto entry : tokenizeString<std::vector<std::string>>(line, ";")) {
|
for (auto entry : tokenizeString<std::vector<std::string>>(line, ";")) {
|
||||||
if (entry.empty()) continue;
|
entry = trim(entry);
|
||||||
|
|
||||||
if (entry[0] == '@') {
|
if (entry.empty()) {
|
||||||
const std::string path = trim(std::string(entry, 1));
|
// skip blank entries
|
||||||
|
} else if (entry[0] == '@') {
|
||||||
|
const std::string path = trim(std::string_view{entry}.substr(1));
|
||||||
std::string text;
|
std::string text;
|
||||||
try {
|
try {
|
||||||
text = readFile(path);
|
text = readFile(path);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue