// NAnt - A .NET build tool
// Copyright (C) 2004 Thomas Strauss (strausst@arcor.de)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Thomas Strauss (strausst@arcor.de)
using System;
using System.IO;
using NUnit.Framework;
using NAnt.Core;
using Tests.NAnt.Core;
using Tests.NAnt.Core.Util;
using Tests.NAnt.VisualCpp;
namespace Tests.NAnt.VSNet.Tasks {
[TestFixture]
public class VCProjectNMakeTest : VisualCppTestBase {
private string _objDir;
private string _sourceDir;
private string _sourcePathName;
private string _copy_bat;
private string _test_build;
private string _vcProject;
private string _vcProjectPathName;
private const string _touchedFileName = "TouchedFile.txt";
private const string _copyFileName = "Copy.bat";
[SetUp]
protected override void SetUp() {
base.SetUp();
_objDir = CreateTempDir("objs");
_sourceDir = CreateTempDir("src");
_copy_bat = "copy \"" + Path.Combine(_sourceDir,_copyFileName)
+ "\" \"" + Path.Combine(_objDir, _touchedFileName) + "\"";
_sourcePathName = CreateTempFile(Path.Combine(_sourceDir, _copyFileName), _copy_bat);
_vcProject = @"
";
_vcProjectPathName = CreateTempFile(Path.Combine(_sourceDir, "NNake.vcproj"), _vcProject);
_vcProjectPathName = _vcProjectPathName.Replace("\\", "/");
_test_build = @"
";
}
///
/// Tests excluded files are actually ignored.
///
[Test]
public void Test_NMakeProject() {
if (CanCompileAndLink) {
RunBuild(_test_build);
Assert.IsTrue(File.Exists(Path.Combine(_objDir, _touchedFileName)),
"File not created.");
}
}
}
[TestFixture]
public class VCProjectExcludeTest : VisualCppTestBase {
private string _objDir;
private string _sourceDir;
private string _sourcePathName;
private string _sourceErrorPathName;
private string _test_build;
private string _vcProject;
private string _vcProjectPathName;
private const string _helloWorld_cpp = @"
#include
extern "+"\"C\""+@" void __declspec( dllexport ) init() {}
";
private const string _error_cpp = @"xxx";
[SetUp]
protected override void SetUp() {
base.SetUp();
_objDir = CreateTempDir("objs");
_sourceDir = CreateTempDir("src");
_sourcePathName = CreateTempFile(Path.Combine(_sourceDir, "HelloWorld.cpp"), _helloWorld_cpp);
_sourceErrorPathName = CreateTempFile(Path.Combine(_sourceDir, "NotBuild.cpp"), _error_cpp);
_vcProject = @"
";
_vcProjectPathName = CreateTempFile(Path.Combine(_sourceDir, "HelloWorld.vcproj"), _vcProject);
_vcProjectPathName = _vcProjectPathName.Replace("\\", "/");
_test_build = @"
";
}
///
/// Tests excluded files are actually ignored.
///
[Test]
public void Test_HelloWorldCompile_ExcludeFile() {
if (CanCompileAndLink) {
RunBuild(_test_build);
Assert.IsTrue(File.Exists(Path.Combine(_objDir, "HelloWorld.dll")),
"dll file not created.");
}
}
}
}