You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: parser_tests.rs
    path of file: ./repos/biome/xtask/codegen/src
    
    the code of the file until where you have to start completion: //! Takes comments from biome_js_parser and turns them into test data.
//! This code is derived from rust_analyzer/xtask/codegen/gen_parser_tests

use std::{
    collections::HashMap,
    fs, mem,
    path::{Path, PathBuf},
};

use crate::{update, Mode};
use xtask::{project_root, Result};

fn extract_comment_blocks(
    text: &str,
    allow_blocks_with_empty_lines: bool,
) -> Vec<(usize, Vec<String>)> {
    let mut res = Vec::new();

    let prefix = "// ";
    let lines = text.lines().map(str::trim_start);

    let mut block = (0, vec![]);
    for (line_num, line) in lines.enumerate() {
        if line == "//" && allow_blocks_with_empty_lines {
            block.1.push(String::new());
            continue;
        }

        let is_comment = line.starts_with(prefix);
        if is_comment {
            block.1.push(line[prefix.len()..].to_string());
        } else {
            if !block.1.is_empty() {
                res.push(mem::take(&mut block));
            }
            block.0 = line_num + 2
    
pub fn generate_parser_tests(mode: Mode) -> Result<()> {
    let tests = tests_from_dir(&project_root().join(Path::new("crates/biome_js_parser/src")))?;
    fn install_tests(tests: &HashMap<String, Test>, into: &str, mode: Mode) -> Result<bool> {
        let tests_dir = project_root().join(into);
        if !tests_dir.is_dir() {
            fs::create_dir_all(&tests_dir)?;
        }
        // ok is never actually read, but it needs to be specified to create a Test in existing_tests
        let existing = existing_tests(&tests_dir, true)?;

        if let Some(t) = existing.keys().find(|&t| !tests.contains_key(t)) {
            panic!("Test is deleted: '{}'", t);
        }

        let mut some_file_was_updated = false;

        for (name, test) in tests {
            let path = match existing.get(name) {
                Some((path, _test)) => path.clone(),
                None => tests_dir
                    .join(name)
                    .with_extension(test.language.extension()),
            };
            if let crate::UpdateResult::Updated = update(&path, &test.text, &mode)? {
                some_file_was_updated = true;
            }

            if let Some(options) = &test.options {
                let path = tests_dir.join(name).with_extension("options.json");

                if let crate::UpdateResult::Updated = update(&path, options, &mode)? {
                    some_file_was_updated = true;
                }
            }
        }

        Ok(some_file_was_updated)
    }

    let mut some_file_was_updated = false;
    some_file_was_updated |= install_tests(
        &tests.ok,
        "crates/biome_js_parser/test_data/inline/ok",
        mode,
    )?;
    some_file_was_updated |= install_tests(
        &tests.err,
        "crates/biome_js_parser/test_data/inline/err",
        mode,
    )?;

    if some_file_was_updated {
        let _ = filetime::set_file_mtime(
            "crates/biome_js_parser/src/tests.rs",
            filetime::FileTime::now(),
        );
    }

    Ok(())
}