Exemplo n.º 1
0
        public void SetUp()
        {
            kernel = new StandardKernel();

            tmp     = new TempDirectory();
            rootDir = new LocalFileSystemDirectory(tmp);
            using (var writer = rootDir.CreateTextFile("file1"))
                writer.WriteLine("Contents of file 1");
            using (var writer = rootDir.CreateTextFile("file2"))
                writer.WriteLine("Contents of file 2");
            using (var writer = rootDir.CreateTextFile("file3"))
                writer.WriteLine("Contents of file 3");

            sourceSet1 = new SourceSet("test1");
            sourceSet1.Add(new SuiteRelativePath("file1"));
            sourceSet1.Add(new SuiteRelativePath("file2"));

            sourceSet2 = new SourceSet("test2");
            sourceSet2.Add(new SuiteRelativePath("file1"));
            sourceSet2.Add(new SuiteRelativePath("file3"));

            kernel.Bind <IFileSystemDirectory>().ToConstant(rootDir).WhenTargetHas <SuiteRootAttribute>();

            var factoryMock = new Mock <ISourceSetFingerprintFactory>();

            factoryMock.Setup(
                f =>
                f.CreateSourceSetFingerprint(It.IsAny <IEnumerable <SuiteRelativePath> >(), It.IsAny <Func <string, bool> >(), It.IsAny <bool>()))
            .Returns <IEnumerable <SuiteRelativePath>, Func <string, bool>, bool>(
                (files, exclusions, fullDependency) => new SourceSetFingerprint(rootDir, files, exclusions, fullDependency));
            fingerprintFactory = factoryMock.Object;
        }
Exemplo n.º 2
0
        public void GeneratedProxyStubIsFiltered()
        {
            var sourceSet = new SourceSet("cpp");

            sourceSet.Add(new SuiteRelativePath("x.cpp"));
            sourceSet.Add(new SuiteRelativePath("y.h"));
            sourceSet.Add(new SuiteRelativePath("real/something.c"));
            sourceSet.Add(new SuiteRelativePath("fake/something.c"));

            const string realProxyStub = @"

/* this ALWAYS GENERATED file contains the proxy stub code */

...";

            const string fakeProxyStub = "this is just a regular file";

            sourceSetRoot.SetFileContents("real/something.c", realProxyStub);
            sourceSetRoot.SetFileContents("fake/something.c", fakeProxyStub);
            sourceSetRoot.SetFileContents("y.h", string.Empty);

            var filteredSet = sourceSet.FilterCppSourceSet(sourceSetRoot, sourceSetRoot);

            sourceSet.Files.Should().HaveCount(4);
            filteredSet.Files.Should().HaveCount(3);

            filteredSet.Files.Should().NotContain(new SuiteRelativePath("real/something.c"));
            filteredSet.Files.Should().Contain(new SuiteRelativePath("fake/something.c"));
        }
Exemplo n.º 3
0
        public void GeneratedIdlHeaderIsFiltered()
        {
            var sourceSet = new SourceSet("cpp");

            sourceSet.Add(new SuiteRelativePath("x.cpp"));
            sourceSet.Add(new SuiteRelativePath("y.h"));
            sourceSet.Add(new SuiteRelativePath("real/something.h"));
            sourceSet.Add(new SuiteRelativePath("fake/something.h"));

            const string realIdlHeader = @"

/* this ALWAYS GENERATED file contains the definitions for the interfaces */

...";

            const string fakeIdlHeader = "this is just a regular file";

            sourceSetRoot.SetFileContents("real/something.h", realIdlHeader);
            sourceSetRoot.SetFileContents("fake/something.h", fakeIdlHeader);
            sourceSetRoot.SetFileContents("y.h", string.Empty);

            var filteredSet = sourceSet.FilterCppSourceSet(sourceSetRoot, sourceSetRoot);

            sourceSet.Files.Should().HaveCount(4);
            filteredSet.Files.Should().HaveCount(3);

            filteredSet.Files.Should().NotContain(new SuiteRelativePath("real/something.h"));
            filteredSet.Files.Should().Contain(new SuiteRelativePath("fake/something.h"));
        }
