Start adding js tests
This commit is contained in:
parent
0b90e4e8cd
commit
f18c52b223
@ -424,6 +424,40 @@ fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString {
|
||||
env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub struct RustdocJS {
|
||||
pub host: Interned<String>,
|
||||
}
|
||||
|
||||
impl Step for RustdocJS {
|
||||
type Output = PathBuf;
|
||||
const DEFAULT: bool = true;
|
||||
const ONLY_HOSTS: bool = true;
|
||||
|
||||
fn should_run(run: ShouldRun) -> ShouldRun {
|
||||
run.path("node")
|
||||
}
|
||||
|
||||
fn make_run(run: RunConfig) {
|
||||
run.builder.ensure(RustdocJS {
|
||||
host: run.host,
|
||||
});
|
||||
}
|
||||
|
||||
fn run(self, _: &Builder) {
|
||||
let cmd = if cfg!(target_os = "windows") {
|
||||
let command = Command::new("cmd");
|
||||
command.args(&["/C", "node src/tools/rustdoc-js/tester.js"]);
|
||||
command
|
||||
} else {
|
||||
let command = Command::new("sh");
|
||||
command.args(&["-c", "node src/tools/rustdoc-js/tester.js"]);
|
||||
command
|
||||
};
|
||||
builder.run(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Tidy {
|
||||
host: Interned<String>,
|
||||
@ -570,6 +604,7 @@ fn run(self, builder: &Builder) {
|
||||
},
|
||||
Test { path: "src/test/run-make", mode: "run-make", suite: "run-make" },
|
||||
Test { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" },
|
||||
Test { path: "src/test/rustdoc-js", mode: "rustdoc-js", suite: "rustdoc-js" },
|
||||
|
||||
Test { path: "src/test/pretty", mode: "pretty", suite: "pretty" },
|
||||
Test { path: "src/test/run-pass/pretty", mode: "pretty", suite: "run-pass" },
|
||||
|
@ -260,6 +260,7 @@ fn run(self, builder: &Builder) -> PathBuf {
|
||||
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Libstd;
|
||||
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::Libstd;
|
||||
RustInstaller, "src/tools/rust-installer", "fabricate", Mode::Libstd;
|
||||
RustdocJS, "node", "node", Mode::Tool;
|
||||
);
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
|
15
src/test/rustdoc-js/basic.js
Normal file
15
src/test/rustdoc-js/basic.js
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
const QUERY = 'String';
|
||||
|
||||
const EXPECTED = [
|
||||
{'all': ['std::string::String']},
|
||||
];
|
26
src/tools/rustdoc-js/tester.js
Normal file
26
src/tools/rustdoc-js/tester.js
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const TEST_FOLDER = 'src/test/rustdoc-js/';
|
||||
|
||||
function loadFile(filePath) {
|
||||
var src = fs.readFileSync(filePath, 'utf8').split('\n').slice(15, -10).join('\n');
|
||||
var Module = module.constructor;
|
||||
var m = new Module();
|
||||
m._compile(src, filePath);
|
||||
return m;
|
||||
}
|
||||
|
||||
fs.readdirSync(TEST_FOLDER).forEach(function(file) {
|
||||
var file = require(TEST_FOLDER + file);
|
||||
const expected = file.EXPECTED;
|
||||
});
|
Loading…
Reference in New Issue
Block a user