-
Notifications
You must be signed in to change notification settings - Fork 1k
Conversation
Note that for now, I have the tests under |
Okay - I set up a vendor initialization function, so I think we can really beat the he** out of this thing now. If the community agrees with the direction, then I will document the structure and usage, and propose a test list to start working against (which would also serve as a high-level functionality cheat sheet). All thoughts welcome. |
This is almost ready to merge, after review and documentation. Increased number of |
@sdboyer - where would you like the harness docs? |
@tro3 my first impulse is to say I've got reviewing this on my TODO list for tomorrow. |
Cool. I do think I'm going to move initial/vendors.txt and final/vendors.txt to the root test case directory, as initial_vendors.txt and final_vendors.txt. I found the current structure a little cumbersome for setting up new tests. Let me know if you think otherwise.
|
Maybe even better would be a single
Then the overall testcase would be a single file to describe it and the |
# Conflicts: # cmd/dep/remove_test.go
Okay, I moved to the yaml config file, blocked the remove tests on Windows, and all seems to be working. Starting to work on documentation. |
nvm this, ofc, the logic has to be a bit different now. You'll still need to rebase back onto master to fix the conflict, though. |
(starting review) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oi, this is a ton of work - thank you! Overall, this is looking really good! Biggest comment is switching from YAML -> JSON - see inline comment.
cmd/dep/integration_test.go
Outdated
test.NeedsExternalNetwork(t) | ||
test.NeedsGit(t) | ||
|
||
filepath.Walk("testdata", func(path string, info os.FileInfo, err error) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's actually put an extra parent directory in here - testdata/harness_tests
is fine (sorry I didn't catch you earlier with this), so that it's easily possible to use the testdata
dir for something other than just this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do. Note that it already can be used for other things. The system just looks for testcase.yaml
, so other directories can exist in parallel. But I have no problem moving them back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, but yeah, I think the extra separator is still worthwhile. Given that we're defining semantics around filesystem organization, I think it's better to have the explicit top-level choice.
test/miniyaml.go
Outdated
} | ||
|
||
// Only parses key:val pairs (both strings) and lists of strings | ||
func ParseYaml(rdr io.Reader) (YamlDoc, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's please use JSON, instead.
I realize that JSON is suboptimal for this purpose, but it's in stdlib, and until we come to a decision in #119, it's not clear what parsers for more human-readable formats we'll have available to us. I'd rather not introduce an extra dependency for just this purpose, and I like introducing a custom parser even less than that.
Also, would I be right to guess that this implementation probably came from somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I wrote it on the fly (looking sheepish). No problem - I'll convert to JSON.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ach, sorry, i wish i'd caught it before you put all the time in on that - sorry! thanks for making the change.
test/int_testcase.go
Outdated
@@ -0,0 +1,269 @@ | |||
// Copyright 2017 The Go Authors. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to abbreviate filename - integration_testcase.go
is fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
test/int_testcase.go
Outdated
if err != nil { | ||
panic(err) | ||
} | ||
rootPath := filepath.Join( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shorter:
rootPath := filepath.FromSlash(filepath.Join(wd, "testdata", name))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k
test/int_testcase.go
Outdated
} | ||
|
||
// | ||
// func (tc *IntegrationTestCase) GetImports() map[string]string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these commented bits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stupidity. Will remove
@sdboyer, harness feedback implemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sooo close! Just a couple of nits.
cmd/dep/integration_test.go
Outdated
@@ -18,51 +18,52 @@ func TestIntegration(t *testing.T) { | |||
test.NeedsExternalNetwork(t) | |||
test.NeedsGit(t) | |||
|
|||
filepath.Walk("testdata", func(path string, info os.FileInfo, err error) error { | |||
filepath.Walk(filepath.Join("testdata", "harness_tests"), | |||
func(path string, info os.FileInfo, err error) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that everything on one line here is fine - even preferable, because it'll de-dent everything below. Go is lax about the 80-width column thing.
If the width thing really bugs you, assign the func to a var and then call the filepath.Walk()
below with it 😄
cmd/dep/integration_test.go
Outdated
testName := strings.Join(parse[1:len(parse)-1], "/") | ||
if strings.HasSuffix(path, "testcase.json") { | ||
parse := strings.Split(path, string(filepath.Separator)) | ||
testName := strings.Join(parse[2:len(parse)-1], "/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want filepath.Base()
here
finalVendors: | ||
- github.com/sdboyer/deptest | ||
- github.com/sdboyer/deptestdos | ||
The test code itself simply walks down the directory tree, looking for `testcase.json` files. These files can be as many levels down the tree as desired. The test name will consist of the directory path from `testdata` to the test case directory itself. In the above example, the test name would be `category1/subcategory1/case1`, and could be singled out with the `-run` option of `go test` (i.e. `go test github.com/golang/dep/cmp/dep -run Integration/category1/subcategory1/case1`). New tests can be added simply by adding a new directory with the json file to the `testdata` tree. There is no need for code modification - the new test will be included automatically. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While wrap may not matter overmuch, I think it'd be worth wrapping these at 80; this is a file that likely will be read in a terminal/editors.
@@ -51,7 +54,7 @@ The test procedure is as follows: | |||
2. Create `src/github.com/golang/notexist` as the project | |||
3. Copy the contents of `initial` to the project | |||
4. `go get` the repos and versions in `imports` to the `src` directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's say fetch
rather than go get
; less misleading.
Also, should probably note in here that we only support git repos.
@sdboyer - latest mods in place. Pls have a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made a few small style nits. Hope you don't mind.
if err := tc.WriteFile(golden, got); err != nil { | ||
tc.t.Fatal(err) | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need the else
for cases where you call t.Fatal
first?
It would improve readability of this test if some of the if ... else if ... else
code could be simplified into something with fewer indentation levels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed on the readability here, but don't see an obvious simplification. There is a 2x3 decision matrix being handled, and some of the quadrants need error handling built in, causing more if
s. Open to suggestions - I am a Go newbie.
test/integration_testcase.go
Outdated
|
||
gotExists, got, err := getFile(working) | ||
if err != nil { | ||
panic(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason for calling panic instead of Fatal here?
test/integration_testproj.go
Outdated
) | ||
|
||
var ( | ||
ProjectRoot string = "src/github.com/golang/notexist" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this var be a const
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. Newbie move.
test/integration_testcase.go
Outdated
UpdateGolden *bool = flag.Bool("update", false, "update golden files") | ||
) | ||
|
||
// To manage a test case directory structure and content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the recommended comment format from go lint
here: IntegrationTestCase ...
@groob, thanks for the feedback. Mods are pushed - please let me know what you think. |
@groob thanks for the extra review! still needs a rebase to fix conflicts :) |
? It says it specifically can't be rebased, due to conflicts (files being deleted/moved across branches). But I think merge is ok? I just did it locally without issue. If it does need a rebase, just let me know to where. |
right, it says GH can't rebase because the repository is set to incorporate PRs via rebase, rather than via merge - and there's a conflict. (i just verified the conflict locally - at least one, in i realize it doesn't report the same conflict on merge, but that's not how we're incorporating PRs at the moment, so you'll need to resolve the rebase conflict, push up the rebased branch, and then we can hit the button here. |
oh wait - i can just do the merge here :) thanks! |
Integration test harness
Addressing #282. @sdboyer, please let me know what you think of this path.