Compare commits

..

No commits in common. "9e9903429eb52aabfb247c079fcc29995b4ee51b" and "197dd79b34818ee27e4681c68b51656e83c55479" have entirely different histories.

4 changed files with 14 additions and 83 deletions

View file

@ -6,9 +6,6 @@
"authors": [ "authors": [
"Nathan McCarty <thatonelutenist@stranger.systems>" "Nathan McCarty <thatonelutenist@stranger.systems>"
], ],
"depends": [
"paths"
],
"provides": { "provides": {
"IUtils": "lib/IUtils.rakumod", "IUtils": "lib/IUtils.rakumod",
"IUtils::IDEMode": "lib/IUtils/IDEMode.rakumod", "IUtils::IDEMode": "lib/IUtils/IDEMode.rakumod",
@ -17,5 +14,5 @@
"bin": { "bin": {
"iutils": "bin/iutils" "iutils": "bin/iutils"
}, },
"resources": [ ] "resources": [ ],
} }

View file

@ -3,22 +3,12 @@ use v6.d;
use IUtils; use IUtils;
use IUtils::Comments; use IUtils::Comments;
#| Execute the tests in an idris project my $contents = "/home/nathan/Projects/Idris/structures/test/src/Main.idr".IO.slurp;
multi MAIN(
"test", say "\nTesting full flagged-expression:";
Str $project-path?, #= Base directory of the project, defaults to $*CWD say $contents ~~ &flagged-expression;
) { when $contents ~~ &flagged-expression {
# CD into the project path if needed say $<test-name>;
chdir($project-path.IO.resolve: :completely) if $project-path; say $<expression-name>;
# Scan for our packages say $<flag><type>;
my @packages = scan-packages;
# Collect tests
my @tests;
for @packages -> $package {
# FIXME
say 'Finding tests for ', $package.ipkg.relative;
for $package.sources -> $source {
say 'Scanning for tests in ', $source;
}
}
} }

View file

@ -3,42 +3,6 @@ unit module IUtils;
need IUtils::IDEMode; need IUtils::IDEMode;
use paths;
#| Structure representing the root of what idris considers a package directory,
#| with the associated ipkg and source files. These can and will overlap within
#| the same directory.
class PackageInfo {
has IO::Path:D $.ipkg is required;
has IO::Path:D $.root is required;
has IO::Path:D @.sources is required;
}
#| Scan a particular ipkg for its associated sources
sub scan-ipkg(IO::Path:D $ipkg --> PackageInfo:D) {
my $contents = $ipkg.slurp;
my $src-dir =
($contents ~~
/ 'sourcedir' \h* '=' \h*
'"' $<value>=[<-["]>*] '"' /)<value>
// "src";
my IO::Path:D @sources =
paths($ipkg.parent.add($src-dir), :file(*.ends-with(".idr"))).map(*.IO);
PackageInfo.new(ipkg => $ipkg, root => $ipkg.parent, sources => @sources)
}
# TODO: Add some parsing of pack.toml to locate test packages and associate them
# with their source ipkg
#| Scan $*CWD to locate ipkgs and their associated sources
sub scan-packages(--> Array[PackageInfo:D]) is export {
my PackageInfo:D @ipkgs =
paths(:file(*.ends-with(".ipkg"))).map(*.IO.&scan-ipkg);
return @ipkgs;
}
# Utility functions for pack # Utility functions for pack
#| Invoke a pack command #| Invoke a pack command
@ -60,34 +24,17 @@ sub pack-run(*@cmd) is export {
#| Build a package with pack #| Build a package with pack
sub pack-build($pkg) is export { sub pack-build($pkg) is export {
pack-run 'build', $pkg pack-run 'build', $pkg;
} }
#| Test a package with pack #| Test a package with pack
sub pack-test($pkg) is export { sub pack-test($pkg) is export {
pack-run 'build', $pkg pack-run 'build', $pkg;
} }
#| Clean a package with pack #| Clean a package with pack
sub pack-clean($pkg) is export { sub pack-clean($pkg) is export {
pack-run 'clean', $pkg pack-run 'clean', $pkg;
}
# Utility functions for idris
#| An error coming from the idris compiler
class IdrisError is Exception {
has Str $.out;
has Str $.err;
has Int $.exit-code;
has Str $.command;
method message {
qq:to/END/;
Error running idris command: $.command
Command exited with $.exit-code
END
}
} }
#| Invoke an idris command #| Invoke an idris command
@ -96,10 +43,7 @@ sub idris-run(*@cmd) is export {
my $out = $proc.out.slurp(:close); my $out = $proc.out.slurp(:close);
my $err = $proc.err.slurp(:close); my $err = $proc.err.slurp(:close);
unless $proc { unless $proc {
IdrisError.new( ($out, $err)
out => $out, err => $err,
exit-code => $proc.exitcode, command => @cmd.Str)
.throw;
} }
return $out; return $out;
} }

View file

@ -10,5 +10,5 @@ my token name { <[\w \-]>+ }
my regex flagged-expression is export { my regex flagged-expression is export {
<&comment-start> \h* <flag> \h* <test-name=&name> \V* \v <&comment-start> \h* <flag> \h* <test-name=&name> \V* \v
[<&comment-start> \V* \v]* [<&comment-start> \V* \v]*
<expression-name=&name> \h+ \: \V* \v $<expression-name>=<expression-name=&name> \h+ \: \V* \v
} }