Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: lockfiles #3231

Merged
merged 14 commits into from
Nov 3, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
dont write local file:https:// urls to lockfile
  • Loading branch information
ry committed Oct 29, 2019
commit 38e11583136832a2c4fe0fe951158f9af1eeaf1d
7 changes: 7 additions & 0 deletions cli/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ impl Lockfile {
/// Lazily reads the filename, checks the given module is included.
/// Returns Ok(true) if check passed
pub fn check(&mut self, m: &CompiledModule) -> Result<bool> {
if m.name.starts_with("file:") {
return Ok(true);
}
if self.need_read {
self.read()?;
}
Expand All @@ -56,7 +59,11 @@ impl Lockfile {
})
}

// Returns true if module was not already inserted.
pub fn insert(&mut self, m: &CompiledModule) -> bool {
if m.name.starts_with("file:") {
return false;
}
let checksum = crate::checksum::gen2(&m.code);
self.map.insert(m.name.clone(), checksum).is_none()
}
Expand Down
14 changes: 14 additions & 0 deletions cli/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ itest!(lock_check_ok {
http_server: true,
});

itest!(lock_check_ok2 {
args: "run 019_media_types.ts --lock=lock_check_ok2.json",
output: "019_media_types.ts.out",
http_server: true,
});

itest!(lock_check_err {
args: "run --lock=lock_check_err.json http:https://127.0.0.1:4545/cli/tests/003_relative_import.ts",
output: "lock_check_err.out",
Expand All @@ -362,6 +368,14 @@ itest!(lock_check_err {
http_server: true,
});

itest!(lock_check_err2 {
args: "run 019_media_types.ts --lock=lock_check_err2.json",
output: "lock_check_err2.out",
check_stderr: true,
exit_code: 10,
http_server: true,
});

itest!(async_error {
exit_code: 1,
args: "run --reload async_error.ts",
Expand Down
9 changes: 9 additions & 0 deletions cli/tests/lock_check_err2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"http:https://localhost:4545/cli/tests/subdir/mt_text_javascript.j1.js": "3a3e002e2f92dc8f045bd4a7c66b4791453ad0417b038dd2b2d9d0f277c44f18",
"http:https://localhost:4545/cli/tests/subdir/mt_text_typescript.t1.ts": "c320ab0a259760e5c78b9ea840af3cc29697109594a3a5b5cea47128102b3e9d",
"http:https://localhost:4545/cli/tests/subdir/mt_application_x_typescript.t4.ts": "42f66736fea7365ff17d5aa9b9655e8551eb81f360dcfb6b77acdd5c9f699e82",
"http:https://localhost:4545/cli/tests/subdir/mt_video_vdn.t2.ts": "54cc82ff3c3b0387df57c7bb8eda4dcd36cbbf499ea483b04ff22c5365d34744",
"http:https://localhost:4545/cli/tests/subdir/mt_application_x_javascript.j4.js": "3a3e002e2f92dc8f045bd4a7c66b4791453ad0417b038dd2b2d9d0f277c44f18",
"http:https://localhost:4545/cli/tests/subdir/mt_application_ecmascript.j2.js": "3a3e002e2f92dc8f045bd4a7c66b4791453ad0417b038dd2b2d9d0f277c44f18",
"http:https://localhost:4545/cli/tests/subdir/mt_video_mp2t.t3.ts": "ee0b46f757b5f78681a4eead44820c2349daef7a5903fe3c624f29dbc98772e1"
}
2 changes: 2 additions & 0 deletions cli/tests/lock_check_err2.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[WILDCARD]Subresource integrety check failed --lock=lock_check_err2.json
http:https://localhost:4545/cli/tests/subdir/mt_text_ecmascript.j3.js
10 changes: 10 additions & 0 deletions cli/tests/lock_check_ok2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"http:https://localhost:4545/cli/tests/subdir/mt_application_ecmascript.j2.js": "3a3e002e2f92dc8f045bd4a7c66b4791453ad0417b038dd2b2d9d0f277c44f18",
"http:https://localhost:4545/cli/tests/subdir/mt_text_ecmascript.j3.js": "3a3e002e2f92dc8f045bd4a7c66b4791453ad0417b038dd2b2d9d0f277c44f18",
"http:https://localhost:4545/cli/tests/subdir/mt_video_vdn.t2.ts": "54cc82ff3c3b0387df57c7bb8eda4dcd36cbbf499ea483b04ff22c5365d34744",
"http:https://localhost:4545/cli/tests/subdir/mt_text_javascript.j1.js": "3a3e002e2f92dc8f045bd4a7c66b4791453ad0417b038dd2b2d9d0f277c44f18",
"http:https://localhost:4545/cli/tests/subdir/mt_application_x_typescript.t4.ts": "42f66736fea7365ff17d5aa9b9655e8551eb81f360dcfb6b77acdd5c9f699e82",
"http:https://localhost:4545/cli/tests/subdir/mt_video_mp2t.t3.ts": "ee0b46f757b5f78681a4eead44820c2349daef7a5903fe3c624f29dbc98772e1",
"http:https://localhost:4545/cli/tests/subdir/mt_application_x_javascript.j4.js": "3a3e002e2f92dc8f045bd4a7c66b4791453ad0417b038dd2b2d9d0f277c44f18",
"http:https://localhost:4545/cli/tests/subdir/mt_text_typescript.t1.ts": "c320ab0a259760e5c78b9ea840af3cc29697109594a3a5b5cea47128102b3e9d"
}