summaryrefslogtreecommitdiff
path: root/cli/tests/integration/info_tests.rs
blob: d266daee0b7689ff95fac78e4188c061200b864e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.

use crate::itest;
use test_util as util;
use test_util::TempDir;

#[test]
fn info_with_compiled_source() {
  let _g = util::http_server();
  let module_path = "http://127.0.0.1:4545/048_media_types_jsx.ts";
  let t = TempDir::new();

  let mut deno = util::deno_cmd()
    .env("DENO_DIR", t.path())
    .current_dir(util::testdata_path())
    .arg("cache")
    .arg(&module_path)
    .spawn()
    .unwrap();
  let status = deno.wait().unwrap();
  assert!(status.success());

  let output = util::deno_cmd()
    .env("DENO_DIR", t.path())
    .env("NO_COLOR", "1")
    .current_dir(util::testdata_path())
    .arg("info")
    .arg(&module_path)
    .output()
    .unwrap();

  let str_output = std::str::from_utf8(&output.stdout).unwrap().trim();
  eprintln!("{}", str_output);
  // check the output of the test.ts program.
  assert!(str_output.contains("emit: "));
  assert_eq!(output.stderr, b"");
}

itest!(_022_info_flag_script {
  args: "info http://127.0.0.1:4545/019_media_types.ts",
  output: "022_info_flag_script.out",
  http_server: true,
});

itest!(_031_info_ts_error {
  args: "info 031_info_ts_error.ts",
  output: "031_info_ts_error.out",
});

itest!(_041_info_flag {
  args: "info",
  output: "041_info_flag.out",
});

itest!(_042_info_flag_location {
  args: "info --location https://deno.land",
  output: "041_info_flag_location.out",
});

itest!(info_json {
  args: "info --json --unstable",
  output: "info_json.out",
});

itest!(info_json_location {
  args: "info --json --unstable --location https://deno.land",
  output: "info_json_location.out",
});

itest!(_049_info_flag_script_jsx {
  args: "info http://127.0.0.1:4545/048_media_types_jsx.ts",
  output: "049_info_flag_script_jsx.out",
  http_server: true,
});

itest!(_055_info_file_json {
  args: "info --quiet --json --unstable 005_more_imports.ts",
  output: "055_info_file_json.out",
  exit_code: 0,
});

itest!(_065_import_map_info {
  args:
    "info --quiet --import-map=import_maps/import_map.json import_maps/test.ts",
  output: "065_import_map_info.out",
});

itest!(_076_info_json_deps_order {
  args: "info --unstable --json 076_info_json_deps_order.ts",
  output: "076_info_json_deps_order.out",
});

itest!(info_missing_module {
  args: "info error_009_missing_js_module.js",
  output: "info_missing_module.out",
});

itest!(info_recursive_modules {
  args: "info --quiet info_recursive_imports_test.ts",
  output: "info_recursive_imports_test.out",
  exit_code: 0,
});

itest!(info_type_import {
  args: "info info_type_import.ts",
  output: "info_type_import.out",
});

itest!(_054_info_local_imports {
  args: "info --quiet 005_more_imports.ts",
  output: "054_info_local_imports.out",
  exit_code: 0,
});

// Tests for AssertionError where "data" is unexpectedly null when
// a file contains only triple slash references (#11196)
itest!(data_null_error {
  args: "info info/data_null_error/mod.ts",
  output: "info/data_null_error/data_null_error.out",
});

itest!(deno_info_types_header_direct {
  args: "info --reload type_directives_01.ts",
  output: "info/types_header.out",
  http_server: true,
});