<commit_before>/*global describe it before after bar = */

"use client";

require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"], 
  function (architect, chai, baseProc) {
    var expect = chai.expect;
    
    expect.setupArchitectTest([
        {
            packagePath: "plugins/c9.core/c9",
            workspaceId: "ubuntu/ip-10-35-77-180",
            startdate: new Date(),
            debug: true,
            hosted: true,
            local: false,
            hostname: "dev.javruben.c9.io",
            davPrefix: "/",
            platform: "linux" //"darwin"
        },
        
        "plugins/c9.core/ext",
        "plugins/c9.core/http",
        "plugins/c9.core/util",
        "plugins/c9.ide.ui/lib_apf",
        {
            packagePath: "plugins/c9.core/settings",
            settings: { state: { console: {
                "json()" : {
                    type: "pane", 
                    nodes: [
                        {
                            type: "tab",
                            editorType: "output",
                            document: { 
                                title: "Output",
                                "output" : {
                                    id: "testoutput1"
                                }
                            },
                            active: "true"
                        },
                        {
                            type: "tab",
                            editorType: "output",
                            document: {
                                title: "Output2",
                                "output" : {
                                    id: "testoutput2"
                                }
                            }
                        }
                    ]
                } } }
            }
        },
        "plugins/c9.core/api.js",
        {
            packagePath: "plugins/c9.ide.ui/ui",
            staticPrefix: "plugins/c9.ide.ui"
        },
        "plugins/c9.ide.editors/document",
        "plugins/c9.ide.editors/undomanager",
        "plugins/c9.ide.editors/editors",
        "plugins/c9.ide.editors/editor",
        {
            packagePath: "plugins/c9.ide.editors/tabmanager",
            testing: 2
        },
        "plugins/c9.ide.ui/focus",
        "plugins/c9.ide.editors/pane",
        "plugins/c9.ide.editors/tab",
        {
            packagePath: "plugins/c9.ide.terminal/terminal",
            installPath: "~/.c9"
        },
        "plugins/c9.ide.run/output",
        "plugins/c9.ide.console/console",
        "plugins/c9.fs/proc",
        "plugins/c9.fs/fs",
        {
            packagePath: "plugins/c9.vfs.client/vfs_client",
            debug: true
        },
        "plugins/c9.vfs.client/endpoint",
        "plugins/c9.ide.auth/auth",
        {
            packagePath: "plugins/c9.ide.run/run",
            testing: true,
            base: baseProc,
            staticPrefix: "plugins/c9.ide.run",
            runners: {
                "node" : {
                    "caption" : "Node.js (current)",
                    "cmd": ["node", "${debug?--debug-brk=15454}", "$file"],
                    "debugger": "v8",
                    "debugport": 15454,
                    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
                    "selector": "source.js",
                    "info": "Your code is running at \\033[01;34m$hostname\\033[00m.\n"
                        + "\\033[01;31mImportant:\\033[00m use \\033[01;32mprocess.env.PORT\\033[00m as the port and \\033[01;32mprocess.env.IP\\033[00m as the host in your scripts!\n"
                },
                "pythoni" : {
                    "caption" : "Python in interactive mode",
                    "cmd": ["python", "-i"],
                    "selector": "source.python",
                    "info": "Hit \\033[01;34mCtrl-D\\033[00m to exit.\n"
                }
            }
        },
        
        // Mock plugins
        {
            consumes: ["apf", "ui", "Plugin"],
            provides: [
                "commands", "menus", "layout", "watcher", 
                "save", "preferences", "anims", "clipboard",
                
                "auth.bootstrap", "info", "dialog.alert", "dialog.question", 
                "dialog.filesave", "dialog.fileoverwrite", "run.gui", "debugger",
                "dialog.error"
            ],
            setup: expect.html.mocked
        },
        {
            consumes: ["run", "proc", "fs", "tabManager", "console", "output"],
            provides: [],
            setup: main
        }
    ], architect);
    
    function main(options, imports, register) {
        var run = imports.run;
        var fs = imports.fs;
        var tabs = imports.tabManager;
        var cnsl = imports.console;
        
        function getHtmlElement(tab) {
            if (typeof tab == "object")
                return tab.pane.aml.getPage("editor::" + tab.editorType).$ext;
        }
        expect.html.setConstructor(getHtmlElement);
        
        function countEvents(count, expected, done) {
            if (count == expected) 
                done();
            else
                throw new Error("Wrong Event Count: "
                    + count + " of " + expected);
        }
        
        var maxTries = 15, retries = 0;
        function waitForOutput(match, callback) {
            setTimeout(function(){
                var value = tabs.focussedTab.editor.ace.session.getValue();
                
                if (retries < maxTries && !value.match(match)) {
                    retries++;
                    return waitForOutput(match, callback);
                }
                
                expect(value, "Output Mismatch").match(match)
                
                // expect.html(tabs.focussedTab, "Output Mismatch")
                //     .text(match);
                
                callback();
            }, 500);
        }
        
        describe('run', function() {
            before(function(done) {
                apf.config.setProperty("allow-select", false);
                apf.config.setProperty("allow-blur", false);

                bar.$ext.style.background = "rgba(220, 220, 220, 0.93)";
                bar.$ext.style.position = "fixed";
                bar.$ext.style.left = "20px";
                bar.$ext.style.right = "20px";
                bar.$ext.style.bottom = "20px";
                bar.$ext.style.height = "150px";
      
                document.body.style.marginBottom = "150px";
                
                document.querySelector(".console").style.height = "100%";
                
                done();
            });
            
            describe("listRunners()", function(){
                it('should list all runners', function(done) {<commit_msg>Fix build tests<commit_after>/*global describe it before after bar = */

"use client";

require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"], 
  function (architect, chai, baseProc) {
    var expect = chai.expect;
    
    expect.setupArchitectTest([
        {
            packagePath: "plugins/c9.core/c9",
            workspaceId: "ubuntu/ip-10-35-77-180",
            startdate: new Date(),
            debug: true,
            hosted: true,
            local: false,
            hostname: "dev.javruben.c9.io",
            davPrefix: "/",
            platform: "linux" //"darwin"
        },
        
        "plugins/c9.core/ext",
        "plugins/c9.core/http",
        "plugins/c9.core/util",
        "plugins/c9.ide.ui/lib_apf",
        {
            packagePath: "plugins/c9.core/settings",
            settings: { state: { console: {
                "json()" : {
                    type: "pane", 
                    nodes: [
                        {
                            type: "tab",
                            editorType: "output",
                            document: { 
                                title: "Output",
                                "output" : {
                                    id: "testoutput1"
                                }
                            },
                            active: "true"
                        },
                        {
                            type: "tab",
                            editorType: "output",
                            document: {
                                title: "Output2",
                                "output" : {
                                    id: "testoutput2"
                                }
                            }
                        }
                    ]
                } } }
            }
        },
        "plugins/c9.core/api.js",
        {
            packagePath: "plugins/c9.ide.ui/ui",
            staticPrefix: "plugins/c9.ide.ui"
        },
        "plugins/c9.ide.editors/document",
        "plugins/c9.ide.editors/undomanager",
        "plugins/c9.ide.editors/editors",
        "plugins/c9.ide.editors/editor",
        {
            packagePath: "plugins/c9.ide.editors/tabmanager",
            testing: 2
        },
        "plugins/c9.ide.ui/focus",
        "plugins/c9.ide.editors/pane",
        "plugins/c9.ide.editors/tab",
        {
            packagePath: "plugins/c9.ide.terminal/terminal",
            installPath: "~/.c9"
        },
        "plugins/c9.ide.run/output",
        "plugins/c9.ide.console/console",
        "plugins/c9.fs/proc",
        "plugins/c9.fs/fs",
        {
            packagePath: "plugins/c9.vfs.client/vfs_client",
            debug: true
        },
        "plugins/c9.vfs.client/endpoint",
        "plugins/c9.ide.auth/auth",
        {
            packagePath: "plugins/c9.ide.run/run",
            testing: true,
            base: baseProc,
            staticPrefix: "plugins/c9.ide.run",
            runners: {
                "node" : {
                    "caption" : "Node.js (current)",
                    "cmd": ["node", "${debug?--debug-brk=15454}", "$file"],
                    "debugger": "v8",
                    "debugport": 15454,
                    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
                    "selector": "source.js",
                    "info": "Your code is running at \\033[01;34m$hostname\\033[00m.\n"
                        + "\\033[01;31mImportant:\\033[00m use \\033[01;32mprocess.env.PORT\\033[00m as the port and \\033[01;32mprocess.env.IP\\033[00m as the host in your scripts!\n"
                },
                "pythoni" : {
                    "caption" : "Python in interactive mode",
                    "cmd": ["python", "-i"],
                    "selector": "source.python",
                    "info": "Hit \\033[01;34mCtrl-D\\033[00m to exit.\n"
                }
            }
        },
        
        // Mock plugins
        {
            consumes: ["apf", "ui", "Plugin"],
            provides: [
                "commands", "menus", "layout", "watcher", 
                "save", "preferences", "anims", "clipboard",
                
                "auth.bootstrap", "info", "dialog.alert", "dialog.question", 
                "dialog.filesave", "dialog.fileoverwrite", "run.gui", "debugger",
                "dialog.error"
            ],
            setup: expect.html.mocked
        },
        {
            consumes: ["run", "proc", "fs", "tabManager", "console", "output"],
            provides: [],
            setup: main
        }
    ], architect);
    
    function main(options, imports, register) {
        var run = imports.run;
        var fs = imports.fs;
        var tabs = imports.tabManager;
        var cnsl = imports.console;
        
        function getHtmlElement(tab) {
            if (typeof tab == "object")
                return tab.pane.aml.getPage("editor::" + tab.editorType).$ext;
        }
        expect.html.setConstructor(getHtmlElement);
        
        function countEvents(count, expected, done) {
            if (count == expected) 
                done();
            else
                throw new Error("Wrong Event Count: "
                    + count + " of " + expected);
        }
        
        var maxTries = 15, retries = 0;
        function waitForOutput(match, callback) {
            setTimeout(function(){
                var value = tabs.focussedTab.editor.ace.session.getValue();
                
                if (retries < maxTries && !value.match(match)) {
                    retries++;
                    return waitForOutput(match, callback);
                }
                
                expect(value, "Output Mismatch").match(match)
                
                callback();
            }, 500);
        }
        
        describe('run', function() {
            before(function(done) {
                apf.config.setProperty("allow-select", false);
                apf.config.setProperty("allow-blur", false);

                bar.$ext.style.background = "rgba(220, 220, 220, 0.93)";
                bar.$ext.style.position = "fixed";
                bar.$ext.style.left = "20px";
                bar.$ext.style.right = "20px";
                bar.$ext.style.bottom = "20px";
                bar.$ext.style.height = "150px";
      
                document.body.style.marginBottom = "150px";
                
                document.querySelector(".console").style.height = "100%";
                
                done();
            });
            
            describe("listRunners()", function(){
                it('should list all runners', function(done) {
{'fraction_non_alphanumeric': 0.13621629585973183, 'fraction_numerical': 0.02195373508177398, 'mean_word_length': 1.089425888871787, 'pattern_counts': {'":': 18, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7002822', 'n_tokens_mistral': 3941, 'n_tokens_neox': 3637, 'n_words': 618}