tazel
A build system for C, C++, Objective-C, Objective-C++ and Zig, with C# project files.
Clonegit clone https://git.progmasoft.com/tazel
Say that the last entry of a text file may leave out its ';'
- Commit
ade3323ddc4bd3d92b2d3e20ef55d4e7b9cdd37f- Author
- Leitwolf11 ·
- Parents
7e00e97f8526
Changes
src/Progmasoft.Tazel/Output/ErrorCodes.cs | 9 +++++---- tests/Progmasoft.Tazel.Tests/DiagnosticTests.cs | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Progmasoft.Tazel/Output/ErrorCodes.cs b/src/Progmasoft.Tazel/Output/ErrorCodes.cs index 8453641..cb5268d 100644 --- a/src/Progmasoft.Tazel/Output/ErrorCodes.cs +++ b/src/Progmasoft.Tazel/Output/ErrorCodes.cs @@ -164,8 +164,9 @@ internal static partial class ErrorCodes new(CustomTooManyArguments, "a command whose arguments do not fit", "The words of a name and the arguments it needs share nine places on the command line.", null, null, Custom), new(CustomNoSemicolon, "a command without its ';'", - "Every command ends with ';', the last one too.", - "build: (\"tazel\" \"build\" \"//...\")", "build: (\"tazel\" \"build\" \"//...\");", Custom), + "Every command ends with ';'; only the last one of the file may leave it out.", + "build: (\"tazel\" \"build\" \"//...\")\ntest: (\"tazel\" \"test\" \"//...\");", + "build: (\"tazel\" \"build\" \"//...\");\ntest: (\"tazel\" \"test\" \"//...\");", Custom), new(CustomNoColon, "a command without its ':'", "The name of a command and its steps are joined by ':'.", "build (\"tazel\" \"build\");", "build: (\"tazel\" \"build\");", Custom), @@ -208,8 +209,8 @@ internal static partial class ErrorCodes "Every entry is name: value; and the value is missing.", "example-version:", "example-version: '0.1.0';", Envs), new(EnvsNoSemicolon, "a value without its ';'", - "Every value of tazel_envs.txt ends with ';', the last one too.", - "example-version: '0.1.0'", "example-version: '0.1.0';", Envs), + "Every value of tazel_envs.txt ends with ';'; only the last one of the file may leave it out.", + "example-version: '0.1.0'\nexample-name: 'demo';", "example-version: '0.1.0';\nexample-name: 'demo';", Envs), new(EnvsNoColon, "a name without its ':'", "A name and its value are joined by ':'.", "example-version '0.1.0';", "example-version: '0.1.0';", Envs), diff --git a/tests/Progmasoft.Tazel.Tests/DiagnosticTests.cs b/tests/Progmasoft.Tazel.Tests/DiagnosticTests.cs index 5a0c3c4..dcbe895 100644 --- a/tests/Progmasoft.Tazel.Tests/DiagnosticTests.cs +++ b/tests/Progmasoft.Tazel.Tests/DiagnosticTests.cs @@ -174,6 +174,23 @@ public sealed class DiagnosticTests Assert.Contains(message, error.Message, StringComparison.Ordinal); } + [Theory] + [InlineData(ErrorCodes.OptionsNoSemicolon, "options")] + [InlineData(ErrorCodes.CustomNoSemicolon, "custom")] + [InlineData(ErrorCodes.EnvsNoSemicolon, "envs")] + public void TheExamplesOfAMissingSemicolonAreWhatTheySay(string code, string reader) + { + var entry = ErrorCodes.Find(code)!; + Assert.Equal(code, DiagnosticOf(reader, entry.Wrong!)?.Code); + // The right text is read without a problem. + _ = reader switch + { + "envs" => TazelEnvsFile.Parse(entry.Right!).Count, + "custom" => CustomParser.Parse(entry.Right!).Count, + _ => TazelOptionsFile.Parse(entry.Right!).Platform is null ? 0 : 1, + }; + } + private static Diagnostic? DiagnosticOf(string reader, string text) { try