Skip to content

Commit

Permalink
from appveyor to sourceforge (exercism#128)
Browse files Browse the repository at this point in the history
* from appveyor to sourceforge

* different server

* 7z

* 7z

* yaml issue fixed

* slashes

* 7z oddities

* directories

* $HOME ?

* atbash tweak

* cache management fix

* commented out extraneous DISPLAY in proof.ci.cob files

* eol issue

* line ends fixed

* strangenesses

* SPACE instead of "" in CUT files

* Trim additional line

* Debug

* Try simplify environment variables

* More debugging

* More tweaking

* Fix path

* Fix path

* Fix path

* Fix env

* Streamline

* eof is lf

* acronym

* acronym

* sqrt

* Fix paths

* Fix cache path

---------

Co-authored-by: Erik Schierboom <[email protected]>
  • Loading branch information
axtens and ErikSchierboom committed Apr 19, 2024
1 parent 6da8588 commit 8f81a31
Show file tree
Hide file tree
Showing 30 changed files with 94 additions and 66 deletions.
21 changes: 6 additions & 15 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
id: cache-gnu-cobol
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84
with:
path: ~\gnucobol-3.2-dev.zip
path: $HOME\gnucobol-3.2.7z
key: ${{ runner.os }}-gnu-cobol-3.2

- name: Download GnuCOBOL
Expand All @@ -45,27 +45,18 @@ jobs:
MaximumRetryCount = 3
RetryIntervalSec = 1
}
Invoke-WebRequest -Uri 'https://ci.appveyor.com/api/projects/GitMensch/gnucobol-3-x-win32-posix/artifacts/gnucobol-3.2-dev-MinGW-binaries%20(debug).zip?job=Environment:%20BUILD_TYPE=MSYS,%20BUILD_BIN=C:\MinGW\msys\1.0\bin' -OutFile ~\gnucobol-3.2-dev.zip @requestOpts
Invoke-WebRequest -Uri 'https://www.arnoldtrembley.com/GC32-BDB-SP1-rename-7z-to-exe.7z' -OutFile $HOME\gnucobol-3.2.7z @requestOpts
- name: Extract GnuCOBOL
shell: pwsh
run: Expand-Archive ~\gnucobol-3.2-dev.zip -DestinationPath gnucobol -Force
run: 7z x $HOME\gnucobol-3.2.7z -ognucobol -y

- name: Fetch CobolCheck
shell: pwsh
run: bin/fetch-cobolcheck.ps1

- name: Setup environment
shell: pwsh
run: |
$env:Path = "D:\a\cobol\cobol\gnucobol\bin;$HOME\bin;" + $env:Path
[System.Environment]::SetEnvironmentVariable('COB_CONFIG_DIR', 'D:\a\cobol\cobol\gnucobol\config')
[System.Environment]::SetEnvironmentVariable('COB_COPY_DIR', 'D:\a\cobol\cobol\gnucobol\copy')
[System.Environment]::SetEnvironmentVariable('COB_CFLAGS', '-I D:\a\cobol\cobol\gnucobol\include')
[System.Environment]::SetEnvironmentVariable('COB_LDFLAGS', '-L D:\a\cobol\cobol\gnucobol\lib')
[System.Environment]::SetEnvironmentVariable('COB_LIBRARY_PATH', 'D:\a\cobol\cobol\gnucobol\lib')
[System.Environment]::SetEnvironmentVariable('COB_LIBS', 'D:\a\cobol\cobol\gnucobol\bin\libcob-4.dll')
- name: Run tests for all exercises
shell: pwsh
run: bin/test.ps1
run: |
bin/setup-environment.ps1
bin/test.ps1
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 "bin"
$outputFile = Join-Path -Path $outputDir -ChildPath "cobolcheck.exe"
New-Item -ItemType Directory -Force -Path $outputDir | Out-Null
$outputFile = Join-Path -Path $PSScriptRoot -ChildPath "cobolcheck.exe"
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts
7 changes: 7 additions & 0 deletions bin/setup-environment.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$env:Path = "${env:GITHUB_WORKSPACE}\gnucobol\bin;${env:GITHUB_WORKSPACE}\bin;${env:Path}"
[System.Environment]::SetEnvironmentVariable('COB_CONFIG_DIR', "${env:GITHUB_WORKSPACE}\gnucobol\config")
[System.Environment]::SetEnvironmentVariable('COB_COPY_DIR', "${env:GITHUB_WORKSPACE}\gnucobol\copy")
[System.Environment]::SetEnvironmentVariable('COB_CFLAGS', "-I ${env:GITHUB_WORKSPACE}\gnucobol\include")
[System.Environment]::SetEnvironmentVariable('COB_LDFLAGS', "-L ${env:GITHUB_WORKSPACE}\gnucobol\lib")
[System.Environment]::SetEnvironmentVariable('COB_LIBRARY_PATH', "${env:GITHUB_WORKSPACE}\gnucobol\lib")
[System.Environment]::SetEnvironmentVariable('COB_LIBS', "${env:GITHUB_WORKSPACE}\gnucobol\bin\libcob-4.dll")
4 changes: 1 addition & 3 deletions exercises/practice/acronym/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
EVALUATE CHAR
WHEN "_"
CONTINUE
WHEN " "
WHEN SPACE
MOVE 1 TO PICKNEXT
CONTINUE
WHEN "-"
Expand All @@ -48,5 +48,3 @@
ADD 1 TO LEN
END-PERFORM.
COMPUTE LEN = 80 - LEN.


