Add unit tests for rc parsing.
These provide some testing for the following cases:
- tokenization
- recognizing comments
- grouping of different lines by command
- import ordering
- import cycles
- bad imports
There's still room for more, in particular in the multi-command case, but this feels like a good start.
Also identified some surprising behaviors that should be fixed. Leaving them tested as documentation of their broken nature.
RELNOTES: None.
PiperOrigin-RevId: 188355929
diff --git a/src/main/cpp/rc_file.cc b/src/main/cpp/rc_file.cc
index bacfd5c..30e56b3 100644
--- a/src/main/cpp/rc_file.cc
+++ b/src/main/cpp/rc_file.cc
@@ -110,6 +110,7 @@
for (const string& imported_rc : *import_stack) {
loop += " " + imported_rc + "\n";
}
+ loop += " " + words[1] + "\n"; // Include the loop.
blaze_util::StringPrintf(error_text,
"Import loop detected:\n%s", loop.c_str());
return ParseError::IMPORT_LOOP;