-
Notifications
You must be signed in to change notification settings - Fork 20
Update multi-module support and add tests #114
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,79 @@ | ||
| import { beforeAll, describe, expect, test } from 'vitest'; | ||
|
|
||
| import { Targets } from '../src/targets' | ||
| import { MakeProject } from '../src/builders/make'; | ||
| import { setupFixture } from './fixtures/projects'; | ||
| import { ReadFileSystem } from '../src/readFileSystem'; | ||
| import { BobProject } from '../src/builders/bob'; | ||
|
|
||
| describe(`pseudo tests`, () => { | ||
| const project = setupFixture(`cs_srvpgm`); | ||
|
|
||
| const fs = new ReadFileSystem(); | ||
| const targets = new Targets(project.cwd, fs); | ||
| let make: MakeProject; | ||
|
|
||
| beforeAll(async () => { | ||
| project.setup(); | ||
| await targets.loadProject(); | ||
|
|
||
| expect(targets.getTargets().length).toBeGreaterThan(0); | ||
| targets.resolveBinder(); | ||
|
|
||
| make = new MakeProject(project.cwd, targets); | ||
| }); | ||
|
|
||
| test(`That test files are understood`, () => { | ||
| expect(targets).toBeDefined(); | ||
|
|
||
| const testModule = targets.getTarget({systemName: `EMPTEST`, type: `MODULE`}); | ||
| expect(testModule).toBeDefined(); | ||
|
|
||
| expect(testModule.deps.length).toBe(3); | ||
| expect(testModule.deps.find(f => f.systemName === `EMPLOYEE`)).toBeDefined(); | ||
| expect(testModule.deps.find(f => f.systemName === `DEPARTMENT`)).toBeDefined(); | ||
| expect(testModule.deps.find(f => f.systemName === `EMPDET`)).toBeDefined(); | ||
| }); | ||
|
|
||
| test('Deps are picked up for the module', () => { | ||
| const empdet = targets.getTarget({systemName: `EMPDET`, type: `MODULE`}); | ||
| expect(empdet).toBeDefined(); | ||
|
|
||
| expect(empdet.deps.length).toBe(2); | ||
| expect(empdet.deps.find(f => f.systemName === `EMPLOYEE`)).toBeDefined(); | ||
| expect(empdet.deps.find(f => f.systemName === `DEPARTMENT`)).toBeDefined(); | ||
|
|
||
| const employees = targets.getTarget({systemName: `EMPLOYEES`, type: `PGM`}); | ||
| expect(employees).toBeDefined(); | ||
|
|
||
| expect(employees.deps.length).toBe(4); | ||
| expect(employees.deps.find(f => f.systemName === `EMPLOYEES` && f.type === `MODULE`)).toBeDefined(); | ||
| expect(employees.deps.find(f => f.systemName === `EMPDET` && f.type === `MODULE`)).toBeDefined(); | ||
| expect(employees.deps.find(f => f.systemName === `EMPS` && f.type === `FILE`)).toBeDefined(); | ||
| expect(employees.deps.find(f => f.systemName === `EMPLOYEE` && f.type === `FILE`)).toBeDefined(); | ||
| }); | ||
|
|
||
| test('ibmi-bob rules', () => { | ||
| const bobProject = new BobProject(targets); | ||
|
|
||
| const files = bobProject.createRules(); | ||
|
|
||
| expect(files[`Rules.mk`]).toBeDefined(); | ||
| expect(files[`Rules.mk`]).toBe(`SUBDIRS = qddssrc qrpglesrc qtestsrc`); | ||
|
|
||
| expect(files[`qtestsrc/Rules.mk`]).toBe(`EMPTEST.MODULE: emptest.test.sqlrpgle qrpgleref/empdet.rpgleinc EMPLOYEE.FILE DEPARTMENT.FILE EMPDET.MODULE`) | ||
|
Check failure on line 64 in cli/test/cs_srvpgm.test.ts
|
||
|
|
||
| console.log(files[`qrpglesrc/Rules.mk`]); | ||
| expect(files[`qrpglesrc/Rules.mk`]).toContain(`EMPLOYEES.MODULE: employees.pgm.sqlrpgle qrpgleref/constants.rpgleinc qrpgleref/empdet.rpgleinc`); | ||
| expect(files[`qrpglesrc/Rules.mk`]).toContain(`EMPLOYEES.PGM: EMPLOYEE.FILE EMPS.FILE EMPDET.MODULE EMPLOYEES.MODULE`); | ||
| }); | ||
|
|
||
| test('makefile', () => { | ||
| const makefile = new MakeProject(targets.getCwd(), targets); | ||
|
|
||
| const contents = makefile.getMakefile().join(`\n`); | ||
|
|
||
| expect(contents).toContain(`$(PREPATH)/EMPLOYEES.PGM:`); | ||
| expect(contents).toContain(`system "CRTPGM PGM($(BIN_LIB)/EMPLOYEES) ENTMOD(EMPLOYEES) MODULE(EMPDET EMPLOYEES) TGTRLS(*CURRENT) BNDDIR($(BNDDIR)) ACTGRP(*NEW)" > .logs/employees.splf`); | ||
| }); | ||
| }); | ||
This file contains hidden or 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 @@ | ||
| --https://www.ibm.com/docs/en/i/7.3?topic=tables-department-table-department | ||
|
|
||
| CREATE OR REPLACE TABLE DEPARTMENT | ||
| (DEPTNO CHAR(3) NOT NULL, | ||
| DEPTNAME VARCHAR(36) NOT NULL, | ||
| MGRNO CHAR(6) NOT NULL, | ||
| ADMRDEPT CHAR(3) NOT NULL, | ||
| LOCATION CHAR(16) NOT NULL, | ||
| PRIMARY KEY (DEPTNO)); | ||
|
|
||
| ALTER TABLE DEPARTMENT | ||
| ADD FOREIGN KEY ROD (ADMRDEPT) | ||
| REFERENCES DEPARTMENT | ||
| ON DELETE CASCADE; | ||
|
|
||
| -- Remove circular reference | ||
| --ALTER TABLE DEPARTMENT | ||
| -- ADD FOREIGN KEY RDE (MGRNO) | ||
| -- REFERENCES EMPLOYEE | ||
| -- ON DELETE SET NULL; | ||
|
|
||
| -- CREATE UNIQUE INDEX XDEPT1 | ||
| -- ON DEPARTMENT (DEPTNO); | ||
|
|
||
| -- CREATE INDEX XDEPT2 | ||
| -- ON DEPARTMENT (MGRNO); | ||
|
|
||
| -- CREATE INDEX XDEPT3 | ||
| -- ON DEPARTMENT (ADMRDEPT); |
This file contains hidden or 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,36 @@ | ||
| A INDARA | ||
| A CA03(03) | ||
| A R SFLDTA SFL | ||
| A RRN 4Y 0H | ||
| A* DISPLAY DTA | ||
| A XSEL 1A B 7 8 | ||
| A XID 3A O 7 12 | ||
| A XNAME 38A O 7 16 | ||
| A* COLOR HELLO | ||
| A R SFLCTL SFLCTL(SFLDTA) | ||
| A SFLPAG(0014) | ||
| A SFLSIZ(9999) | ||
| A OVERLAY | ||
| A 85 SFLDSPCTL | ||
| A 95 SFLDSP | ||
| A N85 SFLCLR | ||
| A SFLRRN 4S 0H SFLRCDNBR(CURSOR) | ||
| A* | ||
| A 6 6'Opt' | ||
| A DSPATR(HI) | ||
| A DSPATR(UL) | ||
| A 6 12'ID' | ||
| A DSPATR(HI) | ||
| A DSPATR(UL) | ||
| A 6 16'Name' | ||
| A DSPATR(UL) | ||
| A COLOR(WHT) | ||
| A R FOOTER_FMT | ||
| A OVERLAY | ||
| A 3 6'F3=Exit' | ||
| A COLOR(BLU) | ||
| A 2 35'Departments' | ||
| A DSPATR(UL) | ||
| A COLOR(WHT) | ||
| A 4 6'5=View 8=New Employee' | ||
| A COLOR(BLU) |
This file contains hidden or 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,34 @@ | ||
| -- https://www.ibm.com/docs/en/i/7.3?topic=tables-employee-table-employee | ||
|
|
||
| CREATE OR REPLACE TABLE EMPLOYEE | ||
| (EMPNO CHAR(6) NOT NULL, | ||
| FIRSTNME VARCHAR(12) NOT NULL, | ||
| MIDINIT CHAR(1) NOT NULL, | ||
| LASTNAME VARCHAR(15) NOT NULL, | ||
| WORKDEPT CHAR(3) , | ||
| PHONENO CHAR(4) , | ||
| HIREDATE DATE , | ||
| JOB CHAR(8) , | ||
| EDLEVEL SMALLINT NOT NULL, | ||
| SEX CHAR(1) , | ||
| BIRTHDATE DATE , | ||
| SALARY DECIMAL(9,2) , | ||
| BONUS DECIMAL(9,2) , | ||
| COMM DECIMAL(9,2) , | ||
| PRIMARY KEY (EMPNO)); | ||
|
|
||
| -- Remove circular reference | ||
| -- ALTER TABLE EMPLOYEE | ||
| -- ADD FOREIGN KEY RED (WORKDEPT) | ||
| -- REFERENCES DEPARTMENT | ||
| -- ON DELETE SET NULL; | ||
|
|
||
| ALTER TABLE EMPLOYEE | ||
| ADD CONSTRAINT NUMBER | ||
| CHECK (PHONENO >= '0000' AND PHONENO <= '9998'); | ||
|
|
||
| -- CREATE UNIQUE INDEX XEMP1 | ||
| -- ON EMPLOYEE (EMPNO); | ||
|
|
||
| -- CREATE INDEX XEMP2 | ||
| -- ON EMPLOYEE (WORKDEPT); |
This file contains hidden or 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,41 @@ | ||
| A INDARA | ||
| A CA12(12) | ||
| A R SFLDTA SFL | ||
| A RRN 4Y 0H | ||
| A* DISPLAY DTA | ||
| A XSEL 1A B 7 8 | ||
| A XID 6A O 7 12 | ||
| A XNAME 30A O 7 20 | ||
| A XJOB 8A O 7 52 | ||
| A* COLOR HELLO | ||
| A R SFLCTL SFLCTL(SFLDTA) | ||
| A SFLPAG(0014) | ||
| A SFLSIZ(9999) | ||
| A OVERLAY | ||
| A 85 SFLDSPCTL | ||
| A 95 SFLDSP | ||
| A N85 SFLCLR | ||
| A SFLRRN 4S 0H SFLRCDNBR(CURSOR) | ||
| A* | ||
| A 6 6'Opt' | ||
| A DSPATR(HI) | ||
| A DSPATR(UL) | ||
| A 6 12'ID' | ||
| A DSPATR(HI) | ||
| A DSPATR(UL) | ||
| A 6 20'Name' | ||
| A DSPATR(UL) | ||
| A COLOR(WHT) | ||
| A 6 52'Job' | ||
| A DSPATR(UL) | ||
| A COLOR(WHT) | ||
| A 5 52'Total' | ||
| A DSPATR(UL) | ||
| A COLOR(WHT) | ||
| A XTOT 9S 2O 5 61 | ||
| A R FOOTER_FMT | ||
| A OVERLAY | ||
| A 3 06'F12=Back' | ||
| A COLOR(BLU) | ||
| A 2 35'Employees' | ||
| A DSPATR(UL) |
This file contains hidden or 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,50 @@ | ||
| A INDARA | ||
| A CA12(12) | ||
| A R DETAIL | ||
| A 6 10'ID' | ||
| A DSPATR(HI) | ||
| A DSPATR(UL) | ||
| A XID 6A O 6 14 | ||
|
|
||
| A 7 7'First' | ||
| A DSPATR(UL) | ||
| A COLOR(WHT) | ||
| A XFIRST 12A B 7 14 | ||
|
|
||
| A 8 5'Initial' | ||
| A DSPATR(UL) | ||
| A COLOR(WHT) | ||
| A XINIT 1A B 8 14 | ||
|
|
||
| A 9 8'Last' | ||
| A DSPATR(UL) | ||
| A COLOR(WHT) | ||
| A XLAST 15A B 9 14 | ||
|
|
||
| A 10 2'Department' | ||
| A DSPATR(UL) | ||
| A COLOR(WHT) | ||
| A XDEPT 3A O 10 14 | ||
|
|
||
| A 11 9'Job' | ||
| A DSPATR(UL) | ||
| A COLOR(WHT) | ||
| A XJOB 8A B 11 14 | ||
|
|
||
| A 12 6'Salary' | ||
| A DSPATR(UL) | ||
| A COLOR(WHT) | ||
| A XSAL 10A B 12 14 | ||
|
|
||
| A 13 7'Phone' | ||
| A DSPATR(UL) | ||
| A COLOR(WHT) | ||
| A XTEL 4A B 13 14 | ||
|
|
||
| A XERR 50A O 15 14COLOR(RED) | ||
| A R HEADER_FMT | ||
| A OVERLAY | ||
| A 3 06'F12=Back Enter=Create' | ||
| A COLOR(BLU) | ||
| A 2 33'New Employee' | ||
| A DSPATR(UL) |
This file contains hidden or 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,40 @@ | ||
| ------------------------------------------------------------------------------- | ||
| -- This procedure will create 5 records into the department table | ||
| ------------------------------------------------------------------------------- | ||
|
|
||
| create or replace procedure popdept() | ||
| language sql | ||
| Result Sets 0 | ||
| Modifies SQL Data | ||
| Specific popdept | ||
| begin | ||
| declare i int default 1; | ||
| declare deptno char(3); | ||
| declare deptname varchar(36); | ||
| declare mgrno char(6); | ||
| declare admrdept char(3); | ||
| declare loc char(16); | ||
|
|
||
| while i <= 5 do | ||
| -- Generate random data (you can adjust this as needed) | ||
| set deptno = right('000' || cast(rand()*1000 as int), 3); | ||
| set mgrno = right('00000' || cast(rand()*1000000 as int), 6); | ||
| set admrdept = right('000' || cast(rand()*1000 as int), 3); | ||
| set loc = 'Location ' || deptno; | ||
|
|
||
| -- Assign department names based on specified categories | ||
| case | ||
| when i = 1 then set deptname = 'Admin'; | ||
| when i = 2 then set deptname = 'IT'; | ||
| when i = 3 then set deptname = 'Finance'; | ||
| when i = 4 then set deptname = 'Management'; | ||
| when i = 5 then set deptname = 'HR'; | ||
| end case; | ||
|
|
||
| -- Insert into department table | ||
| insert into department (deptno, deptname, mgrno, admrdept, location) | ||
| values (deptno, deptname, mgrno, admrdept, loc) with nc; | ||
|
|
||
| set i = i + 1; | ||
| end while; | ||
| end; |
Oops, something went wrong.
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.
what does it mean for a MODULE to be dependent on a different MODULE