Exemplo n.º 4
0
        public void GeneratedGuidDefinitionFileIsFiltered()
        {
            var sourceSet = new SourceSet("cpp");

            sourceSet.Add(new SuiteRelativePath("x.cpp"));
            sourceSet.Add(new SuiteRelativePath("y.h"));
            sourceSet.Add(new SuiteRelativePath("real/something.c"));
            sourceSet.Add(new SuiteRelativePath("fake/something.c"));

            const string realGuidDef = @"

/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */

...";

            const string fakeGuidDef = "this is just a regular file";

            sourceSetRoot.SetFileContents("real/something.c", realGuidDef);
            sourceSetRoot.SetFileContents("fake/something.c", fakeGuidDef);
            sourceSetRoot.SetFileContents("y.h", string.Empty);

            var filteredSet = sourceSet.FilterCppSourceSet(sourceSetRoot, sourceSetRoot);

            sourceSet.Files.Should().HaveCount(4);
            filteredSet.Files.Should().HaveCount(3);

            filteredSet.Files.Should().NotContain(new SuiteRelativePath("real/something.c"));
            filteredSet.Files.Should().Contain(new SuiteRelativePath("fake/something.c"));
        }
Exemplo n.º 5
0
 /// <summary>
 /// A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_strName">The name of the node.</param>
 /// <param name="p_strPath">The path of the file system item being represented by the node.</param>
 public FileSystemTreeNode(string p_strName, string p_strPath)
     : base(p_strName)
 {
     if (!String.IsNullOrEmpty(p_strPath))
     {
         m_sstSources.Add(p_strPath, false);
     }
 }
Exemplo n.º 6
0
 /// <summary>
 ///   A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_strName">The name of the node.</param>
 /// <param name="p_strPath">The path of the file system item being represented by the node.</param>
 public FileSystemTreeNode(string p_strName, string p_strPath)
     : base(p_strName)
 {
     if (!p_strPath.StartsWith(Archive.ARCHIVE_PREFIX) && !p_strPath.StartsWith(NEW_PREFIX) &&
         !Directory.Exists(p_strPath) && !File.Exists(p_strPath))
     {
         throw new FileNotFoundException("The given path is not valid.", p_strPath);
     }
     m_sstSources.Add(p_strPath, false);
 }
Exemplo n.º 7
0
        public void SourceSetIsNotCaseSensitive()
        {
            var set = new SourceSet("test");

            set.Add(new SuiteRelativePath("x/y/z.abc"));
            set.Add(new SuiteRelativePath("x/Y/z.abc"));
            set.Add(new SuiteRelativePath("x/y/Z.abc"));
            set.Add(new SuiteRelativePath("x/y/z.aBc"));

            set.Files.Should().HaveCount(1);
            set.Files.Should().HaveElementAt(0, new SuiteRelativePath("x/y/z.abc"));
        }
Exemplo n.º 8
0
        public void AddingFileChangesFingerprint()
        {
            var dep = new SourceSetDependencies(fingerprintFactory, sourceSet);
            var fp1 = dep.CreateFingerprint();

            using (var writer = rootDir.CreateTextFile("file3"))
                writer.WriteLine("Contents of file 3");
            sourceSet.Add(new SuiteRelativePath("file3"));

            var fp2 = dep.CreateFingerprint();

            fp1.Should().NotBe(fp2);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Recursively adds every file in a given directory to a source set (<see cref="SourceSet"/>)
        /// </summary>
        /// <param name="target">The target source set to be extended</param>
        /// <param name="dir">The root directory for the operation</param>
        private void AddAllFiles(SourceSet target, IFileSystemDirectory dir)
        {
            foreach (var fileName in dir.Files)
            {
                target.Add(new SuiteRelativePath(Path.Combine(suiteRoot.GetRelativePath(dir), fileName)));
            }

            foreach (var childDirectory in dir.ChildDirectories)
            {
                AddAllFiles(target, dir.GetChildDirectory(childDirectory));
            }
        }
Exemplo n.º 10
0
        public void FilesWithIdlExtensionAreFiltered()
        {
            var sourceSet = new SourceSet("cpp");

            sourceSet.Add(new SuiteRelativePath("x.cpp"));
            sourceSet.Add(new SuiteRelativePath("y.h"));
            sourceSet.Add(new SuiteRelativePath("a/b/c/z.c"));
            sourceSet.Add(new SuiteRelativePath("1.idl"));
            sourceSet.Add(new SuiteRelativePath("a/2.idl"));


            sourceSetRoot.SetFileContents("y.h", string.Empty);
            sourceSetRoot.SetFileContents("a/b/c/z.c", string.Empty);

            var filteredSet = sourceSet.FilterCppSourceSet(sourceSetRoot, sourceSetRoot);

            sourceSet.Files.Should().HaveCount(5);
            filteredSet.Files.Should().HaveCount(3);

            filteredSet.Files.Should().NotContain(new SuiteRelativePath("1.idl"));
            filteredSet.Files.Should().NotContain(new SuiteRelativePath("a/2.idl"));
        }
Exemplo n.º 11
0
        public void GeneratedDllDataCIsFiltered()
        {
            var sourceSet = new SourceSet("cpp");

            sourceSet.Add(new SuiteRelativePath("x.cpp"));
            sourceSet.Add(new SuiteRelativePath("y.h"));
            sourceSet.Add(new SuiteRelativePath("real/dlldata.c"));
            sourceSet.Add(new SuiteRelativePath("fake/dlldata.c"));

            const string realDllDataC =
                @"/*********************************************************
   DllData file -- generated by MIDL compiler 

        DO NOT ALTER THIS FILE

   This file is regenerated by MIDL on every IDL file compile.

   To completely reconstruct this file, delete it and rerun MIDL
   on all the IDL files in this DLL, specifying this file for the
   /dlldata command line option

*********************************************************/";

            const string fakeDllDataC = "this is just a regular file";

            sourceSetRoot.SetFileContents("real/dlldata.c", realDllDataC);
            sourceSetRoot.SetFileContents("fake/dlldata.c", fakeDllDataC);
            sourceSetRoot.SetFileContents("y.h", string.Empty);

            var filteredSet = sourceSet.FilterCppSourceSet(sourceSetRoot, sourceSetRoot);

            sourceSet.Files.Should().HaveCount(4);
            filteredSet.Files.Should().HaveCount(3);

            filteredSet.Files.Should().NotContain(new SuiteRelativePath("real/dlldata.c"));
            filteredSet.Files.Should().Contain(new SuiteRelativePath("fake/dlldata.c"));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Recursively adds every file in a given directory to a source set (<see cref="SourceSet"/>)
        /// </summary>
        /// <param name="target">The target source set to be extended</param>
        /// <param name="dir">The root directory for the operation</param>
        /// <param name="ignoreList">Ignore list for the target source set</param>
        private void AddAllFiles(SourceSet target, IFileSystemDirectory dir, SourceSetIgnoreList ignoreList)
        {
            foreach (var fileName in dir.Files)
            {
                var suiteRelativePath = new SuiteRelativePath(Path.Combine(suiteRoot.GetRelativePath(dir), fileName));
                if (!ignoreList.IsIgnored(suiteRelativePath))
                {
                    target.Add(suiteRelativePath);
                }
            }

            foreach (var childDirectory in dir.ChildDirectories)
            {
                AddAllFiles(target, dir.GetChildDirectory(childDirectory), ignoreList);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Recursively adds every file in a given directory to a source set (<see cref="SourceSet"/>)
        /// </summary>
        /// <param name="target">The target source set to be extended</param>
        /// <param name="dir">The root directory for the operation</param>
        private void AddAllFiles(SourceSet target, IFileSystemDirectory dir)
        {
            foreach (var fileName in dir.Files)
            {
                target.Add(new SuiteRelativePath(Path.Combine(suiteRoot.GetRelativePath(dir), fileName)));
            }

            foreach (var childDirectory in dir.ChildDirectories)
            {
                AddAllFiles(target, dir.GetChildDirectory(childDirectory));
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Recursively adds every file in a given directory to a source set (<see cref="SourceSet"/>)
        /// </summary>
        /// <param name="target">The target source set to be extended</param>
        /// <param name="dir">The root directory for the operation</param>
        /// <param name="ignoreList">Ignore list for the target source set</param>
        private void AddAllFiles(SourceSet target, IFileSystemDirectory dir, SourceSetIgnoreList ignoreList)
        {
            foreach (var fileName in dir.Files)
            {
                var suiteRelativePath = new SuiteRelativePath(Path.Combine(suiteRoot.GetRelativePath(dir), fileName));
                if (!ignoreList.IsIgnored(suiteRelativePath))
                {
                    target.Add(suiteRelativePath);
                }
            }

            foreach (var childDirectory in dir.ChildDirectories)
            {
                AddAllFiles(target, dir.GetChildDirectory(childDirectory), ignoreList);
            }
        }