44 changes: 42 additions & 2 deletions exercises/practice/acronym/src/acronym.cob
Original file line number Diff line number Diff line change
@@ -1,10 +1,50 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. ACRONYM.
PROGRAM-ID. acronym.
AUTHOR. kapitaali.
ENVIRONMENT DIVISION.
DATA DIVISION.
FILE SECTION.

WORKING-STORAGE SECTION.
01 WS-ACRONYM PIC X(80).
01 WS-RESULT PIC X(20).

01 LEN PIC 99.
01 PICKNEXT PIC 9.
01 COUNTER PIC 99.
01 IDX PIC 99.
01 CHAR PIC X.

PROCEDURE DIVISION.
ABBREVIATE.
PERFORM STR-LENGTH.
MOVE 1 TO IDX.
MOVE SPACES TO WS-RESULT.
MOVE 1 TO PICKNEXT.
PERFORM VARYING COUNTER FROM 1 BY 1 UNTIL COUNTER = LEN
MOVE WS-ACRONYM(COUNTER:1) TO CHAR
EVALUATE CHAR
WHEN "_"
CONTINUE
WHEN SPACE
MOVE 1 TO PICKNEXT
CONTINUE
WHEN "-"
MOVE 1 TO PICKNEXT
CONTINUE
WHEN OTHER
IF PICKNEXT = 1
MOVE FUNCTION UPPER-CASE(CHAR)
TO WS-RESULT(IDX:1)
ADD 1 TO IDX
END-IF
MOVE 0 TO PICKNEXT
END-PERFORM.

STR-LENGTH.
MOVE 0 TO LEN.
MOVE FUNCTION LENGTH(WS-ACRONYM) TO IDX.
PERFORM VARYING IDX FROM FUNCTION LENGTH(WS-ACRONYM)
BY -1 UNTIL WS-ACRONYM(IDX:1) <> " "
ADD 1 TO LEN
END-PERFORM.
COMPUTE LEN = 80 - LEN.
1 change: 0 additions & 1 deletion exercises/practice/all-your-base/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,3 @@
MOVE WS-RESULT TO WS-DIGITS.
PERFORM STR-LENGTH.
MOVE SPACES TO WS-RESULT(LEN:1).

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ TestCase "15-bit integer"
TestCase "empty list"
MOVE 2 TO WS-INPUTBASE
MOVE 10 TO WS-OUTPUTBASE
MOVE "" TO WS-DIGITS
MOVE SPACE TO WS-DIGITS
PERFORM REBASE
EXPECT WS-RESULT = "0"

