Changeset 13968


Ignore:
Timestamp:
Nov 7, 2019 7:44:12 AM (10 days ago)
Author:
randersson
Message:

#5870 Reverted 13966 because it made tests fail

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/CHANGELOG.txt

    r13966 r13968  
    11================= Unreleased ==================
    2 # Change ; Minor ; Compiler; #5870
    3 Debug log now contains checksums of all generated c-files.
    4 
    52# Fixed ; Minor ; Compiler; #5864
    63Fixed bug where partial variability propagation lead to unbalanced equation systems.
  • trunk/Compiler/ModelicaCompiler/src/jastadd/ModelicaCompiler.jrag

    r13966 r13968  
    13701370        fc.guidManager().setSourceFile(new File(outDir, "modelDescription.xml"));
    13711371        fc.guidManager().processDependentFiles();
    1372         fc.guidManager().writeFileMD5(log);
     1372       
    13731373        log.debug("... code generated.");
    13741374        ASTNode.endStep("generateCode()");
     
    21772177            SplitFilesCodeStream stream = new SplitFilesCodeStream(outFile, debugGen, header);
    21782178            gen.generate(tmpl, stream, header);
    2179            
    21802179            for (File file : stream.files()) {
    2181                 try {
    2182                     fc.guidManager().createFileMD5(outFile, log);
    2183                 } catch (FileNotFoundException e) {
    2184                     throw e;
    2185                 } catch (IOException e) {
    2186                     // Should not happen
    2187                 }
    2188                
    21892180                log.debug("Generated file '" + file + "'.");
    21902181                if (fc != null) {
  • trunk/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/common/GUIDManager.java

    r13966 r13968  
    55import java.io.ByteArrayOutputStream;
    66import java.io.File;
    7 import java.io.FileReader;
    8 import java.io.FileWriter;
    97import java.io.IOException;
    108import java.io.InputStream;
     
    2321import java.util.List;
    2422
    25 import org.jmodelica.util.logging.ModelicaLogger;
    26 
    2723public class GUIDManager {
    2824
     
    8985    public void addDependentString(String input, ByteArrayOutputStream output) {
    9086        dependentFiles.add(new StringOpenable(input, output));
    91     }
    92    
    93     public ArrayList<String> filesMd5 = new ArrayList<String>();
    94 
    95     public void writeFileMD5(ModelicaLogger log) {
    96         for (String fileMd5 : filesMd5) {
    97             log.debug(fileMd5);
    98         }
    99     }
    100 
    101     public void createFileMD5(File file, ModelicaLogger log) throws IOException {
    102         MessageDigest md5;
    103         try {
    104             md5 = MessageDigest.getInstance("MD5");
    105         } catch (NoSuchAlgorithmException e) {
    106             return;
    107         }
    108 
    109         try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {
    110             String line = reader.readLine();
    111             while (line != null) {
    112                 // A naive implementation that is expected to create a digest different from what a command
    113                 // line tool would create. No lines breaks are included in the digest, and no
    114                 // character encodings are specified.
    115                 md5.update(line.getBytes(Charset.forName("UTF-8")));
    116                 line = reader.readLine();
    117             }
    118         }
    119        
    120         String Value = new BigInteger(1,md5.digest()).toString(16);
    121         filesMd5.add("CheckSum of " + file.getName() + " :" + Value);
    12287    }
    12388
  • trunk/Compiler/ModelicaFrontEnd/test/junit/org/jmodelica/test/common/GUIDManagerTest.java

    r13966 r13968  
    33import static org.junit.Assert.assertEquals;
    44import static org.junit.Assert.assertFalse;
    5 import static org.junit.Assert.assertNull;
    65import static org.junit.Assert.assertTrue;
    76
    8 import java.io.BufferedOutputStream;
    9 import java.io.BufferedReader;
    107import java.io.ByteArrayOutputStream;
    11 import java.io.File;
    12 import java.io.Reader;
    138
    149import org.jmodelica.common.GUIDManager;
    15 import org.jmodelica.util.logging.Level;
    16 import org.jmodelica.util.logging.ModelicaLogger;
    1710import org.junit.Before;
    1811import org.junit.Test;
     
    124117        assertEquals(ignoreWhitespace(expected), ignoreWhitespace(actual));
    125118    }
    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     }
    140119
    141120}
Note: See TracChangeset for help on using the changeset viewer.