Skip to content

Commit

Permalink
test for space escaping on MacOS (#62)
Browse files Browse the repository at this point in the history
* test for space escaping on MacOS
* escaping path spaces on Mac
* re-labeled View to Show Hierarchy
* testing whether Parser file exists at the configured path

- v2.17.3
  • Loading branch information
jan-dolejsi authored May 7, 2020
1 parent 7504b39 commit d42b68a
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/github-actions-vscode-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
matrix:
node-version: [10.16]
os: [windows-latest, macos-latest, ubuntu-latest]
# fail-fast: false

runs-on: ${{ matrix.os }}

Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# PDDL support - What's new?

## [2.17.2]
## 2.17.3

Escaping spaces in VAL paths on MacOS.
This is to fix [Issue 57](https://github.com/jan-dolejsi/vscode-pddl/issues/57).

## 2.17.2

Added POPF `PlannerProvider`. Fixed default planner syntax to `$(planner) $(options) $(domain) $(problem)`.

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Planning Domain Description Language support",
"author": "Jan Dolejsi",
"license": "MIT",
"version": "2.17.2",
"version": "2.17.3",
"publisher": "jan-dolejsi",
"engines": {
"vscode": "^1.44.0",
Expand Down
4 changes: 2 additions & 2 deletions src/modelView/DomainTypesView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ export class DomainTypesView extends DomainView<DomainTypesRendererOptions, Grap
if (token.isCancellationRequested) { return undefined; }

if (codeLens instanceof DocumentInsetCodeLens) {
codeLens.command = { command: PDDL_DOMAIN_TYPES_INSET_COMMAND, title: 'View inset', arguments: [codeLens.getDocument().uri, codeLens.getLine()] };
codeLens.command = { command: PDDL_DOMAIN_TYPES_INSET_COMMAND, title: 'Show hierarchy inset', arguments: [codeLens.getDocument().uri, codeLens.getLine()] };
return codeLens;
}
else {
codeLens.command = { command: PDDL_DOMAIN_TYPES_PREVIEW_COMMAND, title: 'View', arguments: [codeLens.getDocument().uri] };
codeLens.command = { command: PDDL_DOMAIN_TYPES_PREVIEW_COMMAND, title: 'Show hierarchy', arguments: [codeLens.getDocument().uri] };
return codeLens;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/modelView/ProblemObjectsView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ export class ProblemObjectsView extends ProblemView<ProblemObjectsRendererOption
if (token.isCancellationRequested) { return null; }

if (codeLens instanceof DocumentInsetCodeLens) {
codeLens.command = { command: PDDL_PROBLEM_OBJECTS_INSET_COMMAND, title: 'View inset', arguments: [codeLens.getDocument().uri, codeLens.getLine()] };
codeLens.command = { command: PDDL_PROBLEM_OBJECTS_INSET_COMMAND, title: 'Show hierarchy inset', arguments: [codeLens.getDocument().uri, codeLens.getLine()] };
return codeLens;
}
else {
codeLens.command = { command: PDDL_PROBLEM_OBJECTS_PREVIEW_COMMAND, title: 'View', arguments: [codeLens.getDocument().uri] };
codeLens.command = { command: PDDL_PROBLEM_OBJECTS_PREVIEW_COMMAND, title: 'Show hierarchy', arguments: [codeLens.getDocument().uri] };
return codeLens;
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/test/suite/ValDownload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { before, after } from 'mocha';

import * as vscode from 'vscode';
import * as path from 'path';
import * as os from 'os';
import * as fs from 'fs';
import { ValDownloader } from '../../validation/ValDownloader';
import { PddlConfiguration, CONF_PDDL, VAL_STEP_PATH, VALIDATION_PATH, VALUE_SEQ_PATH, PDDL_PARSER, PARSER_EXECUTABLE_OR_SERVICE, EXECUTABLE_OR_SERVICE } from '../../configuration/configuration';
import { createTestExtensionContext } from './testUtils';
Expand Down Expand Up @@ -142,6 +144,13 @@ suite('VAL Download and Configuration', () => {
expect(actualValStepPath).to.not.be.undefined;
assert.startsWith(actualValueSeqPath!, path.join(valFolderPath, 'Val-20190911.1-win64'), "value seq path");
expect(askedToOverwrite).to.deep.equal(['ValStep']);

const actualParserPath = conf.getParserPath();

if (actualParserPath.includes(' ') && os.platform() === 'darwin') {
expect(fs.existsSync(actualParserPath)).to.equal(true, `Parser at ${actualParserPath} should exist.`);
expect(actualParserPath).to.include('\ ', "spaces should be escaped by backslash");
}
}
finally {
const allStoredFiles = await utils.afs.getFiles(extensionContext.globalStoragePath);
Expand Down
5 changes: 4 additions & 1 deletion src/test/suite/testUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as assert from 'assert';
import * as path from 'path';
import * as os from 'os';
import * as tmp from 'tmp-promise';
import { PddlExtensionContext, planner } from 'pddl-workspace';
import { Disposable, workspace, ExtensionContext, Memento, extensions, Event, FileType, Uri, ConfigurationTarget } from 'vscode';
Expand Down Expand Up @@ -50,7 +51,9 @@ class MockMemento implements Memento {

export async function createTestExtensionContext(): Promise<ExtensionContext> {
const storage = await tmp.dir({ prefix: 'extensionTestStoragePath' });
const globalStorage = await tmp.dir({ prefix: 'extensionGlobalTestStoragePath' });
// simulate the space in the 'Application\ Support' on MacOS
const globalStoragePrefix = os.platform() === 'darwin' ? 'extensionGlobalTest StoragePath' : 'extensionGlobalTestStoragePath';
const globalStorage = await tmp.dir({ prefix: globalStoragePrefix });
const log = await tmp.file({ mode: 0o644, prefix: 'extensionTests', postfix: 'log' });

return {
Expand Down
8 changes: 7 additions & 1 deletion src/validation/ValDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { ExtensionContext, window, ProgressLocation, workspace, ConfigurationTarget } from 'vscode';
import { instrumentOperationAsVsCodeCommand } from "vscode-extension-telemetry-wrapper";
import * as path from 'path';
import * as os from 'os';
import { utils } from 'pddl-workspace';
import { ValDownloader as ValDownloaderBase, ValVersion, readValManifest, writeValManifest } from 'ai-planning-val';
import { PARSER_EXECUTABLE_OR_SERVICE, CONF_PDDL, VALIDATION_PATH, VALUE_SEQ_PATH, VAL_STEP_PATH, VALIDATOR_VERSION } from '../configuration/configuration';
Expand Down Expand Up @@ -190,7 +191,12 @@ export class ValDownloader extends ValDownloaderBase {
}

private normalizePathIfValid(pathToNormalize?: string): string | undefined {
return pathToNormalize ? path.normalize(pathToNormalize) : pathToNormalize;
if (!pathToNormalize) { return pathToNormalize; }
let normalizedPath = path.normalize(pathToNormalize);
if (os.platform() === 'darwin' && normalizedPath.includes(' ')) {
normalizedPath = normalizedPath.replace(' ', '\\ ');
}
return normalizedPath;
}

async isNewValVersionAvailable(): Promise<boolean> {
Expand Down

0 comments on commit d42b68a

Please sign in to comment.