Skip to content

run tests from save #31

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 1 commit into from
Sep 9, 2019
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
4 changes: 1 addition & 3 deletions src/Channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ class Channel implements Channel {
console.log('RECEIVED:', actionType)
switch (actionType) {
case 'TEST_RUN':

vscode.commands.executeCommand('coderoad.run_test', action.payload)
return
case 'TUTORIAL_CONFIG':
tutorialConfig(action.payload)
return
case 'SETUP_ACTIONS':
console.log(action.payload)
vscode.commands.executeCommand('coderoad.set_current_step', action.payload)
setupActions(action.payload)
return
case 'SOLUTION_ACTIONS':
console.log(action.payload)
solutionActions(action.payload)
return
default:
Expand Down
3 changes: 0 additions & 3 deletions src/actions/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ async function runTest({onSuccess, onFail, onRun, onError}: Props): Promise<void
channel.show(false)
channel.appendLine(stderr)
}
// if (err.stdout) {
// channel.appendLine(err.stdout);
// }
}
}

Expand Down
7 changes: 2 additions & 5 deletions src/actions/tutorialConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,15 @@ const tutorialConfig = async (tutorial: G.Tutorial) => {
await git.setupRemote(tutorial.repo.uri)

// TODO: allow multiple coding languages in a tutorial
const language = tutorial.codingLanguage.toLowerCase()

// setup onSave hook
// console.log(`languageIds: ${languageIds.join(', ')}`)
vscode.workspace.onDidSaveTextDocument((document: vscode.TextDocument) => {
if (document.uri.scheme === 'file' && tutorial.codingLanguage === document.languageId) {
// do work
// TODO: resolve issue if client unaware or out of sync with running test
if (document.uri.scheme === 'file' && language === document.languageId) {
vscode.commands.executeCommand('coderoad.run_test')
}
})

console.log('configured')
}

export default tutorialConfig
21 changes: 14 additions & 7 deletions src/editor/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const COMMANDS = {
START: 'coderoad.start',
OPEN_WEBVIEW: 'coderoad.open_webview',
RUN_TEST: 'coderoad.run_test',
SET_CURRENT_STEP: 'coderoad.set_current_step',
}

interface CreateCommandProps {
Expand All @@ -16,7 +17,7 @@ interface CreateCommandProps {
export const createCommands = ({vscodeExt}: CreateCommandProps) => {
// React panel webview
let webview: any

let currentStepId = ''
return {
// initialize
[COMMANDS.START]: async () => {
Expand Down Expand Up @@ -52,26 +53,32 @@ export const createCommands = ({vscodeExt}: CreateCommandProps) => {

webview.createOrShow(column)
},
[COMMANDS.RUN_TEST]: ({stepId}: {stepId: string}) => {
console.log('run test webview', Object.keys(webview))
[COMMANDS.SET_CURRENT_STEP]: ({stepId}: {stepId: string}) => {
// NOTE: as async, may sometimes be inaccurate
// set from last setup stepAction
currentStepId = stepId
},
[COMMANDS.RUN_TEST]: (current: {stepId: string} | undefined) => {
// use stepId from client, or last set stepId
const payload = {stepId: current ? current.stepId : currentStepId}
runTest({
onSuccess: () => {
console.log('COMMAND TEST_PASS')
webview.send({type: 'TEST_PASS', payload: {stepId}})
webview.send({type: 'TEST_PASS', payload})
vscode.window.showInformationMessage('PASS')
},
onFail: () => {
console.log('COMMAND TEST_FAIL')
webview.send({type: 'TEST_FAIL', payload: {stepId}})
webview.send({type: 'TEST_FAIL', payload})
vscode.window.showWarningMessage('FAIL')
},
onError: () => {
console.log('COMMAND TEST_ERROR')
webview.send({type: 'TEST_ERROR', payload: [stepId]})
webview.send({type: 'TEST_ERROR', payload})
},
onRun: () => {
console.log('COMMAND TEST_RUN')
webview.send({type: 'TEST_RUN', payload: {stepId}})
webview.send({type: 'TEST_RUN', payload})
}
})
},
Expand Down
12 changes: 0 additions & 12 deletions src/services/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,3 @@ class Node {
}

export default new Node()


// export async function clear(): Promise<void> {
// // remove all files including ignored
// // NOTE: Linux only
// const command = 'ls -A1 | xargs rm -rf'
// const { stderr } = await exec(command)
// if (stderr) {
// console.error(stderr)
// throw new Error('Error removing all files & folders')
// }
// }
5 changes: 4 additions & 1 deletion web-app/src/services/state/actions/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export default {
// load step actions
channel.editorSend({
type: 'SETUP_ACTIONS',
payload: step.setup,
payload: {
stepId: step.id,
...step.setup,
}
})
}
},
Expand Down