Expand Down Expand Up @@ -97,7 +97,7 @@ TestCase "input base is one"
TestCase "input base is zero"
MOVE 0 TO WS-INPUTBASE
MOVE 10 TO WS-OUTPUTBASE
MOVE "" TO WS-DIGITS
MOVE SPACE TO WS-DIGITS
PERFORM REBASE
EXPECT WS-ERROR = "input base must be >= 2"

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/allergies/tst/allergies/allergies.cut
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ TestCase "cats: allergic to everything",
TestCase "list when: no allergies"
MOVE 0 TO WS-SCORE
PERFORM LIST-ALLERGENS
EXPECT WS-RESULT-LIST = ""
EXPECT WS-RESULT-LIST = SPACE

TestCase "list when: just eggs"
MOVE 1 TO WS-SCORE
Expand Down
5 changes: 3 additions & 2 deletions exercises/practice/armstrong-numbers/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@
MOVE 0 TO WS-RESULT
END-IF.

DISPLAY WS-ARMSTRONG.
DISPLAY WS-NUMBER.
* DISPLAY WS-ARMSTRONG.
* DISPLAY WS-NUMBER.
2 changes: 1 addition & 1 deletion exercises/practice/binary/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
MOVE CHAR-ERROR TO WS-ERROR
NEXT SENTENCE
END-IF
END-PERFORM.
END-PERFORM.
2 changes: 1 addition & 1 deletion exercises/practice/bob/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@
MOVE "Whatever." TO WS-RESULT
END-IF
END-EVALUATE
END-IF.
END-IF.
2 changes: 1 addition & 1 deletion exercises/practice/bob/tst/bob/bob.cut
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ TestCase "prattling on"
EXPECT WS-RESULT = "Sure."

TestCase "silence"
MOVE "" TO WS-HEYBOB
MOVE SPACE TO WS-HEYBOB
PERFORM BOB
EXPECT WS-RESULT = "Fine. Be that way!"

Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/collatz-conjecture/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
ADD 1 TO WS-STEPS
END-PERFORM.

DISPLAY WS-STEPS.
DISPLAY WS-ERROR.
*DISPLAY WS-STEPS.
*DISPLAY WS-ERROR.
12 changes: 6 additions & 6 deletions exercises/practice/complex-numbers/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@
COMPUTE RESULT-IM = Z1-IM * Z2-RE + Z1-RE * Z2-IM.

C-DIV.
DISPLAY "Z1 (" Z1-RE "," Z1-IM ") Z2 (" Z2-RE "," Z2-IM ")".
* DISPLAY "Z1 (" Z1-RE "," Z1-IM ") Z2 (" Z2-RE "," Z2-IM ")".
COMPUTE TEMP = Z2-RE * Z2-RE + Z2-IM * Z2-IM.
DISPLAY "TEMP " TEMP.
* DISPLAY "TEMP " TEMP.
COMPUTE RESULT-RE = Z1-RE * Z2-RE + Z1-IM * Z2-IM.
COMPUTE RESULT-RE = RESULT-RE / TEMP.
DISPLAY "RESULT-RE " RESULT-RE.
* DISPLAY "RESULT-RE " RESULT-RE.
COMPUTE RESULT-IM = Z1-IM * Z2-RE - Z1-RE * Z2-IM.
DISPLAY Z1-IM "*" Z2-RE "-" Z1-RE "*" Z2-IM.
DISPLAY "= " RESULT-IM " / TEMP=" TEMP.
* DISPLAY Z1-IM "*" Z2-RE "-" Z1-RE "*" Z2-IM.
* DISPLAY "= " RESULT-IM " / TEMP=" TEMP.
COMPUTE RESULT-IM = RESULT-IM / TEMP.
DISPLAY "RESULT-IM " RESULT-IM.
* DISPLAY "RESULT-IM " RESULT-IM.

C-ABS.
MOVE 0 TO RESULT-IM.
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/difference-of-squares/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
WS-SQUARE-OF-SUM - WS-SUM-OF-SQUARES.

SHOW-RESULTS.
DISPLAY WS-SQUARE-OF-SUM.
DISPLAY WS-SUM-OF-SQUARES.
DISPLAY WS-DIFFERENCE-OF-SQUARES.
*DISPLAY WS-SQUARE-OF-SUM.
*DISPLAY WS-SUM-OF-SQUARES.
*DISPLAY WS-DIFFERENCE-OF-SQUARES.

