-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
73f2e43
commit 5faf876
Showing
10 changed files
with
129 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
Source/IntegrationTests/TestFiles/LitTests/LitTest/gomodule/multimodule/DerivedModule.dfy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...tegrationTests/TestFiles/LitTests/LitTest/gomodule/multimodule/dafnysource/helloworld.dfy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
Source/IntegrationTests/TestFiles/LitTests/LitTest/gomodule/multimodule/test-go.dtr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
Binary file modified
BIN
+0 Bytes
(100%)
Source/IntegrationTests/TestFiles/LitTests/LitTest/gomodule/multimodule/test.doo
Binary file not shown.
5 changes: 3 additions & 2 deletions
5
...egrationTests/TestFiles/LitTests/LitTest/gomodule/singlemodule/dafnysource/helloworld.dfy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+0 Bytes
(100%)
...ce/IntegrationTests/TestFiles/LitTests/LitTest/pythonmodule/multimodule/PythonModule1.doo
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...ntegrationTests/TestFiles/LitTests/LitTest/pythonmodule/nestedmodule/SomeNestedModule.doo
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
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}"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters