42 lines
1.6 KiB
C#
42 lines
1.6 KiB
C#
using System;
|
|
using System.IO;
|
|
|
|
// No SQL execution. Model sqlcmd 13's literal :out paths at the process boundary.
|
|
class Sqlcmd13OutputFixture
|
|
{
|
|
static int Main(string[] args)
|
|
{
|
|
if (Path.GetFileNameWithoutExtension(Environment.GetCommandLineArgs()[0]) == "jps")
|
|
{
|
|
Console.WriteLine("123 sun.tools.jps.Jps -lv");
|
|
return 0;
|
|
}
|
|
if (Array.IndexOf(args, "-Q") >= 0) return 0;
|
|
int input = Array.IndexOf(args, "-i");
|
|
if (input < 0) return 86;
|
|
string inputName = Path.GetFileName(args[input + 1]);
|
|
Console.WriteLine("FIXTURE_INPUT=" + inputName);
|
|
if (inputName == "shadow-v34-schema-check.sql")
|
|
return Array.IndexOf(args, "FAIL_SCHEMA") >= 0 ? 67 : 0;
|
|
if (inputName == "upgrade-shadow-v3-to-v33.sql" && Array.IndexOf(args, "FAIL_V33") >= 0)
|
|
return 33;
|
|
if (inputName == "upgrade-shadow-v33-to-v34.sql" && Array.IndexOf(args, "FAIL_V34") >= 0)
|
|
return 34;
|
|
foreach (string line in File.ReadAllLines(args[input + 1]))
|
|
{
|
|
if (!line.StartsWith(":out ")) continue;
|
|
string destination = line.Substring(5).Trim().Trim('"');
|
|
if (destination == "stdout") continue;
|
|
if (destination.Contains("$("))
|
|
{
|
|
Console.Error.WriteLine("sqlcmd13 cannot expand :out destination: " + destination);
|
|
return 13;
|
|
}
|
|
File.WriteAllText(destination, "read-only SQL output fixture\r\n");
|
|
}
|
|
File.WriteAllText("sqlcmd-cwd.txt", Environment.CurrentDirectory);
|
|
Console.WriteLine("EXPORT_SQL_OK");
|
|
return 0;
|
|
}
|
|
}
|