Skip to content

Commit

Permalink
Initial code for auto-test generation
Browse files Browse the repository at this point in the history
  • Loading branch information
khantilchoksi committed Mar 14, 2018
1 parent 03575f0 commit 8f5d3b6
Show file tree
Hide file tree
Showing 10 changed files with 561 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ inventory
aws.js
keys/
ping.yml
ping.retry
*.retry
.viminfo
.bash_history
node_modules/
package-lock.json


20 changes: 20 additions & 0 deletions checkbox_auto_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
- hosts: checkboxio

roles:
- deploy_checkboxio

tasks:
- name: Copying Auto_Test_Files
copy:
src: ~/checkbox_test_generation/
dest: ~/
remote_src: yes
directory_mode: yes


- name: Installing node modules inside it
shell: 'npm install'


#ansible-playbook -i "localhost," -c local provision_ec2.yml --extra-vars="param=checkboxio"
38 changes: 38 additions & 0 deletions checkbox_test_generation/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* NodeJS Test Generation Module
*/


// Core/NPM Modules
const path = require('path');


// Local Modules
const constraints = require('./src/constraint');
const generateTestCases = require('./src/testgenerator');


// Polyfills
require('./src/format-polyfill');



/**
* Parse an input file and generate test cases for it.
*/
(module.exports.main = function() {

// Parse file input, defaulting to subject.js if not provided
let args = process.argv.slice(2);
if( args.length === 0 ) {
args = ["server.js"];
}
let filePath = path.resolve(args[0]);

// Initialize constraints based on input file
let functionConstraints = constraints(filePath);

// Generate test cases
generateTestCases(filePath, functionConstraints);

})();
34 changes: 34 additions & 0 deletions checkbox_test_generation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "checkbox_test_generation",
"version": "1.0.0",
"description": "",
"main": "main.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "mocha;./node_modules/.bin/istanbul cover test.js",
"start": "node server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"chai": "^4.1.2",
"iter-tools": "^1.3.0",
"lodash": "^4.17.4",
"mocha": "^3.5.0",
"randexp": "^0.4.6"
},
"devDependencies": {
"esprima": "^3.0.0",
"faker": "^3.1.0",
"istanbul": "^0.4.5",
"microtime": "^2.1.1",
"mock-fs": "^4.4.0",
"random-js": "^1.0.8"
},
"engines": {
"node": "~8.5.0",
"npm": "~5.3.0"
}
}
89 changes: 89 additions & 0 deletions checkbox_test_generation/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
var express = require('express'),
cors = require('cors'),
marqdown = require('./marqdown.js'),
//routes = require('./routes/designer.js'),
//votes = require('./routes/live.js'),
//upload = require('./routes/upload.js'),
create = require('./routes/create.js'),
study = require('./routes/study.js'),
admin = require('./routes/admin.js');

var app = express();

app.configure(function () {
app.use(express.logger('dev')); /* 'default', 'short', 'tiny', 'dev' */
app.use(express.bodyParser());
});

var whitelist = ['http://chrisparnin.me', 'http://pythontutor.com', 'http://happyface.io', 'http://happyface.io:8003', 'http://happyface.io/hf.html'];
var corsOptions = {
origin: function(origin, callback){
var originIsWhitelisted = whitelist.indexOf(origin) !== -1;
callback(null, originIsWhitelisted);
}
};

app.options('/api/study/vote/submit/', cors(corsOptions));

app.post('/api/design/survey',
function(req,res)
{
console.log(req.body.markdown);
//var text = marqdown.render( req.query.markdown );
var text = marqdown.render( req.body.markdown );
res.send( {preview: text} );
}
);

//app.get('/api/design/survey/all', routes.findAll );
//app.get('/api/design/survey/:id', routes.findById );
//app.get('/api/design/survey/admin/:token', routes.findByToken );

//app.post('/api/design/survey/save', routes.saveSurvey );
//app.post('/api/design/survey/open/', routes.openSurvey );
//app.post('/api/design/survey/close/', routes.closeSurvey );
//app.post('/api/design/survey/notify/', routes.notifyParticipant );


//// ################################
//// Towards general study management.
app.get('/api/study/load/:id', study.loadStudy );
app.get('/api/study/vote/status', study.voteStatus );
app.get('/api/study/status/:id', study.status );

app.get('/api/study/listing', study.listing );

app.post('/api/study/create', create.createStudy );
app.post('/api/study/vote/submit/', cors(corsOptions), study.submitVote );

//// ADMIN ROUTES
app.get('/api/study/admin/:token', admin.loadStudy );
app.get('/api/study/admin/download/:token', admin.download );
app.get('/api/study/admin/assign/:token', admin.assignWinner);

app.post('/api/study/admin/open/', admin.openStudy );
app.post('/api/study/admin/close/', admin.closeStudy );
app.post('/api/study/admin/notify/', admin.notifyParticipant);

//// ################################

//app.post('/api/upload', upload.uploadFile );

// survey listing for studies.
//app.get('/api/design/survey/all/listing', routes.studyListing );

// Download
//app.get('/api/design/survey/vote/download/:token', votes.download );
// Winner
//app.get('/api/design/survey/winner/:token', votes.pickParticipant );

// Voting
//app.get('/api/design/survey/vote/all', votes.findAll );
//app.post('/api/design/survey/vote/cast', votes.castVote );
//app.get('/api/design/survey/vote/status', votes.status );
//app.get('/api/design/survey/vote/stat/:id', votes.getSurveyStats );



app.listen(process.env.MONGO_PORT);
console.log('Listening on port 3002...');
Loading

0 comments on commit 8f5d3b6

Please sign in to comment.