Skip to content
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

Reverted fetch-cobolcheck and fetch-cobolcheck.ps1 scripts. #158

Merged
merged 4 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions bin/exercise_test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$slug=Split-Path $PSScriptRoot -Leaf
$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe"

if (![System.IO.File]::Exists("$cobolcheck")){
$fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1"
echo $fetchCobolcheckPath
Write-Output "Cobolcheck not found. Trying to fetch it."
& "${fetchCobolcheckPath}"
}

Write-Output "Run cobolcheck."
Set-Location $PSScriptRoot

Invoke-Expression "$cobolcheck -p $slug"
Invoke-Expression "cobc -xj test.cob"

if ($Lastexitcode -ne 0) {
exit $Lastexitcode
}
16 changes: 16 additions & 0 deletions bin/exercise_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/
SLUG=${1:-$(basename "${SCRIPT_DIR}")}
COBOLCHECK="${HOME}/cobolcheck/cobolcheck"

if [ ! -f "${COBOLCHECK}" ]; then
echo "Cobolcheck not found, try to fetch it."
cd $SCRIPT_DIR/bin/
bash fetch-cobolcheck
fi
cd $SCRIPT_DIR
$COBOLCHECK -p $SLUG

# compile and run
echo "COMPILE AND RUN TEST"
cobc -xj test.cob
7 changes: 5 additions & 2 deletions bin/fetch-cobolcheck
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# It is only used in the cobol track, and a copy of it is placed in every exercise folder.
# If you change something, make sure to upgrade all scripts in all exercises!

set -eo pipefail
# set -eo pipefail

readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest'

Expand Down Expand Up @@ -45,10 +45,13 @@ get_download_url() {
}

main() {
output_path="/usr/local/bin/cobolcheck${ext}"
output_dir="${HOME}/cobolcheck"
mkdir -p "${output_dir}"
output_path="${output_dir}/cobolcheck${ext}"
download_url="$(get_download_url)"
curl "${curlopts[@]}" --output "${output_path}" "${download_url}"
chmod +x "${output_path}"
echo "Cobolcheck has been downloaded to ${output_path}"
}

main
4 changes: 1 addition & 3 deletions bin/fetch-cobolcheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@ Function Get-DownloadUrl {
}

