Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
535 changes: 376 additions & 159 deletions icrn_manager

Large diffs are not rendered by default.

45 changes: 28 additions & 17 deletions tests/test_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,56 +159,67 @@ setup_test_env() {
mkdir -p "$TEST_REPO/r_kernels"
mkdir -p "$TEST_REPO/python_kernels"

# Create mock catalog
cat > "$TEST_REPO/icrn_kernel_catalog.json" << 'EOF'
# Create mock catalog with paths pointing to test repository
cat > "$TEST_REPO/icrn_kernel_catalog.json" << EOF
{
"R": {
"cowsay": {
"1.0": {
"conda-pack": "cowsay-1.0.tar.gz",
"environment_location": "$TEST_REPO/r_kernels/cowsay/1.0",
"description": "Test R kernel for cowsay package"
}
},
"ggplot2": {
"3.4.0": {
"conda-pack": "ggplot2-3.4.0.tar.gz",
"environment_location": "$TEST_REPO/r_kernels/ggplot2/3.4.0",
"description": "Test R kernel for ggplot2 package"
}
}
},
"Python": {
"numpy": {
"1.24.0": {
"conda-pack": "numpy-1.24.0.tar.gz",
"environment_location": "$TEST_REPO/python_kernels/numpy/1.24.0",
"description": "Test Python kernel for numpy package"
}
}
}
}
EOF

# Create mock kernel packages (valid tar files for testing)
mkdir -p "$TEST_REPO/r_kernels/cowsay/1.0"
mkdir -p "$TEST_REPO/r_kernels/ggplot2/3.4.0"
mkdir -p "$TEST_REPO/python_kernels/numpy/1.24.0"
# Create mock kernel environment directories (in-place environments, not tar files)
mkdir -p "$TEST_REPO/r_kernels/cowsay/1.0/bin"
mkdir -p "$TEST_REPO/r_kernels/ggplot2/3.4.0/bin"
mkdir -p "$TEST_REPO/python_kernels/numpy/1.24.0/bin"

# Create valid tar files with dummy content for testing
echo "dummy content" > "$TEST_REPO/r_kernels/cowsay/1.0/dummy.txt"
tar -czf "$TEST_REPO/r_kernels/cowsay/1.0/cowsay-1.0.tar.gz" -C "$TEST_REPO/r_kernels/cowsay/1.0" dummy.txt 2>/dev/null || true
# Create R kernel mock with conda environment structure
echo "#!/bin/bash" > "$TEST_REPO/r_kernels/cowsay/1.0/bin/activate"
echo "echo 'Activating R conda environment'" >> "$TEST_REPO/r_kernels/cowsay/1.0/bin/activate"
chmod +x "$TEST_REPO/r_kernels/cowsay/1.0/bin/activate"
echo "#!/bin/bash" > "$TEST_REPO/r_kernels/cowsay/1.0/bin/deactivate"
echo "echo 'Deactivating R conda environment'" >> "$TEST_REPO/r_kernels/cowsay/1.0/bin/deactivate"
chmod +x "$TEST_REPO/r_kernels/cowsay/1.0/bin/deactivate"
echo "#!/bin/bash" > "$TEST_REPO/r_kernels/cowsay/1.0/bin/Rscript"
echo "echo '/mock/r/lib'" >> "$TEST_REPO/r_kernels/cowsay/1.0/bin/Rscript"
chmod +x "$TEST_REPO/r_kernels/cowsay/1.0/bin/Rscript"

echo "dummy content" > "$TEST_REPO/r_kernels/ggplot2/3.4.0/dummy.txt"
tar -czf "$TEST_REPO/r_kernels/ggplot2/3.4.0/ggplot2-3.4.0.tar.gz" -C "$TEST_REPO/r_kernels/ggplot2/3.4.0" dummy.txt 2>/dev/null || true
echo "#!/bin/bash" > "$TEST_REPO/r_kernels/ggplot2/3.4.0/bin/activate"
echo "echo 'Activating R conda environment'" >> "$TEST_REPO/r_kernels/ggplot2/3.4.0/bin/activate"
chmod +x "$TEST_REPO/r_kernels/ggplot2/3.4.0/bin/activate"
echo "#!/bin/bash" > "$TEST_REPO/r_kernels/ggplot2/3.4.0/bin/deactivate"
echo "echo 'Deactivating R conda environment'" >> "$TEST_REPO/r_kernels/ggplot2/3.4.0/bin/deactivate"
chmod +x "$TEST_REPO/r_kernels/ggplot2/3.4.0/bin/deactivate"
echo "#!/bin/bash" > "$TEST_REPO/r_kernels/ggplot2/3.4.0/bin/Rscript"
echo "echo '/mock/r/lib'" >> "$TEST_REPO/r_kernels/ggplot2/3.4.0/bin/Rscript"
chmod +x "$TEST_REPO/r_kernels/ggplot2/3.4.0/bin/Rscript"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Test setup missing conda-meta directories for R kernels

The test setup creates mock R kernel environments with bin/ directories but doesn't create the conda-meta/ directories that register_r_library_in_user_catalog checks for on line 506 of icrn_manager. This causes R kernel registration to fail silently in tests, masking the missing error handling bug and preventing proper validation of the R kernel checkout flow.

Fix in Cursor Fix in Web


# Create Python kernel mock with conda environment structure
mkdir -p "$TEST_REPO/python_kernels/numpy/1.24.0/bin"
echo "dummy content" > "$TEST_REPO/python_kernels/numpy/1.24.0/dummy.txt"
echo "#!/bin/bash" > "$TEST_REPO/python_kernels/numpy/1.24.0/bin/activate"
echo "echo 'Activating conda environment'" >> "$TEST_REPO/python_kernels/numpy/1.24.0/bin/activate"
chmod +x "$TEST_REPO/python_kernels/numpy/1.24.0/bin/activate"
echo "#!/bin/bash" > "$TEST_REPO/python_kernels/numpy/1.24.0/bin/deactivate"
echo "echo 'Deactivating conda environment'" >> "$TEST_REPO/python_kernels/numpy/1.24.0/bin/deactivate"
chmod +x "$TEST_REPO/python_kernels/numpy/1.24.0/bin/deactivate"
tar -czf "$TEST_REPO/python_kernels/numpy/1.24.0/numpy-1.24.0.tar.gz" -C "$TEST_REPO/python_kernels/numpy/1.24.0" . 2>/dev/null || true

# Create mock conda-unpack command
echo '#!/bin/bash' > "$TEST_BASE/conda-unpack"
Expand Down
2 changes: 0 additions & 2 deletions tests/test_env/conda-unpack

This file was deleted.

24 changes: 0 additions & 24 deletions tests/test_env/repository/icrn_kernel_catalog.json

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion tests/test_env/repository/r_kernels/cowsay/1.0/dummy.txt

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions tests/test_env/user_home/.icrn/manager_config.json

This file was deleted.

Loading
Loading