Skip to content

Commit 21ed1be

Browse files
Merge pull request #43 from pcoop/branch1
line-wrap for jobcard
2 parents eb7b647 + 2550714 commit 21ed1be

File tree

3 files changed

+122
-2
lines changed

3 files changed

+122
-2
lines changed

__tests__/api/BundleDeploy/BundleDeployer.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,44 @@ describe("BundleDeployer01", () => {
200200
"// MSGCLASS=X,TIME=NOLIMIT";
201201
await testDeployJCL(parms);
202202
});
203+
it("should support long line jobcard", async () => {
204+
205+
let parms: IHandlerParameters;
206+
parms = DEFAULT_PARAMTERS;
207+
setCommonParmsForDeployTests(parms);
208+
parms.arguments.resgroup = "12345678";
209+
parms.arguments.jobcard = "//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT,NOEL=ABCDEFGHIJKMNOPQRSTUVWXYZ";
210+
await testDeployJCL(parms);
211+
});
212+
it("should support really long line jobcard", async () => {
213+
214+
let parms: IHandlerParameters;
215+
parms = DEFAULT_PARAMTERS;
216+
setCommonParmsForDeployTests(parms);
217+
parms.arguments.resgroup = "12345678";
218+
parms.arguments.jobcard = "//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT,NOEL=ABCDEFGHIJKMNOPQRSTUVWXYZ," +
219+
"72CHARS=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz," +
220+
"ALPHABETIC=ABCDEFGHIJKLMNOPQRSTUVWXYZ";
221+
await testDeployJCL(parms);
222+
});
223+
it("should fail with overlong jobcard", async () => {
224+
225+
let parms: IHandlerParameters;
226+
parms = DEFAULT_PARAMTERS;
227+
setCommonParmsForDeployTests(parms);
228+
parms.arguments.resgroup = "12345678";
229+
parms.arguments.jobcard = "//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT,NOEL=ABCDEFGHIJKMNOPQRSTUVWXYZ," +
230+
"ALPHABETIC=ABCDEFGHIJKLMNOPQRSTUVWXYZ," +
231+
"73CHARS=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1";
232+
let err: Error;
233+
try {
234+
await testDeployJCL(parms);
235+
} catch (e) {
236+
err = e;
237+
}
238+
expect(err).toBeDefined();
239+
expect(err.message).toMatchSnapshot();
240+
});
203241
it("should support long bundledir", async () => {
204242

205243
let parms: IHandlerParameters;

__tests__/api/BundleDeploy/__snapshots__/BundleDeployer.test.ts.snap

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ exports[`BundleDeployer01 should deploy successfully 1`] = `"DFHRL2012I"`;
3030

3131
exports[`BundleDeployer01 should deploy successfully 2`] = `"DFHDPLOY DEPLOY command successful."`;
3232

33+
exports[`BundleDeployer01 should fail with overlong jobcard 1`] = `"--jobcard parameter section cannot be split into 72 character lines: '// 73CHARS=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1'."`;
34+
3335
exports[`BundleDeployer01 should generate deploy JCL for csdgroup 1`] = `"DFHRL2037I"`;
3436

3537
exports[`BundleDeployer01 should generate deploy JCL for csdgroup 2`] = `
@@ -248,6 +250,33 @@ DEPLOY BUNDLE(12345678)
248250
"
249251
`;
250252

253+
exports[`BundleDeployer01 should support long line jobcard 1`] = `"DFHRL2037I"`;
254+
255+
exports[`BundleDeployer01 should support long line jobcard 2`] = `
256+
"//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT,
257+
// NOEL=ABCDEFGHIJKMNOPQRSTUVWXYZ
258+
//DFHDPLOY EXEC PGM=DFHDPLOY,REGION=100M
259+
//STEPLIB DD DISP=SHR,DSN=12345678901234567890123456789012345.SDFHLOAD
260+
// DD DISP=SHR,DSN=abcde12345abcde12345abcde12345abcde.SEYUAUTH
261+
//SYSTSPRT DD SYSOUT=*
262+
//SYSIN DD *
263+
*
264+
SET CICSPLEX(12345678);
265+
*
266+
UNDEPLOY BUNDLE(12345678)
267+
SCOPE(12345678)
268+
STATE(DISCARDED)
269+
RESGROUP(12345678);
270+
*
271+
DEPLOY BUNDLE(12345678)
272+
BUNDLEDIR(1234567890)
273+
SCOPE(12345678)
274+
STATE(AVAILABLE)
275+
RESGROUP(12345678);
276+
/*
277+
"
278+
`;
279+
251280
exports[`BundleDeployer01 should support multi-line jobcard 1`] = `"DFHRL2037I"`;
252281

253282
exports[`BundleDeployer01 should support multi-line jobcard 2`] = `
@@ -275,6 +304,35 @@ DEPLOY BUNDLE(12345678)
275304
"
276305
`;
277306

307+
exports[`BundleDeployer01 should support really long line jobcard 1`] = `"DFHRL2037I"`;
308+
309+
exports[`BundleDeployer01 should support really long line jobcard 2`] = `
310+
"//DFHDPLOY JOB DFHDPLOY,CLASS=A,MSGCLASS=X,TIME=NOLIMIT,
311+
// NOEL=ABCDEFGHIJKMNOPQRSTUVWXYZ,
312+
// 72CHARS=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,
313+
// ALPHABETIC=ABCDEFGHIJKLMNOPQRSTUVWXYZ
314+
//DFHDPLOY EXEC PGM=DFHDPLOY,REGION=100M
315+
//STEPLIB DD DISP=SHR,DSN=12345678901234567890123456789012345.SDFHLOAD
316+
// DD DISP=SHR,DSN=abcde12345abcde12345abcde12345abcde.SEYUAUTH
317+
//SYSTSPRT DD SYSOUT=*
318+
//SYSIN DD *
319+
*
320+
SET CICSPLEX(12345678);
321+
*
322+
UNDEPLOY BUNDLE(12345678)
323+
SCOPE(12345678)
324+
STATE(DISCARDED)
325+
RESGROUP(12345678);
326+
*
327+
DEPLOY BUNDLE(12345678)
328+
BUNDLEDIR(1234567890)
329+
SCOPE(12345678)
330+
STATE(AVAILABLE)
331+
RESGROUP(12345678);
332+
/*
333+
"
334+
`;
335+
278336
exports[`BundleDeployer01 should tolerate empty output from DFHDPLOY 1`] = `"undefined"`;
279337

280338
exports[`BundleDeployer01 should tolerate empty output from DFHDPLOY 2`] = `"DFHDPLOY did not generate any output. Most recent status update: 'Submitting DFHDPLOY JCL'."`;

src/api/BundleDeploy/ParmValidator.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,32 @@ export class ParmValidator {
281281
throw new Error("--jobcard parameter is empty");
282282
}
283283

284-
// resolve any new line escape sequences embedded in the jobcard
285-
params.arguments.jobcard = params.arguments.jobcard.replace("\\n", "\n");
284+
// handle long jobcards
285+
if (params.arguments.jobcard.indexOf("\\n") === -1) {
286+
// if the user hasn't embedded new-line characters into the jobcard
287+
// then we'll have to do that ourselves if the value is too long
288+
let jobcardLocal = params.arguments.jobcard;
289+
let jobcardNew = "";
290+
const MAX_JCL_LINE = 71;
291+
while (jobcardLocal.length > MAX_JCL_LINE) {
292+
const indexOflastComma = jobcardLocal.lastIndexOf(",", MAX_JCL_LINE);
293+
294+
if (indexOflastComma === -1) {
295+
throw new Error("--jobcard parameter section cannot be split into 72 character lines: '" + jobcardLocal + "'.");
296+
}
297+
298+
jobcardNew = jobcardNew + jobcardLocal.substring(0, indexOflastComma + 1) + "\n";
299+
jobcardLocal = "// " + jobcardLocal.substring(indexOflastComma + 1);
300+
}
301+
jobcardNew = jobcardNew + jobcardLocal;
302+
params.arguments.jobcard = jobcardNew;
303+
}
304+
else {
305+
// if the user has embedded new-line characters within the jobcard
306+
// then resolve them, the user has taken responsibility for ensuring
307+
// line breaks are in suitable places.
308+
params.arguments.jobcard = params.arguments.jobcard.replace("\\n", "\n");
309+
}
286310

287311
// split the jobcard into a comma separated list
288312
const jobcardParts = params.arguments.jobcard.split(",");

0 commit comments

Comments
 (0)