Skip to content
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

What if we could have multiple example files? #395

Closed
petertseng opened this issue Oct 12, 2016 · 4 comments
Closed

What if we could have multiple example files? #395

petertseng opened this issue Oct 12, 2016 · 4 comments

Comments

@petertseng
Copy link
Member

petertseng commented Oct 12, 2016

When reviewing #393 I realized I wish that we could test that multiple signatures would be accepted by the test suite. But of course we have to pick a certain signature in our example file... or do we?

What about a crazy idea - what if we supported having multiple example files?

This is already supported on x-api - any file that has example in its name will be excluded, so we could have Example2.hs, Example3.hs, etc.

Then we would have to make our .travis.yml support it in a reasonable way.

The idea is that Travis CI would test each example file individually (separately from the other examples) and makes sure that the test suite passes for each.

Potential use cases I can think of:

However, I hope that this doesn't make our tests take too long to run.

Is this idea worth it? Should I try it out to see what happens?

@rbasso
Copy link
Contributor

rbasso commented Oct 12, 2016

... If we also have a way to specify that a certain example should fail the test suite

Humm.... I like that!

Is this idea worth it? Should I try it out to see what happens?

Certainly!

Possible implementation

Add a example folder, containing sub-folders for each example solution:

  • `example/someName/ModuleName.hs
  • `example/someName/package.yaml
  • `example/otherName/ModuleName.hs
  • `example/otherName/package.yaml

When testing, Travis could loop the folders inside example and do the following:

  • Move example/someName/package.yaml. to src/.
  • Move example/someName/ModuleName.hs to test/.

I believe that this will not be problematic.

This will only work if the site excludes everything that has example in the full path, not only in the filename. I don't know how it was implemented... 😕

Do you know anything about that?

I still don't know yet how to check for failing tests. Checking it now...

However, I hope that this doesn't make our tests take too long to run.

If the examples use packages already in Stack's cache this will probably not be a problem.

@petertseng
Copy link
Member Author

I still don't know yet how to check for failing tests. Checking it now...

This will be tricky because we have set -e on, and in the case of a should-fail example we want to invert it. I will welcome ideas on making this work.

@petertseng
Copy link
Member Author

petertseng commented Oct 12, 2016

This will only work if the site excludes everything that has example in the full path, not only in the filename

We will be OK: Evidence in two places:

  1. x-api source:

https://github.com/exercism/x-api/blob/aa4869e999443e3736d12e77436ac195fccf7e6b/lib/xapi/implementation.rb#L8
https://github.com/exercism/x-api/blob/aa4869e999443e3736d12e77436ac195fccf7e6b/lib/xapi/file_bundle.rb#L24

file bundle ignores using the whole path (despite its name, file is a full path, or at least the entire path starting with the exercise dir, so it will at least include anagram/example/blahblah, tested this)

  1. other tracks

They have directories named example.

@petertseng
Copy link
Member Author

petertseng commented Oct 12, 2016

I'm not sure we want to move every single exercise's example to this structure. The examples that would benefit are the ones that need a package.yaml and the exercises where we want to have multiple examples. So at least at first I will support both the simple src/Example.hs and the examples directory, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants