Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:

pull_request:

permissions:
contents: read

jobs:
api:
name: Test API
Expand Down
8 changes: 8 additions & 0 deletions api/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,14 @@ export class Runner {
// Wrap all include directories in quotes
compileParams.incDir = compileParams.incDir.map((dir) => `'${dir}'`);

// Wrap additional compiler and linker parameters in quotes
if(compileParams.cmpparm) {
compileParams.cmpparm = `'${compileParams.cmpparm}'`
}
if(compileParams.lnkparm) {
compileParams.lnkparm = `'${compileParams.lnkparm}'`
}

// Flatten compile parameters and convert to strings
const flattenedCompileParams = ApiUtils.flattenCommandParams(compileParams);

Expand Down
4 changes: 4 additions & 0 deletions api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ export interface RUCRTRPG {
rpgPpOpt?: string,
pOption?: string[],
compileOpt?: string,
cmpparm?: string,
lnkparm?: string,
tgtRls?: string
incDir?: string[],
tgtCcsid?: string | number
Expand All @@ -205,6 +207,8 @@ export interface RUCRTCBL {
module?: string[],
pOption?: string[],
compileOpt?: string,
cmpparm?: string,
lnkparm?: string,
tgtRls?: string
incDir?: string[],
tgtCcsid?: number
Expand Down
20 changes: 20 additions & 0 deletions schemas/testing.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,16 @@
"default": "",
"markdownDescription": "Pre-Compiler COMPILEOPT\n\nRefer to the `COMPILEOPT` parameter in `CRTSQLRPGI` command help."
},
"cmpparm": {
"type": "string",
"default": "",
"markdownDescription": "Additional compiler parameters\n\nSpecifies any additional compiler parameters for producing the command for compiling the module."
},
"lnkparm": {
"type": "string",
"default": "",
"markdownDescription": "Additional linker parameters\n\nSpecifies any additional linker parameters for producing the command for linking the unit test service program."
},
"tgtRls": {
"anyOf": [
{
Expand Down Expand Up @@ -709,6 +719,16 @@
"default": "",
"markdownDescription": "Pre-Compiler COMPILEOPT\n\nRefer to the `COMPILEOPT` parameter in `CRTSQLCBLI` command help."
},
"cmpparm": {
"type": "string",
"default": "",
"markdownDescription": "Additional compiler parameters\n\nSpecifies any additional compiler parameters for producing the command for compiling the module."
},
"lnkparm": {
"type": "string",
"default": "",
"markdownDescription": "Additional linker parameters\n\nSpecifies any additional linker parameters for producing the command for linking the unit test service program."
},
"tgtRls": {
"anyOf": [
{
Expand Down
23 changes: 18 additions & 5 deletions src/components/rpgUnit/rpgUnit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { GitHub, Release } from "./github";

export class RPGUnit implements IBMiComponent {
static readonly ID: string = "RPGUnit";
static readonly VERSION_REGEX = 'v\\d+(\\.\\d+){2}(\\.b\\d{1,3}|\\.r)?';
static readonly VERSION_REGEX = 'v\\d+(\\.\\d+){2}(\\.b\\d{1,3}|\\.r|\\.v)?';
static context: ExtensionContext;

private readonly localAssetPath: string;
Expand Down Expand Up @@ -387,6 +387,15 @@ export class RPGUnit implements IBMiComponent {
// Get new component state
const newState = await this.getRemoteState(connection, installDirectory);
if (newState.status === 'Installed') {
// Approve usage of library if not already approved
const state = GlobalState.get();
const host = connection.currentHost;
const approvedLibraries = state.approvedLibraries[host] ?? [];
if (!approvedLibraries.includes(productLibrary)) {
await GlobalState.set({ ...state, approvedLibraries: { ...state.approvedLibraries, [host]: [...approvedLibraries, productLibrary] } });
await testOutputLogger.log(LogLevel.Info, `${productLibrary}.LIB approved for usage.`);
}

await testOutputLogger.appendWithNotification(LogLevel.Info, `RPGUnit v${VERSION} installed successfully into ${productLibrary}.LIB`);
} else {
await testOutputLogger.appendWithNotification(LogLevel.Error, `RPGUnit v${VERSION} failed to install into ${productLibrary}.LIB`, undefined, errorButtons);
Expand All @@ -396,15 +405,19 @@ export class RPGUnit implements IBMiComponent {

async compareVersions(v1: string, v2: string): Promise<number> {
function normalize(v: string) {
// Remove prefix
v = v.replace('v', '');
// Remove version prefix
if (v.startsWith('v')) {
v = v.slice(1)
}

// Remove production suffix
v = v.replace('.r', '');
if (v.endsWith('.v') || v.endsWith('.r')) {
v = v.slice(0, -2);
}

// Convert beta suffix
if (!v.includes('-beta.')) {
v = v.includes('.b') ? v.replace('.b', '-beta.') : v.includes('b') ? v.replace('b', '-beta.') : v;
v = v.includes('.b') ? v.replace('.b', '-beta.') : (v.includes('b') ? v.replace('b', '-beta.') : v);
}

return v;
Expand Down
Loading