Changeset 13963


Ignore:
Timestamp:
Nov 6, 2019 9:59:58 AM (8 days ago)
Author:
mjohnsson
Message:

#5870 Fixed All Checksum related mj-2630

Location:
branches/dev-mj-2630/Compiler
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-mj-2630/Compiler/ModelicaCompiler/src/jastadd/ModelicaCompiler.jrag

    r13958 r13963  
    21802180            for (File file : stream.files()) {
    21812181                try {
    2182                     fc.guidManager().createFileMD5(outFile, new File(outDir, outFile.getName()), log);
     2182                    fc.guidManager().createFileMD5(outFile, log);
    21832183                } catch (IOException e) {}
    21842184               
  • branches/dev-mj-2630/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/common/GUIDManager.java

    r13958 r13963  
    9999    }
    100100
    101     public void createFileMD5(File file, File outDirectory, ModelicaLogger log) throws IOException {
     101    public void createFileMD5(File file, ModelicaLogger log) throws IOException {
    102102        MessageDigest md5;
    103103        try {
     
    117117            }
    118118        }
    119         try (final FileWriter fw = new FileWriter(outDirectory)) {
    120             String Value = new BigInteger(1,md5.digest()).toString(16);
    121             filesMd5.add("CheckSum of " + file.getName() + " :" + Value);
    122             fw.append("CheckSum of " + file.getName() + " :" + Value);
    123         }
     119       
     120        String Value = new BigInteger(1,md5.digest()).toString(16);
     121        filesMd5.add("CheckSum of " + file.getName() + " :" + Value);
    124122    }
    125123
  • branches/dev-mj-2630/Compiler/ModelicaFrontEnd/test/junit/org/jmodelica/test/common/GUIDManagerTest.java

    r13732 r13963  
    33import static org.junit.Assert.assertEquals;
    44import static org.junit.Assert.assertFalse;
     5import static org.junit.Assert.assertNull;
    56import static org.junit.Assert.assertTrue;
    67
     8import java.io.BufferedOutputStream;
     9import java.io.BufferedReader;
    710import java.io.ByteArrayOutputStream;
     11import java.io.File;
     12import java.io.Reader;
    813
    914import org.jmodelica.common.GUIDManager;
     15import org.jmodelica.util.logging.Level;
     16import org.jmodelica.util.logging.ModelicaLogger;
    1017import org.junit.Before;
    1118import org.junit.Test;
     
    117124        assertEquals(ignoreWhitespace(expected), ignoreWhitespace(actual));
    118125    }
     126   
     127    @Test
     128    public void checksumOfFilesOnlyWrittenAtDebug() {
     129        TestLogger log = new TestLogger(Level.VERBOSE);
     130        guidManager.filesMd5.add("DummyHash");
     131        guidManager.writeFileMD5(log);
     132        assertNull(log.next());
     133       
     134        log = new TestLogger(Level.DEBUG);
     135        guidManager.filesMd5.add("DummyHash");
     136        guidManager.writeFileMD5(log);
     137        assertEquals("DEBUG: DummyHash", log.next());
     138
     139    }
    119140
    120141}
Note: See TracChangeset for help on using the changeset viewer.