From 496eb87d232fb934fddfcea1a925dfcbd7d99a52 Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Sun, 31 Mar 2024 17:43:20 +0300 Subject: [PATCH 01/13] implemented test for ir feature --- tests/metrics/test-ir.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/metrics/test-ir.sh diff --git a/tests/metrics/test-ir.sh b/tests/metrics/test-ir.sh new file mode 100644 index 00000000..e69de29b From 6a3ee7f07372ec73622329fb796e0cea8d56e4c3 Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Sun, 31 Mar 2024 17:55:27 +0300 Subject: [PATCH 02/13] added all the tests to test file --- tests/metrics/test-ir.sh | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tests/metrics/test-ir.sh b/tests/metrics/test-ir.sh index e69de29b..7eb7bbbe 100644 --- a/tests/metrics/test-ir.sh +++ b/tests/metrics/test-ir.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash +# The MIT License (MIT) +# +# Copyright (c) 2021-2024 Yegor Bugayenko +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +set -e +set -o pipefail + +# TODO: ENABLE THIS TESTS RIGHT AFTER IMPLEMENTING ir.sh + +#temp=$1 +#stdout=$2 +# +#{ +# tmp=$(mktemp -d /tmp/XXXX) +# cd "${tmp}" +# mkdir -p "${LOCAL}/${temp}" +# "${LOCAL}/metrics/ir.sh" ./ "${LOCAL}/${temp}/stdout" +# grep "Provided non-git repo" "${LOCAL}/${temp}/stdout" +#} > "${stdout}" 2>&1 +#echo "👍🏻 Didn't fail in non-git directory" +# +#{ +# tmp=$(mktemp -d /tmp/XXXX) +# cd "${tmp}" +# rm -rf ./* +# rm -rf .git +# git init --quiet . +# git config user.email 'foo@example.com' +# git config user.name 'Foo' +# "${LOCAL}/metrics/ir.sh" ./ "t0" +# grep "No files in given repo" "t0" +# file1="one.java" +# file2="two.java" +# touch "${file1}" +# git add "${file1}" +# git config commit.gpgsign false +# git commit --quiet -m "first file" +# "${LOCAL}/metrics/ir.sh" ./ "t1" +# touch "${file2}" +# git add "${file2}" +# git commit --quiet -m "second file" +# "${LOCAL}/metrics/ir.sh" ./ "t2" +# grep "No files in given repo " "t0" # There are no files in repo +# grep "ir 1 " "t1" # Single file in repo +# grep "ir 0.5 " "t2" # Two files in repo +#} > "${stdout}" 2>&1 +#echo "👍🏻 Correctly calculated the IR (Impact Ratio)" From 89efb8d4eb1ac5d93c0e4e95731b66b29f7bddf6 Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Tue, 16 Apr 2024 11:54:09 +0300 Subject: [PATCH 03/13] fixed the way of disabling test for ir --- tests/metrics/test-ir.sh | 79 ++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/tests/metrics/test-ir.sh b/tests/metrics/test-ir.sh index 7eb7bbbe..253a84de 100644 --- a/tests/metrics/test-ir.sh +++ b/tests/metrics/test-ir.sh @@ -23,43 +23,44 @@ set -e set -o pipefail -# TODO: ENABLE THIS TESTS RIGHT AFTER IMPLEMENTING ir.sh +# TODO: ENABLE THIS TESTS RIGHT AFTER IMPLEMENTING ir.sh VIA REMOVING `exit 0` +exit 0 -#temp=$1 -#stdout=$2 -# -#{ -# tmp=$(mktemp -d /tmp/XXXX) -# cd "${tmp}" -# mkdir -p "${LOCAL}/${temp}" -# "${LOCAL}/metrics/ir.sh" ./ "${LOCAL}/${temp}/stdout" -# grep "Provided non-git repo" "${LOCAL}/${temp}/stdout" -#} > "${stdout}" 2>&1 -#echo "👍🏻 Didn't fail in non-git directory" -# -#{ -# tmp=$(mktemp -d /tmp/XXXX) -# cd "${tmp}" -# rm -rf ./* -# rm -rf .git -# git init --quiet . -# git config user.email 'foo@example.com' -# git config user.name 'Foo' -# "${LOCAL}/metrics/ir.sh" ./ "t0" -# grep "No files in given repo" "t0" -# file1="one.java" -# file2="two.java" -# touch "${file1}" -# git add "${file1}" -# git config commit.gpgsign false -# git commit --quiet -m "first file" -# "${LOCAL}/metrics/ir.sh" ./ "t1" -# touch "${file2}" -# git add "${file2}" -# git commit --quiet -m "second file" -# "${LOCAL}/metrics/ir.sh" ./ "t2" -# grep "No files in given repo " "t0" # There are no files in repo -# grep "ir 1 " "t1" # Single file in repo -# grep "ir 0.5 " "t2" # Two files in repo -#} > "${stdout}" 2>&1 -#echo "👍🏻 Correctly calculated the IR (Impact Ratio)" +temp=$1 +stdout=$2 + +{ + tmp=$(mktemp -d /tmp/XXXX) + cd "${tmp}" + mkdir -p "${LOCAL}/${temp}" + "${LOCAL}/metrics/ir.sh" ./ "${LOCAL}/${temp}/stdout" + grep "Provided non-git repo" "${LOCAL}/${temp}/stdout" +} > "${stdout}" 2>&1 +echo "👍🏻 Didn't fail in non-git directory" + +{ + tmp=$(mktemp -d /tmp/XXXX) + cd "${tmp}" + rm -rf ./* + rm -rf .git + git init --quiet . + git config user.email 'foo@example.com' + git config user.name 'Foo' + "${LOCAL}/metrics/ir.sh" ./ "t0" + grep "No files in given repo" "t0" + file1="one.java" + file2="two.java" + touch "${file1}" + git add "${file1}" + git config commit.gpgsign false + git commit --quiet -m "first file" + "${LOCAL}/metrics/ir.sh" ./ "t1" + touch "${file2}" + git add "${file2}" + git commit --quiet -m "second file" + "${LOCAL}/metrics/ir.sh" ./ "t2" + grep "No files in given repo " "t0" # There are no files in repo + grep "ir 1 " "t1" # Single file in repo + grep "ir 0.5 " "t2" # Two files in repo +} > "${stdout}" 2>&1 +echo "👍🏻 Correctly calculated the IR (Impact Ratio)" From 6eac3e304d1efbcddf8536dd5523857c28c0a1e0 Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Tue, 16 Apr 2024 18:00:15 +0300 Subject: [PATCH 04/13] disabled shellcheck SC2317 --- tests/metrics/test-ir.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/metrics/test-ir.sh b/tests/metrics/test-ir.sh index 253a84de..d8dd08cb 100644 --- a/tests/metrics/test-ir.sh +++ b/tests/metrics/test-ir.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash +# shellcheck disable=SC2317 +# TODO: REMOVE SHELLCHECK DISABLE RIGHT AFTER IMPLEMENTING ir.sh # The MIT License (MIT) # # Copyright (c) 2021-2024 Yegor Bugayenko From f338328ec3c0d4a28046f8e755cd8a9b348720cf Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Tue, 16 Apr 2024 18:09:36 +0300 Subject: [PATCH 05/13] added execution permission in git index for test-ir.sh --- tests/metrics/test-ir.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tests/metrics/test-ir.sh diff --git a/tests/metrics/test-ir.sh b/tests/metrics/test-ir.sh old mode 100644 new mode 100755 From 604268730ad3214531948ac5e4c0ae7c3f39af20 Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Tue, 16 Apr 2024 18:18:26 +0300 Subject: [PATCH 06/13] added empty ir.sh --- metrics/ir.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 metrics/ir.sh diff --git a/metrics/ir.sh b/metrics/ir.sh new file mode 100644 index 00000000..7ddaff45 --- /dev/null +++ b/metrics/ir.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# The MIT License (MIT) +# +# Copyright (c) 2021-2024 Yegor Bugayenko +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. \ No newline at end of file From c30cd7c831b834d971fe5d98b48fc8fbcae0093e Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Tue, 16 Apr 2024 18:54:08 +0300 Subject: [PATCH 07/13] added excutional permition for ir.sh and stub in it --- metrics/ir.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) mode change 100644 => 100755 metrics/ir.sh diff --git a/metrics/ir.sh b/metrics/ir.sh old mode 100644 new mode 100755 index 7ddaff45..f71fabb7 --- a/metrics/ir.sh +++ b/metrics/ir.sh @@ -19,4 +19,11 @@ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. \ No newline at end of file +# SOFTWARE. +set -e +set -o pipefail + +output=$(realpath "$2") + +# TODO: REPLACE WITH ACTUAL METRIC CODE +echo "Just stub" >"${output}" From a2442c632610abe84bd8911ca82317634dce273e Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Wed, 17 Apr 2024 16:55:36 +0300 Subject: [PATCH 08/13] updated the stub for ir.sh --- metrics/ir.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/metrics/ir.sh b/metrics/ir.sh index f71fabb7..5c030c97 100755 --- a/metrics/ir.sh +++ b/metrics/ir.sh @@ -26,4 +26,5 @@ set -o pipefail output=$(realpath "$2") # TODO: REPLACE WITH ACTUAL METRIC CODE -echo "Just stub" >"${output}" +echo "IR 0.000 " >"${output}" + From 211ea6fc82e9b8eaaca2b66562967f38919add53 Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Wed, 24 Apr 2024 22:14:17 +0300 Subject: [PATCH 09/13] changed expected bahviour for test-ir.sh --- tests/metrics/test-ir.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/metrics/test-ir.sh b/tests/metrics/test-ir.sh index d8dd08cb..03aaa6a3 100755 --- a/tests/metrics/test-ir.sh +++ b/tests/metrics/test-ir.sh @@ -35,10 +35,12 @@ stdout=$2 tmp=$(mktemp -d /tmp/XXXX) cd "${tmp}" mkdir -p "${LOCAL}/${temp}" - "${LOCAL}/metrics/ir.sh" ./ "${LOCAL}/${temp}/stdout" - grep "Provided non-git repo" "${LOCAL}/${temp}/stdout" + if ! "${LOCAL}/metrics/ir.sh" ./ "${LOCAL}/${temp}/stdout" + then + exit 1 + fi } > "${stdout}" 2>&1 -echo "👍🏻 Didn't fail in non-git directory" +echo "👍🏻 Failed in non-git directory" { tmp=$(mktemp -d /tmp/XXXX) @@ -48,8 +50,10 @@ echo "👍🏻 Didn't fail in non-git directory" git init --quiet . git config user.email 'foo@example.com' git config user.name 'Foo' - "${LOCAL}/metrics/ir.sh" ./ "t0" - grep "No files in given repo" "t0" + if ! "${LOCAL}/metrics/ir.sh" ./ "t0" + then + exit 1 + fi file1="one.java" file2="two.java" touch "${file1}" @@ -61,8 +65,7 @@ echo "👍🏻 Didn't fail in non-git directory" git add "${file2}" git commit --quiet -m "second file" "${LOCAL}/metrics/ir.sh" ./ "t2" - grep "No files in given repo " "t0" # There are no files in repo - grep "ir 1 " "t1" # Single file in repo - grep "ir 0.5 " "t2" # Two files in repo + grep "IR 1" "t1" # Single file in repo + grep "IR 0.5 " "t2" # Two files in repo } > "${stdout}" 2>&1 echo "👍🏻 Correctly calculated the IR (Impact Ratio)" From e4d7b4d3fb2a58554d7ba455f29918a6bac927a8 Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Wed, 24 Apr 2024 22:18:36 +0300 Subject: [PATCH 10/13] fixed todo --- tests/metrics/test-ir.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/metrics/test-ir.sh b/tests/metrics/test-ir.sh index 03aaa6a3..abd0b801 100755 --- a/tests/metrics/test-ir.sh +++ b/tests/metrics/test-ir.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # shellcheck disable=SC2317 -# TODO: REMOVE SHELLCHECK DISABLE RIGHT AFTER IMPLEMENTING ir.sh +# TODO: #259 REMOVE SHELLCHECK DISABLE RIGHT AFTER IMPLEMENTING ir.sh # The MIT License (MIT) # # Copyright (c) 2021-2024 Yegor Bugayenko @@ -25,7 +25,7 @@ set -e set -o pipefail -# TODO: ENABLE THIS TESTS RIGHT AFTER IMPLEMENTING ir.sh VIA REMOVING `exit 0` +# TODO: #259 ENABLE THIS TESTS RIGHT AFTER IMPLEMENTING ir.sh VIA REMOVING `exit 0` exit 0 temp=$1 From e272ec5fdd2d1fd802edb9f2ac2016cdaaadc0d8 Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Wed, 24 Apr 2024 22:19:52 +0300 Subject: [PATCH 11/13] fixed todo in ir.sh --- metrics/ir.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metrics/ir.sh b/metrics/ir.sh index 5c030c97..2a9a6469 100755 --- a/metrics/ir.sh +++ b/metrics/ir.sh @@ -25,6 +25,6 @@ set -o pipefail output=$(realpath "$2") -# TODO: REPLACE WITH ACTUAL METRIC CODE +# TODO: #259 REPLACE WITH ACTUAL METRIC CODE echo "IR 0.000 " >"${output}" From 4a4db782aca8e5ad4d32ad61b7860b1cb8e83fe0 Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Thu, 25 Apr 2024 19:34:44 +0300 Subject: [PATCH 12/13] merged two TODOs in one --- tests/metrics/test-ir.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/metrics/test-ir.sh b/tests/metrics/test-ir.sh index abd0b801..dd27f7e9 100755 --- a/tests/metrics/test-ir.sh +++ b/tests/metrics/test-ir.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash # shellcheck disable=SC2317 -# TODO: #259 REMOVE SHELLCHECK DISABLE RIGHT AFTER IMPLEMENTING ir.sh # The MIT License (MIT) # # Copyright (c) 2021-2024 Yegor Bugayenko @@ -25,7 +24,7 @@ set -e set -o pipefail -# TODO: #259 ENABLE THIS TESTS RIGHT AFTER IMPLEMENTING ir.sh VIA REMOVING `exit 0` +# TODO: #259 ENABLE THIS TESTS RIGHT AFTER IMPLEMENTING ir.sh VIA REMOVING `exit 0` AND REMOVE `shellcheck disable=SC2317` on the top RIGHT AFTER IMPLEMENTING ir.sh exit 0 temp=$1 @@ -35,11 +34,10 @@ stdout=$2 tmp=$(mktemp -d /tmp/XXXX) cd "${tmp}" mkdir -p "${LOCAL}/${temp}" - if ! "${LOCAL}/metrics/ir.sh" ./ "${LOCAL}/${temp}/stdout" - then + if ! "${LOCAL}/metrics/ir.sh" ./ "${LOCAL}/${temp}/stdout"; then exit 1 fi -} > "${stdout}" 2>&1 +} >"${stdout}" 2>&1 echo "👍🏻 Failed in non-git directory" { @@ -50,8 +48,7 @@ echo "👍🏻 Failed in non-git directory" git init --quiet . git config user.email 'foo@example.com' git config user.name 'Foo' - if ! "${LOCAL}/metrics/ir.sh" ./ "t0" - then + if ! "${LOCAL}/metrics/ir.sh" ./ "t0"; then exit 1 fi file1="one.java" @@ -65,7 +62,7 @@ echo "👍🏻 Failed in non-git directory" git add "${file2}" git commit --quiet -m "second file" "${LOCAL}/metrics/ir.sh" ./ "t2" - grep "IR 1" "t1" # Single file in repo + grep "IR 1" "t1" # Single file in repo grep "IR 0.5 " "t2" # Two files in repo -} > "${stdout}" 2>&1 +} >"${stdout}" 2>&1 echo "👍🏻 Correctly calculated the IR (Impact Ratio)" From d88c731eca69259be39bc85b748f935ad7c1be82 Mon Sep 17 00:00:00 2001 From: zaqbez39me Date: Thu, 25 Apr 2024 21:03:24 +0300 Subject: [PATCH 13/13] removed TOOO from ir.sh --- metrics/ir.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/metrics/ir.sh b/metrics/ir.sh index 2a9a6469..aee14c60 100755 --- a/metrics/ir.sh +++ b/metrics/ir.sh @@ -25,6 +25,5 @@ set -o pipefail output=$(realpath "$2") -# TODO: #259 REPLACE WITH ACTUAL METRIC CODE echo "IR 0.000 " >"${output}"