fix(coverage): Error if the emit cache is invalid (#16850)

This commit is contained in:
sigmaSd 2022-11-29 18:43:54 +01:00 committed by GitHub
parent e4fe5ee72a
commit 2656af2544
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 101 additions and 23 deletions

View file

@ -12,7 +12,7 @@ use std::sync::Arc;
/// A hashing function that takes the source code and emit options
/// hash then generates a string hash which can be stored to
/// determine if the cached emit is valid or not.
fn get_source_hash(source_text: &str, emit_options_hash: u64) -> u64 {
pub fn get_source_hash(source_text: &str, emit_options_hash: u64) -> u64 {
FastInsecureHasher::new()
.write_str(source_text)
.write_u64(emit_options_hash)
@ -30,9 +30,7 @@ pub fn emit_parsed_source(
) -> Result<String, AnyError> {
let source_hash = get_source_hash(source, emit_config_hash);
if let Some(emit_code) =
emit_cache.get_emit_code(specifier, Some(source_hash))
{
if let Some(emit_code) = emit_cache.get_emit_code(specifier, source_hash) {
Ok(emit_code)
} else {
// this will use a cached version if it exists