-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: worksofliam <[email protected]>
- Loading branch information
1 parent
b4340e7
commit 063d337
Showing
4 changed files
with
191 additions
and
0 deletions.
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,63 @@ | ||
import { describe, expect, test } from "vitest"; | ||
import { setupFixture, setupIncludeFix, setupProjectFromQsys } from "./fixtures/projects"; | ||
|
||
import { Targets } from '../src/targets' | ||
import { getFiles, renameFiles } from "../src/utils"; | ||
import { scanGlob } from "../src/extensions"; | ||
|
||
import * as path from "path"; | ||
|
||
test(`Auto rename RPGLE program and include and fix-include infos`, async () => { | ||
const cwd = setupFixture(`auto_rename1`); | ||
|
||
// First step is to rename the files | ||
|
||
let targets = new Targets(cwd); | ||
targets.setSuggestions({renames: true}); | ||
|
||
const initialFiles = getFiles(cwd, scanGlob); | ||
targets.loadObjectsFromPaths(initialFiles); | ||
await Promise.allSettled(initialFiles.map(f => targets.parseFile(f))); | ||
|
||
targets.resolveBinder(); | ||
|
||
let allLogs = targets.logger.getAllLogs(); | ||
expect(Object.keys(allLogs).length).toBeGreaterThan(0); | ||
|
||
const pgmSource = allLogs[path.join(`src`, `BBSADMMNUR.rpgle`)].filter(log => log.type === `rename`); | ||
const cbkSource = allLogs[path.join(`src`, `CBKOPTIMIZ.rpgle`)]; | ||
|
||
expect(pgmSource.length).toBe(1); | ||
expect(cbkSource.length).toBe(1); | ||
|
||
expect(pgmSource[0].message).toBe(`Rename suggestion`); | ||
expect(pgmSource[0].type).toBe(`rename`); | ||
expect(pgmSource[0].change.rename.newName).toBe(`BBSADMMNUR.pgm.rpgle`); | ||
|
||
expect(cbkSource[0].message).toBe(`Rename suggestion`); | ||
expect(cbkSource[0].type).toBe(`rename`); | ||
expect(cbkSource[0].change.rename.newName).toBe(`CBKOPTIMIZ.rpgleinc`); | ||
|
||
// Trigger the rename | ||
renameFiles(targets.logger); | ||
|
||
// Next, scan the project again and check the logs | ||
targets = new Targets(cwd); | ||
targets.setSuggestions({includes: true}); | ||
|
||
const newFiles = getFiles(cwd, scanGlob); | ||
targets.loadObjectsFromPaths(newFiles); | ||
await Promise.allSettled(newFiles.map(f => targets.parseFile(f))); | ||
|
||
allLogs = targets.logger.getAllLogs(); | ||
|
||
console.log(allLogs); | ||
const newPgmSource = allLogs[path.join(`src`, `BBSADMMNUR.pgm.rpgle`)].filter(log => log.type === `includeFix`); | ||
|
||
expect(newPgmSource.length).toBe(1); | ||
|
||
expect(newPgmSource[0].message).toBe(`Will update to use unix style path.`); | ||
expect(newPgmSource[0].type).toBe(`includeFix`); | ||
expect(newPgmSource[0].change.lineContent).toBe(` /copy 'src/CBKOPTIMIZ.rpgleinc'`); | ||
expect(newPgmSource[0].line).toBe(11); | ||
}); |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Dave Asta | ||
|
||
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 NONINFRINGEMENT. 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. |
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,103 @@ | ||
H/TITLE Administration Menu | ||
H COPYRIGHT('(C) 2020 David Asta under MIT License') | ||
* SYSTEM : V4R5 | ||
* PROGRAMMER : David Asta | ||
* DATE-WRITTEN: 26/NOV/2020 | ||
* | ||
* This program shows the Administration Menu to a logged in SysOp | ||
********************************************************************** | ||
* INDICATORS USED: | ||
* 33 - *ON = BBS is in Maintenance Mode | ||
********************************************************************** | ||
H/COPY DVBBS400/CURRENTSRC,CBKOPTIMIZ | ||
********************************************************************** | ||
FBBSADMMNUDCF E WORKSTN | ||
FPCONFIG UF E K DISK | ||
********************************************************************** | ||
* Data structures | ||
D/COPY DVBBS400/CURRENTSRC,CBKDTAARA | ||
* Variables | ||
D wCfgKey S 6A | ||
D wMode S 1A | ||
********************************************************************** | ||
C WRITE HEADER | ||
C WRITE FOOTER | ||
C EXFMT MNUADM | ||
C EXSR CheckFkeys | ||
********************************************************************** | ||
* Subroutine called automatically at startup | ||
********************************************************************** | ||
C *INZSR BEGSR | ||
C EVAL SCRSCR = 'BBSADMMNU' | ||
* Get values from DTAARA and show them on the screen | ||
D/COPY DVBBS400/CURRENTSRC,CBKHEADER | ||
C EXSR UpdMaintOnScr | ||
C ENDSR | ||
********************************************************************** | ||
* Check Functions keys pressed by user | ||
********************************************************************** | ||
C CheckFkeys BEGSR | ||
C SELECT | ||
C WHEN *IN12 = *ON | ||
* F12=Go back | ||
C EVAL *INLR = *ON | ||
C RETURN | ||
C WHEN *IN13 = *ON | ||
* F13=General configuration | ||
C CALL 'BBSADGCR' | ||
C WHEN *IN14 = *ON | ||
* F14=Boards & Sub-Boards | ||
C EVAL wMode = 'A' | ||
C CALL 'BBSBRDLR' | ||
C PARM wMode | ||
C WHEN *IN15 = *ON | ||
* F15=Users Management | ||
C EVAL wMode = 'M' | ||
C CALL 'BBSLSTUSRR' | ||
C PARM wMode | ||
C WHEN *IN16 = *ON | ||
* F16=Access Levels | ||
C CALL 'BBSAACCLVR' | ||
C WHEN *IN17 = *ON | ||
* F17=Polls | ||
C EVAL wMode = 'A' | ||
C CALL 'BBSPOLLSLR' | ||
C PARM wMode | ||
C WHEN *IN18 = *ON | ||
* F18=New User default values | ||
C CALL 'BBSADNUDFR' | ||
C WHEN *IN19 = *ON | ||
* F19=Text Files (IFS) | ||
C EVAL wMode = 'A' | ||
C CALL 'BBSIFSFILR' | ||
C PARM wMode | ||
C WHEN *IN20 = *ON | ||
* F20=External Programs | ||
C EVAL wMode = 'A' | ||
C CALL 'BBSETPGMSR' | ||
C PARM wMode | ||
C WHEN *IN24 = *ON | ||
* F24=Set Maintenance Mode ON/OFF | ||
C EVAL wCfgKey = 'MAINTM' | ||
C wCfgKey CHAIN PCONFIG 41 | ||
C 41'ERROR 41' dsply | ||
C 41 GOTO ENDOFSR | ||
C 33 EVAL CNFVAL = 'N' | ||
C 33 EVAL wMAINTM = 'N' | ||
C N33 EVAL CNFVAL = 'Y' | ||
C N33 EVAL wMAINTM = 'Y' | ||
C UPDATE CONFIG 41 | ||
C N41 EXSR UpdMaintOnScr | ||
C ENDSL | ||
C ENDOFSR TAG | ||
C ENDSR | ||
********************************************************************** | ||
* Update Maintenance Mode on Screen | ||
********************************************************************** | ||
C UpdMaintOnScr BEGSR | ||
C IF wMAINTM = 'Y' | ||
C EVAL *IN33 = *ON | ||
C ELSE | ||
C EVAL *IN33 = *OFF | ||
C ENDIF | ||
C ENDSR |
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,4 @@ | ||
* Level optimisation FULL | ||
* The most efficient code is generated. | ||
* Translation time is the longest. | ||
H OPTIMIZE(*FULL) |