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

Test code extraction for exercises with separate file for test cases #80

Open
junedev opened this issue Jul 17, 2022 · 0 comments · May be fixed by #107
Open

Test code extraction for exercises with separate file for test cases #80

junedev opened this issue Jul 17, 2022 · 0 comments · May be fixed by #107
Labels
x:action/improve Improve existing functionality/content x:knowledge/intermediate Quite a bit of Exercism knowledge required x:module/test-runner Work on Test Runners x:rep/large Large amount of reputation x:size/medium Medium amount of work x:type/coding Write code that is not student-facing content (e.g. test-runners, generators, but not exercises)

Comments

@junedev
Copy link
Member

junedev commented Jul 17, 2022

For practice exercises that have a generator, the list of test cases is written into a separate file cases_test.go currently because this is easier to do for the generator then to somehow insert it into an existing test file.

The issue is that the test runner currently can't handle this separate file. The content of that file is ignored which leads to sub-optimal output on the website. The extracted code does not include the actual test case.

The current output e.g. for hamming looks like this:
image

What we would like to have instead is:

var tt = struct {
	s1          string
	s2          string
	want        int
	expectError bool
}{
	description: "long identical strands",
	s1:          "GGACTGAAATCTG",
	s2:          "GGACTGAAATCTG",
	want:        0,
	expectError: false,
}

got, err := Distance(tc.s1, tc.s2)

switch {
// the usual code here
}

This be be doable by AST parsing the cases file and inserting the test cases AST part into the Test function so the result mimics the usual structure that the test runner can handle correctly, see https://github.com/exercism/go-test-runner#subtest-format-specification.

Related: exercism/go#1872

@junedev junedev added x:action/improve Improve existing functionality/content x:knowledge/intermediate Quite a bit of Exercism knowledge required x:module/test-runner Work on Test Runners x:type/coding Write code that is not student-facing content (e.g. test-runners, generators, but not exercises) x:size/medium Medium amount of work x:rep/large Large amount of reputation labels Jul 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:action/improve Improve existing functionality/content x:knowledge/intermediate Quite a bit of Exercism knowledge required x:module/test-runner Work on Test Runners x:rep/large Large amount of reputation x:size/medium Medium amount of work x:type/coding Write code that is not student-facing content (e.g. test-runners, generators, but not exercises)
Projects
None yet
1 participant