~ubuntu-branches/ubuntu/feisty/nant/feisty

« back to all changes in this revision

Viewing changes to tests/NAnt.VisualCpp/Tasks/RcTaskTest.cs

  • Committer: Bazaar Package Importer
  • Author(s): Dave Beckett
  • Date: 2006-06-12 23:30:36 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060612233036-a1uwh0949z0218ep
Tags: 0.84+0.85-rc4-1
* New upstream release
* Acknowledge NMU (Closes: #372588)
* Standards-Version 3.7.2
* Update to latest CLI policy package split.  Build-Depends-Indep: on
  cli-common-dev, libmono-winforms1.0-cil, libmono-winforms2.0-cil and
  mono-gmcs to get 1.0 and 2.0 packages
* Removed patches no longer needed:
  - 01-AssemblyInfoTask.cs.patch
  - 02-ScriptTask.cs.patch
  - 03-XmlResultFormatter.cs.patch
  - 04-SourceControl.patch
  - 05-ExceptionTest.cs

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
                Assert.Ignore("The Resource Compiler (rc.exe) is not available on the PATH.");
57
57
            }
58
58
 
59
 
            RunBuild(FormatBuildFile(""));
 
59
            RunBuild(FormatBuildFile(_resInputFile, ""));
60
60
            Assert.IsTrue(File.Exists(Path.ChangeExtension(_resInputFile, "RES")),
61
61
                "Default compiled resource not created.");
62
62
        }
77
77
            // if the output file is rebuilt
78
78
            System.Threading.Thread.Sleep(1000);
79
79
 
80
 
            RunBuild(FormatBuildFile("output=\"" + outputFile + "\""));
81
 
 
82
 
            DateTime newLastModified = File.GetLastWriteTime(outputFile);
83
 
            Assert.AreEqual(orgLastModified, newLastModified, 
84
 
                "output file should not have been rebuilt");
85
 
        }
86
 
 
87
 
        private string FormatBuildFile(string extra) {
88
 
            return string.Format(CultureInfo.InvariantCulture, _projectXml, _resInputFile, extra);
 
80
            RunBuild(FormatBuildFile(_resInputFile, "output=\"" + outputFile + "\""));
 
81
 
 
82
            DateTime newLastModified = File.GetLastWriteTime(outputFile);
 
83
            Assert.AreEqual(orgLastModified, newLastModified, 
 
84
                "output file should not have been rebuilt");
 
85
        }
 
86
 
 
87
        /// <summary>
 
88
        /// Test to make sure that a modification of an external file that is 
 
89
        /// referenced by a rc file caused the rc file to be rebuilt (bug #1195320).
 
90
        /// </summary>
 
91
        [Test]
 
92
        public void Test_External_Files() {
 
93
            if (!ResourceCompilerPresent) {
 
94
                Assert.Ignore("The Resource Compiler (rc.exe) is not available on the PATH.");
 
95
            }
 
96
 
 
97
            string xmlFile = CreateTempFile(Path.Combine(_resDir, "description.xml"), 
 
98
                "<root/>");
 
99
            string resFile = CreateTempFile(Path.Combine(_resDir, "test-external.rc"), 
 
100
                "IDR_XML_DESCRIPTION     XML               \"description.xml\"");
 
101
            string outputFile = CreateTempFile(Path.Combine(_resDir, "output.res"));
 
102
 
 
103
            RunBuild(FormatBuildFile(resFile, "output=\"" + outputFile + "\""));
 
104
 
 
105
            DateTime orgLastModified = File.GetLastWriteTime(outputFile);
 
106
 
 
107
            // wait for a second to make sure we would get another lastwritetime
 
108
            // if the output file is rebuilt
 
109
            System.Threading.Thread.Sleep(1000);
 
110
 
 
111
            RunBuild(FormatBuildFile(resFile, "output=\"" + outputFile + "\""));
 
112
 
 
113
            DateTime newLastModified = File.GetLastWriteTime(outputFile);
 
114
            Assert.AreEqual(orgLastModified, newLastModified, 
 
115
                "output file should not have been rebuilt");
 
116
 
 
117
            // "modify" xml file
 
118
            File.SetLastWriteTime(xmlFile, DateTime.Now);
 
119
 
 
120
            // rc file should now be recompiled
 
121
            RunBuild(FormatBuildFile(resFile, "output=\"" + outputFile + "\""));
 
122
 
 
123
            // verify whether rc file was rebuilt
 
124
            newLastModified = File.GetLastWriteTime(outputFile);
 
125
            Assert.IsTrue(orgLastModified != newLastModified, 
 
126
                "output file should have been rebuilt");
 
127
        }
 
128
 
 
129
        private string FormatBuildFile(string inputFile, string extra) {
 
130
            return string.Format(CultureInfo.InvariantCulture, _projectXml, inputFile, extra);
89
131
        }
90
132
    }
91
133
}
92