-
Notifications
You must be signed in to change notification settings - Fork 27
added UAST diff algorithm #309
Conversation
uast/diff/diff.go
Outdated
| keys := make(map[string]bool) | ||
| iterate := func(keyset nodes.Object) { | ||
| for key := range keyset { | ||
| if in := keys[key]; !in { |
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.
This comment still applies
|
Also, it would be nice to have some tests for diff generation as well as for appling the diff. |
|
How do we add tests in the repository? I've got some internal ones. |
|
@quinor You can add a test function to a new file |
|
@dennwc how to proceed if the test(s) need serialized data or external resources to work? My current testing procedure is to launch a client that runs the diff on two files and tries to apply it afterwards comparing the result with source, additionally having bblfshd docker running for the source file parsing. |
|
@quinor Feel free to add a To get those YAMLs you can run the |
|
Is there any documentation/examples for the go+CI we are using? |
|
@quinor Don't think about CI right now, you can use |
|
Did not realize there is an unified "go test" framework. That simplifies things alot :) |
b2681a8 to
c65e770
Compare
| @@ -0,0 +1,36 @@ | |||
| #!/usr/bin/env python3 | |||
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.
The script is pretty simple. Can be written in Go as well (it's the only Python file here).
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 only threw it in so that one may try to regenerate/generate new test cases. Also, see the answers below.
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 still think it makes sense to rewrite it in Go. All the SDK is in Go. I see no reason to require Python installation for such a simple script.
| @@ -0,0 +1,148 @@ | |||
| 720_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.
Maybe there is a formal definition for this? For example "source size is less than N bytes/lines" or "the UAST size is less than N bytes/nodes"?
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'm not sure how I'd chosen these. If there was such definition, how to proceed?
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.
The script can check the file size before writing it to the destination.
By the way, if the script was in Go, you can use the Babelfish client directly and count nodes / check the size of the source or the UAST.
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.
The reason I wrote it in Python is I'm not really comfortable with file-processing scripts in Go. Python seemed like a better alternative to bash (that's what it would be written in otherwise).
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.
Also, Python exists on every modern Linux distro so it's still quite portable (see the alternative: bash)
025d8bb to
8c1149e
Compare
|
Needs a rebase on top of a current master at least. Also make sure to run |
Signed-off-by: Wojciech Jabłoński <wj359634@students.mimuw.edu.pl>
Signed-off-by: Wojciech Jabłoński <wj359634@students.mimuw.edu.pl>
Signed-off-by: Wojciech Jabłoński <wj359634@students.mimuw.edu.pl>
Signed-off-by: Wojciech Jabłoński <wj359634@students.mimuw.edu.pl>
Signed-off-by: Wojciech Jabłoński <wj359634@students.mimuw.edu.pl>
Signed-off-by: Wojciech Jabłoński <wj359634@students.mimuw.edu.pl>
Signed-off-by: Wojciech Jabłoński <wj359634@students.mimuw.edu.pl>
Signed-off-by: Wojciech Jabłoński <wj359634@students.mimuw.edu.pl>
Signed-off-by: Wojciech Jabłoński <wj359634@students.mimuw.edu.pl>
Signed-off-by: Wojciech Jabłoński <wj359634@students.mimuw.edu.pl>
Signed-off-by: Wojciech Jabłoński <wj359634@students.mimuw.edu.pl>
Signed-off-by: Wojciech Jabłoński <wj359634@students.mimuw.edu.pl>
|
Have to close this PR - cannot rebase, because it's made from the |
still WIP, diffing works, applying diff not implemented yet