Ejemplo n.º 1
0
        public void NativeLink(ApplePlatform platform, string runtimeIdentifiers)
        {
            Configuration.IgnoreIfIgnoredPlatform(platform);

            var project_path = GenerateProject(platform, name: nameof(NativeLink), runtimeIdentifiers: runtimeIdentifiers, out var appPath);
            var properties   = new Dictionary <string, string> (verbosity);

            SetRuntimeIdentifiers(properties, runtimeIdentifiers);

            var mainContents = @"
class MainClass {
	static int Main ()
	{
		return 123;
	}
}
";
            var mainFile     = Path.Combine(Path.GetDirectoryName(project_path), "Main.cs");

            File.WriteAllText(mainFile, mainContents);

            // Build the first time
            var rv         = DotNet.AssertBuild(project_path, properties);
            var allTargets = BinLog.GetAllTargets(rv.BinLogPath);

            AssertTargetExecuted(allTargets, "_AOTCompile", "A");
            AssertTargetExecuted(allTargets, "_CompileNativeExecutable", "A");
            AssertTargetExecuted(allTargets, "_LinkNativeExecutable", "A");

            // Capture the current time
            var timestamp = DateTime.UtcNow;

            File.WriteAllText(mainFile, mainContents + "\n");

            // Build again
            rv = DotNet.AssertBuild(project_path, properties);

            // Check that some targets executed
            allTargets = BinLog.GetAllTargets(rv.BinLogPath);
            AssertTargetExecuted(allTargets, "_AOTCompile", "B");
            AssertTargetNotExecuted(allTargets, "_CompileNativeExecutable", "B");
            AssertTargetExecuted(allTargets, "_LinkNativeExecutable", "B");

            // Verify that the timestamp of the executable has been updated
            var executable = GetNativeExecutable(platform, appPath);

            Assert.That(File.GetLastWriteTimeUtc(executable), Is.GreaterThan(timestamp), "B: Executable modified");
        }