Skip to content

Commit

Permalink
debug AppVeyor
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed Jun 24, 2019
1 parent 4c33072 commit 63bc05c
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
1 change: 1 addition & 0 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ fn fetch_or_info_command(
let main_future = lazy(move || {
// Setup runtime.
js_check(worker.execute("denoMain()"));
println!("main_module {}", main_module);
debug!("main_module {}", main_module);

worker
Expand Down
55 changes: 55 additions & 0 deletions core/module_specifier.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
use std::fmt;
use std::path::PathBuf;
use url::Url;

//fn normalize_path(path: &Path) -> PathBuf {
// let s = String::from(path.to_str().unwrap());
// let normalized_string = if cfg!(windows) {
// // TODO This isn't correct. Probbly should iterate over components.
// s.replace("\\", "/")
// } else {
// s
// };
//
// PathBuf::from(normalized_string)
//}

#[derive(Debug, Clone, PartialEq)]
/// Resolved module specifier
pub struct ModuleSpecifier(Url);
Expand Down Expand Up @@ -52,12 +65,23 @@ impl ModuleSpecifier {
pub fn resolve_root(
root_specifier: &str,
) -> Result<ModuleSpecifier, url::ParseError> {
// println!("root specifier {}", root_specifier);
let path = PathBuf::from(root_specifier);
// println!("file path {:?}", path);

if let Ok(url) = Url::from_file_path(&path) {
// println!("from file path {:?}", url);
return Ok(ModuleSpecifier(url));
}

if let Ok(url) = Url::parse(root_specifier) {
// println!("url parse was successful {:?}", url);
Ok(ModuleSpecifier(url))
} else {
let cwd = std::env::current_dir().unwrap();
let base = Url::from_directory_path(cwd).unwrap();
let url = base.join(root_specifier)?;
// println!("from apth {:?}", url);
Ok(ModuleSpecifier(url))
}
}
Expand All @@ -80,3 +104,34 @@ impl PartialEq<String> for ModuleSpecifier {
&self.to_string() == other
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn absolute_file_path() {
if cfg!(target_os = "windows") {
assert_eq!(
ModuleSpecifier::resolve_root(r"C:/deno/tests/006_url_imports.ts")
.unwrap()
.to_string(),
"file:///c:/deno/tests/006_url_imports.ts",
);
} else {
assert_eq!(
ModuleSpecifier::resolve_root("/deno/tests/006_url_imports.ts")
.unwrap()
.to_string(),
"file:///deno/tests/006_url_imports.ts",
);
}
assert_eq!(
ModuleSpecifier::resolve_root(
"http://deno.land/core/tests/006_url_imports.ts"
).unwrap()
.to_string(),
"http://deno.land/core/tests/006_url_imports.ts",
);
}
}
8 changes: 5 additions & 3 deletions tools/fetch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ def test_fetch(self):
deno_dir = mkdtemp()
try:
t = os.path.join(tests_path, "006_url_imports.ts")
result = run_output([self.deno_exe, "fetch", t],
quiet=True,
merge_env={"DENO_DIR": deno_dir})
result = run_output(
[self.deno_exe, "fetch", t],
# quiet=True,
merge_env={"DENO_DIR": deno_dir})
print "test_fetch", result.code, result.out, result.err
self.assertEqual(result.out, "")
self.assertEqual(result.code, 0)
# Check that we actually did the prefetch.
Expand Down
9 changes: 6 additions & 3 deletions tools/target_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ def test_ts_library_builder(self):

def test_no_color(self):
t = os.path.join(tests_path, "no_color.js")
result = run_output([self.deno_exe, "run", t],
merge_env={"NO_COLOR": "1"},
quiet=True)
result = run_output(
[self.deno_exe, "run", t],
merge_env={"NO_COLOR": "1"},
# quiet=True
)
print "no_color", result.code, result.out, result.err
assert result.out.strip() == "noColor true"
t = os.path.join(tests_path, "no_color.js")
result = run_output([self.deno_exe, "run", t], quiet=True)
Expand Down

0 comments on commit 63bc05c

Please sign in to comment.