-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented test for irc feature #279
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
49d0882
created test for irc
zaqbez39me 2e061fc
refactored test by splitting it on smaller tests
zaqbez39me d74db57
fixed the way of disabling test for irc
zaqbez39me 68718bf
initialized a stub for future irc metric
zaqbez39me 91b68a9
added executional permission for test-irc.sh
zaqbez39me 3165cbd
disabled SC2317 for test-irc.sh because test is disabled for now
zaqbez39me d38dbad
added executional permission for irc.sh
zaqbez39me 55b09c9
changed expected behaviour for scripts
zaqbez39me a8d73c2
fixed the format of todos
zaqbez39me 0e0e888
merged two TODOs in one
zaqbez39me 212a607
removed TOOO from irc.sh
zaqbez39me File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/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 | ||
|
||
output=$(realpath "$2") | ||
|
||
# TODO: REPLACE WITH ACTUAL METRIC CODE | ||
echo "IRC 0.000 " >"${output}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/usr/bin/env bash | ||
# shellcheck disable=SC2317 | ||
# TODO: REMOVE SHELLCHECK DISABLE RIGHT AFTER IMPLEMENTING irc.sh | ||
# 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 irc.sh VIA REMOVING `exit 0` | ||
exit 0 | ||
|
||
temp=$1 | ||
stdout=$2 | ||
|
||
{ | ||
tmp=$(mktemp -d /tmp/XXXX) | ||
cd "${tmp}" | ||
mkdir -p "${LOCAL}/${temp}" | ||
touch "${LOCAL}/${temp}/file.java" | ||
"${LOCAL}/metrics/irc.sh" "${LOCAL}/${temp}/file.java" "${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' | ||
file1="one.java" | ||
"${LOCAL}/metrics/irc.sh" "./${file1}" "t0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zaqbez39me also should fail |
||
grep "File does not exist" "t0" # The given file does not exist | ||
} > "${stdout}" 2>&1 | ||
echo "👍🏻 Didn't fail in repo without given file" | ||
|
||
{ | ||
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' | ||
file1="one.java" | ||
touch "${file1}" | ||
"${LOCAL}/metrics/irc.sh" "./${file1}" "t0" | ||
grep "No commits yet in repo" "t0" # There are no commits in repo with given file | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zaqbez39me the output is wrong, should be |
||
} > "${stdout}" 2>&1 | ||
echo "👍🏻 Didn't fail in repo without commits" | ||
|
||
{ | ||
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' | ||
|
||
file1="one.java" | ||
touch "${file1}" | ||
git add "${file1}" | ||
git config commit.gpgsign false | ||
git commit --quiet -m "first file" | ||
"${LOCAL}/metrics/irc.sh" "./${file1}" "t2" | ||
grep "irc 1 " "t2" # There is only commit in repo and it is for the given file | ||
|
||
file2="two.java" | ||
touch "${file2}" | ||
git add "${file2}" | ||
git commit --quiet -m "second file" | ||
"${LOCAL}/metrics/irc.sh" "./${file2}" "t3" | ||
grep "irc 0.5 " "t3" # There are two commits in repo and one for the given file | ||
} > "${stdout}" 2>&1 | ||
echo "👍🏻 Correctly calculated the IRC (Impact Ratio by Commits)" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@zaqbez39me should fail here