public void Unified_FailedBuild_ShouldRequireAnotherBuildNotSkipMMP() { RunMMPTest(tmpDir => { foreach (bool xm45 in new bool [] { false, true }) { // First build with a Non-existant file to force us to error inside mmp test TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir) { CSProjConfig = "<MonoBundlingExtraArgs>--resource=Foo.bar</MonoBundlingExtraArgs>", XM45 = xm45 }; TI.GenerateAndBuildUnifiedExecutable(test, shouldFail: true); // Next, build again without the error MonoBundlingExtraArgs test.CSProjConfig = ""; TI.GenerateUnifiedExecutableProject(test); // And try again. // If we fail, we'll likely fail with "did not generate an exe" before returning but let's check anyway var secondBuildResult = TI.BuildProject(Path.Combine(tmpDir, TI.GetUnifiedExecutableProjectName(test))); var secondBuildOutput = secondBuildResult.BuildOutput; Assert.IsTrue(!secondBuildOutput.Contains("Skipping target \"_CompileToNative"), "Did not skip"); Assert.IsTrue(secondBuildOutput.Contains("Building target \"_CompileToNative\" completely"), "Did need to build"); } }); }
public void Dontlink_Allow_ReadonlyAssembly() { string [] sb; RunMMPTest(tmpDir => { // build b.dll string assemblyPath = string.Format("{0}/b.dll", tmpDir); sb = new [] { "-target:library", "-debug", $"-out:{assemblyPath}", $"{tmpDir}/b.cs" }; File.WriteAllText(Path.Combine(tmpDir, "b.cs"), "public class B { }"); TI.RunAndAssert("/Library/Frameworks/Mono.framework/Commands/csc", sb, "b"); File.SetAttributes(assemblyPath, FileAttributes.ReadOnly); File.SetAttributes(Path.ChangeExtension(assemblyPath, ".pdb"), FileAttributes.ReadOnly); // build project referencing a.dll TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir) { References = string.Format(" <Reference Include=\"b\" > <HintPath>{0}</HintPath> </Reference> ", assemblyPath), TestCode = "System.Console.WriteLine (typeof (B));", }; TI.GenerateAndBuildUnifiedExecutable(test, shouldFail: false); test.CSProjConfig = "<LinkMode>SdkOnly</LinkMode>"; TI.GenerateAndBuildUnifiedExecutable(test, shouldFail: false); }); }
public void Dontlink_AllowsUnresolvableReferences() { var sb = new StringBuilder(); RunMMPTest(tmpDir => { // build b.dll sb.Clear(); sb.AppendFormat("-target:library -out:{0}/b.dll {0}/b.cs", tmpDir); File.WriteAllText(Path.Combine(tmpDir, "b.cs"), "public class B { }"); TI.RunAndAssert("/Library/Frameworks/Mono.framework/Commands/mcs", sb, "b"); // build a.dll sb.Clear(); sb.AppendFormat("-target:library -out:{0}/a.dll {0}/a.cs -r:{0}/b.dll", tmpDir); File.WriteAllText(Path.Combine(tmpDir, "a.cs"), "public class A { public A () { System.Console.WriteLine (typeof (B)); }}"); TI.RunAndAssert("/Library/Frameworks/Mono.framework/Commands/mcs", sb, "a"); File.Delete(Path.Combine(tmpDir, "b.dll")); // build project referencing a.dll TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir) { References = string.Format(" <Reference Include=\"a\" > <HintPath>{0}/a.dll</HintPath> </Reference> ", tmpDir), TestCode = "System.Console.WriteLine (typeof (A));", }; TI.GenerateAndBuildUnifiedExecutable(test, shouldFail: false); }); }
public void Dontlink_Allow_ReadonlyAssembly() { var sb = new StringBuilder(); RunMMPTest(tmpDir => { // build b.dll sb.Clear(); string assemblyPath = string.Format("{0}/b.dll", tmpDir); sb.AppendFormat("-target:library -debug -out:{0} {1}/b.cs", assemblyPath, tmpDir); File.WriteAllText(Path.Combine(tmpDir, "b.cs"), "public class B { }"); TI.RunAndAssert("/Library/Frameworks/Mono.framework/Commands/mcs", sb, "b"); File.SetAttributes(assemblyPath, FileAttributes.ReadOnly); File.SetAttributes(assemblyPath + ".mdb", FileAttributes.ReadOnly); // build project referencing a.dll TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir) { References = string.Format(" <Reference Include=\"b\" > <HintPath>{0}</HintPath> </Reference> ", assemblyPath), TestCode = "System.Console.WriteLine (typeof (B));", }; TI.GenerateAndBuildUnifiedExecutable(test, shouldFail: false); test.CSProjConfig = "<LinkMode>SdkOnly</LinkMode>"; TI.GenerateAndBuildUnifiedExecutable(test, shouldFail: false); }); }
public void AllowsUnresolvableReferences() { MMPTests.RunMMPTest(tmpDir => { string [] sb; // build b.dll sb = new [] { "-target:library", $"-out:{tmpDir}/b.dll", $"{tmpDir}/b.cs" }; File.WriteAllText(Path.Combine(tmpDir, "b.cs"), "public class B { }"); TI.RunAndAssert("/Library/Frameworks/Mono.framework/Commands/csc", sb, "b"); // build a.dll sb = new [] { "-target:library", $"-out:{tmpDir}/a.dll", $"{tmpDir}/a.cs", $"-r:{tmpDir}/b.dll" }; File.WriteAllText(Path.Combine(tmpDir, "a.cs"), "public class A { public A () { System.Console.WriteLine (typeof (B)); }}"); TI.RunAndAssert("/Library/Frameworks/Mono.framework/Commands/csc", sb, "a"); File.Delete(Path.Combine(tmpDir, "b.dll")); // build project referencing a.dll TI.UnifiedTestConfig test = new TI.UnifiedTestConfig(tmpDir) { References = string.Format(" <Reference Include=\"a\" > <HintPath>{0}/a.dll</HintPath> </Reference> ", tmpDir), TestCode = "System.Console.WriteLine (typeof (A));", }; TI.GenerateAndBuildUnifiedExecutable(test); }); }