Skip to content

Commit

Permalink
feat: add test target and options
Browse files Browse the repository at this point in the history
  • Loading branch information
everythingfunctional committed Aug 26, 2021
1 parent 36882b1 commit f7cd0ca
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
56 changes: 52 additions & 4 deletions lib/fpm.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,34 @@ export const config = {
order: 4
}
}
},
test: {
title: 'Test options',
description: 'Options for test',
type: 'object',
properties: {
target: {
title: 'Execution target',
description: 'Which test to run',
type: 'string',
default: '',
order: 1
},
runner: {
title: 'Runner',
description: 'Command that should be used to run the executable',
type: 'string',
default: '',
order: 2
},
executable_arguments: {
title: 'Executable Arguments',
description: 'Arguments to be passed to executables',
type: 'string',
default: '',
order: 3
}
}
}
};

Expand Down Expand Up @@ -114,24 +142,44 @@ export function provideBuilder() {
const run_example = atom.config.get('build-fpm.run.example')
const run_target = atom.config.get('build-fpm.run.target')
const run_runner = atom.config.get('build-fpm.run.runner')
const exe_args = atom.config.get('build-fpm.run.executable_arguments')
const run_exe_args = atom.config.get('build-fpm.run.executable_arguments')
let run_args = ['run']
if (compiler.length > 0) {run_args = run_args.concat(['--compiler', compiler])}
if (profile.length > 0) {run_args = run_args.concat(['--profile', profile])}
if (flags.length > 0) {run_args = run_args.concat(['--flag', flags])}
if (run_example) {run_args = run_args.concat(['--example'])}
if (run_target.length > 0) {run_args = run_args.concat(['--target', run_target])}
if (run_runner.length > 0) {run_args = run_args.concat(['--runner', run_runner])}
if (exe_args.length > 0) {run_args = run_args.concat([' -- ', exe_args])}
if (run_exe_args.length > 0) {run_args = run_args.concat([' -- ', run_exe_args])}
const runTarget = {
exec: 'fpm',
name: 'fpm run',
args: run_args,
sh: false,
errorMatch: errorMatch,
warningMatch: warningMatch
}
return [buildTarget, runTarget];
};

const test_target = atom.config.get('build-fpm.run.target')
const test_runner = atom.config.get('build-fpm.run.runner')
const test_exe_args = atom.config.get('build-fpm.run.executable_arguments')
let test_args = ['test']
if (compiler.length > 0) {test_args = test_args.concat(['--compiler', compiler])}
if (profile.length > 0) {test_args = test_args.concat(['--profile', profile])}
if (flags.length > 0) {test_args = test_args.concat(['--flag', flags])}
if (test_target.length > 0) {test_args = test_args.concat(['--target', test_target])}
if (test_runner.length > 0) {test_args = test_args.concat(['--runner', test_runner])}
if (test_exe_args.length > 0) {test_args = test_args.concat([' -- ', test_exe_args])}
const testTarget = {
exec: 'fpm',
name: 'fpm test',
args: test_args,
sh: false,
errorMatch: errorMatch,
warningMatch: warningMatch
};

return [buildTarget, runTarget, testTarget];
}
};
}
1 change: 1 addition & 0 deletions spec/build-fpm-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('build-fpm', () => {
beforeEach(() => {
atom.config.set('build-fpm.general', {compiler: '', profile: '', flags: ''})
atom.config.set('build-fpm.run', {example: false, target: '', runner: '', executable_arguments: ''})
atom.config.set('build-fpm.test', {target: '', runner: '', executable_arguments: ''})
waitsForPromise(() => {
return vouch(temp.mkdir, 'build-fpm-spec-')
.then((dir) => vouch(fs.realpath, dir))
Expand Down

0 comments on commit f7cd0ca

Please sign in to comment.