Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/project/jupyter/test/supported-kernels.ts
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45/*6Do some tests with **all** of the kernels we officially support in CoCalc.78Obviously, this test file should take a while to run, since it starts9up many, many kernels, several of which are old Sage versions.1011Also, sadly the tests are flakie... since some Jupyter kernels are flakie.12*/1314import {} from "mocha";15import * as expect from "expect";16import * as common from "./common";1718/* As of Aug, 2018:1920$ jupyter kernelspec list2122anaconda3 /ext/jupyter/kernels/anaconda323anaconda5 /ext/jupyter/kernels/anaconda524bash /ext/jupyter/kernels/bash25calysto_prolog /ext/jupyter/kernels/calysto_prolog26gap /ext/jupyter/kernels/gap27haskell /ext/jupyter/kernels/haskell28ir /ext/jupyter/kernels/ir29ir-sage /ext/jupyter/kernels/ir-sage30julia /ext/jupyter/kernels/julia31octave /ext/jupyter/kernels/octave32pari_jupyter /ext/jupyter/kernels/pari_jupyter33python2 /ext/jupyter/kernels/python234python2-ubuntu /ext/jupyter/kernels/python2-ubuntu35python3 /ext/jupyter/kernels/python336sage-8.1 /ext/jupyter/kernels/sage-8.137sage-8.2 /ext/jupyter/kernels/sage-8.238sage-develop /ext/jupyter/kernels/sage-develop39sagemath /ext/jupyter/kernels/sagemath40singular /ext/jupyter/kernels/singular41vpython /ext/jupyter/kernels/vpython42*/4344// Set only to focus on only one of the kernels below.45const ONLY = "";4647interface OneTest {48input: string;49output: string;50}5152interface TestKernel {53kernel: string;54tests: OneTest[];55timeout?: number; // in ms56}5758const EXEC_TESTS: TestKernel[] = [59{60kernel: "anaconda3",61tests: [62{63input: "print(1/3,4/3)",64output: "0.3333333333333333 1.3333333333333333\n",65},66],67},68{69kernel: "anaconda5",70tests: [71{72input: "print(1/3,4/3)",73output: "0.3333333333333333 1.3333333333333333\n",74},75],76},77{78kernel: "bash",79tests: [{ input: "echo 'foo bar'", output: "foo bar\n" }],80},81{82kernel: "gap",83tests: [{ input: "1/3 + 4/3", output: "5/3" }],84},85{86kernel: "haskell",87tests: [88{ input: "1/3 + 4/3", output: '{"text/plain":"1.6666666666666665"}' },89],90},91{92kernel: "ir",93tests: [94{95input: "1/3 + 4/3",96output:97'{"text/html":"1.66666666666667","text/latex":"1.66666666666667","text/markdown":"1.66666666666667","text/plain":"[1] 1.666667"}',98},99],100},101{102kernel: "ir-sage",103tests: [104{105input: "1/3 + 4/3",106output:107'{"text/html":"1.66666666666667","text/latex":"1.66666666666667","text/markdown":"1.66666666666667","text/plain":"[1] 1.666667"}',108},109],110},111{112kernel: "julia",113tests: [114{ input: "1/3 + 4/3", output: '{"text/plain":"1.6666666666666665"}' },115],116},117{118kernel: "octave",119tests: [{ input: "1/3 + 4/3", output: "ans = 1.6667\n" }],120},121{122kernel: "pari_jupyter",123tests: [{ input: "1/3 + 4/3", output: '{"text/plain":"5/3"}' }],124timeout: 20000,125},126{127kernel: "python2",128tests: [{ input: "print(1/3,4/3)", output: "(0, 1)\n" }],129},130{131kernel: "python2-ubuntu",132tests: [{ input: "print(1/3,4/3)", output: "(0, 1)\n" }],133},134{135kernel: "python3",136tests: [137{138input: "print(1/3,4/3)",139output: "0.3333333333333333 1.3333333333333333\n",140},141],142},143{144kernel: "sage-8.2",145tests: [{ input: "1/3 + 4/3", output: '{"text/plain":"5/3"}' }],146timeout: 60000,147},148{149kernel: "sage-8.3",150tests: [{ input: "1/3 + 4/3", output: '{"text/plain":"5/3"}' }],151timeout: 60000,152},153{154kernel: "sage-develop",155tests: [{ input: "1/3 + 4/3", output: '{"text/plain":"5/3"}' }],156timeout: 60000,157},158{159kernel: "sagemath",160tests: [{ input: "1/3 + 4/3", output: '{"text/plain":"5/3"}' }],161timeout: 60000,162},163{164/* Rant here: https://github.com/sagemathinc/cocalc/issues/3071 */165kernel: "singular",166tests: [167{168input: "2 + 3",169output:170'{"text/plain":"5\\n skipping text from `(` error at token `)`\\n"}',171},172],173timeout: 30000,174},175{176kernel: "vpython",177tests: [178{179input: "print(1/3,4/3)",180output: "0.3333333333333333 1.3333333333333333\n",181},182],183},184];185186for (const test of EXEC_TESTS) {187if (ONLY && ONLY != test.kernel) {188continue;189}190describe(`tests the "${test.kernel}" kernel -- `, function () {191before(common.default_kernel_path);192after(common.custom_kernel_path);193this.timeout(test.timeout ? test.timeout : 20000);194195let kernel: common.JupyterKernel;196197it(`creates the "${test.kernel}" kernel`, function () {198kernel = common.kernel(test.kernel);199});200201for (const { input, output } of test.tests) {202it(`evaluates "${input}"`, async function () {203expect(await common.exec(kernel, input)).toBe(output);204});205}206207it(`closes the ${test.kernel} kernel`, function () {208kernel.close();209});210});211}212213214