Envoi is a lightweight and robust code execution system capable of executing or judging test cases from source code across multiple languages that are easily extensible/integrated in your usage pattern
Currently Envoi supports: C++, Java, Python 3, Go, JavaScript (Node).
Envoi is fully compatible with TypeScript but can also be used seamlessly with JavaScript
Installation
Envoi requires the respective compile/run tools for each language intended to be used installed on the host system and added to PATH. These include
Langauge | Tool |
---|---|
C++ | g++ |
Java | java jdk |
Python | Python |
Go | go |
JavaScript | node |
Npm installation
$ npm install envoijs
Basic Usage - JavaScript
const Envoi Languages Verdict = ;const runCodeExample = async { const sourceCode = `print("Hello",input())`; const result = await ; console; //{ verdict: 'AC', output: 'Hello From Envoi' } if resultverdict === VerdictAC //check verdict if accepted (indicating success) console;};;
API
SubmissionVerdict>
Envoi(submission) : Promise<Returns a promise resolving to a SubmissionVerdict
Parameters
submission
Type: Submission
Submission
An object type representing a submission
properties
sourceCode and language are required
Property | Type | description | default |
---|---|---|---|
sourceCode | string |
the source code to execute | - |
language | string |
the programming language, can use the helper enum Languages | - |
input? | string |
input fed into the program (stdin) | null |
testCases? | TestCase[] | test cases to run against the program | [ ] |
timeout? | number |
milliseconds before timing out the program (TLE) | 5000 |
SubmissionVerdict
An object type representing the submission result
properties
Property | Type | description |
---|---|---|
verdict | Verdict |
the verdict of the submission - |
output | string |
the output of the program, can also be a description of the compilation error/runtime error or a simple message. i.e "passed test cases" |
Verdict
An enum representing the verdict of a submission as strings
properties
Property | Value | description |
---|---|---|
AC | 'AC' |
The source code executed successfully/passed all test cases |
COMPILATION | 'COMPILATION' |
Compilation error |
ERROR | 'ERROR' |
An error during the whole execution process |
MLE | 'MLE' |
Memory limit exceeded (NOT YET IMPLEMENTED) |
PENDING | 'PENDING' |
Submission is pending |
RUNTIME | 'RUNTIME' |
Runtime error |
TLE | 'TLE' |
Time limit exceeded (timedout) |
WA | 'WA' |
Wrong answer (Failed test cases) |
Languages
An enum representing all the supported languages as string
properties
Property | Value |
---|---|
CPP | 'c++' |
GO | 'go' |
JAVA | 'java' |
JAVASCRIPT | 'javascript' |
PYTHON | 'python' |
TestCase
An object type representing a submission testcase
properties
both properties are required
Property | Type | description |
---|---|---|
input | string |
input for the test case (stdin) |
expectedOutput | string |
expected output for the test case |
Running against test cases - JavaScript
const Envoi Languages Verdict = ;const runCodeExample = async { const sourceCode = ` #include <iostream> using namespace std; int main(){ int a,b; cin>>a>>b; cout<<a+b<<endl; return 0; }`; const result = await ; console; //{ output: 'For input: 21 4\nFound: 25\nExpected:27', verdict: 'WA' } if resultverdict === VerdictWA console;};;
Running against test cases - TypeScript
;const runCodeExample = async { const sourceCode = ` #include <iostream> using namespace std; int main(){ int a,b; cin>>a>>b; cout<<a+b<<endl; return 0; }`; const testCases: TestCase = input: '2 3' expectedOutput: '5' input: '21 4' expectedOutput: '27' //fail this test case ; const result: SubmissionVerdict = await ; console; //{ output: 'For input: 21 4\nFound: 25\nExpected:27', verdict: 'WA' } if resultverdict === VerdictWA console;};;