From ab8cd3a721fb92ac049618ac37a32257520da32b Mon Sep 17 00:00:00 2001 From: MoromugHSE Date: Mon, 1 Apr 2024 06:23:10 +0300 Subject: [PATCH 1/8] Created a metric name uniqueness test (based on measure-file.sh to run all metrics) --- tests/steps/test-unique.sh | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/steps/test-unique.sh diff --git a/tests/steps/test-unique.sh b/tests/steps/test-unique.sh new file mode 100644 index 00000000..9b7f0418 --- /dev/null +++ b/tests/steps/test-unique.sh @@ -0,0 +1,55 @@ +#!/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 + +temp=$1 +stdout=$2 + +{ + java="${temp}/Foo(xls;)';aга привет '\".java" + cat > "${java}" < "${stdout}" 2>&1 +echo "👍🏻 All provided metrics are named uniquely" + From 90e3e451b83ea7c933738de025a9f35235489c67 Mon Sep 17 00:00:00 2001 From: MoromugHSE Date: Mon, 1 Apr 2024 09:58:56 +0300 Subject: [PATCH 2/8] Replaced "expected" literal with expression and cleaned the code according to linter demands. --- tests/steps/test-unique.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/steps/test-unique.sh b/tests/steps/test-unique.sh index 9b7f0418..a7f922df 100644 --- a/tests/steps/test-unique.sh +++ b/tests/steps/test-unique.sh @@ -40,10 +40,10 @@ stdout=$2 private final boolean boom() { return true; } } EOT - $("${LOCAL}/steps/measure-file.sh" "${java}" "${temp}/m1") + "${LOCAL}/steps/measure-file.sh" "${java}" "${temp}/m1" set -x all=$(find "${temp}" -name 'm1.*' -type f -exec basename {} \; | sort) - expected=52 + expected=$(echo "${all}" | wc -l | xargs) actual=$(echo "${all}" | uniq | wc -l | xargs) if [ ! "${actual}" = "${expected}" ]; then echo "Exactly ${expected} unique metric names were expected, but ${actual} were actually found" From d64b2d72c8edb55b5c69e41889a7d21c80f75dce Mon Sep 17 00:00:00 2001 From: MoromugHSE Date: Mon, 1 Apr 2024 20:44:43 +0300 Subject: [PATCH 3/8] Now I'm 100% sure. This build even works in docker. I can't imagine it failing. I cannot. --- tests/steps/test-discover-repos.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/steps/test-discover-repos.sh b/tests/steps/test-discover-repos.sh index 8cd63bb0..fc55ab88 100755 --- a/tests/steps/test-discover-repos.sh +++ b/tests/steps/test-discover-repos.sh @@ -34,8 +34,8 @@ tex=${TARGET}/foo.tex echo "${msg}" echo "${msg}" | grep "Found 1 repositories in page #0" echo "${msg}" | grep "Found 3 total repositories in GitHub" - test -e "${csv}" test -s "${tex}" + test -e "${csv}" test "$(wc -l < "${csv}" | xargs)" = '4' } > "${stdout}" 2>&1 echo "👍🏻 Small repositories discovery test is succeed" @@ -46,8 +46,8 @@ echo "👍🏻 Small repositories discovery test is succeed" echo "${msg}" echo "${msg}" | grep "Found 60 total repositories in GitHub" echo "${msg}" | grep "We will use only the first 35 repositories" - test -e "${csv}" test -s "${tex}" + test -e "${csv}" test "$(wc -l < "${csv}" | xargs)" = '36' } > "${stdout}" 2>&1 echo "👍🏻 Medium repositories discovery test is succeed" From 6b1c57940fdfe70977ac5cb44b4525cef7e24eb1 Mon Sep 17 00:00:00 2001 From: MoromugHSE Date: Mon, 1 Apr 2024 21:34:26 +0300 Subject: [PATCH 4/8] I've removed redundant target from non-docker runs. Should work? --- tests/steps/test-discover-repos.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/steps/test-discover-repos.sh b/tests/steps/test-discover-repos.sh index fc55ab88..8cd63bb0 100755 --- a/tests/steps/test-discover-repos.sh +++ b/tests/steps/test-discover-repos.sh @@ -34,8 +34,8 @@ tex=${TARGET}/foo.tex echo "${msg}" echo "${msg}" | grep "Found 1 repositories in page #0" echo "${msg}" | grep "Found 3 total repositories in GitHub" - test -s "${tex}" test -e "${csv}" + test -s "${tex}" test "$(wc -l < "${csv}" | xargs)" = '4' } > "${stdout}" 2>&1 echo "👍🏻 Small repositories discovery test is succeed" @@ -46,8 +46,8 @@ echo "👍🏻 Small repositories discovery test is succeed" echo "${msg}" echo "${msg}" | grep "Found 60 total repositories in GitHub" echo "${msg}" | grep "We will use only the first 35 repositories" - test -s "${tex}" test -e "${csv}" + test -s "${tex}" test "$(wc -l < "${csv}" | xargs)" = '36' } > "${stdout}" 2>&1 echo "👍🏻 Medium repositories discovery test is succeed" From fe6897aa641ae7b372f1a5789c7df0a32698c430 Mon Sep 17 00:00:00 2001 From: MoromugHSE Date: Mon, 1 Apr 2024 22:15:46 +0300 Subject: [PATCH 5/8] Desperate times -- trying to make test-unique.sh executable --- tests/steps/test-unique.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/steps/test-unique.sh b/tests/steps/test-unique.sh index a7f922df..e7465882 100644 --- a/tests/steps/test-unique.sh +++ b/tests/steps/test-unique.sh @@ -27,7 +27,7 @@ temp=$1 stdout=$2 { - java="${temp}/Foo(xls;)';aга привет '\".java" + java="${temp}/Foo(xls;)';не привет '\".java" cat > "${java}" < Date: Tue, 2 Apr 2024 13:27:44 +0300 Subject: [PATCH 6/8] Temporary removed test-unique.sh --- tests/steps/test-unique.sh | 55 -------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 tests/steps/test-unique.sh diff --git a/tests/steps/test-unique.sh b/tests/steps/test-unique.sh deleted file mode 100644 index e7465882..00000000 --- a/tests/steps/test-unique.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/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 - -temp=$1 -stdout=$2 - -{ - java="${temp}/Foo(xls;)';не привет '\".java" - cat > "${java}" < "${stdout}" 2>&1 -echo "👍🏻 All provided metrics are named uniquely" - From b94f093a2f00ec1e4f475a3ccfd4e2f68b5dc907 Mon Sep 17 00:00:00 2001 From: MoromugHSE Date: Tue, 2 Apr 2024 13:29:33 +0300 Subject: [PATCH 7/8] Recreated test-unique.sh -- hopely executable now --- tests/steps/test-unique.sh | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/steps/test-unique.sh diff --git a/tests/steps/test-unique.sh b/tests/steps/test-unique.sh new file mode 100644 index 00000000..e7465882 --- /dev/null +++ b/tests/steps/test-unique.sh @@ -0,0 +1,55 @@ +#!/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 + +temp=$1 +stdout=$2 + +{ + java="${temp}/Foo(xls;)';не привет '\".java" + cat > "${java}" < "${stdout}" 2>&1 +echo "👍🏻 All provided metrics are named uniquely" + From b4e1d55331492bdf5cddcf724d7714786ae5c4f8 Mon Sep 17 00:00:00 2001 From: MoromugHSE Date: Tue, 2 Apr 2024 14:22:50 +0300 Subject: [PATCH 8/8] Now git sees test-unique.sh as executable --- tests/steps/test-unique.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tests/steps/test-unique.sh diff --git a/tests/steps/test-unique.sh b/tests/steps/test-unique.sh old mode 100644 new mode 100755