Skip to content

Commit 8a3b244

Browse files
committed
Test cases to prove granular makefiles
Signed-off-by: worksofliam <[email protected]>
1 parent 5aa4a91 commit 8a3b244

File tree

5 files changed

+97
-12
lines changed

5 files changed

+97
-12
lines changed

cli/test/cs_srvpgm.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe(`pseudo tests`, () => {
5454
expect(empdet.deps.find(f => f.systemName === `EMPLOYEE`)).toBeDefined();
5555
expect(empdet.deps.find(f => f.systemName === `DEPARTMENT`)).toBeDefined();
5656

57-
const allRequirements = targets.getRequiredObjects([empdet]);
57+
const allRequirements = targets.getRequiredChildren([empdet]);
5858
expect(allRequirements.length).toBe(3);
5959
expect(allRequirements.find(f => f.systemName === `EMPLOYEE` && f.type === `FILE`)).toBeDefined();
6060
expect(allRequirements.find(f => f.systemName === `DEPARTMENT` && f.type === `FILE`)).toBeDefined();
@@ -69,7 +69,7 @@ describe(`pseudo tests`, () => {
6969
expect(employees.deps.find(f => f.systemName === `EMPS` && f.type === `FILE`)).toBeDefined();
7070
expect(employees.deps.find(f => f.systemName === `EMPLOYEE` && f.type === `FILE`)).toBeDefined();
7171

72-
const requiredForEmployees = targets.getRequiredObjects([employees]);
72+
const requiredForEmployees = targets.getRequiredChildren([employees]);
7373
expect(requiredForEmployees.length).toBe(6);
7474

7575
expect(requiredForEmployees.find(f => f.systemName === `EMPLOYEES` && f.type === `PGM`)).toBeDefined();

cli/test/cs_with_bnddir.test.ts

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,70 @@ describe(`pseudo tests`, () => {
9696
expect(steps.length).toBe(8);
9797
});
9898

99-
test('makefile partial', async () => {
99+
test('makefile partial (without parents, object has no children)', async () => {
100100
const makefile = new MakeProject(targets.getCwd(), targets, fs);
101-
makefile.setPartialOptions({partial: true, parents: true});
101+
makefile.setPartialOptions({parents: false});
102+
await makefile.setupSettings();
103+
104+
const resolvedObjects = targets.getResolvedObjects();
105+
106+
const nept = resolvedObjects.find(f => f.systemName === `NEMP` && f.type === `FILE`);
107+
const targetsOut = makefile.generateTargets([nept]).join(`\n`);
108+
console.log(targetsOut);
109+
110+
expect(targetsOut).toContain(`all: .logs .evfevent library $(PREPATH)/NEMP.FILE`);
111+
expect(targetsOut).not.toContain(`$(PREPATH)/NEWEMP.PGM:`);
112+
113+
const rules = makefile.generateGenericRules([nept]).join(`\n`);
114+
console.log(rules);
115+
116+
expect(rules).toContain(`$(PREPATH)/NEMP.FILE:`);
117+
});
118+
119+
test('makefile partial (without parents, object with children)', async () => {
120+
const makefile = new MakeProject(targets.getCwd(), targets, fs);
121+
makefile.setPartialOptions({parents: false, withChildren: true});
122+
await makefile.setupSettings();
123+
124+
const resolvedObjects = targets.getResolvedObjects();
125+
126+
const nept = resolvedObjects.find(f => f.systemName === `NEWEMP` && f.type === `PGM`);
127+
const targetsOut = makefile.generateTargets([nept]).join(`\n`);
128+
console.log(targetsOut);
129+
130+
expect(targetsOut).toContain(`all: .logs .evfevent library $(PREPATH)/NEWEMP.PGM`);
131+
expect(targetsOut).toContain(`$(PREPATH)/NEWEMP.PGM:`);
132+
133+
const rules = makefile.generateGenericRules([nept]).join(`\n`);
134+
console.log(rules);
135+
136+
expect(rules).toContain(`$(PREPATH)/NEMP.FILE:`);
137+
});
138+
139+
test('makefile partial (without parents, object with children, but using withChildren false)', async () => {
140+
const makefile = new MakeProject(targets.getCwd(), targets, fs);
141+
makefile.setPartialOptions({parents: false, withChildren: false});
142+
await makefile.setupSettings();
143+
144+
const resolvedObjects = targets.getResolvedObjects();
145+
146+
const nept = resolvedObjects.find(f => f.systemName === `NEWEMP` && f.type === `PGM`);
147+
const targetsOut = makefile.generateTargets([nept]).join(`\n`);
148+
console.log(targetsOut);
149+
150+
expect(targetsOut).toContain(`all: .logs .evfevent library $(PREPATH)/NEWEMP.PGM`);
151+
expect(targetsOut).not.toContain(`$(PREPATH)/NEWEMP.PGM:`);
152+
153+
const rules = makefile.generateGenericRules([nept]).join(`\n`);
154+
console.log(rules);
155+
156+
expect(rules).not.toContain(`$(PREPATH)/NEMP.FILE:`);
157+
expect(rules).toContain(`$(PREPATH)/NEWEMP.PGM: qrpglesrc/newemp.pgm.sqlrpgle`);
158+
});
159+
160+
test('makefile partial (with parents)', async () => {
161+
const makefile = new MakeProject(targets.getCwd(), targets, fs);
162+
makefile.setPartialOptions({parents: true});
102163
await makefile.setupSettings();
103164

104165
const resolvedObjects = targets.getResolvedObjects();
@@ -116,6 +177,30 @@ describe(`pseudo tests`, () => {
116177
expect(rules).toContain(`$(PREPATH)/NEMP.FILE:`);
117178
expect(rules).toContain(`$(PREPATH)/NEWEMP.PGM:`);
118179
expect(rules).toContain(`$(PREPATH)/DEPTS.PGM:`);
180+
expect(rules).not.toContain(`$(PREPATH)/EMPLOYEES.PGM:`);
181+
});
182+
183+
test('makefile partial (with parents, and children parent)', async () => {
184+
const makefile = new MakeProject(targets.getCwd(), targets, fs);
185+
makefile.setPartialOptions({parents: true, parentsChildren: true});
186+
await makefile.setupSettings();
187+
188+
const resolvedObjects = targets.getResolvedObjects();
189+
190+
const nept = resolvedObjects.find(f => f.systemName === `NEMP` && f.type === `FILE`);
191+
const targetsOut = makefile.generateTargets([nept]).join(`\n`);
192+
console.log(targetsOut);
193+
194+
expect(targetsOut).toContain(`all: .logs .evfevent library $(PREPATH)/NEMP.FILE $(PREPATH)/NEWEMP.PGM $(PREPATH)/DEPTS.PGM`);
195+
expect(targetsOut).toContain(`$(PREPATH)/NEWEMP.PGM: $(PREPATH)/EMPLOYEE.FILE $(PREPATH)/NEMP.FILE`);
196+
197+
const rules = makefile.generateGenericRules([nept]).join(`\n`);
198+
console.log(rules);
199+
200+
expect(rules).toContain(`$(PREPATH)/NEMP.FILE:`);
201+
expect(rules).toContain(`$(PREPATH)/NEWEMP.PGM:`);
202+
expect(rules).toContain(`$(PREPATH)/DEPTS.PGM:`);
203+
expect(rules).toContain(`$(PREPATH)/EMPLOYEES.PGM:`);
119204
});
120205

121206
test('ibmi-bob rules', () => {

cli/test/make.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ test('generateTargets (post-resolve)', async () => {
191191
const project = new MakeProject(cwd, targets, new ReadFileSystem());
192192

193193
const srvpgma = targets.getTarget({systemName: `SRVPGMA`, type: `SRVPGM`});
194-
const srvpgmaRequirements = targets.getRequiredObjects([srvpgma]);
194+
const srvpgmaRequirements = targets.getRequiredChildren([srvpgma]);
195195
expect(srvpgmaRequirements.length).toBe(3);
196196
expect(srvpgmaRequirements.map(r => r.systemName)).toEqual([
197197
`FILEB`,
198198
`MODULEB`,
199199
`SRVPGMA`
200200
]);
201201

202-
project.setPartialOptions({partial: true, parents: false});
202+
project.setPartialOptions({withChildren: true});
203203

204204
const targetContent = project.generateTargets([srvpgma]);
205205

cli/test/project.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ describe(`company_system tests`, () => {
308308
const makeProject = new MakeProject(project.cwd, targets, fs);
309309
await makeProject.setupSettings();
310310

311-
makeProject.setPartialOptions({partial: true, parents: true});
311+
makeProject.setPartialOptions({withChildren: true, parents: true});
312312

313313
const deptsFile = targets.getTarget({systemName: `DEPTS`, type: `FILE`});
314314

@@ -325,7 +325,7 @@ describe(`company_system tests`, () => {
325325
const makeProject = new MakeProject(project.cwd, targets, fs);
326326
await makeProject.setupSettings();
327327

328-
makeProject.setPartialOptions({partial: false, parents: true});
328+
makeProject.setPartialOptions({withChildren: true, parents: true});
329329

330330
const empFile = targets.getTarget({systemName: `EMPLOYEE`, type: `FILE`});
331331

@@ -351,7 +351,7 @@ describe(`company_system tests`, () => {
351351
const makeProject = new MakeProject(project.cwd, targets, fs);
352352
await makeProject.setupSettings();
353353

354-
makeProject.setPartialOptions({partial: false, parents: true});
354+
makeProject.setPartialOptions({withChildren: true, parents: true});
355355

356356
const deptsFile = targets.getTarget({systemName: `EMPLOYEE`, type: `FILE`});
357357

cli/test/project2.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ describe(`company_system tests`, () => {
302302
const makeProject = new MakeProject(project.cwd, targets, fs);
303303
await makeProject.setupSettings();
304304

305-
makeProject.setPartialOptions({partial: false, parents: true});
305+
makeProject.setPartialOptions({withChildren: true, parents: true});
306306

307307
const deptsFile = targets.getTarget({systemName: `DEPTS`, type: `FILE`});
308308

@@ -319,7 +319,7 @@ describe(`company_system tests`, () => {
319319
const makeProject = new MakeProject(project.cwd, targets, fs);
320320
await makeProject.setupSettings();
321321

322-
makeProject.setPartialOptions({partial: false, parents: true});
322+
makeProject.setPartialOptions({withChildren: true, parents: true});
323323

324324
const employeeFile = targets.getTarget({systemName: `EMPLOYEE`, type: `FILE`});
325325

@@ -347,7 +347,7 @@ describe(`company_system tests`, () => {
347347
const makeProject = new MakeProject(project.cwd, targets, fs);
348348
await makeProject.setupSettings();
349349

350-
makeProject.setPartialOptions({partial: false, parents: true});
350+
makeProject.setPartialOptions({withChildren: true, parents: true});
351351

352352
const empFile = targets.getTarget({systemName: `EMPLOYEE`, type: `FILE`});
353353

0 commit comments

Comments
 (0)