mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 20:38:55 +00:00
test(std/wasi): add wasi-testsuite as a submodule (#7042)
This commit is contained in:
parent
54d336ab20
commit
f7174267e3
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +1,6 @@
|
||||
[submodule "deno_third_party"]
|
||||
path = third_party
|
||||
url = https://github.com/denoland/deno_third_party.git
|
||||
[submodule "std/wasi/testdata"]
|
||||
path = std/wasi/testdata
|
||||
url = git@github.com:khronosproject/wasi-test-suite.git
|
||||
|
@ -1,17 +1,32 @@
|
||||
/* eslint-disable */
|
||||
|
||||
import { assert, assertEquals } from "../testing/asserts.ts";
|
||||
import { copy } from "../fs/mod.ts";
|
||||
import * as path from "../path/mod.ts";
|
||||
import Context from "./snapshot_preview1.ts";
|
||||
|
||||
const ignore = [
|
||||
"wasi_clock_time_get_realtime.wasm",
|
||||
];
|
||||
|
||||
// TODO(caspervonb) investigate why these tests are failing on windows and fix
|
||||
// them.
|
||||
if (Deno.build.os == "windows") {
|
||||
ignore.push("std_fs_metadata_absolute.wasm");
|
||||
ignore.push("std_fs_metadata_relative.wasm");
|
||||
ignore.push("std_fs_read_dir_absolute.wasm");
|
||||
ignore.push("std_fs_read_dir_relative.wasm");
|
||||
}
|
||||
|
||||
if (import.meta.main) {
|
||||
const options = JSON.parse(Deno.args[0]);
|
||||
const binary = await Deno.readFile(Deno.args[1]);
|
||||
const pathname = Deno.args[1];
|
||||
const binary = await Deno.readFile(pathname);
|
||||
const module = await WebAssembly.compile(binary);
|
||||
|
||||
const context = new Context({
|
||||
env: options.env,
|
||||
args: options.args,
|
||||
args: [pathname].concat(options.args),
|
||||
preopens: options.preopens,
|
||||
});
|
||||
|
||||
@ -25,115 +40,83 @@ if (import.meta.main) {
|
||||
} else {
|
||||
const rootdir = path.dirname(path.fromFileUrl(import.meta.url));
|
||||
const testdir = path.join(rootdir, "testdata");
|
||||
const outdir = path.join(testdir, "snapshot_preview1");
|
||||
|
||||
for await (const entry of Deno.readDir(testdir)) {
|
||||
if (!entry.name.endsWith(".rs")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const process = Deno.run({
|
||||
cmd: [
|
||||
"rustc",
|
||||
"--target",
|
||||
"wasm32-wasi",
|
||||
"--out-dir",
|
||||
outdir,
|
||||
path.join(testdir, entry.name),
|
||||
],
|
||||
stdout: "inherit",
|
||||
stderr: "inherit",
|
||||
});
|
||||
|
||||
const status = await process.status();
|
||||
assert(status.success);
|
||||
|
||||
process.close();
|
||||
|
||||
// TODO(caspervonb) allow the prelude to span multiple lines
|
||||
const source = await Deno.readTextFile(path.join(testdir, entry.name));
|
||||
const prelude = source.match(/^\/\/\s*\{.*/);
|
||||
if (prelude) {
|
||||
const basename = entry.name.replace(/.rs$/, ".json");
|
||||
await Deno.writeTextFile(
|
||||
path.join(outdir, basename),
|
||||
prelude[0].slice(2),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for await (const entry of Deno.readDir(outdir)) {
|
||||
if (!entry.name.endsWith(".wasm")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Deno.test(entry.name, async function () {
|
||||
const basename = entry.name.replace(/\.wasm$/, ".json");
|
||||
const prelude = await Deno.readTextFile(path.resolve(outdir, basename));
|
||||
const options = JSON.parse(prelude);
|
||||
Deno.test({
|
||||
name: entry.name,
|
||||
ignore: ignore.includes(entry.name),
|
||||
fn: async function () {
|
||||
const basename = entry.name.replace(/\.wasm$/, ".json");
|
||||
const prelude = await Deno.readTextFile(
|
||||
path.resolve(testdir, basename),
|
||||
);
|
||||
const options = JSON.parse(prelude);
|
||||
|
||||
await Deno.mkdir(`${testdir}/scratch`);
|
||||
const workdir = await Deno.makeTempDir();
|
||||
await copy(
|
||||
path.join(testdir, "fixtures"),
|
||||
path.join(workdir, "fixtures"),
|
||||
);
|
||||
|
||||
try {
|
||||
const process = await Deno.run({
|
||||
cwd: testdir,
|
||||
cmd: [
|
||||
`${Deno.execPath()}`,
|
||||
"run",
|
||||
"--quiet",
|
||||
"--unstable",
|
||||
"--allow-all",
|
||||
import.meta.url,
|
||||
prelude,
|
||||
path.resolve(outdir, entry.name),
|
||||
],
|
||||
stdin: "piped",
|
||||
stdout: "piped",
|
||||
stderr: "piped",
|
||||
});
|
||||
try {
|
||||
const process = await Deno.run({
|
||||
cwd: workdir,
|
||||
cmd: [
|
||||
`${Deno.execPath()}`,
|
||||
"run",
|
||||
"--quiet",
|
||||
"--unstable",
|
||||
"--allow-all",
|
||||
import.meta.url,
|
||||
prelude,
|
||||
path.resolve(testdir, entry.name),
|
||||
],
|
||||
stdin: "piped",
|
||||
stdout: "piped",
|
||||
stderr: "piped",
|
||||
});
|
||||
|
||||
if (options.stdin) {
|
||||
const stdin = new TextEncoder().encode(options.stdin);
|
||||
await Deno.writeAll(process.stdin, stdin);
|
||||
}
|
||||
|
||||
process.stdin.close();
|
||||
|
||||
const stdout = await Deno.readAll(process.stdout);
|
||||
|
||||
if (options.stdout) {
|
||||
assertEquals(new TextDecoder().decode(stdout), options.stdout);
|
||||
} else {
|
||||
await Deno.writeAll(Deno.stdout, stdout);
|
||||
}
|
||||
|
||||
process.stdout.close();
|
||||
|
||||
const stderr = await Deno.readAll(process.stderr);
|
||||
|
||||
if (options.stderr) {
|
||||
assertEquals(new TextDecoder().decode(stderr), options.stderr);
|
||||
} else {
|
||||
await Deno.writeAll(Deno.stderr, stderr);
|
||||
}
|
||||
|
||||
process.stderr.close();
|
||||
|
||||
if (options.files) {
|
||||
for (const [key, value] of Object.entries(options.files)) {
|
||||
assertEquals(value, await Deno.readTextFile(`${testdir}/${key}`));
|
||||
if (options.stdin) {
|
||||
const stdin = new TextEncoder().encode(options.stdin);
|
||||
await Deno.writeAll(process.stdin, stdin);
|
||||
}
|
||||
|
||||
process.stdin.close();
|
||||
|
||||
const stdout = await Deno.readAll(process.stdout);
|
||||
|
||||
if (options.stdout) {
|
||||
assertEquals(new TextDecoder().decode(stdout), options.stdout);
|
||||
} else {
|
||||
await Deno.writeAll(Deno.stdout, stdout);
|
||||
}
|
||||
|
||||
process.stdout.close();
|
||||
|
||||
const stderr = await Deno.readAll(process.stderr);
|
||||
|
||||
if (options.stderr) {
|
||||
assertEquals(new TextDecoder().decode(stderr), options.stderr);
|
||||
} else {
|
||||
await Deno.writeAll(Deno.stderr, stderr);
|
||||
}
|
||||
|
||||
process.stderr.close();
|
||||
|
||||
const status = await process.status();
|
||||
assertEquals(status.code, options.exitCode ? +options.exitCode : 0);
|
||||
|
||||
process.close();
|
||||
} catch (err) {
|
||||
throw err;
|
||||
} finally {
|
||||
await Deno.remove(workdir, { recursive: true });
|
||||
}
|
||||
|
||||
const status = await process.status();
|
||||
assertEquals(status.code, options.exitCode ? +options.exitCode : 0);
|
||||
|
||||
process.close();
|
||||
} catch (err) {
|
||||
throw err;
|
||||
} finally {
|
||||
await Deno.remove(`${testdir}/scratch`, { recursive: true });
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
1
std/wasi/testdata
Submodule
1
std/wasi/testdata
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 419874edc0dd334df55760ba626ecc94a1df7cc9
|
1
std/wasi/testdata/fixture/directory/file
vendored
1
std/wasi/testdata/fixture/directory/file
vendored
@ -1 +0,0 @@
|
||||
directory/file
|
@ -1 +0,0 @@
|
||||
file
|
1
std/wasi/testdata/fixture/file
vendored
1
std/wasi/testdata/fixture/file
vendored
@ -1 +0,0 @@
|
||||
file
|
@ -1 +0,0 @@
|
||||
directory
|
1
std/wasi/testdata/fixture/symlink_to_file
vendored
1
std/wasi/testdata/fixture/symlink_to_file
vendored
@ -1 +0,0 @@
|
||||
file
|
9
std/wasi/testdata/std_env_args.rs
vendored
9
std/wasi/testdata/std_env_args.rs
vendored
@ -1,9 +0,0 @@
|
||||
// { "args": ["one", "two", "three" ]}
|
||||
|
||||
fn main() {
|
||||
let mut args = std::env::args();
|
||||
assert_eq!(args.len(), 3);
|
||||
assert_eq!(args.next().unwrap(), "one");
|
||||
assert_eq!(args.next().unwrap(), "two");
|
||||
assert_eq!(args.next().unwrap(), "three");
|
||||
}
|
6
std/wasi/testdata/std_env_vars.rs
vendored
6
std/wasi/testdata/std_env_vars.rs
vendored
@ -1,6 +0,0 @@
|
||||
// { "env": { "one": "1", "two": "2", "three": "3" } }
|
||||
|
||||
fn main() {
|
||||
let vars = std::env::vars();
|
||||
assert_eq!(vars.count(), 3);
|
||||
}
|
6
std/wasi/testdata/std_fs_create_dir.rs
vendored
6
std/wasi/testdata/std_fs_create_dir.rs
vendored
@ -1,6 +0,0 @@
|
||||
// { "preopens": { "/scratch": "scratch" } }
|
||||
|
||||
fn main() {
|
||||
assert!(std::fs::create_dir("/scratch/directory").is_ok());
|
||||
assert!(std::fs::metadata("/scratch/directory").unwrap().is_dir());
|
||||
}
|
6
std/wasi/testdata/std_fs_file_create.rs
vendored
6
std/wasi/testdata/std_fs_file_create.rs
vendored
@ -1,6 +0,0 @@
|
||||
// { "preopens": { "/scratch": "scratch" } }
|
||||
|
||||
fn main() {
|
||||
assert!(std::fs::File::create("/scratch/file").is_ok());
|
||||
assert!(std::fs::metadata("/scratch/file").unwrap().is_file());
|
||||
}
|
23
std/wasi/testdata/std_fs_file_metadata.rs
vendored
23
std/wasi/testdata/std_fs_file_metadata.rs
vendored
@ -1,23 +0,0 @@
|
||||
// { "preopens": { "/fixture": "fixture" } }
|
||||
|
||||
fn main() {
|
||||
let file = std::fs::File::open("/fixture/file").unwrap();
|
||||
let metadata = file.metadata().unwrap();
|
||||
assert!(metadata.is_file());
|
||||
assert!(metadata.len() == 5);
|
||||
|
||||
let file = std::fs::File::open("/fixture/symlink_to_file").unwrap();
|
||||
let metadata = file.metadata().unwrap();
|
||||
assert!(metadata.is_file());
|
||||
assert!(metadata.len() == 5);
|
||||
|
||||
let file = std::fs::File::open("/fixture/directory/file").unwrap();
|
||||
let metadata = file.metadata().unwrap();
|
||||
assert!(metadata.is_file());
|
||||
assert!(metadata.len() == 15);
|
||||
|
||||
let file = std::fs::File::open("/fixture/directory/symlink_to_file").unwrap();
|
||||
let metadata = file.metadata().unwrap();
|
||||
assert!(metadata.is_file());
|
||||
assert!(metadata.len() == 15);
|
||||
}
|
16
std/wasi/testdata/std_fs_file_read.rs
vendored
16
std/wasi/testdata/std_fs_file_read.rs
vendored
@ -1,16 +0,0 @@
|
||||
// { "preopens": { "/fixture": "fixture" } }
|
||||
|
||||
use std::io::Read;
|
||||
|
||||
fn main() {
|
||||
let mut file = std::fs::File::open("/fixture/file").unwrap();
|
||||
let mut buffer = [0; 2];
|
||||
|
||||
assert_eq!(file.read(&mut buffer).unwrap(), 2);
|
||||
assert_eq!(&buffer, b"fi");
|
||||
|
||||
assert_eq!(file.read(&mut buffer).unwrap(), 2);
|
||||
assert_eq!(&buffer, b"le");
|
||||
|
||||
assert_eq!(file.read(&mut buffer).unwrap(), 1);
|
||||
}
|
33
std/wasi/testdata/std_fs_file_seek.rs
vendored
33
std/wasi/testdata/std_fs_file_seek.rs
vendored
@ -1,33 +0,0 @@
|
||||
// { "preopens": { "/fixture": "fixture" } }
|
||||
|
||||
use std::io::Seek;
|
||||
|
||||
fn main() {
|
||||
let mut file = std::fs::File::open("/fixture/file").unwrap();
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Current(0)).unwrap(), 0);
|
||||
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Start(1)).unwrap(), 1);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Start(2)).unwrap(), 2);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Start(3)).unwrap(), 3);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Start(4)).unwrap(), 4);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Start(5)).unwrap(), 5);
|
||||
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Current(-1)).unwrap(), 4);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Current(-1)).unwrap(), 3);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Current(-1)).unwrap(), 2);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Current(-1)).unwrap(), 1);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Current(-1)).unwrap(), 0);
|
||||
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Current(1)).unwrap(), 1);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Current(1)).unwrap(), 2);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Current(1)).unwrap(), 3);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Current(1)).unwrap(), 4);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::Current(1)).unwrap(), 5);
|
||||
|
||||
assert_eq!(file.seek(std::io::SeekFrom::End(0)).unwrap(), 5);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::End(-1)).unwrap(), 4);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::End(-2)).unwrap(), 3);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::End(-3)).unwrap(), 2);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::End(-4)).unwrap(), 1);
|
||||
assert_eq!(file.seek(std::io::SeekFrom::End(-5)).unwrap(), 0);
|
||||
}
|
17
std/wasi/testdata/std_fs_file_set_len.rs
vendored
17
std/wasi/testdata/std_fs_file_set_len.rs
vendored
@ -1,17 +0,0 @@
|
||||
// { "preopens": { "/scratch": "scratch" } }
|
||||
|
||||
fn main() {
|
||||
let file = std::fs::File::create("/scratch/file").unwrap();
|
||||
|
||||
assert!(file.set_len(0).is_ok());
|
||||
assert_eq!(file.metadata().unwrap().len(), 0);
|
||||
|
||||
assert!(file.set_len(5).is_ok());
|
||||
assert_eq!(file.metadata().unwrap().len(), 5);
|
||||
|
||||
assert!(file.set_len(25).is_ok());
|
||||
assert_eq!(file.metadata().unwrap().len(), 25);
|
||||
|
||||
assert!(file.set_len(0).is_ok());
|
||||
assert_eq!(file.metadata().unwrap().len(), 0);
|
||||
}
|
15
std/wasi/testdata/std_fs_file_sync_all.rs
vendored
15
std/wasi/testdata/std_fs_file_sync_all.rs
vendored
@ -1,15 +0,0 @@
|
||||
// { "preopens": { "/scratch": "scratch" } }
|
||||
|
||||
fn main() {
|
||||
let file = std::fs::File::create("/scratch/file").unwrap();
|
||||
|
||||
assert!(file.set_len(5).is_ok());
|
||||
assert!(file.sync_all().is_ok());
|
||||
let metadata = std::fs::metadata("/scratch/file").unwrap();
|
||||
assert_eq!(metadata.len(), 5);
|
||||
|
||||
assert!(file.set_len(25).is_ok());
|
||||
assert!(file.sync_all().is_ok());
|
||||
let metadata = std::fs::metadata("/scratch/file").unwrap();
|
||||
assert_eq!(metadata.len(), 25);
|
||||
}
|
15
std/wasi/testdata/std_fs_file_sync_data.rs
vendored
15
std/wasi/testdata/std_fs_file_sync_data.rs
vendored
@ -1,15 +0,0 @@
|
||||
// { "preopens": { "/scratch": "scratch" } }
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
fn main() {
|
||||
let mut file = std::fs::File::create("/scratch/file").unwrap();
|
||||
|
||||
assert!(file.write(b"Hello").is_ok());
|
||||
assert!(file.sync_data().is_ok());
|
||||
assert_eq!(std::fs::read("/scratch/file").unwrap(), b"Hello");
|
||||
|
||||
assert!(file.write(b", world!").is_ok());
|
||||
assert!(file.sync_data().is_ok());
|
||||
assert_eq!(std::fs::read("/scratch/file").unwrap(), b"Hello, world!");
|
||||
}
|
9
std/wasi/testdata/std_fs_file_write.rs
vendored
9
std/wasi/testdata/std_fs_file_write.rs
vendored
@ -1,9 +0,0 @@
|
||||
// { "preopens": { "/scratch": "scratch" }, "files": { "scratch/file": "file" } }
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
fn main() {
|
||||
let mut file = std::fs::File::create("/scratch/file").unwrap();
|
||||
assert_eq!(file.write(b"fi").unwrap(), 2);
|
||||
assert_eq!(file.write(b"le").unwrap(), 2);
|
||||
}
|
11
std/wasi/testdata/std_fs_hard_link.rs
vendored
11
std/wasi/testdata/std_fs_hard_link.rs
vendored
@ -1,11 +0,0 @@
|
||||
// { "preopens": { "/fixture": "fixture", "/scratch": "scratch" } }
|
||||
|
||||
fn main() {
|
||||
assert!(
|
||||
std::fs::hard_link("/fixture/file", "/scratch/hardlink_to_file").is_ok()
|
||||
);
|
||||
assert_eq!(
|
||||
std::fs::read("/fixture/file").unwrap(),
|
||||
std::fs::read("/scratch/hardlink_to_file").unwrap()
|
||||
);
|
||||
}
|
26
std/wasi/testdata/std_fs_metadata.rs
vendored
26
std/wasi/testdata/std_fs_metadata.rs
vendored
@ -1,26 +0,0 @@
|
||||
// { "preopens": { "/fixture": "fixture" } }
|
||||
|
||||
fn main() {
|
||||
let metadata = std::fs::metadata("/fixture/directory").unwrap();
|
||||
assert!(metadata.is_dir());
|
||||
|
||||
let metadata = std::fs::metadata("/fixture/symlink_to_directory").unwrap();
|
||||
assert!(metadata.is_dir());
|
||||
|
||||
let metadata = std::fs::metadata("/fixture/file").unwrap();
|
||||
assert!(metadata.is_file());
|
||||
assert_eq!(metadata.len(), 5);
|
||||
|
||||
let metadata = std::fs::metadata("/fixture/symlink_to_file").unwrap();
|
||||
assert!(metadata.is_file());
|
||||
assert_eq!(metadata.len(), 5);
|
||||
|
||||
let metadata = std::fs::metadata("/fixture/directory/file").unwrap();
|
||||
assert!(metadata.is_file());
|
||||
assert_eq!(metadata.len(), 15);
|
||||
|
||||
let metadata =
|
||||
std::fs::metadata("/fixture/directory/symlink_to_file").unwrap();
|
||||
assert!(metadata.is_file());
|
||||
assert_eq!(metadata.len(), 15);
|
||||
}
|
17
std/wasi/testdata/std_fs_read.rs
vendored
17
std/wasi/testdata/std_fs_read.rs
vendored
@ -1,17 +0,0 @@
|
||||
// { "preopens": { "/fixture": "fixture" } }
|
||||
|
||||
fn main() {
|
||||
assert_eq!(std::fs::read("/fixture/file").unwrap(), b"file\n");
|
||||
assert_eq!(
|
||||
std::fs::read("/fixture/symlink_to_file").unwrap(),
|
||||
b"file\n"
|
||||
);
|
||||
assert_eq!(
|
||||
std::fs::read("/fixture/directory/file").unwrap(),
|
||||
b"directory/file\n"
|
||||
);
|
||||
assert_eq!(
|
||||
std::fs::read("/fixture/directory/symlink_to_file").unwrap(),
|
||||
b"directory/file\n"
|
||||
);
|
||||
}
|
9
std/wasi/testdata/std_fs_read_dir.rs
vendored
9
std/wasi/testdata/std_fs_read_dir.rs
vendored
@ -1,9 +0,0 @@
|
||||
// { "preopens": { "/fixture": "fixture" } }
|
||||
|
||||
fn main() {
|
||||
let entries = std::fs::read_dir("/fixture").unwrap();
|
||||
assert_eq!(entries.count(), 4);
|
||||
|
||||
let entries = std::fs::read_dir("/fixture/directory").unwrap();
|
||||
assert_eq!(entries.count(), 2);
|
||||
}
|
11
std/wasi/testdata/std_fs_rename.rs
vendored
11
std/wasi/testdata/std_fs_rename.rs
vendored
@ -1,11 +0,0 @@
|
||||
// { "preopens": { "/scratch": "scratch" } }
|
||||
|
||||
fn main() {
|
||||
let old_path = "/scratch/old_file";
|
||||
let new_path = "/scratch/new_file";
|
||||
|
||||
assert!(std::fs::write(old_path, b"Hello, world!").is_ok());
|
||||
assert!(std::fs::rename(old_path, new_path).is_ok());
|
||||
assert!(std::fs::read(old_path).is_err());
|
||||
assert_eq!(std::fs::read(new_path).unwrap(), b"Hello, world!");
|
||||
}
|
23
std/wasi/testdata/std_fs_symlink_metadata.rs
vendored
23
std/wasi/testdata/std_fs_symlink_metadata.rs
vendored
@ -1,23 +0,0 @@
|
||||
// { "preopens": { "/fixture": "fixture" } }
|
||||
|
||||
fn main() {
|
||||
let metadata = std::fs::symlink_metadata("/fixture/directory").unwrap();
|
||||
assert!(metadata.file_type().is_dir());
|
||||
|
||||
let metadata =
|
||||
std::fs::symlink_metadata("/fixture/symlink_to_directory").unwrap();
|
||||
assert!(metadata.file_type().is_symlink());
|
||||
|
||||
let metadata = std::fs::symlink_metadata("/fixture/file").unwrap();
|
||||
assert!(metadata.file_type().is_file());
|
||||
|
||||
let metadata = std::fs::symlink_metadata("/fixture/symlink_to_file").unwrap();
|
||||
assert!(metadata.file_type().is_symlink());
|
||||
|
||||
let metadata = std::fs::symlink_metadata("/fixture/directory/file").unwrap();
|
||||
assert!(metadata.file_type().is_file());
|
||||
|
||||
let metadata =
|
||||
std::fs::symlink_metadata("/fixture/directory/symlink_to_file").unwrap();
|
||||
assert!(metadata.file_type().is_symlink());
|
||||
}
|
5
std/wasi/testdata/std_fs_write.rs
vendored
5
std/wasi/testdata/std_fs_write.rs
vendored
@ -1,5 +0,0 @@
|
||||
// { "preopens": { "/scratch": "scratch" }, "files": { "scratch/file": "file" } }
|
||||
|
||||
fn main() {
|
||||
assert!(std::fs::write("/scratch/file", b"file").is_ok())
|
||||
}
|
7
std/wasi/testdata/std_io_stderr.rs
vendored
7
std/wasi/testdata/std_io_stderr.rs
vendored
@ -1,7 +0,0 @@
|
||||
// { "stderr": "Hello, stderr!" }
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
fn main() {
|
||||
assert!(std::io::stderr().write_all(b"Hello, stderr!").is_ok())
|
||||
}
|
9
std/wasi/testdata/std_io_stdin.rs
vendored
9
std/wasi/testdata/std_io_stdin.rs
vendored
@ -1,9 +0,0 @@
|
||||
// { "stdin": "Hello, stdin!" }
|
||||
|
||||
use std::io::Read;
|
||||
|
||||
fn main() {
|
||||
let mut buffer = String::new();
|
||||
assert!(std::io::stdin().read_to_string(&mut buffer).is_ok());
|
||||
assert_eq!(buffer, "Hello, stdin!")
|
||||
}
|
7
std/wasi/testdata/std_io_stdout.rs
vendored
7
std/wasi/testdata/std_io_stdout.rs
vendored
@ -1,7 +0,0 @@
|
||||
// { "stdout": "Hello, stdout!" }
|
||||
|
||||
use std::io::Write;
|
||||
|
||||
fn main() {
|
||||
assert!(std::io::stdout().write_all(b"Hello, stdout!").is_ok())
|
||||
}
|
5
std/wasi/testdata/std_process_exit.rs
vendored
5
std/wasi/testdata/std_process_exit.rs
vendored
@ -1,5 +0,0 @@
|
||||
// { "exitCode": "120" }
|
||||
|
||||
fn main() {
|
||||
std::process::exit(120);
|
||||
}
|
Loading…
Reference in New Issue
Block a user