Progmasoft Git

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 how include: and import: differ in .tazelignore

include: reads a file each time it is named and import: once, as
#include and #import do; either takes a quoted path beside the file or
one in angle brackets below TAZEL_HOME/Include/Ignore. The docs and the
help say so, and a test reads both forms under both directives.
Commit
c605a590fe07b08943ce776a19fa4529b6de3075
Author
Leitwolf11 ·
Parents
2044b86c13fb

Files · Download .tar.gz

Changes

 docs/commands.md                            |  8 +++++---
 src/Progmasoft.Tazel/Cli/Help.cs            |  5 +++--
 tests/Progmasoft.Tazel.Tests/IgnoreTests.cs | 10 ++++++++--
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/docs/commands.md b/docs/commands.md
index 5ff5987..d08f124 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -238,9 +238,11 @@ A `.tazelignore` holds gitignore rules: comments, `*`, `**`, `?`, `[...]`, ancho
 directories, `\` escapes, `!` negation, trailing spaces dropped unless escaped, the last matching rule deciding, and
 nothing inside an ignored directory brought back. A file applies to its directory and below, after the files above
 it. `regex:` and `!regex:` take a .NET regular expression over the path relative to the file's directory, with `/`
-between its parts; it must compile and finish within a second on a path. `pragma:once`, `import:` and `include:` read
-other files as the directives of the text files do, `<file>` below `$TAZEL_HOME/Include/Ignore/`; there are no
-conditions. A gitignore rule that starts with one of these words takes a backslash: `\regex:name`. A `.gitignore` is
+between its parts; it must compile and finish within a second on a path. `include:` and `import:` put another file's
+rules in their place, as `#include` and `#import` do: `include:` each time it is named, `import:` once, and a file
+read with `import:` is not read again by `include:` either; `pragma:once` first in a file makes every inclusion of it
+an import. Each takes a path in quotes, beside the file that names it, or in angle brackets, below
+`$TAZEL_HOME/Include/Ignore/`; where the file is does not change which of the two reads it. There are no conditions. A gitignore rule that starts with one of these words takes a backslash: `\regex:name`. A `.gitignore` is
 not read.
 
 The rules apply to package discovery, `//...` and the other patterns, source globs and module archives. A path or a
diff --git a/src/Progmasoft.Tazel/Cli/Help.cs b/src/Progmasoft.Tazel/Cli/Help.cs
index efdb523..4051410 100644
--- a/src/Progmasoft.Tazel/Cli/Help.cs
+++ b/src/Progmasoft.Tazel/Cli/Help.cs
@@ -221,8 +221,9 @@ internal static class Help
             tazel ignore delete|del <pattern>
 
             A .tazelignore holds gitignore rules, and regex:EXPRESSION or !regex:EXPRESSION for a .NET regular
-            expression over the path relative to its directory; pragma:once, import:<file>, import:"file",
-            include:<file> and include:"file" read other files in place. It applies to its directory and below, to
+            expression over the path relative to its directory; include: and import: put another file's rules in
+            their place, as #include and #import do: include: each time, import: once; either takes "file", beside
+            this one, or <file>, below $TAZEL_HOME/Include/Ignore; pragma:once makes a file an import wherever named. It applies to its directory and below, to
             package discovery, //..., source globs and the archives of modules; a path or label named explicitly is
             never ignored. A .gitignore is not read.
 
diff --git a/tests/Progmasoft.Tazel.Tests/IgnoreTests.cs b/tests/Progmasoft.Tazel.Tests/IgnoreTests.cs
index b36bb10..14dcfd8 100644
--- a/tests/Progmasoft.Tazel.Tests/IgnoreTests.cs
+++ b/tests/Progmasoft.Tazel.Tests/IgnoreTests.cs
@@ -179,8 +179,14 @@ public sealed class IgnoreTests
     {
         using var module = new TemporaryModule().Write("home/Include/Ignore/common.ignore.txt", "*.o\n");
         using var home = new Home(Path.Combine(module.Root, "home"));
-        var rules = IgnoreFile.Read(Path.Combine(module.Root, ".tazelignore"), "import:<common.ignore.txt>\n");
-        Assert.Equal("*.o", Assert.Single(rules).Text);
+        var file = Path.Combine(module.Root, ".tazelignore");
+        Assert.Equal("*.o", Assert.Single(IgnoreFile.Read(file, "import:<common.ignore.txt>\n")).Text);
+        // Where a file is does not choose the directive: include: reads it each time, import: once, both ways.
+        module.Write("local.ignore.txt", "*.l\n");
+        Assert.Equal(2, IgnoreFile.Read(file, "include:<common.ignore.txt>\ninclude:<common.ignore.txt>\n").Count);
+        Assert.Equal(2, IgnoreFile.Read(file, "include:\"local.ignore.txt\"\ninclude:\"local.ignore.txt\"\n").Count);
+        Assert.Single(IgnoreFile.Read(file, "import:\"local.ignore.txt\"\nimport:\"local.ignore.txt\"\n"));
+        Assert.Single(IgnoreFile.Read(file, "import:<common.ignore.txt>\ninclude:<common.ignore.txt>\n"));
     }
 
     [Fact]