Permalink
Browse files

test for making sure we can actually find headers in the includepath

  • Loading branch information...
1 parent ebd2383 commit 2529e0e6b6d943080c22e1237fd959020ee4579b Lucas Meijer committed Apr 16, 2012
Showing with 24 additions and 1 deletion.
  1. +12 −0 CakePath.cs
  2. +1 −1 RecursiveIncludeScanner.cs
  3. +10 −0 Tests/RecursiveIncludeScannerTest.cs
  4. +1 −0 cake.csproj
View
@@ -0,0 +1,12 @@
+namespace cake
+{
+ internal static class CakePath
+ {
+ public static string Combine(string dir, string includedFile)
+ {
+ if (dir.Length == 0)
+ return includedFile;
+ return dir + "/" + includedFile;
+ }
+ }
+}
@@ -45,7 +45,7 @@ private string FindSpecifiedIncludeFileInSearchDirs(string includingFile, string
foreach(var dir in includeDirs)
{
- var file_in_dir = Path.Combine(dir,includedFile);
+ var file_in_dir = CakePath.Combine(dir,includedFile);
if (File.Exists(file_in_dir))
return file_in_dir;
if (_willFileBeGeneratedAtPath(file_in_dir))
@@ -45,6 +45,16 @@ public void CanFindHeaderWithSubDirectorySpecification()
Assert.AreEqual("sub1/myheader.h", result.Single());
}
+ [Test]
+ public void CanFindHeaderInIncludePath()
+ {
+ var ris = new RecursiveIncludeScanner(new[] {"sub1"}, file => false, f => ScanFileMock(f, "myheader.h"));
+ Directory.CreateDirectory("sub1");
+ File.WriteAllText("sub1/myheader.h", "//boss");
+ var result = ris.GetFilesIncludedBy("test.c");
+ Assert.AreEqual("sub1/myheader.h", result.Single());
+ }
+
private static IEnumerable<string> ScanFileMock(string file)
{
return ScanFileMock(file, "myheader.h");
View
@@ -52,6 +52,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BuildHistory.cs" />
+ <Compile Include="CakePath.cs" />
<Compile Include="FileAssert.cs" />
<Compile Include="GenerationRecord.cs" />
<Compile Include="MissingHeaderException.cs" />

0 comments on commit 2529e0e

Please sign in to comment.