Skip to content

Commit

Permalink
refactor some code and update docs ready for v0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
CaribouJohn committed Aug 11, 2020
1 parent 4c011a2 commit 8e444ff
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 194 deletions.
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,25 @@ For more information about PySys please visit the [PySys project page](https://p

## Features

![overview](images/example_screen1.png)

* See your PySys project structure at a quick glance
* Create and run tests directly from the UI
* Set custom arguments with which to run your tests
* Test failures are displayed in the vscode problems tab

![overview](images/example_screen1.png)
![problems tab](images/custom_settings.png)
* From PySys 1.6 Test failures are displayed in the vscode problems tab
![problems tab](images/probtab.png)
* show the tests as a flat structure or in tree form
![flat toggle](images/flat.gif)

## Requirements

Python and the PySys framework are required to use this extension.

## Settings
The extension will use the python and pysys that are currently on the path. The status bar will show the version of PySys found.
![problems tab](images/version.png)

![settings](images/settings.png)

* **PySys Interpreter :** the default PySys interpreter the application will use.

***
___The extension will not load if python or PySys are not detected.___

## PySys view

Expand Down Expand Up @@ -59,3 +60,7 @@ Run projects, directories or individual tests with default settings.
Or set your own settings for running projects or directories, such as setting custom run arguments.

![custom](images/custom.gif)

Finally if you use PySys 1.6+ the output of your runs will be automatically shown in the problems tab of vscode. These problems can then be used to navigate to the source of the error.

![problems](images/problems.gif)
Binary file added images/custom_settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/flat.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/problems.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/probtab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/version.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 0 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@
],
"main": "./out/extension",
"contributes": {
"configuration": {
"title": "Python interpeter for Pysys",
"properties": {
"pysys.defaultInterpreterPath": {
"type": "string",
"description": "Path to Python that has Pysys installed. The extension will attempt to set this, but the value can be overidden manually."
}
}
},
"taskDefinitions": [
{
"type": "pysys",
Expand Down
58 changes: 32 additions & 26 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,52 @@
import * as vscode from "vscode";
import semver = require("semver");

import {PysysProjectView} from "./pysys/pysysView";
import { PysysEnvironment } from "./utils/pysysEnvironment";
import { PysysRunner } from "./utils/pysysRunner";
import { PysysTaskProvider } from "./utils/pysysTaskProvider";



export async function activate(context: vscode.ExtensionContext): Promise<void> {

const logger: vscode.OutputChannel = vscode.window.createOutputChannel("Pysys Extension");
logger.show();
logger.appendLine("Started Pysys Extension");
logger.appendLine(vscode.env.remoteName || "local");
const pysysEnv = new PysysEnvironment(logger);

// todo: here we need to also check for Apama - we can do this by checking to see if the extension
// configuration exists - softwareag.apama.apamahome
// if it does, we can try the test below to see if we can run with no modifications
// otherwise we should ask whether to use the python/pysys included in here
// we would do this by setting up the commands to run similarly to the apama extension where
// we source the environment && run the command

// check config
// check user prefs - need to save them
// set up commands similar to apama extension (use them in PysysRunner instead of hard coded ones)

// semver.lt(corrVersion , "10.5.3") - we can use semver to restrict capabilities if required.
// we should consider adding an element to the status bar at the bottom to show what versions
// we are running with

if(vscode.workspace.workspaceFolders !== undefined) {
let tprov: PysysTaskProvider | undefined = await buildStatusBar(logger,context);
if(vscode.workspace.workspaceFolders !== undefined && tprov !== undefined) {
const myClonedArray : vscode.WorkspaceFolder[] = [...vscode.workspace.workspaceFolders];

vscode.window.registerTreeDataProvider(
"pysysProjects",
new PysysProjectView(logger, myClonedArray, context)
new PysysProjectView(logger, myClonedArray, context,tprov)
);
}
}
async function buildStatusBar(logger: vscode.OutputChannel, context: vscode.ExtensionContext) : Promise<PysysTaskProvider|undefined> {
if(context !== undefined) {
let interpreter = " python -m pysys "; //default - no longer configurable
let versionCmd: PysysRunner = new PysysRunner("version", `${interpreter} --version`, logger);
let versionOutput: any = await versionCmd.run(".",[]);
let version = "";
let versionlines: string[] = versionOutput.stdout.split("\n");
const pat : RegExp = new RegExp(/PySys.System.Test.Framework\s+\(version\s+([^\s]+)\s+on\s+Python\s+([^)]+)\)/);


const taskprov = new PysysTaskProvider();
context.subscriptions.push(vscode.tasks.registerTaskProvider("pysys", taskprov));
for (let index: number = 0; index < versionlines.length; index++) {
const line : string = versionlines[index];
if ( pat.test(line) ) {
version = RegExp.$1;
}
}

if(version) {
let statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 100);
statusBar.text = `Pysys ${version}`;
statusBar.show();
context.subscriptions.push(statusBar);
let taskProvider = new PysysTaskProvider(version);
context.subscriptions.push(vscode.tasks.registerTaskProvider("pysys", taskProvider));
return taskProvider;
}
}
return undefined;
}

export function deactivate():void {
Expand Down
42 changes: 4 additions & 38 deletions src/pysys/pysysView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,26 @@ import {PysysRunner} from "../utils/pysysRunner";
import {PysysTaskProvider} from "../utils/pysysTaskProvider";
import {pickWorkspaceFolder, pickDirectory, createTaskConfig} from "../utils/fsUtils";
import * as path from "path";
import semver = require("semver");

export class PysysProjectView implements vscode.TreeDataProvider<PysysTreeItem> {

private _onDidChangeTreeData: vscode.EventEmitter<PysysTreeItem | undefined> = new vscode.EventEmitter<PysysTreeItem | undefined>();
readonly onDidChangeTreeData: vscode.Event<PysysTreeItem | undefined> = this._onDidChangeTreeData.event;

private workspaceList: PysysWorkspace[] = [];
private taskProvider: PysysTaskProvider;

private config: vscode.WorkspaceConfiguration;
private interpreter: string | undefined;

private isFlatStructure: boolean;

constructor(private logger: vscode.OutputChannel,
private workspaces: vscode.WorkspaceFolder[],
private context: vscode.ExtensionContext) {
private context: vscode.ExtensionContext,
private taskProvider: PysysTaskProvider) {

this.config = vscode.workspace.getConfiguration("pysys");
this.interpreter = this.config.get("defaultInterpreterPath");
this.interpreter = " python -m pysys ";
this.registerCommands();
this.buildStatusBar();
this.taskProvider = new PysysTaskProvider();

this.isFlatStructure = false;

Expand All @@ -37,12 +34,6 @@ export class PysysProjectView implements vscode.TreeDataProvider<PysysTreeItem>
workspaces.forEach( ws => this.workspaceList.push(
new PysysWorkspace(ws.name, collapedState , ws, ws.uri.fsPath,context.asAbsolutePath('resources'))
));

vscode.workspace.onDidChangeConfiguration(async e => {
if(e.affectsConfiguration('pysys.defaultInterpreterPath')) {
this.taskProvider = new PysysTaskProvider();
}
});
}

registerCommands(): void {
Expand Down Expand Up @@ -261,31 +252,6 @@ export class PysysProjectView implements vscode.TreeDataProvider<PysysTreeItem>
}
}

async buildStatusBar() {
if(this.context !== undefined) {
let versionCmd: PysysRunner = new PysysRunner("version", `${this.interpreter} --version`, this.logger);
let versionOutput: any = await versionCmd.run(".",[]);

let versionlines: string[] = versionOutput.stdout.split("\n");
const pat : RegExp = new RegExp(/PySys.System.Test.Framework\s+\(version\s+([^\s]+)\s+on\s+Python\s+([^)]+)\)/);

let version: string | undefined;
for (let index: number = 0; index < versionlines.length; index++) {
const line : string = versionlines[index];
if ( pat.test(line) ) {
version = RegExp.$1;
}
}

if(version) {
let statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 100);
statusBar.text = `Pysys ${version}`;
statusBar.show();
this.context.subscriptions.push(statusBar);
}
}
}

async listTests(ws: vscode.WorkspaceFolder): Promise<PysysTest[]> {
let testPattern: vscode.RelativePattern = new vscode.RelativePattern(ws.uri.fsPath, "**/pysystest.xml");
let testNames: vscode.Uri[] = await vscode.workspace.findFiles(testPattern);
Expand Down
94 changes: 0 additions & 94 deletions src/utils/pysysEnvironment.ts

This file was deleted.

Loading

0 comments on commit 8e444ff

Please sign in to comment.