|
1 |
| -var http = require('http'); |
2 |
| -var express = require('express'); |
3 |
| -var path = require('path'); |
4 |
| -var app = express(); |
5 |
| -var exec = require('child_process').exec; |
6 |
| - |
7 |
| -function run_my_first_test() { |
8 |
| - exec("pytest my_first_test.py"); |
9 |
| -} |
10 |
| - |
11 |
| -function run_test_demo_site() { |
12 |
| - exec("pytest test_demo_site.py"); |
13 |
| -} |
14 |
| - |
15 |
| -function run_my_first_test_with_demo_mode() { |
16 |
| - exec("pytest my_first_test.py --demo_mode"); |
17 |
| -} |
18 |
| - |
19 |
| -function run_test_demo_site_with_demo_mode() { |
20 |
| - exec("pytest test_demo_site.py --demo_mode"); |
| 1 | +const http = require('http'); |
| 2 | +const express = require('express'); |
| 3 | +const path = require('path'); |
| 4 | +const app = express(); |
| 5 | +const exec = require('child_process').exec; |
| 6 | +var server_info = '\nServer running at http://127.0.0.1:3000/ (CTRL-C to stop)'; |
| 7 | + |
| 8 | +function run_command(command) { |
| 9 | + console.log("\n" + command); |
| 10 | + exec(command, (err, stdout, stderr) => console.log(stdout, server_info)); |
21 | 11 | }
|
22 | 12 |
|
23 | 13 | app.get('/', function(req, res) {
|
24 | 14 | res.sendFile(path.join(__dirname + '/index.html'));
|
25 |
| -}) |
| 15 | +}); |
26 | 16 |
|
27 | 17 | app.get('/run_my_first_test', function(req, res) {
|
28 | 18 | res.sendFile(path.join(__dirname + '/index.html'));
|
29 | 19 | res.redirect('/');
|
30 |
| - run_my_first_test() |
31 |
| -}) |
| 20 | + run_command("pytest my_first_test.py"); |
| 21 | +}); |
32 | 22 |
|
33 | 23 | app.get('/run_test_demo_site', function(req, res) {
|
34 | 24 | res.sendFile(path.join(__dirname + '/index.html'));
|
35 | 25 | res.redirect('/');
|
36 |
| - run_test_demo_site() |
37 |
| -}) |
| 26 | + run_command("pytest test_demo_site.py"); |
| 27 | +}); |
38 | 28 |
|
39 | 29 | app.get('/run_my_first_test_with_demo_mode', function(req, res) {
|
40 | 30 | res.sendFile(path.join(__dirname + '/index.html'));
|
41 | 31 | res.redirect('/');
|
42 |
| - run_my_first_test_with_demo_mode() |
43 |
| -}) |
| 32 | + run_command("pytest my_first_test.py --demo_mode"); |
| 33 | +}); |
44 | 34 |
|
45 | 35 | app.get('/run_test_demo_site_with_demo_mode', function(req, res) {
|
46 | 36 | res.sendFile(path.join(__dirname + '/index.html'));
|
47 | 37 | res.redirect('/');
|
48 |
| - run_test_demo_site_with_demo_mode() |
49 |
| -}) |
| 38 | + run_command("pytest test_demo_site.py --demo_mode"); |
| 39 | +}); |
50 | 40 |
|
51 | 41 | app.listen(3000, "127.0.0.1", function() {
|
52 |
| - console.log('Server running at http://127.0.0.1:3000/ (CTRL-C to stop)'); |
| 42 | + console.log(server_info); |
53 | 43 | });
|
0 commit comments