$downloadUrl = Get-DownloadUrl
$outputDir = Join-Path -Path $HOME -ChildPath "cobolcheck"
$outputFile = Join-Path -Path $outputDir -ChildPath "cobolcheck.exe"
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe"
SimaDovakin marked this conversation as resolved.
Show resolved Hide resolved
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts
2 changes: 2 additions & 0 deletions bin/sync-fetch-cobolcheck-files → bin/sync-exercise-files
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ for test_dir in exercises/{concept,practice}/*; do
for file in fetch-cobolcheck fetch-cobolcheck.ps1; do
cp "bin/${file}" "${test_dir}/bin/${file}"
done
cp "bin/exercise_test.sh" "${test_dir}/test.sh"
cp "bin/exercise_test.ps1" "${test_dir}/test.ps1"
done
7 changes: 5 additions & 2 deletions exercises/practice/acronym/bin/fetch-cobolcheck
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# It is only used in the cobol track, and a copy of it is placed in every exercise folder.
# If you change something, make sure to upgrade all scripts in all exercises!

set -eo pipefail
# set -eo pipefail

readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest'

Expand Down Expand Up @@ -45,10 +45,13 @@ get_download_url() {
}

main() {
output_path="/usr/local/bin/cobolcheck${ext}"
output_dir="${HOME}/cobolcheck"
mkdir -p "${output_dir}"
output_path="${output_dir}/cobolcheck${ext}"
download_url="$(get_download_url)"
curl "${curlopts[@]}" --output "${output_path}" "${download_url}"
chmod +x "${output_path}"
echo "Cobolcheck has been downloaded to ${output_path}"
}

main
4 changes: 1 addition & 3 deletions exercises/practice/acronym/bin/fetch-cobolcheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@ Function Get-DownloadUrl {
}

$downloadUrl = Get-DownloadUrl
$outputDir = Join-Path -Path $HOME -ChildPath "cobolcheck"
$outputFile = Join-Path -Path $outputDir -ChildPath "cobolcheck.exe"
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe"
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts
12 changes: 5 additions & 7 deletions exercises/practice/acronym/test.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
$slug=Split-Path $PSScriptRoot -Leaf
$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe"
$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue
$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe"

if ($cobolcheckCmd) {
$cobolcheck = $cobolcheckCmd.Path
Write-Output "Found cobolcheck, using $cobolcheck"
} elseif (![System.IO.File]::Exists("$cobolcheck")){
if (![System.IO.File]::Exists("$cobolcheck")){
$fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1"
echo $fetchCobolcheckPath
Write-Output "Cobolcheck not found. Trying to fetch it."
& "$PSScriptRoot\bin\fetch-cobolcheck.ps1"
& "${fetchCobolcheckPath}"
}

Write-Output "Run cobolcheck."
Expand Down
8 changes: 2 additions & 6 deletions exercises/practice/acronym/test.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/
SLUG=${1:-$(basename "${SCRIPT_DIR}")}
COBOLCHECK=./bin/cobolcheck
COBOLCHECK="${HOME}/cobolcheck/cobolcheck"

WHICH_COBOLCHECK=$(which cobolcheck)
if [[ $? -eq 0 ]] ; then
echo "Found cobolcheck, using $COBOLCHECK"
COBOLCHECK=$WHICH_COBOLCHECK
elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then
Comment on lines -6 to -10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SimaDovakin I think the remove of this part is what breaks the test runner. The cobol test runner downloads the cobolcheck file to: https://github.com/exercism/cobol-test-runner/blob/main/Dockerfile#L16

What I would suggest to do is:

  • Either revert the WHICH part that was deleted, or
  • Change the location of cobolcheck in the test runner (and also update the test.sh files in the tests/* directories to match what is used here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... Ok, I'll return "WHICH" part back.

if [ ! -f "${COBOLCHECK}" ]; then
echo "Cobolcheck not found, try to fetch it."
cd $SCRIPT_DIR/bin/
bash fetch-cobolcheck
Expand Down
7 changes: 5 additions & 2 deletions exercises/practice/all-your-base/bin/fetch-cobolcheck
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# It is only used in the cobol track, and a copy of it is placed in every exercise folder.
# If you change something, make sure to upgrade all scripts in all exercises!

set -eo pipefail
# set -eo pipefail

readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest'

Expand Down Expand Up @@ -45,10 +45,13 @@ get_download_url() {
}

main() {
output_path="/usr/local/bin/cobolcheck${ext}"
output_dir="${HOME}/cobolcheck"
mkdir -p "${output_dir}"
output_path="${output_dir}/cobolcheck${ext}"
download_url="$(get_download_url)"
curl "${curlopts[@]}" --output "${output_path}" "${download_url}"
chmod +x "${output_path}"
echo "Cobolcheck has been downloaded to ${output_path}"
}

main
4 changes: 1 addition & 3 deletions exercises/practice/all-your-base/bin/fetch-cobolcheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@ Function Get-DownloadUrl {
}

$downloadUrl = Get-DownloadUrl
$outputDir = Join-Path -Path $HOME -ChildPath "cobolcheck"
$outputFile = Join-Path -Path $outputDir -ChildPath "cobolcheck.exe"
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe"
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts
12 changes: 5 additions & 7 deletions exercises/practice/all-your-base/test.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
$slug=Split-Path $PSScriptRoot -Leaf
$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe"
$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue
$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe"

if ($cobolcheckCmd) {
$cobolcheck = $cobolcheckCmd.Path
Write-Output "Found cobolcheck, using $cobolcheck"
} elseif (![System.IO.File]::Exists("$cobolcheck")){
if (![System.IO.File]::Exists("$cobolcheck")){
$fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1"
echo $fetchCobolcheckPath
Write-Output "Cobolcheck not found. Trying to fetch it."
& "$PSScriptRoot\bin\fetch-cobolcheck.ps1"
& "${fetchCobolcheckPath}"
}

Write-Output "Run cobolcheck."
Expand Down
8 changes: 2 additions & 6 deletions exercises/practice/all-your-base/test.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/
SLUG=${1:-$(basename "${SCRIPT_DIR}")}
COBOLCHECK=./bin/cobolcheck
COBOLCHECK="${HOME}/cobolcheck/cobolcheck"

WHICH_COBOLCHECK=$(which cobolcheck)
if [[ $? -eq 0 ]] ; then
echo "Found cobolcheck, using $COBOLCHECK"
COBOLCHECK=$WHICH_COBOLCHECK
elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then
if [ ! -f "${COBOLCHECK}" ]; then
echo "Cobolcheck not found, try to fetch it."
cd $SCRIPT_DIR/bin/
bash fetch-cobolcheck
Expand Down
7 changes: 5 additions & 2 deletions exercises/practice/allergies/bin/fetch-cobolcheck
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# It is only used in the cobol track, and a copy of it is placed in every exercise folder.
# If you change something, make sure to upgrade all scripts in all exercises!

set -eo pipefail
# set -eo pipefail

readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest'

Expand Down Expand Up @@ -45,10 +45,13 @@ get_download_url() {
}

main() {
output_path="/usr/local/bin/cobolcheck${ext}"
output_dir="${HOME}/cobolcheck"
mkdir -p "${output_dir}"
output_path="${output_dir}/cobolcheck${ext}"
download_url="$(get_download_url)"
curl "${curlopts[@]}" --output "${output_path}" "${download_url}"
chmod +x "${output_path}"
echo "Cobolcheck has been downloaded to ${output_path}"
}

main
4 changes: 1 addition & 3 deletions exercises/practice/allergies/bin/fetch-cobolcheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@ Function Get-DownloadUrl {
}

$downloadUrl = Get-DownloadUrl
$outputDir = Join-Path -Path $HOME -ChildPath "cobolcheck"
$outputFile = Join-Path -Path $outputDir -ChildPath "cobolcheck.exe"
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe"
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts
12 changes: 5 additions & 7 deletions exercises/practice/allergies/test.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
$slug=Split-Path $PSScriptRoot -Leaf
$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe"
$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue
$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe"

if ($cobolcheckCmd) {
$cobolcheck = $cobolcheckCmd.Path
Write-Output "Found cobolcheck, using $cobolcheck"
} elseif (![System.IO.File]::Exists("$cobolcheck")){
if (![System.IO.File]::Exists("$cobolcheck")){
$fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1"
echo $fetchCobolcheckPath
Write-Output "Cobolcheck not found. Trying to fetch it."
& "$PSScriptRoot\bin\fetch-cobolcheck.ps1"
& "${fetchCobolcheckPath}"
}

Write-Output "Run cobolcheck."
Expand Down
8 changes: 2 additions & 6 deletions exercises/practice/allergies/test.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/
SLUG=${1:-$(basename "${SCRIPT_DIR}")}
COBOLCHECK=./bin/cobolcheck
COBOLCHECK="${HOME}/cobolcheck/cobolcheck"

WHICH_COBOLCHECK=$(which cobolcheck)
if [[ $? -eq 0 ]] ; then
echo "Found cobolcheck, using $COBOLCHECK"
COBOLCHECK=$WHICH_COBOLCHECK
elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then
if [ ! -f "${COBOLCHECK}" ]; then
echo "Cobolcheck not found, try to fetch it."
cd $SCRIPT_DIR/bin/
bash fetch-cobolcheck
Expand Down
7 changes: 5 additions & 2 deletions exercises/practice/anagram/bin/fetch-cobolcheck
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# It is only used in the cobol track, and a copy of it is placed in every exercise folder.
# If you change something, make sure to upgrade all scripts in all exercises!

set -eo pipefail
# set -eo pipefail

readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest'

Expand Down Expand Up @@ -45,10 +45,13 @@ get_download_url() {
}

main() {
output_path="/usr/local/bin/cobolcheck${ext}"
output_dir="${HOME}/cobolcheck"
mkdir -p "${output_dir}"
output_path="${output_dir}/cobolcheck${ext}"
download_url="$(get_download_url)"
curl "${curlopts[@]}" --output "${output_path}" "${download_url}"
chmod +x "${output_path}"
echo "Cobolcheck has been downloaded to ${output_path}"
}

main
4 changes: 1 addition & 3 deletions exercises/practice/anagram/bin/fetch-cobolcheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@ Function Get-DownloadUrl {
}

$downloadUrl = Get-DownloadUrl
$outputDir = Join-Path -Path $HOME -ChildPath "cobolcheck"
$outputFile = Join-Path -Path $outputDir -ChildPath "cobolcheck.exe"
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe"
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts
12 changes: 5 additions & 7 deletions exercises/practice/anagram/test.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
$slug=Split-Path $PSScriptRoot -Leaf
$cobolcheck = "$PSScriptRoot\bin\cobolcheck.exe"
$cobolcheckCmd = Get-Command "cobolcheck.exe" -ErrorAction SilentlyContinue
$cobolcheck = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe"

if ($cobolcheckCmd) {
$cobolcheck = $cobolcheckCmd.Path
Write-Output "Found cobolcheck, using $cobolcheck"
} elseif (![System.IO.File]::Exists("$cobolcheck")){
if (![System.IO.File]::Exists("$cobolcheck")){
$fetchCobolcheckPath = Join-Path -Path "${PSScriptRoot}" "bin" "fetch-cobolcheck.ps1"
echo $fetchCobolcheckPath
Write-Output "Cobolcheck not found. Trying to fetch it."
& "$PSScriptRoot\bin\fetch-cobolcheck.ps1"
& "${fetchCobolcheckPath}"
}

Write-Output "Run cobolcheck."
Expand Down
8 changes: 2 additions & 6 deletions exercises/practice/anagram/test.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#!/usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )/
SLUG=${1:-$(basename "${SCRIPT_DIR}")}
COBOLCHECK=./bin/cobolcheck
COBOLCHECK="${HOME}/cobolcheck/cobolcheck"

WHICH_COBOLCHECK=$(which cobolcheck)
if [[ $? -eq 0 ]] ; then
echo "Found cobolcheck, using $COBOLCHECK"
COBOLCHECK=$WHICH_COBOLCHECK
elif [ ! -f $SCRIPT_DIR/bin/cobolcheck ]; then
if [ ! -f "${COBOLCHECK}" ]; then
echo "Cobolcheck not found, try to fetch it."
cd $SCRIPT_DIR/bin/
bash fetch-cobolcheck
Expand Down
7 changes: 5 additions & 2 deletions exercises/practice/armstrong-numbers/bin/fetch-cobolcheck
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# It is only used in the cobol track, and a copy of it is placed in every exercise folder.
# If you change something, make sure to upgrade all scripts in all exercises!

set -eo pipefail
# set -eo pipefail

readonly LATEST='https://api.github.com/repos/0xE282B0/cobol-check/releases/latest'

Expand Down Expand Up @@ -45,10 +45,13 @@ get_download_url() {
}

main() {
output_path="/usr/local/bin/cobolcheck${ext}"
output_dir="${HOME}/cobolcheck"
mkdir -p "${output_dir}"
output_path="${output_dir}/cobolcheck${ext}"
download_url="$(get_download_url)"
curl "${curlopts[@]}" --output "${output_path}" "${download_url}"
chmod +x "${output_path}"
echo "Cobolcheck has been downloaded to ${output_path}"
}

main
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@ Function Get-DownloadUrl {
}

$downloadUrl = Get-DownloadUrl
$outputDir = Join-Path -Path $HOME -ChildPath "cobolcheck"
$outputFile = Join-Path -Path $outputDir -ChildPath "cobolcheck.exe"
New-Item -ItemType Directory -Path $outputDir -Force | Out-Null
$outputFile = Join-Path -Path "${HOME}" "cobolcheck" "cobolcheck.exe"
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts
Loading
Loading