-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release 4.8.0 #5733
Release 4.8.0 #5733
Changes from 15 commits
098a538
2d8f49a
80e7fc3
73f2e43
5faf876
34d4ece
e92da7b
fa034f5
0026205
50b1cd3
7e954bc
e19e205
ad0c2e5
0421812
8ca95a7
d1c76d0
93d2972
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// This file is used to regenerate PythonModule1.doo | ||
// RUN: echo 'lit should ignore this file' | ||
|
||
module DafnyModule1 { | ||
method HelloWorld() | ||
{ | ||
print "Hello World"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
file_format_version = "1.0" | ||
dafny_version = "4.7.0.0" | ||
dafny_version = "4.8.0.0" | ||
[options_by_module.DafnyModule1] | ||
go-module-name = "GoModule1" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
file_format_version = "1.0" | ||
dafny_version = "4.7.0.0" | ||
dafny_version = "4.8.0.0" | ||
[options_by_module.DafnyModule1] | ||
python-module-name = "PythonModule1" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// This file is used to regenerate PythonModule1.doo | ||
// RUN: echo 'lit should ignore this file' | ||
|
||
module DafnyModule1 { | ||
method HelloWorld() | ||
{ | ||
print "Hello World"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
file_format_version = "1.0" | ||
dafny_version = "4.7.0.0" | ||
dafny_version = "4.8.0.0" | ||
[options_by_module."Some.Nested.Module"] | ||
python-module-name = "SomeNestedModule" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// This file is used to regenerate SomeNestedModule.doo | ||
// RUN: echo 'lit should ignore this file' | ||
|
||
module Some.Nested.Module { | ||
method HelloWorld() | ||
{ | ||
print "Hello World"; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using Xunit.Sdk; | ||
|
||
namespace XUnitExtensions.Lit { | ||
public class CpCommand : ILitCommand { | ||
|
||
private readonly string options; | ||
private readonly string fileOrFolder; | ||
private readonly string destination; | ||
|
||
private CpCommand(string options, string fileOrFolder, string destination) { | ||
this.options = options; | ||
this.fileOrFolder = fileOrFolder; | ||
this.destination = destination; | ||
} | ||
|
||
public static ILitCommand Parse(string[] args) { | ||
if (args.Length != 2 && args.Length != 3) { | ||
throw new ArgumentException($"Wrong number of arguments for cp, expected 2 or 3 but got {args.Length}: " + string.Join(", ", args)); | ||
} | ||
|
||
string fileOrFolder; | ||
string destination; | ||
string options; | ||
|
||
if (args.Length == 2) { | ||
options = ""; | ||
fileOrFolder = args[0]; | ||
destination = args[1]; | ||
} else { | ||
options = args[0]; | ||
fileOrFolder = args[1]; | ||
destination = args[2]; | ||
} | ||
return new CpCommand(options, fileOrFolder, destination); | ||
} | ||
static void CopyDirectory(string sourceDir, string destinationDir, bool recursive, bool force) { | ||
// Get information about the source directory | ||
var dir = new DirectoryInfo(sourceDir); | ||
|
||
// Check if the source directory exists | ||
if (!dir.Exists) | ||
throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}"); | ||
|
||
// Cache directories before we start copying | ||
DirectoryInfo[] dirs = dir.GetDirectories(); | ||
|
||
// Create the destination directory | ||
Directory.CreateDirectory(destinationDir); | ||
|
||
// Get the files in the source directory and copy to the destination directory | ||
foreach (FileInfo file in dir.GetFiles()) { | ||
string targetFilePath = Path.Combine(destinationDir, file.Name); | ||
if (force && File.Exists(targetFilePath)) { | ||
File.Delete(targetFilePath); | ||
} | ||
file.CopyTo(targetFilePath); | ||
} | ||
|
||
// If recursive and copying subdirectories, recursively call this method | ||
if (recursive) { | ||
foreach (DirectoryInfo subDir in dirs) { | ||
string newDestinationDir = Path.Combine(destinationDir, subDir.Name); | ||
CopyDirectory(subDir.FullName, newDestinationDir, true, force); | ||
} | ||
} | ||
} | ||
public async Task<int> Execute(TextReader inputReader, | ||
TextWriter outputWriter, TextWriter errorWriter) { | ||
if (File.Exists(fileOrFolder)) { | ||
try { | ||
if (File.Exists(destination) && options.Contains('f')) { | ||
File.Delete(destination); | ||
} | ||
File.Copy(fileOrFolder, destination); | ||
} catch (Exception e) { | ||
await outputWriter.WriteLineAsync(e.ToString()); | ||
return 1; | ||
} | ||
} else if (Directory.Exists(fileOrFolder)) { | ||
try { | ||
var actualDestination = Directory.Exists(destination) | ||
? Path.Combine(destination, Path.GetFileName(fileOrFolder)) | ||
: destination; | ||
CopyDirectory(fileOrFolder, actualDestination, options.Contains('r'), options.Contains('f')); | ||
} catch (Exception e) { | ||
await outputWriter.WriteLineAsync(e.ToString()); | ||
return 1; | ||
} | ||
} else { | ||
throw new ArgumentException("File or folder " + fileOrFolder + " not found"); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
public override string ToString() { | ||
return $"%cp {(options != "" ? options + " " : "")}{fileOrFolder} {destination}"; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,32 @@ | ||
using System.ComponentModel; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
|
||
namespace XUnitExtensions.Lit; | ||
|
||
|
||
public class ExitCommand : ILitCommand { | ||
private readonly int expectedExitCode; | ||
private readonly string expectedExitCode; | ||
private readonly ILitCommand operand; | ||
|
||
public ExitCommand(int exitCode, ILitCommand operand) { | ||
public ExitCommand(string exitCode, ILitCommand operand) { | ||
this.expectedExitCode = exitCode; | ||
this.operand = operand; | ||
} | ||
|
||
public async Task<int> Execute(TextReader inputReader, | ||
TextWriter outputWriter, TextWriter errorWriter) { | ||
var exitCode = await operand.Execute(inputReader, outputWriter, errorWriter); | ||
if (exitCode == expectedExitCode) { | ||
var exitCode = 1; | ||
try { | ||
exitCode = await operand.Execute(inputReader, outputWriter, errorWriter); | ||
} catch (Win32Exception) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect this exception would be a different one on non-Windows platforms. Or is it used on all platforms in .NET? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Windows does not have the "rm" command so I'm not sure if the original returns an exception if the file does not exist or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: the code was working fine in other platforms without the try catch, so I'm not expecting this to break any other platform. |
||
if (expectedExitCode == "-any") { | ||
} else { | ||
throw; | ||
} | ||
} | ||
|
||
if (expectedExitCode == "-any" || exitCode.ToString() == expectedExitCode) { | ||
return 0; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good thing to add!