4 changes: 2 additions & 2 deletions exercises/practice/hamming/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@

END-PERFORM.

DISPLAY "Hamming Distance is: " WS-HAMMING.
DISPLAY WS-ERROR.
*DISPLAY "Hamming Distance is: " WS-HAMMING.
*DISPLAY WS-ERROR.
1 change: 0 additions & 1 deletion exercises/practice/hello-world/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
HELLO-WORLD.
MOVE "Hello, World!" TO WS-RESULT.


2 changes: 1 addition & 1 deletion exercises/practice/luhn/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
MOVE "FALSE" TO WS-VALID
END-IF.

DISPLAY WS-VALID.
*DISPLAY WS-VALID.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ TestCase "paired square brackets"
EXPECT WS-RESULT = 1

TestCase "empty string"
MOVE "" TO WS-INPUT
MOVE SPACE TO WS-INPUT
PERFORM ISPAIRED
EXPECT WS-RESULT = 1

Expand Down
10 changes: 5 additions & 5 deletions exercises/practice/nucleotide-count/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
END-EVALUATE
END-PERFORM.

DISPLAY "A: " WS-A.
DISPLAY "C: " WS-C.
DISPLAY "G: " WS-G.
DISPLAY "T: " WS-T.
DISPLAY WS-ERROR.
*DISPLAY "A: " WS-A.
*DISPLAY "C: " WS-C.
*DISPLAY "G: " WS-G.
*DISPLAY "T: " WS-T.
*DISPLAY WS-ERROR.
2 changes: 1 addition & 1 deletion exercises/practice/raindrops/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
MOVE WS-NUMBER TO WS-RESULT
END-IF.

DISPLAY WS-RESULT.
*DISPLAY WS-RESULT.
2 changes: 1 addition & 1 deletion exercises/practice/reverse-string/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
MOVE FUNCTION TRIM(WS-STRING LEADING)
TO WS-STRING.

DISPLAY WS-STRING.
*DISPLAY WS-STRING.
2 changes: 1 addition & 1 deletion exercises/practice/rna-transcription/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
INSPECT WS-COMPLEMENT CONVERTING WS-DNA
TO WS-RNA.

DISPLAY WS-COMPLEMENT.
*DISPLAY WS-COMPLEMENT.
1 change: 0 additions & 1 deletion exercises/practice/roman-numerals/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,3 @@
ALL "c" BY COLUMN-LETTER-CHARACTERS(3).
MAKE-ROMAN-EXIT.
EXIT.

4 changes: 2 additions & 2 deletions exercises/practice/rotational-cipher/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
TO WS-CIPHER (WS-CHAR-INDEX:1)
END-PERFORM.

DISPLAY "Plain: " WS-TEXT.
DISPLAY "Cipher: " WS-CIPHER.
*DISPLAY "Plain: " WS-TEXT.
*DISPLAY "Cipher: " WS-CIPHER.
2 changes: 1 addition & 1 deletion exercises/practice/scrabble-score/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@
END-IF

SET LETTER-INDEX UP BY 1
END-PERFORM.
END-PERFORM.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ TestCase "english-like word"
EXPECT WS-RESULT = 8

TestCase "empty input"
MOVE "" TO WS-WORD
MOVE SPACE TO WS-WORD
PERFORM SCRABBLE-SCORE
EXPECT WS-RESULT = 0

Expand Down
4 changes: 1 addition & 3 deletions exercises/practice/square-root/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@

PROCEDURE DIVISION.
SQUARE-ROOT.
COMPUTE WS-SQRT = WS-NUMBER ** .5

DISPLAY WS-SQRT.
COMPUTE WS-SQRT = WS-NUMBER ** 0.5.
1 change: 0 additions & 1 deletion exercises/practice/square-root/src/square-root.cob
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@

PROCEDURE DIVISION.
SQUARE-ROOT.

1 change: 0 additions & 1 deletion exercises/practice/yacht/.meta/proof.ci.cob
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,3 @@
END-PERFORM.
BUBBLE-SORT-EXIT.
EXIT.

0 comments on commit 8f81a31

Please sign in to comment.