From 3205c5ff3f287b863328a6ad8563994e2c48d8e2 Mon Sep 17 00:00:00 2001 From: YingjieLiu <18706819589@163.com> Date: Sun, 26 May 2019 11:32:12 +0800 Subject: [PATCH 1/2] Fix test cases --- .../patch_test_files/example7_new.c | 52 +++++++++++++++ .../patch_test_files/example7_old.c | 65 +++++++++++++++++++ test/test_analytics/test_analyzer_cpp.py | 8 +-- test/test_analytics/test_detect_change.py | 22 +++++-- 4 files changed, 138 insertions(+), 9 deletions(-) create mode 100644 test/test_analytics/patch_test_files/example7_new.c create mode 100644 test/test_analytics/patch_test_files/example7_old.c diff --git a/test/test_analytics/patch_test_files/example7_new.c b/test/test_analytics/patch_test_files/example7_new.c new file mode 100644 index 00000000000..9782b3507f9 --- /dev/null +++ b/test/test_analytics/patch_test_files/example7_new.c @@ -0,0 +1,52 @@ +/* added in H */ +struct node +{ + int data; + struct node *next; +}*head; + +/* added in H, edited in I */ +void append(int num) +{ + struct node *temp, *prev; + temp=head; + while(temp!=NULL) + { + if(temp->data==num) + { + if(temp==head) + { + head=temp->next; + free(temp); + return 1; + } + else + { + prev->next=temp->next; + free(temp); + return 1; + } + } + else + { + prev=temp; + temp= temp->next; + } + } + return 0; +} + +/* added in H, edited in G */ +void add( int num ) +{ + struct node *temp; + temp=(struct node *)malloc(sizeof(struct node)); + temp->data=num; + if (head== NULL) + { + head=temp; + head->next=NULL; + } +} + +/* insert() is deleted in I */ diff --git a/test/test_analytics/patch_test_files/example7_old.c b/test/test_analytics/patch_test_files/example7_old.c new file mode 100644 index 00000000000..6157d001d3f --- /dev/null +++ b/test/test_analytics/patch_test_files/example7_old.c @@ -0,0 +1,65 @@ +/* added in H */ +struct node +{ + int data; + struct node *next; +}*head; + +/* added in H */ +void append(int num) +{ + struct node *temp,*right; + temp= (struct node *)malloc(sizeof(struct node)); + temp->data=num; + right=(struct node *)head; + while(right->next != NULL) + right=right->next; + right->next =temp; + right=temp; + right->next=NULL; +} + +/* added in H */ +void add( int num ) +{ + struct node *temp; + temp=(struct node *)malloc(sizeof(struct node)); + temp->data=num; + if (head== NULL) + { + head=temp; + head->next=NULL; + } + else + { + temp->next=head; + head=temp; + } +} + +/* added in H */ +void insert(int num) +{ + int c=0; + struct node *temp; + temp=head; + if(temp==NULL) + { + add(num); + } + else + { + while(temp!=NULL) + { + if(temp->datanext; + } + if(c==0) + add(num); + else if(c Date: Sun, 26 May 2019 12:24:32 +0800 Subject: [PATCH 2/2] fix test_analyzer.py --- test/test_analytics/test_analyzer.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/test/test_analytics/test_analyzer.py b/test/test_analytics/test_analyzer.py index fd011d463aa..3ed8ca8b7b5 100644 --- a/test/test_analytics/test_analyzer.py +++ b/test/test_analytics/test_analyzer.py @@ -32,23 +32,23 @@ async def test_analyzer_master_only(az): history_truth = { 'K': { - 'display': {'adds': 0, 'dels': 5} + 'display': {'adds': 0, 'dels': 5, 'added_units': 0, 'removed_units': 10} }, 'F': { - 'display': {'adds': 14, 'dels': 0}, - 'count': {'adds': 12, 'dels': 0} + 'display': {'adds': 14, 'dels': 0, 'added_units': 23, 'removed_units': 0}, + 'count': {'adds': 12, 'dels': 0, 'added_units': 19, 'removed_units': 0} }, 'E': { - 'append': {'adds': 29, 'dels': 0}, - 'add': {'adds': 11, 'dels': 0} + 'append': {'adds': 29, 'dels': 0, 'added_units': 44, 'removed_units': 0}, + 'add': {'adds': 11, 'dels': 0, 'added_units': 25, 'removed_units': 0} }, 'D': { - 'str_replace': {'adds': 26, 'dels': 0} + 'str_replace': {'adds': 26, 'dels': 0, 'added_units': 76, 'removed_units': 0} }, # TODO: fix \No newline at the end of file 'C': { - 'str_append_chr': {'adds': 30, 'dels': 4}, - 'str_equals': {'adds': 0, 'dels': 1} + 'str_append_chr': {'adds': 30, 'dels': 4, 'added_units': 78, 'removed_units': 21}, + 'str_equals': {'adds': 0, 'dels': 1, 'added_units': 0, 'removed_units': 0} }, # Commit `B` is an example of imperfect diff, # it removes `str_append` and adds a new function `str_append_chr` @@ -56,15 +56,16 @@ async def test_analyzer_master_only(az): # diff doesn't separate these changes into two chunks # please see here: https://github.com/UltimateBeaver/test_feature_branch/commit/caaac10f604ea7ac759c2147df8fb2b588ee2a27 'B': { - 'str_append': {'adds': 6, 'dels': 3}, - 'str_append_chr': {'adds': 3, 'dels': 2}, - 'str_equals': {'adds': 11, 'dels': 0} + 'str_append': {'adds': 6, 'dels': 3, 'added_units': 29, 'removed_units': 21}, + 'str_append_chr': {'adds': 3, 'dels': 2, 'added_units': 21, 'removed_units': 15}, + 'str_equals': {'adds': 11, 'dels': 0, 'added_units': 27, 'removed_units': 0} }, 'A': { - 'str_append': {'adds': 7, 'dels': 0}, - 'str_len': {'adds': 6, 'dels': 0} + 'str_append': {'adds': 7, 'dels': 0, 'added_units': 29, 'removed_units': 0}, + 'str_len': {'adds': 6, 'dels': 0, 'added_units': 13, 'removed_units': 0} }, + # # branch J from commit A, merge back through F # 'J': { # 'count': {'adds': 12, 'dels': 0},