mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
e0cfc9da39
This reverts commitf6fd6619e7
. I'm seeing a difference between canary and 1.45.2. In `deno-docs/reference_gen` I can't download dax when running `deno task types` ``` ~/src/deno-docs/reference_gen# deno upgrade --canary Looking up latest canary version Found latest versionf6fd6619e7
Downloading https://dl.deno.land/canary/f6fd6619e708a515831f707438368d81b0c9aa56/deno-aarch64-apple-darwin.zip Deno is upgrading to versionf6fd6619e7
Archive: /var/folders/9v/kys6gqns6kl8nksyn4l1f9v40000gn/T/.tmpb5lDnq/deno.zip inflating: deno Upgraded successfully ~/src/deno-docs/reference_gen# deno -v deno 1.45.2+f6fd661 ~/src/deno-docs/reference_gen# rm -rf /Users/ry/Library/Caches/deno ~/src/deno-docs/reference_gen# deno task types Task types deno task types:deno && deno task types:node Task types:deno deno run --allow-read --allow-write --allow-run --allow-env --allow-sys deno-docs.ts error: JSR package manifest for '@david/dax' failed to load. expected value at line 1 column 1 at file:///Users/ry/src/deno-docs/reference_gen/deno-docs.ts:2:15 ~/src/deno-docs/reference_gen# deno upgrade --version 1.45.2 Downloading https://github.com/denoland/deno/releases/download/v1.45.2/deno-aarch64-apple-darwin.zip Deno is upgrading to version 1.45.2 Archive: /var/folders/9v/kys6gqns6kl8nksyn4l1f9v40000gn/T/.tmp3R7uhF/deno.zip inflating: deno Upgraded successfully ~/src/deno-docs/reference_gen# rm -rf /Users/ry/Library/Caches/deno ~/src/deno-docs/reference_gen# deno task types Task types deno task types:deno && deno task types:node Task types:deno deno run --allow-read --allow-write --allow-run --allow-env --allow-sys deno-docs.ts Task types:node deno run --allow-read --allow-write=. --allow-env --allow-sys node-docs.ts ```
94 lines
2.3 KiB
Rust
94 lines
2.3 KiB
Rust
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
use std::io::Read;
|
|
|
|
use deno_fetch::reqwest;
|
|
use pretty_assertions::assert_eq;
|
|
use regex::Regex;
|
|
use test_util as util;
|
|
|
|
#[tokio::test]
|
|
async fn deno_serve_port_0() {
|
|
let mut child = util::deno_cmd()
|
|
.current_dir(util::testdata_path())
|
|
.arg("serve")
|
|
.arg("--port")
|
|
.arg("0")
|
|
.arg("./serve/port_0.ts")
|
|
.stdout_piped()
|
|
.spawn()
|
|
.unwrap();
|
|
let stdout = child.stdout.as_mut().unwrap();
|
|
let mut buffer = [0; 52];
|
|
let _read = stdout.read(&mut buffer).unwrap();
|
|
let msg = std::str::from_utf8(&buffer).unwrap();
|
|
let port_regex = Regex::new(r"(\d+)").unwrap();
|
|
let port = port_regex.find(msg).unwrap().as_str();
|
|
|
|
let cert = reqwest::Certificate::from_pem(include_bytes!(
|
|
"../testdata/tls/RootCA.crt"
|
|
))
|
|
.unwrap();
|
|
|
|
let client = reqwest::Client::builder()
|
|
.add_root_certificate(cert)
|
|
.http2_prior_knowledge()
|
|
.build()
|
|
.unwrap();
|
|
|
|
let res = client
|
|
.get(&format!("http://127.0.0.1:{port}"))
|
|
.send()
|
|
.await
|
|
.unwrap();
|
|
assert_eq!(200, res.status());
|
|
|
|
let body = res.text().await.unwrap();
|
|
assert_eq!(body, "deno serve --port 0 works!");
|
|
|
|
child.kill().unwrap();
|
|
child.wait().unwrap();
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn deno_serve_no_args() {
|
|
let mut child = util::deno_cmd()
|
|
.current_dir(util::testdata_path())
|
|
.arg("serve")
|
|
.arg("--port")
|
|
.arg("0")
|
|
.arg("./serve/no_args.ts")
|
|
.stdout_piped()
|
|
.spawn()
|
|
.unwrap();
|
|
let stdout = child.stdout.as_mut().unwrap();
|
|
let mut buffer = [0; 52];
|
|
let _read = stdout.read(&mut buffer).unwrap();
|
|
let msg = std::str::from_utf8(&buffer).unwrap();
|
|
let port_regex = Regex::new(r"(\d+)").unwrap();
|
|
let port = port_regex.find(msg).unwrap().as_str();
|
|
|
|
let cert = reqwest::Certificate::from_pem(include_bytes!(
|
|
"../testdata/tls/RootCA.crt"
|
|
))
|
|
.unwrap();
|
|
|
|
let client = reqwest::Client::builder()
|
|
.add_root_certificate(cert)
|
|
.http2_prior_knowledge()
|
|
.build()
|
|
.unwrap();
|
|
|
|
let res = client
|
|
.get(&format!("http://127.0.0.1:{port}"))
|
|
.send()
|
|
.await
|
|
.unwrap();
|
|
assert_eq!(200, res.status());
|
|
|
|
let body = res.text().await.unwrap();
|
|
assert_eq!(body, "deno serve with no args in fetch() works!");
|
|
|
|
child.kill().unwrap();
|
|
child.wait().unwrap();
|
|
}
|