mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-04-05 20:55:01 +08:00
move console runner to named file and clean output then run in action
This commit is contained in:
parent
16e1e5e52d
commit
7ed985a023
4
.github/workflows/run_integration_tests.yml
vendored
4
.github/workflows/run_integration_tests.yml
vendored
@ -47,5 +47,5 @@ jobs:
|
||||
- name: Unzip archives
|
||||
run: sudo apt-get install p7zip-full && cd archive && 7z x part1-archive.7z && 7z x part2-archive.7z
|
||||
|
||||
- name: List Unzipped
|
||||
run: ls archive
|
||||
- name: Run tests
|
||||
run: dotnet run --project tools/UglyToad.PdfPig.ConsoleRunner/UglyToad.PdfPig.ConsoleRunner.csproj "archive/"
|
@ -11,7 +11,7 @@ namespace UglyToad.PdfPig.ConsoleRunner
|
||||
{
|
||||
if (args.Length == 0)
|
||||
{
|
||||
Console.WriteLine("At least 1 argument, path to test file directory, may be provided.");
|
||||
Console.WriteLine("At least 1 argument, path to test file directory, must be provided.");
|
||||
return 7;
|
||||
}
|
||||
|
||||
@ -32,9 +32,13 @@ namespace UglyToad.PdfPig.ConsoleRunner
|
||||
|
||||
var hasError = false;
|
||||
var errorBuilder = new StringBuilder();
|
||||
var fileList = Directory.GetFiles(path, "*.pdf");
|
||||
var fileList = Directory.GetFiles(path, "*.pdf", SearchOption.AllDirectories);
|
||||
var runningCount = 0;
|
||||
|
||||
|
||||
Console.WriteLine($"Found {fileList.Length} files.");
|
||||
|
||||
Console.WriteLine($"{GetCleanFilename("File")}| Size\t| Words\t| Pages");
|
||||
|
||||
foreach (var file in fileList)
|
||||
{
|
||||
if (maxCount.HasValue && runningCount >= maxCount)
|
||||
@ -61,7 +65,11 @@ namespace UglyToad.PdfPig.ConsoleRunner
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"Read {numWords} words on {numPages} pages in document {file}.");
|
||||
var filename = Path.GetFileName(file);
|
||||
|
||||
var size = new FileInfo(file);
|
||||
|
||||
Console.WriteLine($"{GetCleanFilename(filename)}| {size.Length}\t| {numWords}\t| {numPages}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -84,5 +92,17 @@ namespace UglyToad.PdfPig.ConsoleRunner
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static string GetCleanFilename(string name, int maxLength = 30)
|
||||
{
|
||||
if (name.Length <= maxLength)
|
||||
{
|
||||
var fillLength = maxLength - name.Length;
|
||||
|
||||
return name + new string(' ', fillLength);
|
||||
}
|
||||
|
||||
return name.Substring(0, maxLength);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"profiles": {
|
||||
"UglyToad.PdfPig.ConsoleRunner": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "\"C:\\temp\\pdfs\\archive\""
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user