how to add file types to `raco test`?

67 views
Skip to first unread message

Matthew Butterick

unread,
Jul 5, 2015, 7:51:22 PM7/5/15
to racket...@googlegroups.com
`raco test` will automatically test every .rkt and .scrbl file in a directory. Suppose I make `#lang foo` and thus many of my test files end with .foo. I would want all .foo files to be automatically tested as well. Is there a way to use "info.rkt" to tell `raco test` to add file types? (Should there be?) 

Of course the workaround is just to make a .rkt file that runs the files, but it seems like "info.rkt" is the better place (inasmuch as this op is the inverse of `test-omit-paths`)

Jack Firth

unread,
Jul 6, 2015, 2:54:46 PM7/6/15
to racket...@googlegroups.com
On Sunday, July 5, 2015 at 4:51:22 PM UTC-7, Matthew Butterick wrote:
> `raco test` will automatically test every .rkt and .scrbl file in a directory. Suppose I make `#lang foo` and thus many of my test files end with .foo. I would want all .foo files to be automatically tested as well. Is there a way to use "info.rkt" to tell `raco test` to add file types? (Should there be?) 
>
>
> Of course the workaround is just to make a .rkt file that runs the files, but it seems like "info.rkt" is the better place (inasmuch as this op is the inverse of `test-omit-paths`)

I've recently run into the inverse, where I'd like to tell raco test to exclude all files of a particular extension. test-omit-paths lets me exclude directories and individual files, but not extensions. Perhaps something like glob-patterns in .gitignore files would be useful?

Matthew Butterick

unread,
Jul 9, 2015, 6:53:43 PM7/9/15
to racket...@googlegroups.com
Further investigation reveals that the source code of `compiler/commands/test` is adamant that the only acceptable extensions are 'rkt' and 'scrbl', and that anything else needs to be handled with 'test-command-line-arguments' [1]. So this kind of thing will work in an "info.rkt", with each file added as (list "sourcename.ext" ()):

#lang info

(define test-command-line-arguments
(list (list "extra-source-1.ext" '()) (list "extra-source-2.ext" '()) ... ))

However it doesn't seem possible to, for instance, generate a list of files from `directory-list` and `filter` them, as the functions available within #lang info are a very tiny subset of racket/base. [2]

Maybe there's a clever way to circumvent this restriction with a submodule or macro, but so far `raco` detects and rejects my attempts.

[1] http://docs.racket-lang.org/raco/test.html#%28part._test-config-info%29
[2] http://docs.racket-lang.org/raco/info_rkt.html?q=info.rkt
> --
> You received this message because you are subscribed to the Google Groups "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Jay McCarthy

unread,
Jul 9, 2015, 7:00:33 PM7/9/15
to Matthew Butterick, racket...@googlegroups.com
I think the right thing to do is just make an extension for the
extension and/or the way the file list is built. I'll look into it on
Monday.

Jay
--
Jay McCarthy
http://jeapostrophe.github.io

"Wherefore, be not weary in well-doing,
for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
- D&C 64:33

Jay McCarthy

unread,
Jul 28, 2015, 4:22:15 PM7/28/15
to Matthew Butterick, racket...@googlegroups.com
I'm a little later than I expected, but I just added the ability to
use regexps in test-omit-paths and in a new info.rkt property called
test-include-paths. The test case [1] shows an example where all files
matching #rx".*include.*" are included, such as the file
`b-include-1.racket-file`. This should be sufficient for you to add
any suffixes/etc you need.

Jay

1. https://github.com/racket/compiler/blob/master/compiler-test/tests/compiler/test/extensions/info.rkt

Matthew Butterick

unread,
Jul 28, 2015, 6:08:22 PM7/28/15
to Jay McCarthy, racket...@googlegroups.com
Very nice. Thank you Jay. That will be a big help.
Reply all
Reply to author
Forward
0 new messages