Skip to content

Feature/refactor test runner #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
configure tutorial progress
  • Loading branch information
ShMcK committed Nov 14, 2019
commit 9b9ed40a86c542bd4becd114596c161e18223eef
9 changes: 6 additions & 3 deletions src/actions/tutorialConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as G from 'typings/graphql'
import * as vscode from 'vscode'
import * as git from '../services/git'
import languageMap from '../editor/languageMap'
import {COMMANDS} from '../editor/commands'

interface TutorialConfigParams {
config: G.TutorialConfig,
Expand All @@ -19,15 +20,17 @@ const tutorialConfig = async ({config, alreadyConfigured, }: TutorialConfigParam
await git.setupRemote(config.repo.uri)
}

vscode.commands.executeCommand('coderoad.config_test_runner', config.testRunner)
vscode.commands.executeCommand(COMMANDS.CONFIG_TEST_RUNNER, config.testRunner)

const fileFormats = config.testRunner.fileFormats

// verify if file test should run based on document saved
const shouldRun = (document: vscode.TextDocument): boolean => {
const shouldRunTest = (document: vscode.TextDocument): boolean => {
// must be a file
if (document.uri.scheme !== 'file') {
return false
}
// must configure with file formatss
if (fileFormats && fileFormats.length) {
const fileFormat: G.FileFormat = languageMap[document.languageId]
if (!fileFormats.includes(fileFormat)) {
Expand All @@ -39,7 +42,7 @@ const tutorialConfig = async ({config, alreadyConfigured, }: TutorialConfigParam

// setup onSave hook
vscode.workspace.onDidSaveTextDocument((document: vscode.TextDocument) => {
if (shouldRun(document)) {
if (shouldRunTest(document)) {
vscode.commands.executeCommand('coderoad.run_test')
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/editor/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as vscode from 'vscode'
import ReactWebView from './ReactWebView'
import createTestRunner, {Payload} from '../services/testRunner'

const COMMANDS = {
export const COMMANDS = {
START: 'coderoad.start',
OPEN_WEBVIEW: 'coderoad.open_webview',
CONFIG_TEST_RUNNER: 'coderoad.config_test_runner',
Expand Down
2 changes: 1 addition & 1 deletion src/services/testRunner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const createTestRunner = (config: TestRunnerConfig, callbacks: Callbacks) => {

const outputChannelName = 'TEST_OUTPUT'

return async (payload: Payload, onSuccess?: () => void) => {
return async (payload: Payload, onSuccess?: () => void): Promise<void> => {
console.log('------------------- run test ------------------')

// track processId to prevent multiple
Expand Down
2 changes: 1 addition & 1 deletion src/services/testRunner/parser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TapParser from 'tap-parser'
const TapParser = require('tap-parser')

// https://github.com/tapjs/tap-parser#var-p--new-parseroptions-cb
const options = {
Expand Down
6 changes: 4 additions & 2 deletions web-app/src/services/apollo/queries/tutorial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export default gql`
}
data {
config {
testRunner
fileFormats
testRunner {
command
fileFormats
}
repo {
uri
branch
Expand Down