Skip to content

Commit

Permalink
Enhancements to PYTHONPATH.
Browse files Browse the repository at this point in the history
  • Loading branch information
khatchad committed Apr 8, 2024
1 parent 3794eb0 commit 55e5ee8
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public CAstNode visitImportFrom(ImportFrom importFrom) throws Exception {
String moduleName = s.get();
LOGGER.finer("Module name from " + importFrom + " is: " + moduleName + ".");

if (!isLocalModule(moduleName)) moduleName = s.get() + "/__init__";
if (!isLocalModule(moduleName)) moduleName += "/" + MODULE_INITIALIZATION_ENTITY_NAME;

LOGGER.finer("Module name from " + importFrom + " is: " + moduleName + ".");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2042,6 +2042,157 @@ public void testModule20()
}

/**
* Test for https://github.com/wala/ML/issues/177.
*
* <p>This test should not need a PYTHONPATH.
*/
@Test
public void testModule14()
throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
test(
new String[] {"proj10/C/__init__.py", "proj10/C/B.py", "proj10/A.py"},
"C/B.py",
"f",
"proj10",
1,
1,
new int[] {2});
}

/**
* Test for https://github.com/wala/ML/issues/178.
*
* <p>This test should not need a PYTHONPATH.
*/
@Test
public void testModule15()
throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
test(
new String[] {"proj11/C/__init__.py", "proj11/C/B.py", "proj11/A.py"},
"C/B.py",
"f",
"proj11",
1,
1,
new int[] {2});
}

/** This test should not need a PYTHONPATH. */
@Test
public void testModule16()
throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
test(
new String[] {"proj12/C/__init__.py", "proj12/C/B.py", "proj12/A.py"},
"C/B.py",
"f",
"proj12",
1,
1,
new int[] {2});
}

/**
* Test for https://github.com/wala/ML/issues/178. Multi-submodule case. See
* https://docs.python.org/3/tutorial/modules.html#packages.
*
* <p>This test should not need a PYTHONPATH.
*/
@Test
public void testModule17()
throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
test(
new String[] {
"proj13/C/__init__.py", "proj13/C/D/__init__.py", "proj13/C/D/B.py", "proj13/A.py"
},
"C/D/B.py",
"f",
"proj13",
1,
1,
new int[] {2});
}

/**
* Test for https://github.com/wala/ML/issues/178. Multi-submodule case. See
* https://docs.python.org/3/tutorial/modules.html#packages. This test has multiple modules in
* different packages.
*
* <p>This test should not need a PYTHONPATH.
*/
@Test
public void testModule18()
throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
test(
new String[] {
"proj14/C/__init__.py",
"proj14/C/E.py",
"proj14/C/D/__init__.py",
"proj14/C/D/B.py",
"proj14/A.py"
},
"C/D/B.py",
"f",
"proj14",
1,
1,
new int[] {2});

test(
new String[] {
"proj14/C/__init__.py",
"proj14/C/E.py",
"proj14/C/D/__init__.py",
"proj14/C/D/B.py",
"proj14/A.py"
},
"C/E.py",
"g",
"proj14",
1,
1,
new int[] {2});
}

/**
* Test for https://github.com/wala/ML/issues/177.
*
* <p>This test should not need a PYTHONPATH.
*/
@Test
public void testModule19()
throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
test(
new String[] {
"proj15/C/__init__.py", "proj15/C/D/__init__.py", "proj15/C/D/B.py", "proj15/A.py"
},
"C/D/B.py",
"f",
"proj15",
1,
1,
new int[] {2});
}

/**
* Test for https://github.com/wala/ML/issues/178.
*
* <p>This test should not need a PYTHONPATH.
*/
@Test
public void testModule20()
throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
test(
new String[] {"proj16/C/__init__.py", "proj16/C/B.py", "proj16/A.py"},
"C/B.py",
"D.f",
"proj16",
1,
1,
new int[] {3});
}

/**
>>>>>>> 8beb49c (Enhancements to PYTHONPATH (#94))
* Test for https://github.com/wala/ML/issues/178.
*
* <p>This test should not need a PYTHONPATH.
Expand Down

0 comments on commit 55e5ee8

Please sign in to comment.