protected void RunTest(string name) { var root = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var file = Path.Combine(root, "TestData", name + ".txt"); var text = File.ReadAllText(file); (var input, var expected_output) = SplitTestFile(text); var compiler = new AidlCompiler(); var results = compiler.Run(input, out var output); Assert.False(results.LogMessages.Any()); #if GENERATE_OUTPUT using (var sw = new StreamWriter(file)) { sw.WriteLine(input); sw.WriteLine(); sw.WriteLine("####"); sw.WriteLine(); sw.WriteLine(output); } Assert.Ignore("Generating output for this test."); #endif // GENERATE_OUTPUT Assert.AreEqual(StripLineEndings(expected_output), StripLineEndings(output)); }
public override bool Execute() { if (SourceAidlFiles.Length == 0) // nothing to do { return(true); } var opts = new ConverterOptions() { Verbose = true, ParcelableHandling = ParcelableHandling.Ignore, }; if (!string.IsNullOrEmpty(ParcelableHandlingOption)) { opts.ParcelableHandling = ToParcelableHandling(ParcelableHandlingOption); } if (!string.IsNullOrEmpty(OutputNamespace)) { opts.OutputNS = OutputNamespace; } foreach (var file in References) { opts.AddReference(file.ItemSpec); } foreach (var file in SourceAidlFiles) { opts.AddFile(file.ItemSpec); } var tool = new AidlCompiler(); using (var fsw = TextWriter.Null /*File.AppendText (Path.Combine (IntermediateOutputDirectory, "AidlFilesWrittenAbsolute.txt"))*/) { tool.FileWritten += (file, source) => Log.LogDebugMessage("Written ... {0}", file); string outPath = Path.Combine(IntermediateOutputDirectory, "aidl"); var ret = tool.Run(opts, assemblyFile => AssemblyDefinition.ReadAssembly(assemblyFile), (dir, file) => { var dst = Path.GetFullPath(Path.Combine(outPath, Path.ChangeExtension(file, ".cs"))); if (!dst.StartsWith(outPath)) { dst = Path.Combine(outPath, Path.ChangeExtension(Path.GetFileName(file), ".cs")); } string dstdir = Path.GetDirectoryName(dst); if (!Directory.Exists(dstdir)) { Directory.CreateDirectory(dstdir); } fsw.WriteLine(dst); fsw.Flush(); return(dst); }); if (ret.LogMessages.Count > 0) { foreach (var p in ret.LogMessages) { Log.LogError("{0} {1}: {2}", Path.GetFullPath(p.Key), p.Value.Location, p.Value.ToString()); } } } return(true); }